Skip to content

Instantly share code, notes, and snippets.

@stevenklise
stevenklise / post.rb
Created August 20, 2012 21:12
Has n, :through
post '/races/new' do
# params = {"cars" => [ {"car_id" => 1, "duration" => 30}, {"car_id" => 2, "duration" => 40} ] }
race = Race.new
# Assuming that "car_id" is the same as the DB ID
params["cars"].each do |car|
# Here we are making a new "Racing" for each car listed in the params. See that I'm using ":car_id" and not ":car" which I showed you above. In the above ":car" accepted an entire Car model, but it can also accept just the ID of a Car by doing "
race.racings << Racing.new(:car_id => car["car_id"], :duration => car["duration"])
<span class="n">xoff</span> <span class="o">+=</span> <span class="mf">0.01</span><span class="o">;</span>
<strong> <span class="n">xoff</span> <span class="o">+=</span> <span class="mf">0.01</span><span class="o">;</span></strong>
@stevenklise
stevenklise / chatlogs_to_file.rb
Created May 13, 2012 05:14
Save chatlogs to file as JSON from Redis
require 'date'
require 'uri'
require 'redis'
require 'json'
# Parse out the parts of the redistogo uri
uri = URI.parse ENV['REDISTOGO_URL']
# Create connection to Redis using the uri info
@redis = Redis.new :host => uri.host, :port => uri.port, :password => uri.password
@stevenklise
stevenklise / parse_csv_to_hubot.rb
Created May 8, 2012 04:06
Save a csv of presentation times names and urls to Hubot's Redis brain
require 'csv'
require 'json'
require 'redis'
require 'uri'
# Open the csv as a csv.
csv = CSV.read('./thesis.csv')
# Outputs as a 2D array but I want a hash to turn in to JSON.
thesisweek = {
@stevenklise
stevenklise / hack.sh
Created April 1, 2012 14:58 — forked from noahcrowley/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@stevenklise
stevenklise / todo.md
Created March 20, 2012 03:23
Todo list for my thesis

THESIS TODO

An annotated to do list for itpirl.com sorted by priority (top is highest priority).

TODO

  • Fix Calendar Authentication : Calendar events are broken when hosted on Heroku.
  • Event view : Sorting & time formatting of event views, categorization, filtering
  • Initiate IRC Client per user : All chat traffic is going through one instance of the IRC Client. This is non ideal. Instantiate a new client for every visiter to the website.
  • User List : Key to knowing who is in the room
@stevenklise
stevenklise / reset.css
Created March 7, 2012 22:42
Eric Meyer's CSS Reset
# Copy & Paste Code
## Eric Meyer's Reset
############################################
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

Uploading The New Batch of OCR Texts

In this document I use bold text to denote the name

There are 1,188 files in the ThesisTXT_round2 folder, and currently 1,094 Thesis records on itparchive.com. This mismatch is based on file names that were not properly parsed by the original upload script.

Each Thesis can have multiple Documentations. A Documentation stores the URL of the PDF, some admnistrative information about the state of the PDF and a text field titled paper with the contents of the corresponding .txt file. We will assume that all of the text files from the second round of OCR are better than all of the first round. And since some Documentations might not match to the new text files if we relied on the new text file replacing the contents of paper there could be a few Documentations which don't have their paper field updated. So the first step is to erase the paper field on every Documentation.

Out with the Old

@stevenklise
stevenklise / truecause.coffee
Created January 10, 2012 19:39
Hubot script to take a phrase and make it true.
# Take arguments and make them a true thing on the internet
#
# http://true-cause-i-read-it-on-the-internet.net/
#
# make true <string> - Add statement to a url on true-cause-i-read-it-on-the-internet.net
module.exports = (robot) ->
robot.hear /make true (.+)/i, (msg) ->
assertion = msg.match[1] or 'cats-are-your-friends'
assertion = assertion.split(' ').join('-')
@stevenklise
stevenklise / config.ru
Created December 4, 2011 20:08
Mapping multiple apps with Rack
require 'rubygems'
require 'sinatra'
require './index'
run Rack::URLMap.new("/" => CoolApp.new, "/ohnice" => BetterApp.new)