Skip to content

Instantly share code, notes, and snippets.

View eightbitraptor's full-sized avatar

Matt Valentine-House eightbitraptor

View GitHub Profile
#!/usr/bin/env ruby
require 'net/http'
def build_is_fucked_on(server)
cruise_output = Net::HTTP.get(URI.parse("http://#{server}:3333/XmlStatusReport.aspx"))
return true if cruise_output.include? 'lastBuildStatus="Failure"'
return false
end
count = 0
while true
@eightbitraptor
eightbitraptor / remote_diff.sh
Created January 26, 2010 11:53
A naive way of diffing 2 files on seperate servers
#!/bin/bash
path1=`echo $1 | awk -F, '{print $1}'`/$2
path2=`echo $1 | awk -F, '{print $2}'`/$2
if `curl -Ss $path1 | file - | grep text`; then
diff <(curl -Ss $path1) <(curl -Ss $path2)
else
diff <(curl -Ss $path1 | md5) <(curl -Ss $path2 | md5)
fi
@eightbitraptor
eightbitraptor / simple pager
Created November 12, 2010 15:48
select id from blah, and get the output in a form suitable for copying and pasting to other sql statements/arrays etc
#!/usr/bin/env ruby
output = ""
ARGF.each do |line|
next if line.match(/^\+/)
if line.match(/\|\s+(\S+)/)
output << ($1 + ",")
end
end
@eightbitraptor
eightbitraptor / init.el
Created February 7, 2011 16:55
my emacs init.el
(setq
elisp-path "~/.emacs.d/"
vendor-path "~/.emacs.d/vendor/")
;; Default Text Mode stuff
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
(setq make-backup-files nil)
(setq-default save-place t)
@eightbitraptor
eightbitraptor / person_test.rb
Created September 21, 2011 17:05 — forked from tenderlove/person_test.rb
Use minitest/spec with Rails 3
require 'test_helper'
require 'minitest/autorun'
module Tenderlove
class Spec < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
@eightbitraptor
eightbitraptor / post.rb
Created October 12, 2011 09:36
Testing gist.el with some code from the post parser of ebr.com
lines = File.open(path)
body = lines.map do |l|
if l.match /^::(.*)::(.*)$/
instance_variable_set("@#{$1}", $2.strip )
self.class.send(:attr_accessor, "#{$1}")
nil
else
l
end
@eightbitraptor
eightbitraptor / go go TDD
Created October 19, 2011 10:40
My 2 favourite config lines ever
autocmd BufRead,BufNewFile *_spec.rb
\ map ;t :w\|:!rspec --no-color %<cr>
autocmd BufRead,BufNewFile *_test.rb
\ map ;t :w\|:!ruby -Ilib %<cr>
@eightbitraptor
eightbitraptor / ordered_jobs_spec.rb
Created November 14, 2011 21:02
A first pass solution for @martinrue's Ordered Jobs Kata
# started writing the tests for OrderedJobs class
# wrote no jobs and a single job, when I got to single job
# left that test failing because I realised I needed some
# kind of Job, and potentially a parser.
#
# Started working on a job class, tdd'd it to have a name
# and an optional dependancy, and nothing else.
#
# Still need a way of getting strings into Jobs to make my
# single job test case pass though, to keep the OrderedJobs
@eightbitraptor
eightbitraptor / jenkins_mon.ru
Created November 24, 2011 13:28
build status monitor
require 'rack'
require 'jenkins-remote-api'
class OhGodBuildBot
def initialize
@jenkins = Ci::Jenkins.new('http://172.21.6.241:8080/')
end
def failing?
@jenkins.list_all_job_names.map{ |job| @jenkins.current_status_on_job(job) }.include? "failure"
@eightbitraptor
eightbitraptor / pokedex.sh
Created January 19, 2012 11:48
get a random pokemon name
#!/bin/bash
#cat pokedex.html | grep '<tr>' -A 3 | grep 'title=' | cut -d' ' -f 7 | sed -e 's/.*\>\(.*\)<\/a>/\1/'
main(){
echo `random_pokemon`
}
random_pokemon() {
index=`expr $RANDOM \% $(count) + 1`
pokedex | head -$index | tail -n 1