Skip to content

Instantly share code, notes, and snippets.

##
# This is the ugly work-around for working with gems from local source.
# Comment in as required, and then run 'bundle update'.
###
# gem 'sia_squirrel', :path => 'c:/dev/repos/gems/sia_squirrel', :require => 'sia_squirrel'
# gem 'sia_beaver', :path => 'c:/dev/repos/gems/sia_beaver', :require => 'sia_beaver'
# gem 'sia_crypto', :path => 'c:/dev/repos/gems/sia_crypto', :require => 'sia_crypto'
gem 'sia_squirrel'
gem 'sia_beaver'
gem 'sia_crypto'
@ciaranarcher
ciaranarcher / minesweeper.rb
Created July 20, 2012 14:51 — forked from stubotnik/minesweeper.rb
Minesweeper Kata
module Minesweeper
class Game
attr_reader :fields
def initialize
@fields = []
@allow_input = true
@ciaranarcher
ciaranarcher / gist:3181851
Created July 26, 2012 12:50
TB Deployment Error
13:49:17,411 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "hermes-knob.yml"
13:49:17,442 INFO [org.torquebox.core] (MSC service thread 1-1) evaling: C:\dev\repos\hermes\torquebox.rb
13:49:17,442 ERROR [org.torquebox.core.runtime] (MSC service thread 1-1) Error during evaluation: require 'rubygems'
require 'torquebox-configure'
TorqueBox::Configuration::GlobalConfiguration.load_configuration( %q{C:\dev\repos\hermes\torquebox.rb} ).to_java: org.jruby.exceptions.RaiseException: (LoadError) Could not find blankslate (= 2.1.2.4) amongst [bundler-1.1.4, bundler-1.1.3, rake-0.9.2.2, rake-0.8.7, torquebox-2.0.3, torquebox-backstage-1.0.3, torquebox-cache-2.0.3-java, torquebox-capistrano-support-2.0.3, torquebox-configure-2.0.3-java, torquebox-core-2.0.3-java, torquebox-messaging-2.0.3-java, torquebox-naming-2.0.3-java, torquebox-no-op-2.0.3, torquebox-rake-support-2.0.3, torquebox-security-2.0.3-java, torquebox-stomp-2.0.3, torquebox-transactions-2.0.3, torquebox
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "sia_squirrel/version"
Gem::Specification.new do |s|
s.name = "x"
s.version = X::VERSION
s.authors = ["Ciaran Archer"]
s.email = ["[email protected]"]
s.homepage = "http://x.x.com"
module X
VERSION = '0.0.1'
end
module MyPrinter
def self.print(str, times=1)
p ((str + ' ') * times).strip
end
end
@ciaranarcher
ciaranarcher / spec_helper.rb
Created August 3, 2012 09:23
Rolling back all transactions during tests.
# Always rollback transactions for all databases
RSpec.configure do |c|
c.around(:each) do |example|
Sequel.transaction(SIASquirrel.databases.values, :rollback=>:always) { example.run }
end
end
@ciaranarcher
ciaranarcher / vhosts.sh
Created October 10, 2012 10:33
vhosts investigation
# create list of hosts
cat content_vhosts.conf | grep ServerName | awk '{ print $2 }' | sort >> sorted_hosts.txt
# health check for each
# use cntlm proxy, max op time of 5s
for host in `cat sorted_hosts.txt`
do
curl -sLk -x http://localhost:3128 -m 5 -w "$host : %{url_effective} %{http_code} in %{num_redirects} redirs\\n" $host -o /dev/null
done
@ciaranarcher
ciaranarcher / spec_helper.rb
Created November 25, 2012 19:54
Stubbing Helper
def stub_save!(obj)
obj.stub(:save!).and_return true if obj.respond_to? :save!
end
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"