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
require 'digest/md5' | |
Digest::MD5.hexdigest('http://foo-bar.com/yay/?foo=bar&a=22') | |
# "43facc5eb5ce09fd41a6b55dba3fe2fe" | |
#http://stackoverflow.com/questions/67890/whats-the-best-way-to-hash-a-url-in-ruby |
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
require "rubygems" | |
require "progressbar" | |
pbar = ProgressBar.new("Update Offer",big_array.size) | |
big_array.each do | e | | |
do_something | |
pbar.inc | |
end | |
###################### oder mit progress-monitor http://github.com/mikisvaz/progress-monitor |
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
sudo gem update --system | |
sudo gem install gemcutter --source http://gemcutter.org | |
sudo gem tumble |
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
RAILS_DEFAULT_LOGGER.error {my_object.errors.full_messages.to_s} |
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
Rails.env.staging? | |
Rails.env => "development" |
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
mkdir -p ~/Library/Application\ Support/TextMate/Bundles | |
cd ~/Library/Application\ Support/TextMate/Bundles | |
git clone git://github.com/grimen/formtastic_tmbundle.git 'Formtastic.tmbundle' | |
osascript -e 'tell app "TextMate" to reload bundles' |
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 every seconds, &block | |
while true | |
yield | |
sleep seconds | |
end | |
end | |
class Fixnum | |
def minutes | |
self * 60 |
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
validates_format_of :email, | |
:with => /^([^\s]+)((?:[-a-z0-9]\.)[a-z]{2,})$/i |
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
open('output.txt', 'w') { |f| f << "This file contains great truths.\n"} |
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/ruby | |
#example: | |
# youtube2mp3 EzgGTTtR0kc | |
VLC = "/Applications/VLC.app/Contents/MacOS/VLC" | |
youtube_id = ARGV.first || STDIN.read | |
raise "no youtube id is given" unless youtube_id | |
system "#{VLC} -I dummy http://www.youtube.com/watch?v=#{youtube_id} |