Mat Brown outoftime

View monkeypatch.rb
1 2 3 4 5 6 7 8 9 10
#
# Monkeypatching gem dependencies is a fact of life. But it's dangerous, because *any* update
# to a library might change internals that your patch depends on. This little snippet allows you
# to leave "reminders" in your code that you're relying on a particular version of a gem, and blows
# up if the gem loaded at runtime doesn't fit the requirement.
#
# Example:
#
# monkeypatch('awesome_lib', '1.2.2') do
# module AwesomeLib
View clip.rb
1 2 3 4 5 6 7
class Object
def clip
string = to_s
IO.popen('pbcopy', 'w') { |io| io << string }
string
end
end
View speaker.md
View CQL3 Allowed Type Transitions
1 2 3 4 5 6 7 8 9 10
FROM TO ALLOWED?
===================================
ascii -> blob true
ascii -> boolean false
ascii -> decimal false
ascii -> double false
ascii -> inet false
ascii -> int false
ascii -> float false
ascii -> bigint false
View import.rb
1 2 3 4 5 6 7 8 9 10
connection = Cequel.connect(...)
table = connection.schema.read_table(:assessors)
 
my_data.each do |row|
typecast_row = {}
row.each_pair do |column_name, value|
typecast_row[column_name] = table.column(column_name).cast(value)
end
connection[:assessors].insert(typecast_row)
end
View sorted_set.js
1 2 3 4 5 6 7 8 9 10
var SortedSet = function () {
// your code here...
}
 
var set = new SortedSet()
set.add(3).add(1).add(3).add(5).add(8).add(-4).add(6)
var answer = [-4, 1, 3, 5, 6, 8]
if (set.toArray() < answer || set.toArray() > answer) {
console.log("Got ", set.toArray())
process.exit(1)
View pdb.rb
1 2 3 4 5 6 7 8 9
#!/usr/bin/env ruby
 
require 'rubygems'
require 'readline'
require 'yajl'
require 'term/ansicolor'
 
Color = Object.new
Color.extend(Term::ANSIColor)
View benchmark.rb
1 2 3 4 5 6 7 8 9 10
require 'bundler'
Bundler.require
 
require 'benchmark'
 
database = CassandraCQL::Database.new('127.0.0.1:9160')
begin
database.execute("CREATE KEYSPACE bm_test WITH strategy_class='SimpleStrategy' AND strategy_options:replication_factor=1")
database.execute("USE bm_test")
database.execute("CREATE COLUMNFAMILY bm_test (KEY uuid PRIMARY KEY) WITH comparator = uuid AND default_validation = text")
View gist:4163589
1 2 3 4 5 6 7 8 9 10
CREATE TABLE stats (
column_name text,
column_value int,
test_id uuid,
score int,
height int,
PRIMARY KEY (column_name, column_value, test_id)
);
 
-- Now let's say we have a logical row with score=20, height=150
View xscreensaver-xchat.rb
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
 
IO.popen('/usr/bin/xscreensaver-command -watch') do |io|
while line = io.gets
case line
when /^BLANK\b/, /^LOCK\b/
system('xchat', '-e', '--command=away')
when /^UNBLANK\b/
system('xchat', '-e', '--command=back')
end
Something went wrong with that request. Please try again.