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
@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 / Gemfile
Created November 4, 2011 04:09 — forked from mattheworiordan/Gemfile
Test PDF within Cucumber and Capybara
# normal Gem dependancy declarations
# ...
group :test, :cucumber do
gem 'pdf-reader'
end
after "deploy:stop", "delayed_job:stop"
after "deploy:start", "delayed_job:start"
after "deploy:restart", "delayed_job:restart"
namespace :delayed_job do
desc "Stop the delayed_job process"
task :stop, :roles => :app do
run "cd #{current_path}; script/delayed_job -e #{rails_env} stop"
end
@fadhlirahim
fadhlirahim / scheduled_job.rb
Created May 7, 2012 07:11 — forked from kares/scheduled_job.rb
Recurring Job using Delayed::Job
#
# Recurring Job using Delayed::Job
#
# Setup Your job the "plain-old" DJ (perform) way, include this module
# and Your handler will re-schedule itself every time it succeeds.
#
# Sample :
#
# class MyJob
# include Delayed::ScheduledJob
@fadhlirahim
fadhlirahim / cs-iife.coffee
Created July 7, 2012 03:17 — forked from ryanflorence/cs-iife.coffee
CoffeeScript Immediately Invoked Function Expressions
increment = do ->
x = 0
->
x++
# Add fixture-generation methods to ControllerExampleGroup. We load
# this file within our spec_helper.rb
# http://pivotallabs.com/users/jb/blog/articles/1152-javascripttests-bind-reality-
Spec::Rails::Example::ControllerExampleGroup.class_eval do
# Saves the markup to a fixture file using the given name
def save_fixture(markup, name)
fixture_path = File.join(RAILS_ROOT, '/tmp/js_dom_fixtures')
Dir.mkdir(fixture_path) unless File.exists?(fixture_path)
@fadhlirahim
fadhlirahim / theme.html
Created October 5, 2012 08:29 — forked from soemarko/theme.html
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
/**
* An extension that always calls success when a spy is called.
*
* @example
* spyOn(foo, 'bar').andCallSuccessWith("baz");
* var options = {
* success: jasmine.createSpy();
* }
* foo.bar(options);
* expect(options.success).toBeCalledWith("baz");
#controller
@start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)
#view
<%= date_select('range', 'start_date', :order => [:month, :day, :year])%>