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
# steps I took | |
$ git clone [email protected]: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 |
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
# | |
# 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 [email protected]:kjwierenga/rufus-scheduler.git # fresh clone of my fork | |
$ cd rufus-scheduler |
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
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? |
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
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 |
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
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 |
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
> date -d-1day | |
Mon Sep 6 09:08:43 CEST 2010 | |
> date -d-1day +%Y%m | |
201009 |
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
Getting up and running with OS X, Textmate & Scheme | |
=================================================== | |
SCHEME | |
====== | |
I ran across two implementations of Scheme which appear to work well with OS X. | |
mit-scheme & PLT Scheme. | |
I was able to install mit-scheme from darwin ports ( sudo port install mit-scheme) |
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
def counter(start, inc) | |
lambda do | |
current = start | |
start += inc | |
current | |
end | |
end | |
result = counter(10, 2) |
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
def returning(value, &block) | |
yield | |
value | |
end | |
def counter(start, inc) | |
lambda do | |
returning start do | |
start += inc | |
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
# My final solution to 'Closures' exercise at the | |
# Scottish Ruby Conference - Ruby Tutorial | |
# by Chad Fowler and Keavy McMinn. | |
# The returning keyword/proc is not defined in Ruby 1.8. Define it here | |
# | |
def returning(value, &block) | |
yield | |
value | |
end |
OlderNewer