This file contains hidden or 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 tokenize(text) | |
word = /([a-z][a-z'\-]+[a-z]+)/ | |
stopwords = ["the","and","to","of","a","i","in","was","he","that","it","his","her","you","as","had","with","for","she","not","at","but","be","my","on","have","him","is","said","me","which","by","so","this","all","from","they","no","were","if","would","or","when","what","there","been","one","could","very","an"] | |
text.tr('’', "'"). # Normalize apostrophe | |
downcase. # Normalize | |
scan(word). # Tokens | |
to_a.flatten. # Flat array of matches | |
reject {|w| stopwords.include? w } # Remove stopwords | |
end |
This file contains hidden or 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 'fech' | |
require 'fastercsv' | |
class Fech2CSV | |
def initialize | |
@filing_id = ARGV[0] | |
@line = ARGV[1] | |
@filing = Fech::Filing.new(@filing_id) | |
@filing.download |
This file contains hidden or 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
STOPWORDS = ["the","and","to","of","a","i","in","was","he","that","it","his","her","you","as","had","with","for","she","not","at","but","be","my","on","have","him","is","said","me","which","by","so","this","all","from","they","no","were","if","would","or","when","what","there","been","one","could","very","an"] | |
def snippet(terms) | |
text = "" | |
tokens = terms.split(/ /) | |
tokens.reject! {|q| STOPWORDS.include? q } | |
tokens.each do |tok| | |
text << self.first_message.clean_text.gsub(/\n/," "). | |
scan(/(?:[a-zA-Z0-9\.'-_\$,\:]+ ?){0,5}?#{tok}[ ,\:](?:[a-zA-Z0-9\.'-_\$,\:]+ ?){0,5}?/i).join(" ... ") |
This file contains hidden or 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
puts contributions.map{|q| '"' + q.instance_values['attributes'].values.join('","') + '"' }.join("\n") |
This file contains hidden or 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 ApIzer | |
class State | |
attr_reader :to_fips_index, :to_full_index, :to_usps_index, :to_ap_index | |
# >> ApIzer::State.find('Alabama').usps | |
# AL | |
# >> ApIzer::State.find('AL').ap | |
# Ala. | |
This file contains hidden or 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
{"VA"=>"s", "ND"=>"b", "AL"=>"B", "NY"=>"h", "NE"=>"c", "MD"=>"T", "DE"=>"H", "MN"=>"W", "CO"=>"F", "RI"=>"m", "HI"=>"K", "ME"=>"U", "WY"=>"x", "MO"=>"X", "IA"=>"L", "AZ"=>"D", "OH"=>"i", "IL"=>"N", "KY"=>"Q", "OR"=>"k", "GA"=>"J", "NH"=>"d", "TN"=>"p", "TX"=>"q", "IN"=>"O", "SC"=>"n", "ID"=>"M", "NJ"=>"e", "AR"=>"C", "FL"=>"I", "MS"=>"Y", "SD"=>"o", "OK"=>"j", "CT"=>"G", "PA"=>"l", "MI"=>"V", "MT"=>"Z", "WI"=>"v", "KS"=>"P", "CA"=>"E", "VT"=>"t", "NV"=>"g", "UT"=>"r", "NM"=>"f", "MA"=>"S", "WV"=>"w", "AK"=>"A", "LA"=>"R", "NC"=>"a", "WA"=>"u"} |
This file contains hidden or 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 sankeyIze = function(ox, oy, dx, dy) { | |
var curve = ((dx-ox) * 0.25) | |
var path = ""; | |
path += "M "+ ox + "," + oy; | |
path += "Q " + (ox+curve) + "," + oy + " " + ((ox+dx)/2) +","+ ((oy+dy)/2); | |
path += "Q " + (dx-curve) + "," + dy + " " + dx + "," + dy; | |
return path; | |
}; |
This file contains hidden or 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
# dammit, endorse liberty | |
def assign_candidate_id | |
return if self.candidate_id && self.candidate_id.length > 0 | |
bag = { | |
"Ron, Paul" => "P80000748", | |
"Ron, P" => "P80000748", | |
"Newt, Gingrich" => "P60003654", | |
"ROMNE, MITT" => "P80003353" | |
} |
This file contains hidden or 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
diff --git a/public/javascripts/app/models/schools_fb.js b/public/javascripts/app/models/schools_fb.js | |
index a64a106..c851723 100644 | |
--- a/public/javascripts/app/models/schools_fb.js | |
+++ b/public/javascripts/app/models/schools_fb.js | |
@@ -46,9 +46,9 @@ propublica.models.SchoolsFB = propublica.Model.extend({ | |
saveAccessToken : function(e, status) { | |
if (status['status'] !== "connected") return; | |
- var user_id = status['session']['uid']; | |
- var access_token = status['session']['access_token']; |
This file contains hidden or 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
diff --git a/public/javascripts/app/models/schools_fb.js b/public/javascripts/app/models/schools_fb.js | |
index a64a106..c851723 100644 | |
--- a/public/javascripts/app/models/schools_fb.js | |
+++ b/public/javascripts/app/models/schools_fb.js | |
@@ -46,9 +46,9 @@ propublica.models.SchoolsFB = propublica.Model.extend({ | |
saveAccessToken : function(e, status) { | |
if (status['status'] !== "connected") return; | |
- var user_id = status['session']['uid']; | |
- var access_token = status['session']['access_token']; |