Skip to content

Instantly share code, notes, and snippets.

@rajib
rajib / .bash_profile
Created October 28, 2009 05:23
.bash_profile
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@rajib
rajib / generate slug
Created January 19, 2010 07:18
generate_slug.rb
class Post < ActiveRecord::Base
before_validation :generate_slug
def generate_slug
self.slug = self.title.dup if self.slug.blank?
self.slug.slugorize!
end
end
and in lib/core_extensions/string.rb
@rajib
rajib / Evolution of a Ruby Programmer.rb
Created February 18, 2010 07:07 — forked from bernerdschaefer/Evolution of a Ruby Programmer.rb
Evolution of a Ruby Programmer.rb
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
@rajib
rajib / recursive search file and delete..
Created April 30, 2010 08:55
recursive search file and delete..
find . -name "*.<file extention>"|xargs rm
def fetch_class(path)
current_page?(path) ? "class = 'current'" : ""
end
Example: <li <%= fetch_class(new_request_path) %>> text </li>
@rajib
rajib / .gitconfig
Created May 8, 2010 03:02
.gitconfig
# ADD LOCAL CONFIGURATION HERE
# DO NOT EDIT BELOW THIS LINE
[color]
diff = auto
status = auto
branch = auto
[core]
excludesfile = ~/.gitignore
git rebase -i A <sha>
git reset --soft HEAD^
git commit --amend
git rebase --continue
namespace :save do
desc "it will create/generate route urls"
task :route_urls => :environment do
all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes
routes = all_routes.collect do |route|
name = ActionController::Routing::Routes.named_routes.routes.index(route)
verb = route.conditions[:method]
segs = route.segments.inject("") { |str,s| str << s.to_s }
segs.chop! if segs.length > 1
reqs = route.requirements.empty? ? "" : route.requirements
<div style="border-top:1px solid #404040">
<div style="color:#fff;;padding:10px">Welcome to Titanium</div>
</div>
<div>
<div class="span-10 mLeft45">
<div>
<fieldset>
<legend>Sign in to Twitter</legend>
<p>
<label for="username">Username or email</label><br>
input type="text" id="username" name="username" class="title" (make this as HTML tag)
</p>
<p>