Skip to content

Instantly share code, notes, and snippets.


Evan Light elight

  • Heroku
  • Washington, DC
View GitHub Profile
View fiveruns-starling-bench.rb
require 'rubygems'
require 'fiveruns-starling'
require 'benchmark'
q ="")
num_times = 10_000
Benchmark.bmbm do |x|"push #{num_times}") do
View die_code.rb
class DieCode < String
cattr_accessor :wild_die
attr_reader :dice, :pips
REGEXP = /(^\d+)D\+?([12])?$/
class << self
def valid?(code)
code =~ REGEXP
package com.example.myproject;
import java.util.Date;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
View gist:122078
try {
URL url = new URL (urlStr);
String encoding = Base64Coder.encodeString(authInfo);
// Need to work with URLConnection to set request property
URLConnection uc = url.openConnection();
uc.setRequestProperty ("Authorization", "Basic " + encoding);
BufferedReader rd = new BufferedReader(new InputStreamReader(uc.getInputStream()));
StringBuffer sb = new StringBuffer();
View xcoder
# A little hack that I threw together to help me bulk transcode content for our Apple TVs.
while !ARGV.empty?
infile = ARGV.shift
outfile = infile[0..-5] + ".mp4"
cmd = "mencoder -profile appletv-mod \"#{infile}\" -o \"/home/evan/Desktop/Drobo/Movies/#{outfile}\""
puts cmd
t0 =
View movie_meta.rb
# A windows script to lookup movie files in Wikipedia, find the entry for the film,
# and extract the film synopsis, download the film's poster, and stuff it in iTunes.
# It's a bit naive about over-loaded names at the moment but the simple hack to that is
# add "(film)" to the file name.
# We hate physical media in our house as my wife and I have a tendency to lose/destroy DVDs.
require 'rubygems'
require 'rbwikipedia'
require 'active_support'
View kata_2_iterative_solution.rb
require 'test/unit'
def chop(target, input)
puts "--------------------------------"
puts "chop #{target}, #{input.inspect}"
return -1 if input.empty? || target < 0 || target < input.first || target > input.last
found = false
@current_index = input.length / 2
@current_array = input
while !found do
elight / Rakefile
Created Nov 21, 2009
Rakefile for running Scala Spec specifications based upon @berkel's android-helloworld-scala Rakefile
View Rakefile
require 'rubygems'
require 'rake'
require 'rexml/document'
require 'rake/clean'
fail "need SCALA_HOME set" unless ENV['SCALA_HOME']
fail "need ANDROID_SDK set" unless ENV['ANDROID_SDK']
def manifest
@parsed ||= begin
View gist:339729
+__rvm_parse_args:373> [[ -z '' ]]
+__rvm_parse_args:373> [[ ! -z '' ]]
+__rvm_parse_args:374> [[ ! -z '' ]]
+__rvm_parse_args:374> [[ ! -z '' ]]
+__rvm_parse_args:3> [[ 1 -gt 0 ]]
+__rvm_parse_args:4> rvm_token=1.8.7+holygrail
+__rvm_parse_args:4> shift
+__rvm_parse_args:5> case 1.8.7+holygrail (fetch|version|srcdir|reset|debug|reload|implode|seppuku|update|monitor|notes)
+__rvm_parse_args:5> case 1.8.7+holygrail (package)
+__rvm_parse_args:5> case 1.8.7+holygrail (use)
View whopper.rb
TOPPING_NAMES = %w[ketchup mustard mayonnaise pickles onions lettuce tomato]
burger = Product.create(:name => "Burger")
toppings = burger.option_types.create(:name => "toppings", :presentation => "Toppings")
all_toppings = TOPPING_NAMES.inject([]) do |all, topping|
all << toppings.option_values.create(:name => topping, :presentation => topping.upcase)