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
FactoryGirl.factories.each{ |fac| puts fac.name.capitalize unless fac.name.to_s.include? "_" };nil |
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
#otherwise this list isn't going to contain all models. | |
Rails.application.eager_load! | |
ActiveRecord::Base.descendants.each do |model| | |
puts model.name | |
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 Fixnum | |
def ordinalize | |
if (11..13).include?(self % 100) | |
"#{self}th" | |
else | |
case self % 10 | |
when 1; "#{self}st" | |
when 2; "#{self}nd" | |
when 3; "#{self}rd" | |
else "#{self}th" |
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 WatchController < ApplicationController | |
def index | |
max_cast = 222 #todo-fetchMaxCastNumber | |
base_url = "http://railscasts.com/episodes/" | |
options = "?autoplay=true" | |
random_cast = Random.rand(max_cast) | |
redirect_to base_url + random_cast.to_s + options | |
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
# Assuming Ubuntu 10.04 with git already installed. | |
# | |
# Make sure to secure your server: http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/ | |
# These instructions are based on: | |
# http://sitaramc.github.com/gitolite/doc/1-INSTALL.html: | |
# First, get you id_rsa.pub onto the server as /tmp/YourName.pub | |
scp ~/ssh/id_rsa.pub [email protected]:/tmp/ |
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
#Author: Ian Moss aka oceanician : http://twitter.com/oceanician | |
#First Published: https://gist.github.com/1009253 | |
#I'm running as part of a rails project with: | |
# ruby script/runner lib\weekends.rb | |
# Returns parameter from_date if it is a Friday. | |
def next_friday( from_date ) | |
while from_date.cwday!=5 | |
from_date = from_date + 1.day | |
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
Original Video: http://vimeo.com/18252871 by Victor Savkin ( http://twitter.com/avix1000 ) | |
Asciicast by Ian Moss ( http://twitter.com/oceanician ) of CTI Digital: Grails team - http://www.ctisn.com | |
------------------------------------------------------------------------------------- | |
"Hi, I'm Victor Savkin." | |
"3rd Gradle screencast." | |
"Create the gradle build file" | |
"How to run the app" | |
"How to create the war" |
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
if(Environment.current == Environment.DEVELOPMENT) { | |
... | |
} | |
//i.e. in Bootstrap.groovy? |
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
3.times { | |
println it | |
} | |
println "---" | |
3.upto(9) { | |
println it | |
} | |
println "---" | |
3.step(9,3) { | |
println it |
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
grails create-app Creates a Grails application for the given name | |
grails create-domain-class Creates a new domain class | |
grails generate-all Generates a CRUD interface (controller + views) for a domain class | |
grails install-plugin Installs a plug-in for the given URL or name and version | |
grails create-controller Creates a new controller | |
grails interactive Starts Grails CLI (script runner) in interactive mode. | |
Keeps the JVM running between grails commands for faster script execution. | |
grails console Load the Grails interactive Swing console | |
grails run-app grails [environment]* run-app - Runs a Grails application |