This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'hirb' | |
# irb options | |
IRB.conf[:AUTO_INDENT]=true | |
# Hirb | |
Hirb.enable :pager=>false | |
# make hashes show up as yaml (from the Hirb documentation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then /^show me the page$/ do | |
save_and_open_page | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project < ActiveRecord::Base | |
extend ActiveSupport::Memoizable | |
def my_method | |
# method code goes here | |
end | |
memoize :my_method | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Client < ActiveRecord::Base | |
validates_presence_of :name, :zip, :address, :city, :phone_number | |
# only change the humanized text for zip and name. The other attributes will still be humanized | |
# just as they normally would. | |
HUMANIZED_COLUMNS = {:zip => "Postal code", :name => "Company contact name"} | |
def self.human_attribute_name(attribute) | |
HUMANIZED_COLUMNS[attribute.to_sym] || super | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this step creates an account with the name specified and changes the host to use the | |
# new subdomain generated by the account factory. | |
Given /^an account called "(.*)"$/ do |name| | |
account = Factory(:account, :name => name) # "Factory" is from factory girl | |
host! "#{account.cname}.local" | |
end | |
# use the step like this | |
Scenario: A made up scenario |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in config/initializers/date_time_format.rb | |
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( | |
:short => lambda { |time| time.strftime("%b #{time.day.ordinalize}, %Y - %H:%M") } | |
) | |
# To use this time format do: | |
DateTime.now.to_s(:short) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include this in application controller | |
module Authentication | |
protected | |
# Inclusion hook to make #current_user and #signed_in? | |
# available as ActionView helper methods. | |
def self.included(base) | |
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
end | |
# Returns true or false if the user is signed in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rake" | |
require "rake/clean" | |
require "fileutils" | |
$pdk_path = "/opt/PalmPDK" | |
SRC = FileList["src/**/*.cpp"] | |
OBJ = SRC.ext("o") | |
CLEAN.include("src/**/*.o") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); | |
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
glTexParameterf(GL_TEXTURE_2D,GL_GENERATE_MIPMAP, GL_TRUE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_branch { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
RED="\[\033[0;31m\]" | |
GREEN="\[\033[0;32m\]" | |
WHITE="\[\033[0;37m\]" | |
CYAN="\[\033[0;36m\]" | |
PS1="$RED\$(date +%H:%M) \w$GREEN \$(parse_git_branch)$CYAN[\$(~/.rvm/bin/rvm-prompt i v g)]$WHITE\$ " |
OlderNewer