Skip to content

Instantly share code, notes, and snippets.

View caseydreier's full-sized avatar

Casey Dreier caseydreier

View GitHub Profile
@caseydreier
caseydreier / extract-subset.py
Created February 6, 2025 17:15
Example processing and collation of open NASA contracts extracted by fetch-contracts.py
"""
Analyzes and filters NASA contract data from CSV files generated by fetch-contracts.py.
Key functionality:
- Filters records by award type (grants, cooperative agreements)
- Validates records are active within specified date range
- Deduplicates contract records by keeping latest modification
- Calculates summaries by state and congressional district
- Generates filtered CSV output and summary statistics
@caseydreier
caseydreier / pi-cycle.py
Created March 14, 2024 16:52
Pi-day nonsense
from decimal import Decimal, getcontext
import sys
import time
if len(sys.argv) < 2:
print('Not enough arguments')
quit()
max_iterations = int(sys.argv[1]) # The maximum number of iterations to perform
excess_prec = 2 # Additional precision to help avoid rounding errors
@caseydreier
caseydreier / application.js
Created September 13, 2011 18:42
Application.js file with jqplot.js loader libraries
// System-wide application js manifest
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require jqplot
@caseydreier
caseydreier / jqplot.js
Created September 13, 2011 18:34
JQPlot loader file for Sprockets
// Loads the JQPlot files as defined in jquery.jqplot.js
//= require jqplot/jqplot.core.js
//= require jqplot/jqplot.linearTickGenerator.js
//= require jqplot/jqplot.linearAxisRenderer.js
//= require jqplot/jqplot.axisTickRenderer.js
//= require jqplot/jqplot.axisLabelRenderer.js
//= require jqplot/jqplot.tableLegendRenderer.js
//= require jqplot/jqplot.lineRenderer.js
//= require jqplot/jqplot.markerRenderer.js
//= require jqplot/jqplot.divTitleRenderer.js
@caseydreier
caseydreier / gist:1211729
Created September 12, 2011 16:43
Creation of local variables in non-executed code in Ruby 1.9.2
if false
one = 1
two = 2
three = 3
end
# Local variables are defined now, but not set to anything
puts local_variables
=> [:one, :two, :three, :_]
@caseydreier
caseydreier / signups_controller.rb
Created March 8, 2011 15:09
Controller showing scoped collection filter so we can use it as a nested resource or regular resource.
# This report displays users who have created new accounts during the specified time period.
class Admin::Reports::SignupsController < Admin::Reports::ApplicationController
before_filter :load_building, :only => :show
before_filter :parse_dates_or_use_default
helper_method :title_for_display
def index
@users_created_count = collection_filter.created_between(@start_date, @end_date).active.count
if params[:summary]
@dorms = @current_site.university.try(:dorms)
@caseydreier
caseydreier / sinatra_start.rb
Created March 5, 2011 15:46
Helpful libraries and Bundler integration with Sinatra.
# Gemfile
source :rubygems
gem 'sinatra', "~> 1.0.0"
gem 'sinatra-default_charset'
gem 'sinatra-reloader'
gem 'sinatra-static-assets'
gem 'emk-sinatra-url-for'
gem 'activesupport'
@caseydreier
caseydreier / views-view-field--name.tpl.php
Created March 4, 2011 19:23
Return localized taxonomy in a view
<?php
/**
* Override the taxonomy term name to make sure it's the translated version.
* Since Views does not support localizable taxonomy but we want Views to handle all good rendering stuff
* it does, we just replace any occurrence of the original value with our localized string translation,
* and leave the rest the same in the pre-rendered output.
* Note that you should set your $tid to reference the proper value in your $row object, and that this is
* for localized taxonomy only.
*/
$tid = $row->node_node__term_data_tid;
# Installed via:
# rails plugin install git://github.com/rails/exception_notification.git
# Then, created an initializer in
# config/initializers/exception_notification.rb:
Rsf::Application.config.middleware.use ExceptionNotifier,
:email_prefix => "[RSF ERROR] ",
:sender_address => %{"notifier" <notifier@example.com>},
:exception_recipients => %w{webmaster@singlebrook.com}
source :gemcutter
gem "rails", "2.3.4"
gem "radiant", "0.8.1"
gem "sqlite3-ruby", "1.2.5", :require => "sqlite3"
gem "mysql"
gem "rack", "1.0.0"