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
#!/usr/bin/env ruby | |
# | |
# Send a growl message with latest updates in your feed | |
# | |
# edit your crontab (crontab -e) and add this line | |
# (this checks your feed every 30 minutes) | |
# */30 * * * * ~/bin/WakoopaGrowl.rb > /dev/null | |
# | |
# create a yaml file (mate ~/.wakoopa_growl) within your homedirectory | |
# username: your_username |
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
# port of http://www.perlmonks.org/?node_id=162190 | |
# | |
# Please refactor this if necessary | |
# leonb -at- beriedata -dot- nl | |
# | |
class String | |
def yoda | |
word = %w{is be will show do try are teach have}.select { |word| self =~ /\b#{word}\b/ }[0] | |
if word | |
x = (self =~ /\b#{word}\b/) + word.size |
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 branche | |
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
#!/usr/bin/env ruby | |
# | |
# Tracklisting: (c) 2010 KinkFM.com and their listeners | |
# Code: (c) 2010 Leon Berenschot, Wendbaar.nl | |
# | |
# Find the tracks of the Kink1500 in your iTunes library | |
# Usage: | |
# - First create a playlist called "Kink 1500-2010" | |
# - From the commandline execute 'ruby ./find_1500.rb' | |
# |
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
<%= image_submit_tag "button_volgende_stap.gif", :title=> t('form.submit'), :onclick => "needToConfirm = false;" %> | |
<% content_for :page_js do %> | |
<script> | |
var needToConfirm = false; | |
window.onbeforeunload = confirmExit; | |
function confirmExit() { | |
if (needToConfirm) { | |
return "U heeft onbewaarde wijzigingen. Doorgaan?"; |
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
File Pattern: | |
!(/\.(?!htaccess)[^/]*|(swf|mp3|jpeg|gif|png|psd|log|pdf|sql|bz2)|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp)$ | |
Folder Pattern: | |
!.*/(\.[^/]*|public/system|server/gems|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ |
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 AppServer | |
attr_accessor :admin_password, :port | |
end | |
class Configuration | |
attr_accessor :tail_logs, :max_connections, :admin_password | |
def app_server | |
@app_server ||= AppServer.new | |
yield @app_server if block_given? |
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
module MyAccessors | |
@@my_accessors = [] | |
def my_accessor var | |
attr_accessor var | |
@@my_accessors << var | |
end | |
def my_attributes |
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
# In 1.9 the Time#to_s method doesn't return in the format as outlined in the pickaxe book (PDF page 747): | |
it "ouput of #to_s is different in 1.8 and 1.9" do | |
time = Time.at(1289349987) | |
time.strftime("%a %b %d %H:%M:%S %z %Y").should eql('Wed Nov 10 01:46:27 +0100 2010') # passes | |
time.to_s.should eql('Wed Nov 10 01:46:27 +0100 2010') # fails | |
end | |
# Failure/Error: time.to_s.should eql('Wed Nov 10 01:46:27 +0100 2010') | |
# expected "Wed Nov 10 01:46:27 +0100 2010" |
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 capture(*streams) | |
require 'stringio' | |
streams.map! { |stream| stream.to_s } | |
begin | |
result = StringIO.new | |
streams.each { |stream| eval "$#{stream} = result" } | |
yield | |
ensure | |
streams.each { |stream| eval("$#{stream} = #{stream.upcase}") } |
OlderNewer