Skip to content

Instantly share code, notes, and snippets.

View sxross's full-sized avatar

s.ross sxross

View GitHub Profile
@sxross
sxross / install_node.sh
Created November 27, 2011 19:28
Installing node.js Using Homebrew
$ sudo brew install node
Password:
Formula already installed: /usr/local/Cellar/node/0.2.2
steve-rosss-iMac-2:~ sxross$ sudo brew uninstall node
Uninstalling /usr/local/Cellar/node/0.2.2...
steve-rosss-iMac-2:~ sxross$ sudo brew install node
==> Downloading http://nodejs.org/dist/node-v0.2.2.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.2.2
==> make install
@sxross
sxross / html_tag.coffee
Created May 27, 2011 21:06
Coffeescript HTML Tag Helper Class
# HTML Tag class
#
# Purpose: Programmatically generate HTML so you aren't scotch-taping
# strings together all the time.
#
# Usage: targetString = Tag.make(tagName, attributeHash, text)
#
# Where: targetString: is what you will eventually inject into the DOM -- the HTML
# tagName: is the actual tag name (i.e., "tr" or "input")
# attributeHash: is the set of tag attributes, for example --
# This may well be user error, but CoffeeScript:
ubb_text: ubb_text.replace /\[img\](.+?)\[\/img\]/gi, (str, args...) ->
throw "oh, crap!" unless args[0]
image_url: if args[0].match(/^http/i) then args[0] else "http://www1.istockphoto.com${args[0]}"
"<img src=\"${image_url}\" />"
# The resultant js is:
ubb_text = ubb_text.replace(/\[img\](.+?)\[\/img\]/gi, function(str) {
require "mongo_mapper"
MongoMapper.database = 'test'
module FindOrCreate
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module FindOrCreate
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def find_or_create(arg)
first(arg) || create(arg)
#!/usr/env ruby
require 'rubygems'
require 'fileutils'
class Object
def empty?
return true if self.nil?
case
when String, Array, Hash
return true if self.length == 0
Some basic features and scenarios for authentication. Implementation left out. Sorry.
Feature: Signing up for an account
In order to use the site
As a visitor
I sign up for an account
Scenario:
Given I'm an anonymous visitor
And I go to the home page