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
table tr th {background:#222; color:#fff; padding:0; border:#111 solid 1px; text-align: center; font-weight: bold;} | |
table tr td {border:1px #ccc solid; padding:5px;} | |
table tr td.rightright {background: #eee;} | |
table tr td h4 {margin:0; padding:0; font-weight:normal;} | |
#from here => http://net.tutsplus.com/tutorials/other/building-a-forum-from-scratch-with-ruby-on-rails/ | |
table { |
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} |
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 | |
Dir.chdir(File.expand_path("~/Library/Application\ Support/TextMate/Bundles/")) do | |
Dir.foreach(".") do |dir| | |
if File.directory?(dir) | |
Dir.chdir(dir) do | |
puts "Update Bundle #{File.basename Dir.getwd}" | |
puts %x{git pull} | |
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
# analytics/app/support/report_invoker.rb | |
class ReportInvoker | |
def self.build_reports(dir) | |
new(dir).build_reports | |
end | |
attr_reader :dir | |
def initialize(dir) |
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 colorize(text, color_code) | |
"\e[#{color_code}m#{text}\e[0m" | |
end | |
def red(text); colorize(text, 31); end | |
def green(text); colorize(text, 32); end | |
def yellow(text); colorize(text, 33); 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
require 'json' | |
#export | |
users = User.all.map {|user| {:id => user.id, :name => user.name }} | |
File.open("/tmp/users.json","w") do |f| | |
f.write(JSON.pretty_generate(users)) | |
end | |
#import |