Skip to content

Instantly share code, notes, and snippets.

# Turn darcs patches into git commits
#
# This code can handle:
# * adding files
# * modifying file contents
# * removing files
# * adding directories (ignored)
# * removing directories (ignored)
# * renaming files
# * renaming empty directories
@ashmoran
ashmoran / ash.zsh-theme.bash
Last active December 14, 2015 05:49
My oh-my-zsh theme
# My theme - ash.moran@patchspace.co.uk
# Based on Fino theme with bits from dallas and robbyrussell
# Fino notes:
# Use with a dark background and 256-color terminal!
# Meant for people with RVM and git. Tested only on OS X 10.7.
# You can set your computer name in the ~/.box-name file if you want.
# Borrowing shamelessly from these oh-my-zsh themes:
# bira
require_relative 'test_helper'
require 'rack/test'
require 'minitest/autorun'
require 'capybara'
require 'capybara/dsl'
include Capybara::DSL
def app
MyApp::Server
def hash_options(args, defaults)
args.assert_valid_keys(*defaults.keys)
defaults.merge(args).values
end
def my_method(args = {})
some, other, blah =
*hash_options(args, :some => 'value', other: 'value 2', blah: 'value 3')
# Use
@ashmoran
ashmoran / fibonacci_spec.io
Created December 12, 2012 15:32
The Fibonacci sequence in Io
Fibonacci := Object clone
Fibonacci generate := method(n,
if(n == 1 or n == 2, 1, generate(n - 1) + generate(n - 2))
)
Object Fibonacci := Fibonacci
describe(fibonacci, Fibonacci,
setup(
@ashmoran
ashmoran / new_operator.io
Created December 10, 2012 22:51
Adding a new operator in Io - woah!
OperatorTable println
"ADDING A NEW OPERATOR!!!" println
"" println
OperatorTable addOperator("^|", 11)
true ^| := method(bool, if(bool, false, true))
false ^| := method(bool, if(bool, true, false))
OperatorTable println
@ashmoran
ashmoran / market_agent.rb
Created October 21, 2012 16:11
Trailing Stop Loss kata extracts for the Celluloid mailing list
require 'celluloid'
require_relative 'timers/null_timer'
require_relative 'timers/too_late_timer'
class MarketAgent
include Celluloid
class ActionError < RuntimeError; end
@ashmoran
ashmoran / sketch.rb
Created June 29, 2012 16:04 — forked from mattwynne/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationCreator
require 'spec_helper'
describe NIO::Monitor do
let :readable do
reader, writer = IO.pipe
writer << "have some data"
reader
end
let :selector do
@ashmoran
ashmoran / report_ability.rb
Created December 22, 2011 12:54
Example of using the CanCan language described in https://gist.github.com/1509779
class Ability
ReportAbility = AbilityBuilder.new do
def build
can :update_content, Report do |report|
report.being_edited_by?(user)
end
can :check_in_report, Report do |report|
report.being_edited_by?(user)
end
end