Skip to content

Instantly share code, notes, and snippets.

View thejefflarson's full-sized avatar
👨‍👩‍👧‍👦
being a dad

Jeff Larson thejefflarson

👨‍👩‍👧‍👦
being a dad
View GitHub Profile
def import(stat, &blk)
puts "trying #{stat}"
begin
block_given? ? blk.call : Object.const_get(stat).import(@date)
rescue GatticaError => exception
puts "*** got a GA error: #{exception} ***"
sleep 10
retry
end
end
require 'rubygems'
require 'pp'
unless self.class.const_defined? "IRB_RC_HAS_LOADED"
# Log to STDOUT if in Rails
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
@brianboyer
brianboyer / import_usat
Created February 16, 2011 16:50
PostgreSQL importer for the pre-processed census files provided to IRE members by Paul Overberg and Anthony DeBarros from USA Today.
#! /bin/sh
#
# usat_import
# Created by Ryan Nagle, Chris Groskopf and Brian Boyer
#
# PostgreSQL importer for the pre-processed census files provided to IRE
# members by Paul Overberg and Anthony DeBarros from USA Today.
#
# To get the source files, join IRE (it's cheap!):
# http://www.ire.org/getcensus/
// First things first, add our special CSRF token to every jQuery Ajax
// request.
$(document).ajaxSend(function(e, xhr, options) {
var token = $("meta[name='csrf-token']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
});
class TweetClassifier
GOOD = %w[superior quality excellent superb outstanding magnificent
great exceptional marvelous wonderful awesome]
BAD = %w[inferior shoddy careless miserable horrible
incompetent awful atrocious terrible pathetic crappy]
FACETS = %w[article story piece column]
SEARCH = "http://search.twitter.com/search.json"
@ryanpitts
ryanpitts / Hartnett Command Performance
Created May 11, 2011 19:11
Let your Mac read you the latest @wmhartnett updates from Twitter
read -a choices <<<'Agnes Kathy Princess Vicki Victoria Bruce Fred Junior Ralph Albert Bahh Bells Boing Bubbles Cellos Deranged Hysterical Trinoids Whisper Zarvox'; n=${#choices[*]}; voice=${choices[$((RANDOM%n))]}; curl https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=wmhartnett | grep '<description>.*</description>' | sed -e 's/<\/*description>//g' -e 's/ \/ wmhartnett//g' -e 's/wmhartnett: //g' | say -v $voice
@tlrobinson
tlrobinson / Makefile
Created June 25, 2011 03:31
Remote Makefiles fun
MAKEFILE=$(lastword $(MAKEFILE_LIST))
REMOTE?=$(REMOTE_USER)@$(REMOTE_HOST)
REMOTE_SSH?=ssh -p $(REMOTE_PORT)
REMOTE_SHELL?=$(REMOTE_SSH) $(REMOTE) $(REMOTE_LOGIN)
REMOTE_MAKE?=cat $(MAKEFILE) | $(REMOTE_SHELL) make -f /dev/stdin -C $(REMOTE_BASE)
# LOCAL COMMANDS:
hello:
$ curl -I http://t.co/a87DAaC
HTTP/1.1 301 Moved Permanently
Date: Sat, 20 Aug 2011 22:53:39 GMT
Server: hi
Location: http://nyti.ms/p8ZGNT
Cache-Control: private,max-age=300
Expires: Sat, 20 Aug 2011 22:58:39 GMT
Connection: close
Content-Type: text/html; charset=UTF-8
// Demonstration of dynamic super() calls.
// Because of JS reserved words, "ssuper()" is the method name,
// and is passed the current object, as well as the name of
// the current method.
function GreatGrandParent() {};
GreatGrandParent.prototype.method = function() {
console.log("In the GreatGrandParent.");
};
@myersjustinc
myersjustinc / mercator.html
Created November 14, 2011 19:12
Mercator scale factors by latitude
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Mercator craziness</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">//<![CDATA[
var map;
var circles = [];
function degToRad(degrees) {return degrees * Math.PI / 180;}