Skip to content

Instantly share code, notes, and snippets.

View afbroman's full-sized avatar

Andrew Broman afbroman

  • University of Wisconsin-Madison
  • Madison, Wisconsin
  • X @afbroman
View GitHub Profile
# place in config/initalizers
module ActiveRecord
class Base
# Establishes a connection to the database that's used by all Active Record objects.
def self.mysql2_connection(config)
config[:username] = 'root' if config[:username].nil?
if Mysql2::Client.const_defined? :FOUND_ROWS
config[:flags] = Mysql2::Client::FOUND_ROWS | Mysql2::Client::MULTI_STATEMENTS
#!/usr/bin/env ruby
require 'rubygems'
require 'active_ldap'
ActiveLdap::Base.setup_connection(
:host => 'ldap.example.com',
:base => 'dc=example,dc=com',
)
@afbroman
afbroman / Mutex _dump_data
Created May 23, 2013 14:24
ActiveLdap throwing TypeError
TypeError (no _dump_data is defined for class Mutex):
activesupport (3.2.13) lib/active_support/message_verifier.rb:53:in `dump'
activesupport (3.2.13) lib/active_support/message_verifier.rb:53:in `generate'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:300:in `[]='
actionpack (3.2.13) lib/action_dispatch/middleware/session/cookie_store.rb:64:in `set_cookie'
rack (1.4.5) lib/rack/session/abstract/id.rb:335:in `commit_session'
rack (1.4.5) lib/rack/session/abstract/id.rb:211:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
@afbroman
afbroman / pull_data
Created May 27, 2013 22:15
Pull data from SIF HTML pages
def pull(*sif_array)
sif_array.each do |sif|
a = Analyzer.new "/Volumes/backup/SAGE/2013.05.27 results/others/#{sif}", "./2013_05_27/#{sif}.csv"
a.pull_data
a.output_csv
end
end
@afbroman
afbroman / gist.rb
Created March 28, 2014 17:38 — forked from ahoward/gist.rb
## conduce - be conducive to; "The use of computers in the classroom lead to better writing"
#
# a model+view component for rails that combines the conductor and presenter
# pattern via a model capable of generating view-centric methods
#
module Conducer
# base class
#
@afbroman
afbroman / portland_school_data.csv
Last active August 29, 2015 14:17
Portland School Data
ID Name OverallRating NumberOfStudents DropoutsCurr DropoutsLast AttendancePctCurr AttendancePctPrev MathPctCurr MathPctPrev SchoolType
822 Abernethy Elementary School Outstanding 421 0 0 95.5 95.2 73.0 88.9 E
823 Ainsworth Elementary School Outstanding 527 0 0 95.9 95.4 73.0 86.2 E
824 Alameda Elementary School Outstanding 718 0 0 96.0 95.5 73.0 89.6 E
4507 Alliance High School In Need of Improvement 235 68 55 82.1 80.8 85.1 27.7 HSG
826 Arleta Elementary School Satisfactory 405 0 0 94.3 94.2 71.6 54.7 E
4162 Arts Communication & Technology School In Need of Improvement 230 17 9 87.9 83.2 85.1 50.0 HSG
827 Astor Elementary School Outstanding 448 0 0 95.2 95.0 71.6 77.6 E
828 Atkinson Elementary School Satisfactory 412 0 0 95.3 94.8 73.0 62.3 E
830 Beach Elementary School Satisfactory 515 0 0 95.2 94.3 71.6 63.9 E
@afbroman
afbroman / index.html
Created March 28, 2015 23:55
Portland School Data
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loading CSV Data with D3</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
</head>
<body>
<h2>SVG image:</h2>
@afbroman
afbroman / index.html
Last active August 29, 2015 14:18
Portland Schools: Math Standards
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Portland Schools: Math Standards</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
</head>
<body>
<h2>Portland Public Schools</h2>
@afbroman
afbroman / index.html
Last active August 29, 2015 14:18
Portland Public Schools: Math Standards
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Portland Schools: Math Standards</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<link href="style.css" media="screen" rel="stylesheet" />
</head>
<body>
@afbroman
afbroman / index.html
Last active August 29, 2015 14:19
Portland Public School math results: scatterplot
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Portland Schools: Math Standards</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<link href="style.css" media="screen" rel="stylesheet" />
</head>
<body>