Skip to content

Instantly share code, notes, and snippets.

@Stubbs
Stubbs / watchr.rb
Created March 9, 2011 18:13
This is a watchr config script that watches all the Python files in the directories specified by the "watch" command. You can specify one for each Django app in your project.
require "ruby-growl"
watch ('project/(.*).py') {|md| code_changed "#{md[0]}"}
def code_changed(file)
# Get the path of the file that changed
dir = File.dirname(file)
test(dir)
end
@Stubbs
Stubbs / gist:999180
Created May 30, 2011 17:24
Statsd error
buildstats@buildstats-desktop:~/statsd$ node stats.js config.json
/home/buildstats/statsd/config.js:2
"graphitePort": 2003,
^
SyntaxError: Unexpected token :
at Module._compile (node.js:458:37)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at loadModule (node.js:283:14)
@Stubbs
Stubbs / behat.sh
Created November 23, 2011 14:17
Behat Bash Autocompletion
#
# Add this to your /etc/bash_completion.d directory for behat parameter auto completion.
#
_behat()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
@Stubbs
Stubbs / pre-commit
Created January 17, 2012 10:30
pre-commit hook to stop you commiting broken tests.
#!/bin/sh
# Script to check the status of the last test run & cancel the commit if there are any errors or failures
RESULTS="tests/reports/testsuites.xml"
# Check the test results exist, and have results in them.
if [ ! -s $RESULTS ]
then
echo "WTF is this shit? You've not even tried to run the tests. You suck, man."
@Stubbs
Stubbs / watchr.rb
Created February 2, 2012 12:57
watchr script to auto-run phing tests
# Watchr config script to run phing tests every time you save PHP or fixtures.
# See http://criticallog.thornet.net/2011/03/08/autotesting-with-watchr-growl-and-phpunit/
#
watch('./(.*).(php|inc)') { |m| code_changed(m[0]) }
watch('./fixtures.sql') { |m| code_changed(m[0]) }
watch('phpdebug_trigger') { |m| code_changed(m[0]) }
def code_changed(file)
run "phing test"
@Stubbs
Stubbs / install_jenkins.sh
Created February 3, 2012 10:35
Script to install everything you need for PHP CI on a Debian box.
#!/bin/bash
## Install Git #########################################
apt-get install git
## Install Ant #########################################
apt-get install ant
## Install Jenkins #####################################
@Stubbs
Stubbs / gist:2724564
Created May 18, 2012 10:36
Dirty hack for Macvim when it hangs trying to add new lines to files.
" DIRTY!
" For some reason, Macvim hangs when trying to insert a new line when editing
" mysql & javascript file.
"
" You can work around that by switching to another filetype that doesn't have
" the problem, then back again, hence these two hacks.
"
augroup mysqlhack
au!
YUI.add('fc_cone', function(Y)
{
Y.ConeIcon = Y.Base.create("coneIcon", Y.Shape, [Y.Circle], {}, {
ATTRS: {
radius: {
value: 5
},
stroke: {
weight: 2,
color: '#fff'
@Stubbs
Stubbs / gist:3497762
Created August 28, 2012 12:52
Sublime text 2 phpunit plugin error.
# Running in folder: /Users/stuart/Projects/lpsite/modules/recurring_payments/tests
$ phpunit -c phpunit.xml /Users/stuart/Projects/lpsite/modules/recurring_payments/tests/recurring_payments/RecurringPaymentErrorTest.php
-c: phpunit: command not found
@Stubbs
Stubbs / gist:5004858
Created February 21, 2013 13:52
Can you use wild cards in Puppet exec?
exec {"load-crm-fixtures":
command => "mysql -u db_user -ppassword db_name < *.sql",
cwd => "${rootDir}/sites/${siteDirectory}/db/crm/fixtures/",
path => ['/usr/bin'],
require => Exec['clean-crm-db'],
logoutput => true
}