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
require 'json' | |
MY_JSON_FILE = File.open('big_json.json').read | |
MY_MARSHAL_FILE = File.open('big_json.dat').read | |
class FileLoader | |
def load_via_json | |
JSON.parse(MY_JSON_FILE) | |
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
puts "if you're happy and you know it, NoMethodError" | |
(nil.fnord rescue nil) |
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
# uber-hacky dynamic collection names for MongoID models: | |
# | |
# class MyModel | |
# include Mongoid::PrefixableDocument # ...instead of Mongoid::Document | |
# include Mongoid::Timestamps | |
# | |
# field :foobar, :type => Integer | |
# | |
# def my_method; 123; 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
require 'rubygems' | |
require 'rspec' | |
require 'mongoid' | |
describe "is this a bug?" do | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new('localhost','27017').db('mongotest') | |
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
# i hope this helps... | |
# to set the username and picture send these events to fm | |
# -> you don't need to define any event handlers | |
# -> the session token (_session) could be your unique session id | |
# or the unique user id (it's hashed) | |
# set the user name | |
{ "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" } |
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
# the "abstract" node | |
class BPGraph::Node | |
# initialize an instance with id of the correct subclass from a node_key | |
def self.load(node_key) | |
end | |
def initialize(node_id) | |
@node_class ||= :node |
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
namespace :tlnt do | |
desc "deploy to staging environment" | |
task :deploy_staging => :environment do | |
deploy_to_environment(:staging) | |
end | |
desc "restart staging environment" | |
task :restart_staging => :environment do | |
restart_environment(:staging) |
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
#include <stdio.h> | |
#include <time.h> | |
void clearscreen(){ | |
fputs("\033[H\033[2J", stdout); | |
} | |
int main(int argc, char* argv[]){ | |
char *frame01 = |
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
def geohashify_n(n: Double, rLeft: Int, rRight: Int, depth: Int): String = { | |
val mid = ((rRight - rLeft) / 2) + rLeft | |
if (depth == 0) | |
return "" | |
if (n > mid) | |
"1" + geohashify_n(n, mid, rRight, depth - 1) | |
else | |
"0" + geohashify_n(n, rLeft, mid, depth - 1) |
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
import scala.collection.immutable.HashMap; | |
val tbl = HashMap[Char, Int]( | |
'M' -> 1000, | |
'D' -> 500, | |
'C' -> 100, | |
'L' -> 50, | |
'X' -> 10, | |
'V' -> 5, | |
'I' -> 1 |
OlderNewer