Skip to content

Instantly share code, notes, and snippets.

View alterisian's full-sized avatar

Ian Moss alterisian

View GitHub Profile
@alterisian
alterisian / fixnum_ordinalize.rb
Created November 27, 2012 13:07
Adds ordinalize i.e. th,st,rd to a number for use in date string outputs
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"
@alterisian
alterisian / watch_controller.rb
Created September 14, 2011 12:24
So that we can watch a random railscast.
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
@alterisian
alterisian / gitolite_hn.bash
Created June 20, 2011 16:21 — forked from masnick/gitolite_hn.bash
Setting up gitolite (hn)
# 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 you@git.you.com:/tmp/
@alterisian
alterisian / weekends.rb
Created June 5, 2011 18:32
Weekends left til the end of summer
#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
@alterisian
alterisian / victor_savkin_3_using_gradle_for_building_a_webapp.asciicast.txt
Created January 5, 2011 11:31
Ascii Cast for Using Gradle For Building A Webapp by Victor Savkin
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"
@alterisian
alterisian / EnvironmentConditional.groovy
Created December 15, 2010 11:02
EnvironmentConditional.groovy
if(Environment.current == Environment.DEVELOPMENT) {
...
}
//i.e. in Bootstrap.groovy?
@alterisian
alterisian / numbers.groovy
Created November 11, 2010 12:48
example of looping in groovy - similar to ruby I guess
3.times {
println it
}
println "---"
3.upto(9) {
println it
}
println "---"
3.step(9,3) {
println it
@alterisian
alterisian / grailsCheatSheet
Created November 11, 2010 11:55
Grails Command Line Cheat Sheet
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
@alterisian
alterisian / heroku_to_github.txt
Created October 28, 2010 13:10
How to git your existing heroku app into a new github repo
git remote add github [EMAIL PROTECTED]:myaccount/myapp.git
git remote add heroku [EMAIL PROTECTED]:myapp.git
Then you can do “git push heroku” and “git push github”, or pull, or
From: http://blog.mindtonic.net/using-github-and-heroku-together
(Date.parse("2010-12-03")-Date.today).days