Skip to content

Instantly share code, notes, and snippets.

View davidlee's full-sized avatar

David Lee davidlee

View GitHub Profile
# NOTE: see http://www.dribin.org/dave/blog/archives/2007/11/28/ssh_agent_leopard/
# on leopard, DON'T run ssh-agent; just ssh-add and it will work.
export agentfile=/tmp/.ssh_agent
function start_ssh_agent() {
echo > $agentfile
chmod 600 $agentfile
ssh-agent > $agentfile
load_ssh_agent
function remember() {
echo -e "tell application \"Finder\"\n display dialog \"${@}\"\n end tell" | osascript &
disown
}
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMM8?????????????????????????????????????????????????????NMMMMMMMMMMMMM
MMMMMMMMMMM=????????????????????????????????????????????????????????MMMMMMMMMMMM
MMMMMMMMMM8???????????????????????????????????????+O????????????????MMMMMMMMMMMM
MMMMMMMMMMO???????????????????????????????????????IM????????????????MMMMMMMMMMMM
MMMMMMMMMMO????????????????????+$NMN7+???NMZ??????I?????????????????MMMMMMMMMMMM
MMMMMMMMMMO?????8DO?+????????OMMMMMMMMMI?MMMMMD?????????????????????MMMMMMMMMMMM
MMMMMMMMMMO??++?=OMMMMMMO???ZMMMMMMMMMMMN??MMMMMMI??????????????????MMMMMMMMMMMM
MMMMMMMMMMO8NNMMMMMMMMMMMM7DMMMMMMMMMMMMM+??+I8MMM??????????????????MMMMMMMMMMMM
module Spec
module Example
SLOW_SPECS_WARNING = "SKIPPED: CONTINUOUS INTEGRATION only (SLOW_SPECS=y)"
module ExampleGroupMethods
def skip_unless_ci
before(:each) { pending SLOW_SPECS_WARNING } unless ENV['SLOW_SPECS']
end
alias :describe :context
# strip whitespace before commit
for i in $(git diff-index --cached --name-only HEAD); do
EXISTS=$(git diff-files --name-only | grep $i);
if [ "$EXISTS" != "" ]; then
echo unstaged dirty changes for $i, not touching
else
perl -pe 's/[\t ]+$//g' -i $i;
git-add $i;
fi
done
context 'unauthorized' do
it "ACK an attempt to CONNECT" do
result = json_request :command => 'CONNECT', :message_id => 'antarctica'
result['command'].should == "ACK"
result['message_id'].should == "antarctica"
end
it "send an ERROR for any message which is not a CONNECT" do
result = json_request :command => 'SHOWTABLES', :message_id => 'snoo', :location => 'wibble'
result['command'].should == "ERROR"
#!/usr/bin/env ruby
#
# Sample Ruby script using the Selenium client API
#
require 'rubygems'
gem "rspec", "=1.2.6"
gem "selenium-client", ">=1.2.16"
require "selenium/client"
require "selenium/rspec/spec_helper"
# assumes a User model with restful_authentication and a string time_zone column
class ApplicationController < ActionController::Base
around_filter :set_timezone
def set_timezone
TzTime.zone = TimeZone[ current_user && current_user.time_zone || session[:utc_offset_hours] || 0 ]
yield
TzTime.reset!
end
@davidlee
davidlee / gist:214687
Created October 20, 2009 22:34
Pure javascript timezone management for Rails
module ApplicationHelper
def local_time(time)
capture_haml do
haml_tag :span, time.utc.to_s, :class => 'time'
end
end
def local_date(time)
capture_haml do
@davidlee
davidlee / gist:189989
Created September 20, 2009 23:47
script/firefox for selenium firefox path
#!/bin/sh
export FIREFOX=/Applications/Firefox.app
/usr/bin/open $FIREFOX $1