Skip to content

Instantly share code, notes, and snippets.

View alameenkhader's full-sized avatar

Al Ameen Khader alameenkhader

  • Vista, California
View GitHub Profile
@MyExperiments
MyExperiments / application.rb
Last active August 29, 2015 14:02
Adding class/module to lib folder of rails application. By adding the lib folder to autoload_path, you don't need to require the file (require 'file') in other classes.
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env)
module TestApplication
class Application < Rails::Application
#add the lib folder to autoload path
config.autoload_paths += %W(#{config.root}/lib/assets/ #{config.root}/lib/)
@MyExperiments
MyExperiments / deep_open_struct.rb
Last active August 29, 2015 13:56
Convert a nested hash into an OpenStruct object.
require 'ostruct'
def deep_ostruct(hash)
if hash
hash.each do |k,v|
hash["#{k}"] = deep_ostruct(v) if v.is_a?(Hash)
end
end
OpenStruct.new(hash)
end
@rajraj
rajraj / es.sh
Created January 3, 2012 20:07 — forked from aaronshaf/es.sh
Install ElasticSearch on CentOS 6
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk.i686 -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@nileshtrivedi
nileshtrivedi / hash_builder.rb
Created November 24, 2011 17:49 — forked from brentd/gist:360506
HashBuilder allows you to build a Hash in Ruby similar to Builder with some enhancements
# Allows you to build a Hash in a fashion very similar to Builder. Example:
# Fork of https://gist.github.com/360506 by BrentD with some enhancements
#
# HashBuilder.build! do |h|
# h.name "Nilesh"
# h.skill "Ruby"
# h.skill "Rails" # multiple calls of the same method will collect the values in an array
# h.location "Udaipur, India" do # If a block is given, first argument will be set as value for :name
# h.location do
# h.longitude 24.57