Skip to content

Instantly share code, notes, and snippets.

View retospect's full-sized avatar

Reto Stamm retospect

View GitHub Profile
@retospect
retospect / rails notes.txt
Created October 20, 2010 16:52
Rails Notes - project generation
References
http://railscasts.com/episodes/218-making-generators-in-rails-3
http://edgeguides.rubyonrails.org/generators.html
@retospect
retospect / san mateo ids
Created January 25, 2011 21:10
Checkin ID's for San Mateo
VID Dist. Name
47bae90ff964a520d24d1fe3 21 BJ's Restaurant & Brewhouse
4c2f94e9ed37a593ea886703 56 Toys Are Us
4aefa901f964a520cfd921e3 64 Staples - Bridgepointe
4b2d5755f964a520a1d424e3 81 Hallmark Creations
4840c7c2f964a5202d501fe3 98 Mimi's Cafe - San Mateo
4cadf334632b370496b26b6e 102 Fortify Software
4b23e8edf964a520a25c24e3 105 Marshalls - Foster City
4c2e69533896e21e7a39e290 117 Irol's Place
4a09b759f964a52049741fe3 117 Target - San Mateo Fashion Island
@retospect
retospect / la
Created January 25, 2011 22:08
LA Checkin VID's
VID Dist Name
4cb90ed2bac93704d1fae17c 0 Layla's Mediterranean Cafe
4caf773aeb65b1f7b9f363cd 0 OneWest Bank
4cbf0660ca4aa1cdf5a317b4 0 Beverly Hilton
4cb89e6ddd41a35d0c5cdca0 0 CBEST
4caf362039458cfa1c7cf89f 0 West Coast ENT
4cbcce884495721e9a865c7a 0 Ameriprise
4c2bcd4577cfe21ee217b5f1 26 Lea Journo Salon
4ced9b6982125481491260a1 35 Gang, Tyre, Ramer & Brown
4bc5fc2edb8fa593948b9b37 55 USB Financial Services
@retospect
retospect / spec_helper.rb
Created February 11, 2011 20:20
How to get nice test messages in your rspec test logs, and reset mongoid records
RSpec.configure do |config|
config.mock_with :mocha
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
# use_transactional_fixtures config option was removed by Mongoid
@retospect
retospect / gist:972775
Created May 15, 2011 00:18
Math 10: Graphing pinky length with R
# Gnu R code to generate histogram for lab
length_of_pinky = c(6,5.5,5.5,6.5,5.5, 5,5.5,6.5,5.5,6, 5.5,6,5.5,5,6, 5,6.5,6,5.5,5, 5.5,7.5,6,5.5,5.5, 6,5.5,6,6.5,7)
hist(length_of_pinky, seq(4.75, 7.75, 0.5), prob=TRUE, main="Histogram of students pinky length [cm]", xlab="Length of pinky [cm]")
lines(density(length_of_pinky, bw=0.25), col="blue")
curve(dnorm(x,mean=mean(length_of_pinky), sd=sd(length_of_pinky)), add=TRUE, col="green")
@retospect
retospect / gist:1004073
Created June 2, 2011 07:34
Amazon Turk data extraction hack
#!/opt/local/bin/ruby
require "ruby-debug"
filename = 'ex_dataset.csv'
file = File.new(filename, 'r')
line_count = -1
col_headers = {}
results = Hash.new(0)
file.each_line do |row|
line_count = line_count + 1
@retospect
retospect / fitbit_beeminder.rb
Created September 27, 2012 17:24
Hack to pull fitbit data to Beeminder
require 'rubygems'
gem "beeminder", "= 0.2.2"
require 'fitgem'
require 'json'
require 'beeminder'
consumer_key = 'FITBIT_KEY'
consumer_secret = 'FITBIT_SECRET'
token = 'FITBIT_TOKEN'
secret = ''
@retospect
retospect / rescuetime.rb
Created September 27, 2012 21:39
Hack for rescuetime-beeminder integration
require 'rubygems'
require 'json'
gem 'beeminder', "0.2.2"
require 'beeminder'
require 'open-uri'
require 'uri'
require 'ruby-debug'
# Pulls data from Rescuetime and sends it to Beeminder.
# Maybe run it in an hourly cron job.
# Enter your keys and tokens below.
@retospect
retospect / config
Created June 20, 2014 17:04
Print pianobar song and artist in tab name on osx
# ~/.config/pianobar/config
user = user@example.com
password = very_secret
event_command = /Users/username/.config/pianobar/tabname.sh
Device kWh/year CO2 peak hour use CO2 low/use Sources
Electric Tumble Drier 556kWh 167kg 83kg [1]
Gas Tumble Drier 15kWh 122kg 119kg [2]
Dishwasher 1 1 1
Tesla Model 3 50 1 1 1 50 miles/day [4]
Chevy Bolt 1 1 1
Chevy Volt 1 1 1
Toyota Plug in Prius 1 1 1
Toyota Tundra Pickup 1 1 1
VW Bug 1 1 1 1