This file contains 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
# Actual test | |
it "prefixes each of it's locks with :prefix:" do | |
expect(ZookeeperLocker).to receive(:lock_no_retry) | |
.with(start_with("hello")) | |
lock_for_time_range "hello", @window do | |
# nothing | |
end | |
end | |
This file contains 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 MyQ | |
def initialize | |
@head = @tail = [] | |
end | |
def enq(obj) | |
@tail << obj << [] # must use methods that mutate the array here | |
@tail = @tail[1] | |
obj | |
end |
This file contains 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
pg_dump -a -N schema_1 -N schema_2 \ | |
--dbname=<redacted> | \ | |
pg_restore -Fc -j 8 --verbose \ | |
--dbname=<redacted> |
This file contains 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
database=> BEGIN; | |
BEGIN | |
database=> PREPARE dumb AS SELECT 'dumb'; | |
PREPARE | |
database=> ROLLBACK; | |
ROLLBACK | |
database=> PREPARE dumb AS SELECT 'dumb'; | |
ERROR: prepared statement "dumb" already exists |
This file contains 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 Test | |
module ClassMethods | |
attr_accessor :var | |
# Make everything in ClassMethods a class method on whatever includes this | |
def self.included(klass) | |
klass.extend ClassMethods | |
end | |
end | |
end | |
This file contains 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 Test | |
module ClassMethods | |
attr_accessor :var | |
# Make everything in ClassMethods a class method on whatever includes this | |
def self.included(klass) | |
klass.extend ClassMethods | |
end | |
end | |
end |
This file contains 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
my_table = "table_name" | |
conn = ActiveRecord::Base.connection | |
begin | |
conn.execute "CREATE TABLE #{my_table} (key INTEGER, val TEXT);" | |
klass = Class.new(ActiveRecord::Base) do | |
self.table_name = my_table | |
primary_key = "key" | |
default_scope { order("key DESC NULLS LAST") } |
NewerOlder