Skip to content

Instantly share code, notes, and snippets.

View stereosupersonic's full-sized avatar

MICE Portal stereosupersonic

View GitHub Profile
@stereosupersonic
stereosupersonic / checksum.rb
Created October 27, 2009 08:47
Url to Hash-String
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
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
@stereosupersonic
stereosupersonic / install gemcutter
Created November 19, 2009 19:41
install gemcutter
sudo gem update --system
sudo gem install gemcutter --source http://gemcutter.org
sudo gem tumble
@stereosupersonic
stereosupersonic / validation_errors_to_log.rb
Created December 16, 2009 10:49
validation_errors_to_log
RAILS_DEFAULT_LOGGER.error {my_object.errors.full_messages.to_s}
@stereosupersonic
stereosupersonic / env.rb
Created January 12, 2010 08:06
Rails Enviroment
Rails.env.staging?
Rails.env => "development"
@stereosupersonic
stereosupersonic / install textmate bundle
Created January 16, 2010 17:17
install textmate bundle
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'
def every seconds, &block
while true
yield
sleep seconds
end
end
class Fixnum
def minutes
self * 60
@stereosupersonic
stereosupersonic / validate_email.rb
Created February 4, 2010 13:20
validate email adress
validates_format_of :email,
:with => /^([^\s]+)((?:[-a-z0-9]\.)[a-z]{2,})$/i
@stereosupersonic
stereosupersonic / string_to_file.rb
Created August 4, 2010 12:38
Write Text to a File
open('output.txt', 'w') { |f| f << "This file contains great truths.\n"}
@stereosupersonic
stereosupersonic / youtube2mp3
Created November 16, 2010 15:17
convert youtube videos to mp3 on OSX
#!/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}