Skip to content

Instantly share code, notes, and snippets.

View robey's full-sized avatar

Robey Pointer robey

View GitHub Profile
File.open("test/fixtures/ketama_results", "r").each_line { |x| a = x.split(" "); puts " { \"#{a[0].gsub('\\', '\\\\\\')}\", #{a[1]}UL, #{a[2]}UL, \"#{a[3].split(':')[0]}\" }," }
set print pretty on
@robey
robey / rbdiff.sh
Created December 18, 2008 06:20 — forked from al3x/rbdiff.sh
function rbpatch {
local branch
branch=$(git name-rev --name-only head 2>/dev/null)
git diff ${1:-master}..head > "~/Desktop/${branch}-patch.txt"
}
def with_temp_folder(&block)
count = 0
begin
name = "/tmp/test#{rand(2 ** 32)}"
Dir.mkdir(name)
rescue SystemCallError
retry if count < 10
raise
end
@robey
robey / quick_feedback_runner.rb
Created February 3, 2009 19:36
draw a progress bar during tests
require 'test/unit/ui/console/testrunner'
def running_under_textmate?
ENV.keys.any? { |key| key =~ /^TM_/ }
end
begin
require 'redgreen' unless running_under_textmate?
rescue LoadError
end
// allows you to do this (manifest is of type Manifest[T]):
// val obj: T = manifest.create()
implicit def manifest2creator[T](m: Manifest[T]): Creator[T] = new Creator(m)
class Creator[T](m: Manifest[T]) {
def create(): T = m.erasure.newInstance().asInstanceOf[T]
}
import sbt._
import java.io.File
protected class StandardProject(info: ProjectInfo) extends DefaultProject(info) {
override def dependencyPath = "lib"
override def disableCrossPaths = true
val homeFolder = Path.fromFile(new File(System.getProperty("user.home")))
override def ivyCacheDirectory = Some(homeFolder / ".ivy2-sbt" ##)
#!/usr/bin/ruby
require "rubygems"
require "thrift_client"
$:.push('./target/gen-rb')
require "funny_name_generator"
client = ThriftClient.new(FunnyNameGenerator::Client, "localhost:9999", :transport_wrapper => nil)
p client.get_name()
@robey
robey / gist:1276493
Created October 10, 2011 20:51
sample coffeescript
class CamSet
server: 'http://example.com/cam/'
constructor: (@name, @max, @viewDiv, @messageDiv) ->
@urls = []
@urlMap = {}
now = new Date()
@dates = (new Date(now.getTime() - 60000 * i) for i in [max - 1 .. 0])
@urls = (this.urlForDate(d) for d in @dates)
@current = @urls.length - 1
@robey
robey / fix-github.user.js
Created March 29, 2012 20:51
small "user extension" for chrome to fix github's display of inline code
// ==UserScript==
// @name Fix github
// @namespace http://www.lag.net/fix-github/
// @version 1.0
// @description Fix the CSS for inline code segments of a markdown page on github.
//
// @include http://github.com/*
// @include https://github.com/*
// @include http://wiki.github.com/*
// @include http://help.github.com/*