Skip to content

Instantly share code, notes, and snippets.


Tim Haines timhaines

View GitHub Profile
View Add_to_array_inconsistencies.rb
def measure_time task_description
beginning =
puts "Time to #{task_description}: #{ - beginning} seconds"
def add a, i
a << i
View IOSpeedTest
# IO speed tests on a new softlayer server using the cheap 500gb Sata drives.
#62500 blocks per gig
# want to double ram
# have 12gb, so want 24gb worth
# 62500 * 24 = 1500000
time sh -c "dd if=/dev/zero of=ddfile bs=16k count=1500000 && sync"
#paste output:
1500000+0 records in
View gist:547403
require "nestful"
require "roauth"
def upload(path_to_file)
twitpic_key = "my_twitpic_api_key"
oauth_url = ""
oauth = {
:access_key => "account_access_key",
:access_secret => "account_access_secret",
timhaines / th_tweets.txt
Created Jan 1, 2011
@TrainedHedonist's tweets
View th_tweets.txt
View these by putting the ID in the url. I.e. for the first one,
On Twitter:
On Favstar:
16086877353: I hope I'm never with a woman that cackles. A laugh, chortle, or guffaw is fine. Cackling, no.
16116045254: Just went jogging and some hotshot blew right by me. I showed him a thing or two when I ran past him and tumbled over a birch tree stump.
16132364963: Discovering the woman you're with is wearing granny panties is sort of like seeing a Unicorn drop a deuce.
16163485559: I like to spice up speed dating with an impromptu existential meltdown.
16180942217: It's been a while since I've had a hangover. It's supposed to feel like John Goodman is sitting on your face, right?
16317523206: "I get what you're saying about climate change, but I would like to talk about pornography now instead." (inappropriate segue)
timhaines / resque_retry.rb
Created Sep 9, 2011 — forked from PatrickTulskie/resque_retry.rb
Retry failed Resque jobs in Ruby
View resque_retry.rb
# inspired by
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
# retry all :)
Resque::Failure.count.times do |i|
timhaines / name_display.rb
Created Feb 22, 2012
Name Display in Page Title
View name_display.rb
def name_for_page_title user
result = "@" + user.screen_name
if I18n.locale == :en
result += user.screen_name.last == "s" ? "’" : "’s"
result += " (#{})" unless user.screen_name ==
return result
View gist:1896693
stats slabs
STAT 1:chunk_size 96
STAT 1:chunks_per_page 10922
STAT 1:total_pages 1
STAT 1:total_chunks 10922
STAT 1:used_chunks 10344
STAT 1:free_chunks 578
STAT 1:free_chunks_end 0
STAT 1:mem_requested 936814
STAT 1:get_hits 5477766
View gist:2474197
Exec: /usr/local/Cellar/riak/1.1.1x86_64/libexec/erts-5.8.5/bin/erlexec -boot /usr/local/Cellar/riak/1.1.1x86_64/libexec/releases/1.1.1/riak -embedded -config /usr/local/Cellar/riak/1.1.1x86_64/libexec/etc/app.config -pa ./lib/basho-patches -args_file /usr/local/Cellar/riak/1.1.1x86_64/libexec/etc/vm.args -- console
Root: /usr/local/Cellar/riak/1.1.1x86_64/libexec
Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:64] [hipe] [kernel-poll:true]
=INFO REPORT==== 23-Apr-2012::15:03:29 ===
alarm_handler: {set,{system_memory_high_watermark,[]}}
** ./lib/basho-patches/etop_txt.beam hides /usr/local/Cellar/riak/1.1.1x86_64/libexec/lib/observer-0.9.10/ebin/etop_txt.beam
** /usr/local/Cellar/riak/1.1.1x86_64/libexec/lib/observer-0.9.10/ebin/etop_txt.beam hides /usr/local/Cellar/riak/1.1.1x86_64/libexec/lib/basho-patches/etop_txt.beam
** Found 2 name clashes in code paths
View gist:5109052


Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPad

Consumer key: CjulERsDeqhhjSme66ECg
timhaines / gist:6153982
Last active Dec 20, 2015
Consent of the governed - from the 2nd paragraph of the Declaration of Independence
View gist:6153982
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness.