Skip to content

Instantly share code, notes, and snippets.

View damien's full-sized avatar
🤝
Open for business! Hire me for your project at https://mindglob.com

Damien Wilson damien

🤝
Open for business! Hire me for your project at https://mindglob.com
View GitHub Profile
@damien
damien / version.js
Created March 19, 2012 17:00
A simple version class
var Version = function (major, minor, patch) {
this.major = major
this.minor = minor
this.patch = patch
}
Version.prototype.toString = function () {
return [this.major, this.minor, this.patch].join(".")
}
@damien
damien / redis-say.rb
Created March 14, 2012 19:15
Say whatever redis tells you to
#!/usr/bin/env ruby
%w(uri logger rubygems redis childprocess).each do |dep|
begin
require dep
rescue LoadError
puts "The #{dep} gem could not be loaded! Try running: gem install #{dep}"
end
end
@damien
damien / gist:2009676
Created March 10, 2012 01:46
start function from unicorn init.d script
#!/bin/bash
unicorn_start() {
if ! unicorn_is_running ; then
echo "Unicorn Starting, Type: ${APP_TYPE} interface, App Name: ${application}"
if [[ $APP_TYPE == "rails" ]] ; then
bundle exec $UNICORN_EXEC -E $RAILS_ENV -c $UNICORN_CONF -D
unicorn_status=$?
else
bundle exec $UNICORN_EXEC -E $RACK_ENV -c $UNICORN_CONF -D /data/${application}/current/config.ru
unicorn_status=$?
@damien
damien / cucumber_table_persistence.feature
Created January 18, 2012 00:53
Cucumber table persistance
Feature: Table persistence
Scenario: We try to modify a table and it keeps its changes when we pass it to another step
When we have the following table and then set an arbitrary value inside the step definition
| one | 1 |
| fizz | buzz |
Then the table should retain this modification when passed to another step
@damien
damien / ie-check.js
Created October 21, 2011 19:58
Detect IE8 with jQuery
// Assuming jQuery in $
if ($.browser.msie && parseInt($.browser.version, 10) === 8)) {
// do stuff
}
@damien
damien / config.ru
Created August 15, 2011 21:35
A simple rack middleware to debug the request pipeline
# Usage example
require "inspect_middleware"
use InspectMiddleware
run GenericSinatraApp
@damien
damien / Gemfile
Created January 5, 2011 07:21
A quick test to mess around with em-synchrony.
source :rubygems
gem "eventmachine"
gem "em-synchrony", :require => "em-synchrony"
gem "em-http-request", :require => "em-http"
┌─[damien@Thor] - [~/src/em-http-request] - [Wed Dec 15, 11:26]
└─[$]> autotest
loading autotest/rspec2
bundle exec /Users/damien/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -S /Users/damien/.rvm/gems/ruby-1.9.2-p0@em-http-request/gems/rspec-core-2.0.1/bin/rspec --autotest '/Users/damien/src/em-http-request/spec/encoding_spec.rb' '/Users/damien/src/em-http-request/spec/mock_spec.rb' '/Users/damien/src/em-http-request/spec/multi_spec.rb' '/Users/damien/src/em-http-request/spec/request_spec.rb'
......F...........F..............................................F.................
Failures:
1) EventMachine::HttpEncoding should be fast on long string escapes
Failure/Error: (Time.now - s).should be_close(1, 0.5)
expected 1 +/- (< 0.5), got 0.481466
@damien
damien / clonableFields.jquery.js
Created September 21, 2010 20:58
Form interaction plugin inspired by Vidget's 'Single-Use JQuery' Plugins post: http://www.viget.com/extend/single-use-jquery-plugins/
(function($) {
$.fn.cloneableFields = function() {
return this.each(function() {
var container = $(this);
var fields = container.find('li:last');
var label = 'Add another ' + fields.find('label').text();
container.count = function() {
return this.find('li').size();
};
┌─[damien@protos] - [~/.vim] - [Tue Aug 24, 05:00]
└─[$] <git:(master*)> <rvm:(ruby-1.9.2)> rake zoomwin --trace
(in /Users/damien/.vim)
** Invoke zoomwin (first_time)
** Execute zoomwin
****************************************
* Installing zoomwin *
****************************************