This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
name: "error", | |
length: 97, | |
severity: "ERROR", | |
code: "42P01", | |
position: "13", | |
file: "parse_relation.c", | |
line: "873", | |
routine: "parserOpenTable" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[4] pry(main)> User.all.second | |
User Load (42.5ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL | |
=> #<User id: 2, ...> | |
[5] pry(main)> User.all.offset(1).limit(1) | |
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL LIMIT 1 OFFSET 1 | |
=> [#<User id: 2, ...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use ctrl-a as the prefix (instead of the default ctrl-b) | |
set-option -g prefix C-a | |
# pres ctrl-a, ctrl-a to flip between windows | |
bind-key C-a last-window | |
# use vi keybinding (basically just hjkl for navigation) | |
set-window-option -g mode-keys vi | |
bind-key -t vi-copy 'v' begin-selection | |
bind-key -t vi-copy 'y' copy-selection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include ngGrid in our app: | |
@app = angular.module("breeze", ["... "ngGrid", ...]) | |
# try to DI sortService from ngGrid | |
# (https://github.com/angular-ui/ng-grid/blob/8017eee035ac21ce9989eb26ea5dc6c13b9553cd/src/services/SortService.js) | |
ComplaintReportCtrl = ($scope, ComplaintReport, $sortService) -> | |
# then call it: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '4.0.0' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Error: | |
RangeTest#test: | |
FloatDomainError: Infinity | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:97:in `to_r' | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:97:in `==' | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:97:in `==' | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:97:in `!=' | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:97:in `_field_changed?' | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:66:in `write_attribute' | |
/home/dave/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.1/lib/active_record/attribute_methods/write.rb:21:in `__temp__e657d6f52716e67656=' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CLONE | |
dave@lexi:~/projects$ git clone https://github.com/rails/rails-dev-box.git | |
Cloning into 'rails-dev-box'... | |
remote: Counting objects: 267, done. | |
remote: Compressing objects: 100% (185/185), done. | |
remote: Total 267 (delta 79), reused 222 (delta 52) | |
Receiving objects: 100% (267/267), 80.74 KiB, done. | |
Resolving deltas: 100% (79/79), done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateGroups < ActiveRecord::Migration | |
def change | |
create_table :groups do |t| | |
t.integer :user_id | |
t.string :name | |
t.string :emails, array: true, null: false, default: [] | |
t.timestamps | |
end | |
add_index :groups, :user_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH q_geocodes(name, id) AS (VALUES ('SF', 6096070),('NYC', 6164533)) | |
SELECT | |
q_geocodes.name, | |
AVG(CAST(end_time + (time_zone * INTERVAL '1 sec') AS time)) AS mean_wake_time, | |
COUNT(events.*) AS counts, | |
histogram(EXTRACT(epoch FROM CAST(end_time + (time_zone * INTERVAL '1 sec') AS time)) :: real, EXTRACT(epoch FROM '04:00'::time) :: real, EXTRACT(epoch FROM '12:00'::time) :: real, 16) AS hist, | |
EXTRACT(DOW FROM (end_time + time_zone * INTERVAL '1 sec' )) AS dow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from: https://wiki.postgresql.org/wiki/Aggregate_Histogram | |
CREATE OR REPLACE FUNCTION hist_sfunc (state INTEGER[], val REAL, min REAL, max REAL, nbuckets INTEGER) RETURNS INTEGER[] AS $$ | |
DECLARE | |
bucket INTEGER; | |
i INTEGER; | |
BEGIN | |
-- width_bucket uses nbuckets + 1 (!) and starts at 1. | |
bucket := width_bucket(val, min, max, nbuckets - 1) - 1; | |