Skip to content

Instantly share code, notes, and snippets.

View trobrock's full-sized avatar

Trae Robrock trobrock

View GitHub Profile
@trobrock
trobrock / Periodical Problems
Created July 7, 2009 19:30
Trouble getting the MooTools periodical function working, now working
// I am getting the error:
// 'this.clock = this.iterateClock(current, future).periodical(1000, this); is undefined'
// After it display the days left once, it throws the error
//
// This is now the working version
var Main = new Class({
Implements : [Options],
options : {
@trobrock
trobrock / SMS_Short_Code_Process.php
Created May 17, 2010 13:52
Will parse the Twitter firehose for a hash tag, and then emulate the process of an sms short code voting system using Twitter as the backend. Built overnight at the Twitter Chirp conference
<?php
require('phirehose_0.2.4/lib/Phirehose.php');
class SmsShortCode extends Phirehose {
/**
* Enqueue each status
*
* @param string $status
@trobrock
trobrock / rails-word_cloud-helper.rb
Created May 31, 2010 20:07
A helper for rails to create a tag cloud out a string of words (space delimited). Adapted the idea from here: http://snippets.dzone.com/posts/show/6027
def word_cloud(words)
wordcount = {}
words.split(/\s/).each do |word|
word.downcase!
if word.strip.size > 0
wordcount[word.strip] = (wordcount.key?(word.strip)) ? (wordcount[word.strip] + 1) : 0
end
end
s = []
@trobrock
trobrock / node.rb
Created June 15, 2010 14:27
Check to see if a node is part of a binary search tree
class Node
attr_accessor :left, :right, :value
def is_bst?(min = -1.0/0, max = 1.0/0)
# exit if the siblings are not of the Node type or Nil and have valid value
return false unless is_valid?
return false unless left.nil? or left.is_bst?(min, value)
return false unless right.nil? or right.is_bst?(value, max)
value > min and value < max
describe CardsController, "for a logged in user" do
before(:each) do
@cardset = Factory(:cardset)
profile = @cardset.profile
controller.stubs(:require_user).returns(true)
controller.stubs(:current_user).returns(profile)
end
context "and created card" do
before(:each) do
@trobrock
trobrock / rebuild_server.sh
Created December 24, 2010 21:28
simple script that helps when working on a chef recipe using rackspace
NODE=$1;
SERVER=$2;
knife cookbook upload -a;
ID=`knife rackspace server list | grep $SERVER | awk '{print $1}'`;
knife rackspace server delete $ID;
knife node delete -y $NODE;
knife client delete -y $NODE;
var pnlChart = {
INCOME: [
{ interval: "Jan 2011", value: 100, name: null },
{ interval: "Feb 2011", value: 200, name: null },
{ interval: "Mar 2011", value: 300, name: null }
],
EXPENSE: [
{ interval: "Jan 2011", value: 100, name: null },
{ interval: "Feb 2011", value: 200, name: null },
{ interval: "Mar 2011", value: 300, name: null }
var paramify = function(hash){
var attrs = [];
for (var k in hash) {
attrs.push(k + "=" + hash[k]);
}
attrs = attrs.sort();
return attrs.join('&');
sudo gem update --system --backtrace
Updating rubygems-update
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Package::TarInput::Zlib
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:64:in `each'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:55:in `loop'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:55:in `each'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:32:in `initialize'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:17:in `new'
bundle install --deployment --quiet --without development test
/usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_output.rb:65:in `add_gem_contents': uninitialized constant Gem::Package::TarOutput::Zlib (NameError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_writer.rb:113:in `add_file'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_output.rb:63:in `add_gem_contents'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/package/tar_output.rb:31:in `open'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/package.rb:68:in `open'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/builder.rb:77:in `write_package'
from /usr/local/lib/ruby/1.8/open-uri.rb:32:in `open_uri_original_open'
from /usr/local/lib/ruby/1.8/open-uri.rb:32:in `open'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/builder.rb:76:in `write_package'