Skip to content

Instantly share code, notes, and snippets.

View jmhodges's full-sized avatar
🐶
return of the

Jeff Hodges jmhodges

🐶
return of the
View GitHub Profile
#include <ruby.h>
#include <node.h>
int main(int argc, char **argv) {
ruby_init();
ruby_script("embedded");
// The bizness
rb_thread_t th = ALLOC(struct rb_thread); \
th->last_status = 0;
if !defined?(JSON)
require 'yajl'
else
require 'json'
module Yajl
LOOKUP = %w[null boolean string bytes int long float double].
inject({}){|h,k| h[k.inspect] = k; h }
def self.dump(obj)
JSON.dump(obj)
end
package main
import (
"fmt"
"time"
)
// SlowShepherd is for making sure that a func used in a tight loop
// does not cause a thundering herd problem. If the function
// thunderingHerdFunc returns quicker than the sleepInterval given,
#!/usr/bin/env ruby
two_words = Hash.new(0)
three_words = Hash.new(0)
def windowed_words_to_hash(words, word_hash)
i = 0
while i < words.size-1
key = [words[i], words[i+1]]
word_hash[key] += count
i += 1
(lines) M=> (w+c+j: smallcount) # YMapper
(w+c+j: smallcount) R=> (w+c+j: y_cj) # YReducer
(w+c+j: y_cj) M=> (w+c: y_cj) # XMapper
(w+c: y_cj) R=> (w+c: x_wc) # XReducer
(w+c: x_wc) M=> (w: x_wc) # GMapper
(w: x_wc) R=> (w: g_w) # GReducer
(w+c+j: y_cj) M=> (w: [c+j, y_cj]) # YToWordMapper
@jmhodges
jmhodges / hm.rb
Created September 25, 2009 21:02
class User < Personalization
# vroommm. honk, honk. hey, bill! runnin' a little late, aren't we?
CHARPOOL = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l I O)
def test_open_with_write_clears_existing_file
FileUtils.mkdir_p('/path/to')
path = '/path/to/file.txt'
File.open(path, 'w') do |f|
f << 'Yada Yada'
end
File.open(path, 'w') do |f|
f << 'Yada Yada'
end
require 'transformer'
require 'json'
some_canonical_example_of_input =
File.open('canonical.json'){|f| JSON.parse(f.read)}
another_canonical_example_of_input =
File.open('another.json'){|f| JSON.parse(f.read)}
MyHashTransformer = Transformer do
http://qafscity1.wc1.yellowpages.com:35200/cgi-bin/citystaterv?hits=25&sortby=dirlookup&qtpipeline=citylookup&spell=0&qtf_spellcheck=0&qtf_lemmatize=0&query=AND%28citystatelookup:string%28%22HI%22,mode=%22all%22,annotation_class=%22citystatelookup%22%29,filter%28AND%28NOT(citytype:%22zp%22),meta.collection:sbcCityState%29%29%29&urid=rserv-67b76039-b2ca-4932-b381-e8b062cfdd62&resubmitflags=8048&qtype=directories
http://wc1fs11.wc1.yellowpages.com:15200/cgi-bin/asearch?qtpipeline=boostnowcname&query=xrank%28AND%28namesearch:string%28%22Nationwide+Insurance%22,mode=%22all%22,annotation_class%3D%22namesearch%22%29,filter%28AND%28meta.collection:sbcYP,directorycode:OR%28%22INT%22,ARDMZ,DAMZ,DCNMZ,FWMZ,IAR,ICB,IDS,IDW,IFW,IGB,IGR,IMK%29%29%29%29,city:string%28%22fort+worth%22,linguistics=%22off%22,mode=%22all%22%29,boost=500000%29&sortby=%20-relnamesearch%20%2Btier%20-prioritypointvalue%20%2Bsenioritydate%20%2Blistingname%20%2Bstate%20%2Bcity%20%2Baddresstext%20%2Bphonetext&qtf_geosearch%3Acenter=%2832.725278%2C-97.320556%29&qtf_geosearch%3Aradius=200&qtf_geosearch%3Aunit=mi&rpf_navigation:enabled=0&resubmitflags=8048&qtf_propername_listingnames:addconsidered=1&qtf_propername_listingnames:consideredverbose=1&qtf_propername_custom_listingnames:addconsidered=1&qtf_propername_custom_listingnames:consideredverbose=1&qtf_propername_custom_listingnames:phrasing=1&qtf_lemmatize=1&spell=0&qtf_spellcheck=0&qtf_spellcheck:addconsid