Skip to content

Instantly share code, notes, and snippets.

View fadhlirahim's full-sized avatar
💭
Most happiest building code that make sense.

Fadhli Rahim fadhlirahim

💭
Most happiest building code that make sense.
View GitHub Profile
%a weekday name.
%A weekday name (full).
%b month name.
%B month name (full).
%c date and time (locale)
%d day of month [01,31].
%H hour [00,23].
%I hour [01,12].
%j day of year [001,366].
%m month [01,12].
ActiveRecord::Base.logger = Logger.new(STDOUT)
#########################################################
# Facebooker hack. To make authlogic facebook_connect work
# if app is deployed in sub directory. Put it at
# config/initializers/facebooker_hack.rb
#########################################################
Facebooker.module_eval do
def self.path_prefix
'/directory_name'
end
end
# Making Cucumber & ThinkingSphinx play together
# Only works on thinking-sphinx 1.3.2
#
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV["RAILS_ENV"] ||= "cucumber"
# Code snippet
# Cap recipe to run rake db:Seed on production server
namespace :deploy do
desc "Run rake db:seed on production machine"
task :db_seed, :roles => :app do
run "cd #{current_path}; rake RAILS_ENV=production db:seed"
end
end
@fadhlirahim
fadhlirahim / baby_talk.rb
Created April 29, 2011 17:48 — forked from kamal/baby_talk.rb
Extending a model in a Rails 3 (pre-3.1) engine
module BabyTalk
class Engine < Rails::Engine
config.to_prepare do
User.class_eval do
has_many :participations, :foreign_key => "participant_id"
has_many :rooms, :through => :participations
end
end
end
end
@fadhlirahim
fadhlirahim / rails_3_1_beta_1_changes.md
Created May 6, 2011 02:45 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

@fadhlirahim
fadhlirahim / iptables_commands
Created October 2, 2011 07:09
Useful iptables command
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 110 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 2525 -j ACCEPT
sudo iptables -vnL --line-numbers
sudo iptables -D INPUT <line_number>
@fadhlirahim
fadhlirahim / vagrant-capistrano
Created October 3, 2011 10:46
Vagrant capistrano config bit
# Don't forget to run this vagrant command first
# vagrant ssh-config >> ~/.ssh/config
set :user, 'vagrant'
set :run_method, :sudo
role :app, '33.33.33.10'
ssh_options[:keys] = `vagrant ssh_config | grep IdentityFile`.split.last
@fadhlirahim
fadhlirahim / .gemrc
Created October 4, 2011 17:41
.gemrc
---
:update_sources: true
:backtrace: false
:verbose: true
:bulk_threshold: 1000
:benchmark: false
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com
- http://gems.github.com