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 '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 = { |
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 '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 |
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
<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> |
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
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"]) |
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
{ | |
"name": "node-static-test", | |
"version": "0.0.1", | |
"engines": { | |
"node": "0.8.x" | |
}, | |
"dependencies" : { | |
"http": "latest", | |
"node-static": "latest" | |
} |
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
# http://help.github.com/ignore-files/ | |
# git config --global core.excludesfile ~/.gitignore_global | |
# Ruby Config # | |
############### | |
.sass-cache/ | |
.bundle/ | |
# Compiled source # | |
################### |
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
class Point { | |
int year; | |
int population; | |
float rateOfChange; | |
Point(int _year, int _population){ | |
year = _year; | |
population = _population; | |
} |
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
install_root = File.expand_path(File.dirname(__FILE__)) | |
if !ARGV[0] | |
puts "ERROR: You must supply the name of the app you want to create. Like this:" | |
puts "./new_sinatra_app my_app" | |
exit 1 |
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
var http = require('http'); | |
// Set up ecstatic to read from the root folder of this app. | |
var ecstatic = require('ecstatic')(__dirname); | |
var matchRoutes = function (req, res) { | |
console.log('Request: '+ req.method + ' ' + req.url) | |
// Match the main route "/" | |
if (req.url === "/" ) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); |
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
50.times do | |
%x(curl --data "vote=dog" http://www.therehasneverbeenanythinglikethis.com/vote) | |
sleep (2.0) | |
end |