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 / notes.md
Last active August 29, 2015 14:06 — forked from DavidWittman/notes.md

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

@fadhlirahim
fadhlirahim / .drone.yml
Created October 20, 2014 12:18
Speed up drone.yml bundle install
image: bradrydzewski/ruby:2.0.0
cache:
- /tmp/bundler
script:
- mkdir -p /tmp/bundler
- sudo chown -R $UID /tmp/bundler
- bundle install --quiet --path /tmp/bundler
@fadhlirahim
fadhlirahim / task.rb
Last active August 29, 2015 14:08
Write a PID file in Rails
# Sample module you can include in a rake task that checks a pid file before running
# Usage:
# require 'task'
#
# class Job
# include Task
# end
module Task
def self.included(base)
base.extend(ClassMethods)
%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]