Skip to content

Instantly share code, notes, and snippets.

@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,
@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 / 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 / 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 / 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 / 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
<!doctype html>
<html>
<head>
<style type="text/css">
#number {
font-family: Helvetica, Arial, sans-serif;
font-size: 100px;
}
</style>
</head>
@bycoffe
bycoffe / README.md
Created October 20, 2012 18:14
xkcd-style pollster charts in d3
@bycoffe
bycoffe / README.md
Created October 20, 2012 21:17
xkcd-style Pollster charts in d3
require 'daybreak'
require 'fech'
db = Daybreak::DB.new 'filings.db'
Fech::Search.new(:date => Date.today).results.each do |result|
db[result.filing_id] = result.filing(:csv_parser => Fech::CsvDoctor).download.rows_like(//)
end