Skip to content

Instantly share code, notes, and snippets.

View kjwierenga's full-sized avatar

Klaas Jan Wierenga kjwierenga

View GitHub Profile
@kjwierenga
kjwierenga / ask_for_branch.rb
Created April 28, 2010 08:38 — forked from LeipeLeon/ask_for_branch.rb
Capistrano task to push a deploy tag after deploying a new version.
set(:branch) do
if :production == stage
branch = Capistrano::CLI.ui.ask("#{`git branch`}\n\nWhich branch do you want to deploy?: ")
raise "Error: The master branch cannot be deployed to production." if 'master' == branch
else
`git branch | grep ^* | sed s/\\*\\ //`.chomp # use current active branch for staging
end
end
Entry.transaction do
Playlist.all.each do |playlist|
if positions_max = playlist.entries.maximum(:position)
ActiveRecord::Base.connection.execute("
UPDATE entries SET position = #{positions_max + 1} - position
WHERE playlist_id = #{playlist.id}")
end
end
end
def schedule_event(event)
now = Time.now
# Determine the next occurrence starting at (Time.now - event.duration) to
# catch the current occurence where start_at <= Time.now but end_at > Time.now.
#
# When occurrence == nil, this means the event will never occur.
occurrence = event.occurrences(:starting => now - event.duration, :count => 1)
return if occurrence.nil?
@kjwierenga
kjwierenga / gist:107502
Created May 6, 2009 12:25
steps required to bring fork of rufus-scheduler in sync again after branch renaming
#
# Steps I took to re-sync my fork of rufus-scheduler to the
# new branches on jmettraux/rufus-scheduler after the following renames:
#
# master -> onezero
# twozero -> master
#
$ git clone git@github.com:kjwierenga/rufus-scheduler.git # fresh clone of my fork
$ cd rufus-scheduler
# steps I took
$ git clone git@github.com:kjwierenga/rufus-scheduler.git
$ cd rufus-scheduler
$ git branch -a
* master
origin/HEAD
origin/master
origin/twozero
$ git remote add upstream git://github.com/jmettraux/rufus-scheduler.git