- Twitter: @0utoftime
- Website or Blog: http://github.com/outoftime
- Company: Rap Genius http://rapgenius.com
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
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 |
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
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") |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'readline' | |
require 'yajl' | |
require 'term/ansicolor' | |
Color = Object.new | |
Color.extend(Term::ANSIColor) |
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
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) |
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
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 |
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 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 |
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 Object | |
def clip | |
string = to_s | |
IO.popen('pbcopy', 'w') { |io| io << string } | |
string | |
end | |
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
# | |
# 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 |
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 Trie | |
include Enumerable | |
def initialize | |
@leaf, @children = false, {} | |
end | |
def <<(value) | |
add_enum(value_to_enum(value)) | |
end |