Skip to content

Instantly share code, notes, and snippets.

HASH_COMMAND_MATCHER = /(#d(?:\s|$|([0-9]+))(?:\s|$))/
# hash commands for twitter:
# `#d` : delete the last twitter post in the wire
# `#d35235` : delete tweet with id 35235 from the wire
def process_hash_commands
cmds = []
@payload.each do |tweet|
if Update.find_by_native_item_id(tweet.id).nil?
tweet.text =~ HASH_COMMAND_MATCHER
def multi
poll_ids = params[:id].split(',')
@polls = Poll.find(:all, :conditions => {:id => poll_ids})
json = @polls.to_json(:include => {:contest => {}, :pollster => {}, :scores => {:include => :candidate}})
json = params[:callback] ? params[:callback] + '(' + json + ')' : json
respond_to do |format|
format.json { render :json => json }
end
end
# S_G_WV_0_49607_1.xml
desc "import to db from xml"
task :import do
AP_FILES.each do |file|
a = AP::Import.new(file)
puts file.inspect
file_id = file.gsub(/\/.+\/([A-Z]_[A-Z]_[A-Z]{1,2}_[0-9]{1,2}).*$/){|q| $1.to_s.to_i(36).to_s}
a.to_db(file_id.to_i)
puts "imported #{file}"
module Graticule #:nodoc:
module Geocoder #:nodoc:
class Google
def initialize(key)
@key = key
@proxies = ["http://127.0.0.1:8080", "http://127.0.0.1:8081", "http://127.0.0.1:8082"]
@url = URI.parse @proxies[rand(@proxies.length)] + '/maps/geo'
end
end
end
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
$KCODE = "UTF8"
require 'rubygems'
require 'rest_client'
require 'readability'
require 'sanitize'
require 'twitter-text'
require 'crack/json'
require 'curb'
<style>
#q,#shadow_q {
position:absolute;
top:5px;
left:5px;
width:500px;
height:30px;
font-size:25px;
}
#q {
@ashaw
ashaw / feh.rb
Created December 16, 2010 04:57
module ActiveRecord
class StatementInvalid < ActiveRecordError
def new(msg)
super unless msg =~ /MySQL server has gone away/
ActiveRecord::Base.verify_active_connections!
end
end
end
.infinite_frowns {
color: #660000;
background: #FFEEEE;
}
.infinite_smiles {
color: #000;
background: #CCFFCC;
}
updateSearchStatus : function(e, status) {
console.log(arguments);
var args = Array.prototype.slice.call(arguments)
var first = parseInt(args.slice(2,3),10) + 1;
var last = (function() {
var humanStatus = args.slice(1,2);
console.log(humanStatus.toString());
return (humanStatus.toString() === "atEnd" || humanStatus.toString() === "disableBoth")
? CompareFacilities.facilities.length : first + 3;
})();