Skip to content

Instantly share code, notes, and snippets.

require 'iconv'
def shift
line = ''
in_quote = 0
loop do
if read_line = $stdin.gets("\n")
line += read_line.chomp
else
return nil
# Input - Lunch Records
# { "date": "10-25-2011", "tasty": true, "food": "pizza", "restaurant": "Antico Pizza" }
# { "date": "10-24-2011", "tasty": true, "food": "tacos", "restaurant": "Taqueria del Sol" }
# { "date": "10-23-2011", "tasty": false, "food": "wings", "restaurant": "Wing Nuts" }
# { "date": "10-22-2011", "tasty": true, "food": "sandwiches", "restaurant": "Super Pan" }
# { "date": "10-22-2011", "tasty": true, "food": "pizza", "restaurant": "Fellini's Pizza" }
class TastyMapper < Wukong::Streamer::LineStreamer
def process(line)
lunch = JSON.parse(line)
=
/\/\/\/\ --------
< > | |
< > --> | |
< > --> | |
< > | |
\/\/\/\/ --------
apply = if Prototype.Browser.IE
(o, a) ->
a or= []
switch a.length
when 0 then return @call o
when 1 then return @call o, a[0]# shreddin' the argument powder
when 2 then return @call o, a[0], a[1]# \__O_/
when 3 then return @call o, a[0], a[1], a[2]# |
when 4 then return @call o, a[0], a[1], a[2], a[3]# \ /\
when 5 then return @call o, a[0], a[1], a[2], a[3], a[4]# \ /
#!/usr/bin/env bash
WD=`pwd`
tiger_em () {
directory=$WD/$1
shift
until [ -z "$1" ]
do
get_em $directory "ftp://ftp2.census.gov/geo/tiger/TIGER2010/"$1
shift
var Point = function(x, y){
if(_.isUndefined(y)){
var arr = x.slice();
x = arr.shift();
y = arr.shift();
}
this.x = (x || 0);
this.y = (y || 0);
};
function repeat(n) { return (new Array(n)).join(" "); }
function format(json){
var chars = json.split("")
, inString = false
, formatted = ""
, tabCount = 1
;
chars.forEach(function(chr){
switch(chr)
{
if Stat.exists? :url => url, :date_for => date_for
stat = Stat.first(:conditions => {:url => url, :date_for => date_for})
self.id = stat.id
new_hits = hits
reload
@new_record = false
errors.clear
increment(:hits, new_hits)
end
.infinite_frowns {
color: #660000;
background: #FFEEEE;
}
.infinite_smiles {
color: #000;
background: #CCFFCC;
}
@onyxfish
onyxfish / elections.chicagotribune.com.vcl
Created November 3, 2010 18:55
Elections Center Varnish Configuration File
backend app1 {
.host = "1.1.1.1";
.port = "80";
}
backend app2 {
.host = "2.2.2.2";
.port = "80";
}