Skip to content

Instantly share code, notes, and snippets.

@bycoffe
bycoffe / fech-json.rb
Created September 20, 2012 14:14
Convert a Fech filing to JSON
require 'fech'
require 'json'
module Fech
class Filing
def to_json
rows_like(//).to_json
end
end
end
@bycoffe
bycoffe / README.md
Created August 20, 2012 14:39
Placing n elements around a circle with radius r

This demonstrates the math used to create the "seating chart"-style shapes on our House Outlook page.

@bycoffe
bycoffe / index.html
Created August 7, 2012 16:29 — forked from enjalot/index.html
Simple Pie Chart example with D3.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Testing Pie Chart</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
@bycoffe
bycoffe / public_file_crawler.rb
Created August 3, 2012 19:30
A script for scraping the FCC's website and finding political file submissions
require 'open-uri'
require 'nokogiri'
class PublicFileCrawler
def initialize(params={})
@call_sign = params[:call_sign]
@url = "https://stations.fcc.gov/station-profile/#{@call_sign}/political-files/browse-%3e2012"
@checked = {}
@found = {}
@bycoffe
bycoffe / LICENSE
Last active March 13, 2022 18:37
D3.js world map with force layout
Copyright (c) 2016 Aaron Bycoffe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
@bycoffe
bycoffe / gist:2906827
Created June 10, 2012 18:25
Fech::Search example
require 'fech'
search = Fech::Search.new(date: Date.today, form_type: 'F6')
search.results.sort_by { |x| -x.filing_id.to_i }.each do |result|
filing = Fech::Filing.new(result.filing_id, :csv_parser => Fech::CsvDoctor)
filing.download unless File.exists? filing.file_path
filing.rows_like(/f65/) do |row|
p [filing.filing_id,
filing.summary.committee_name,
row.contributor_last_name,
{:rec_type=>"TEXT", :filer_committee_id_number=>"SA11ai", :back_reference_tran_id_number=>nil, :text=>"Regarding negative receipts listed on line 11(a)(i) with the description of 'ACH Return', these are interbank clearing of electronic payments processed by the Automated Clearing House (ACH) network of participating banks and the Federal Reserve. These are returns of contributions by individuals which have been deducted from our credit card merchant account or bank account by the credit card company or bank."}
["TEXT", "SA11ai", nil, "Regarding negative receipts listed on line 11(a)(i) with the description of 'ACH Return', these are interbank clearing of electronic payments processed by the Automated Clearing House (ACH) network of participating banks and the Federal Reserve. These are returns of contributions by individuals which have been deducted from our credit card merchant account or bank account by the credit card company or bank."]
["TEXT", "SA15", nil, "\"Regarding 'Asset Sales' reported on Schedule A supporting Line 15 of our report", " occasionally the RNC has used office equipment that we need to dispose of. This equipment may be sold in bulk to a commercial liquidation business or piece by piece to individuals. When this is done", " these items are reported as 'asset sale' and the price charged is such that they in no way constitute a political contribution. The used assets liquidated by sale to individuals or business are reported as 'Asset Sale' and are priced at fair market value. These items s
original = Fech::Filing.new(764200)
original.download
amendment = Fech::Filing.new(764828)
amendment.download
comparison = Fech::Comparison.new(amendment, original)
p comparison.summary
# {:date_signed=>"20120207"}
@bycoffe
bycoffe / fechexample
Created February 25, 2012 18:11
FECh example
filing = Fech::Filing.new(766953)
filing.download
fields = [:contributor_first_name,
:contributor_last_name,
:contributor_organization_name,
:contribution_amount]
rows = filing.rows_like(/sa/, :include => fields)