Start irb with tab completion enabled
irb --readline -r irb/completionExecuting shel commands in ruby
system "curl http://www.google.com"
Combination of in_groups_of and cycle helper
<table><% articles.in_groups_of(2, false) do |row_tasks| %><tr><%row_tasks.each do |task| %><td style="background-color:<%=cycle("red","white","blue") %>"><%= task.title %></td><% end %></tr><% end %></table>
Customized error fields
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag| if html_tag =~ /type="hidden"/ || html_tag =~ /<label/ html_tag else "<span class='error_message'>#{[instance_tag.error_message].flatten.first.sub(/^\^/, '')}</span>" + "<span class='field_error'>#{html_tag}</span>" endend
Removing remote branch from GIT
git push git@github.com:genlinux/Freelance.git :heads/rubyist.rb
! [rejected] master -> master (non-fast forward)
git push origin +master:master
Just put this in your ~/.irbrc file:
ReplyDeleterequire 'irb/completion'
require 'irb/ext/save-history'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
Removing p tags from text
ReplyDeletetext.gsub(/(^[ ]*<p>[ ]*)|([ ]*<\/p>[ ]*$)/, '')