👨👩👧👦
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
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" | |
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
// 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); | |
}); |
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
#! /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/ |
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 '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 |
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 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 |
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
.infinite_frowns { | |
color: #660000; | |
background: #FFEEEE; | |
} | |
.infinite_smiles { | |
color: #000; | |
background: #CCFFCC; | |
} |
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
var detectBackOrForward = function(onBack, onForward) { | |
hashHistory = [window.location.hash]; | |
historyLength = window.history.length; | |
return function() { | |
var hash = window.location.hash, length = window.history.length; | |
if (hashHistory.length && historyLength == length) { | |
if (hashHistory[hashHistory.length - 2] == hash) { | |
hashHistory = hashHistory.slice(0, -1); | |
onBack(); |
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
module ProPublica | |
class GoogleComparer | |
BASE_URL = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" | |
WEB_TITLE_DELIMITERS = /(-|\|).*$/ | |
def initialize(facility_name) | |
@facility_name = facility_name | |
url_encoded_facility_name = CGI.escape(@facility_name) | |
@results = JSON.parse(RestClient.get(BASE_URL + url_encoded_facility_name))['responseData']['results'] | |
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
ALNUM = /[a-z0-9]/i | |
PUNCT = /[^a-z0-9\s]/i | |
REPEAT = /(.)\1{2,}/ | |
UPPER = /[A-Z]/ | |
LOWER = /[a-z]/ | |
ACRONYM = /^[A-Z]+('?s|[.,])?$/ | |
ALL_ALPHA = /^[a-z]+$/i | |
CONSONANT = /[bcdfghjklmnpqrstvwxz]/i | |
VOWEL = /[aeiouy]/i | |
CONSONANT_5 = /[bcdfghjklmnpqrstvwxz]{5}/i |
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
var ArrayProto = Array.prototype | |
, ObjProto = Object.prototype | |
; | |
// Array Tests | |
["forEach", "map", "reduce", "reduceRight", "filter", "every", "some", | |
"indexOf", "lastIndexOf"].forEach(function(key){ | |
var d = document.createElement("div"); | |
d.textContent = key + ": " + ArrayProto[key]; | |
document.body.appendChild(d); | |
}); |