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 'rubygems' | |
require 'fiveruns-starling' | |
require 'benchmark' | |
q = Starling.new("127.0.0.1:22122") | |
num_times = 10_000 | |
Benchmark.bmbm do |x| | |
x.report("push #{num_times}") do |
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 DieCode < String | |
cattr_accessor :wild_die | |
attr_reader :dice, :pips | |
REGEXP = /(^\d+)D\+?([12])?$/ | |
class << self | |
def valid?(code) | |
code =~ REGEXP | |
end |
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
package com.example.myproject; | |
import java.util.Date; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.util.Log; | |
import android.view.Menu; | |
import android.view.MenuItem; |
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
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(); |
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/ruby | |
# 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 = Time.now |
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
# 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' |
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 '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 |
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 '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 |
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
+__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) |
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
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) | |
all | |
end | |
OlderNewer