Skip to content

Instantly share code, notes, and snippets.

View JackDanger's full-sized avatar

Jack Danger JackDanger

View GitHub Profile
module Shoulda
module Macros
def should_change(expression, options = {})
by, from, to = get_options!([options], :by, :from, :to)
stmt = "change #{expression.inspect}"
stmt << " from #{from.inspect}" if from
stmt << " to #{to.inspect}" if to
stmt << " by #{by.inspect}" if by
expression_eval = lambda { eval(expression) }
diff --git a/jquery.validate.js b/jquery.validate.js
index c77350c..f9a940f 100644
--- a/jquery.validate.js
+++ b/jquery.validate.js
@@ -488,9 +488,12 @@ $.extend($.validator, {
check: function( element ) {
element = this.clean( element );
- // if radio/checkbox, validate first element in group instead
+ // if radio/checkbox, validate first visible element in group instead
# If your factories are automatically signing themselves in:
Factory.define :user do |f|
# kill the session automatically created by AuthLogic
f.after_create do |u|
(s = Session.find(u)) && s.destroy
end
end
#!/usr/bin/env ruby
# urlmonitor - print out the URLs requested system wide on the main network interface
# Accept a network interface name as an optional argument
iface = ARGV.first
# No interface specified? Try to guess which one is king..
unless iface
`ifconfig -l`.split.each do |iface|
next if iface =~ /^lo/
String.prototype.addMoneyCommas = function(){
return $.map(
$.grep(
// the input str, reversed, broken into sets of three
this.split('').reverse().join('').split(/(...)/),
// with the oddly-blank entries removed
function(str){if(0 != str.length) return true}
),
function(str){
// with the individual pieces then re-reversed
// A javascript DOM application framework API that just feels right.
// TODO: please build this into an actual framework for me. KTHXBYE.
App('chat', function(selection){
// anything you want to run at
// initialization you can add here
selection.click(function(){
# Saves an MP3 of the phrase using Google's text-to-voice.
#
# USAGE
#
# From the command line:
#
# $ ruby google-say.rb Hello World
#
# Or you can just require it and call Google.say(phrase)
require 'open-uri'
# Requirements for a better Rails mailer:
#
# - Full integration with existing ActionView views and routes
# - Easily testable design
# - Simple way to group similar email operations
# - Standardized API so every message is called the same way
file "public/stylesheets/cache/bundle.css" => FileList["public/stylesheets/*.css"] do |t|
File.open(t.name, 'w') do |bundle|
bundle.write( t.prerequisites.map {|css| File.read(css) }.join("\n") )
end
puts "***\nWrote #{t.prerequisites.size} Javascript files into bundle.css"
end
file "public/javascripts/cache/bundle.js" => FileList["public/javascripts/*.js"] do |t|
@JackDanger
JackDanger / setup_ubuntu.sh
Created February 10, 2010 05:57
install Rails essentials on ubuntu
#/bin/bash
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install build-essential
sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.1 mysql-common mysql-server-5.1 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 libhtml-template-perl mysql-server-core-5.1 libmysqlclient16 libreadline5 psmisc
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar xvzf rubygems-1.3.5.tgz