This demonstrates the math used to create the "seating chart"-style shapes on our House Outlook page.
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 '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, |
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
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 |
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 '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 = {} |
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
<!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> |
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 'fech' | |
require 'json' | |
module Fech | |
class Filing | |
def to_json | |
rows_like(//).to_json | |
end | |
end | |
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
<!doctype html> | |
<html> | |
<head> | |
<style type="text/css"> | |
#number { | |
font-family: Helvetica, Arial, sans-serif; | |
font-size: 100px; | |
} | |
</style> | |
</head> |
Most code via http://dan.iel.fm/xkcd/
Pollster data via http://elections.huffingtonpost.com/pollster/api
xkcd-style Pollster charts
Code via http://dan.iel.fm/xkcd
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 '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 |