Skip to content

Instantly share code, notes, and snippets.

@HatemMahmoud
HatemMahmoud / rails-page-title-01.rhtml.erb
Created March 22, 2010 17:03
A simple way to customize page titles in Rails views
<!-- in views/products/index.html.erb -->
<% @title = "Catalog" %>
<!-- in application.rhtml.erb -->
<title><%= @title.titleize + ' - My Great Store' %></title>
@HatemMahmoud
HatemMahmoud / rails-page-title-02.rb
Created March 22, 2010 17:05
A simple way to customize page title in Rails controllers
#in products_controller.rb
before_filter :set_title
def set_title
# default title for this controller
@title = 'Products'
end
def index
# different title for this action
@title = 'Catalog'
@HatemMahmoud
HatemMahmoud / Ubuntu rbenv
Created September 7, 2011 12:56
Installing Ruby 1.9.2 with OpenSSL on Ubuntu 11.04 using ruby-build and rbenv
# for more info: https://gist.github.com/1120938
@HatemMahmoud
HatemMahmoud / find_and_move_files.sh
Created October 22, 2011 05:09
Find and move all files
find . -type f -name "*" -print0 | xargs -0 -J% mv % .
@HatemMahmoud
HatemMahmoud / rmagick_on_ubuntu.sh
Created October 24, 2011 09:40
Installing rmagick on Ububtu 11.04
sudo apt-get install imagemagick
sudo apt-get install libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev
gem install rmagick
@HatemMahmoud
HatemMahmoud / postgres_socket_path_on_ubuntu.sh
Created October 24, 2011 09:41
Postgres socket path on Ubuntu
sudo mkdir /var/run/postgresql
sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/

Management

  • Pivotal Tracker
  • Flowdock

Repo

  • Github

Testing

  • RSpec
  • FactroyGirl
@HatemMahmoud
HatemMahmoud / rjb.sh
Created March 6, 2012 15:00
Rjb - Ruby Java Bridge
# Reference: http://www.ibm.com/developerworks/java/tutorials/j-rjb/j-rjb-pdf.pdf
$ java -version
$ apt-cache search jdk
$ apt-get install sun-java6-jdk
$ export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.26/"
$ export PATH=$PATH:$JAVA_HOME/bin
$ gem install rjb
$ irb
irb(main):001:0> require 'rjb'
@HatemMahmoud
HatemMahmoud / ruby-debug_ruby193.sh
Created March 31, 2012 13:13
ruby-debug error with Ruby 1.9.3
# Error: /Users/hatem/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require': dlopen(/Users/hatem/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
# First download linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem from http://rubyforge.org/frs/?group_id=8883
# Then, install the new gems
gem install linecache19-0.5.13.gem
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/Users/hatem/.rbenv/versions/1.9.3-p0/include/ruby-1.9.1/ruby-1.9.3-p0/
# Then, update your app
bundle update ruby-debug-base19
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
@HatemMahmoud
HatemMahmoud / rbenv-gems-error.sh
Created July 3, 2012 16:10
Fixing command not found errors with rbenv
# Problem
$ rspec
-bash: rspec: command not found
# Solution
gem install rspec-core && rbenv rehash