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
Maurices-MacBook-Pro:Projects ben$ mkdir gitfoo | |
Maurices-MacBook-Pro:Projects ben$ cd gitfoo/ | |
Maurices-MacBook-Pro:gitfoo ben$ g init | |
Initialized empty Git repository in /Users/ben/Projects/gitfoo/.git/ | |
Maurices-MacBook-Pro:gitfoo ben$ touch foo | |
echMaurices-MacBook-Pro:gitfoo ben$ echo 'foo' >> foo | |
Maurices-MacBook-Pro:gitfoo ben$ g c -am 'initial commit' | |
# On branch master | |
# | |
# Initial commit |
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
de2nq092qkqfxll=> create index ben_test_partial on units (city_name) where is_deleted = true; | |
CREATE INDEX | |
de2nq092qkqfxll=> explain select count(*) from units where city_name = 'San Francisco' and is_deleted = true; | |
QUERY PLAN | |
---------------------------------------------------------------------------------------- | |
Aggregate (cost=1276.17..1276.17 rows=1 width=0) | |
-> Bitmap Heap Scan on units (cost=35.38..1276.00 rows=331 width=0) | |
Recheck Cond: (((city_name)::text = 'San Francisco'::text) AND is_deleted) | |
-> Bitmap Index Scan on ben_test_partial (cost=0.00..35.37 rows=331 width=0) | |
Index Cond: ((city_name)::text = 'San Francisco'::text) |
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 Foo | |
def initialize | |
yield(self) if block_given? | |
end | |
end | |
# Shouldn't these be equivalent? Why isn't thing1 created? | |
f1 = Foo.new { |me| @thing1 = 'this is thing1' } | |
f1.instance_variable_get("@thing1") #=> nil |
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
Why are indicies being handled differently in these cases? Below are three different but equivalent queries i would think should handle indicies the same: | |
Indicies: | |
Locations: | |
Indexes: | |
"locations_pkey" PRIMARY KEY, btree (id) | |
"index_locations_on_simplified_polygon" gist (simplified_polygon) | |
Check constraints: | |
"enforce_srid_simplified_polygon" CHECK (st_srid(simplified_polygon) = 4326) |
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
module Foo | |
module_function | |
def wtf? | |
'wtf?' | |
end | |
end | |
Foo.wtf? #=> 'wtf?' |
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 Foo | |
def initialize(options) | |
@bar = options.fetch(:bar, nil) | |
@baz = options.fetch(:baz, nil) | |
end | |
end | |
def Foo(options) | |
Foo.new(options) | |
end |
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
case | |
when true | |
puts 'yes' | |
when false | |
puts 'no' | |
else | |
puts 'i dont understand' | |
end | |
case |
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
# | |
# Indexes for units table | |
# | |
Indexes: | |
"units_pkey" PRIMARY KEY, btree (id) | |
"index_units_on_normalization" UNIQUE, btree (normalization) | |
"index_units_on_city_id" btree (city_id) | |
"index_units_on_coordinates" gist (coordinates) | |
"index_units_on_neighborhood_id" btree (neighborhood_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
class Foo; end | |
describe Foo do | |
# expected behavior | |
context 'when not testing with let' do | |
it "uses the same Foo object inside threads" do | |
foo = Foo.new | |
obj_id = @foo.object_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
Class.class | |
=> Class | |
Class.new.class | |
=> Class | |
Class.instance_methods.count | |
=> 109 | |
Class.new.instance_methods.count |
NewerOlder