Skip to content

Instantly share code, notes, and snippets.

View millisami's full-sized avatar
🎯
Focusing on landing a Web3 Job

Sachin Sagar Rai millisami

🎯
Focusing on landing a Web3 Job
View GitHub Profile
class Foo < ActiveRecord::Base
include Models::Scopes::Order
default_scope recently_updated # didn't realize you could do this
end
@millisami
millisami / ubuntu-11.10-gems.erb
Created December 11, 2011 19:16 — forked from kashif/ubuntu-11.10-gems.erb
Chef bootstrap With rvm and ruby 1.9.3 on ubuntu 11.10
bash -c '
<% if knife_config[:bootstrap_proxy] -%>
(
cat <<'EOP'
<%= "proxy = #{knife_config[:bootstrap_proxy]}" %>
EOP
) > ~/.curlrc
<% end -%>
if [ ! -f /usr/bin/chef-client ]; then
@millisami
millisami / application_with_config.rb
Created December 22, 2011 10:32 — forked from mislav/application_with_config.rb
Read custom config from settings.yml into a Rails 3 app
# needs the "hashie" gem in Gemfile
require 'erb'
module Movies
class Application < Rails::Application
# read from "settings.yml" and optional "settings.local.yml"
settings = ERB.new(IO.read(File.expand_path('../settings.yml', __FILE__))).result
mash = Hashie::Mash.new(YAML::load(settings)[Rails.env.to_s])
@millisami
millisami / application.css
Created December 29, 2011 04:25 — forked from lucapette/application.css
twitter bootstrap rails 3.1 notes
/*
*= require_self
*/
html, body {
background-color: #eee;
}
body {
padding-top: 40px; /* 40px to make the container go all the way to the bottom of the topbar */
}
@millisami
millisami / Folder Preferences
Created January 1, 2012 13:16 — forked from chrisyour/Folder Preferences
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@millisami
millisami / system_bang.rb
Created January 24, 2012 09:17 — forked from thbar/system_bang.rb
Please don't use ruby 'system' without checking exit code
module Kernel
def system!(command)
raise "Failed to launch command #{command}" unless system(command)
end
end
@millisami
millisami / gist:1670556
Created January 24, 2012 14:57 — forked from jsierles/gist:84082
Custom Knife Plugin for adding various actions
#!/usr/bin/ruby
#
# Joshua Sierles, 37signals, 2009
require 'rubygems'
require 'thor'
require 'chef'
require 'chef/node'
require 'chef/rest'
@millisami
millisami / application.rb
Created April 7, 2012 15:31 — forked from finack/application.rb
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
@millisami
millisami / _ubuntu-11.10-standalone.sh
Created April 17, 2012 17:49 — forked from fnichol/_ubuntu-10.04-standalone.sh
Chef bootstrap template for Ubuntu 11.10
### Ensure variables are declared
[[ -z "$RUBY_VERSION" ]] && printf ">>> RUBY_VERSION must be set.\n" && exit 10
[[ -z "$RUBY_HOME" ]] && printf ">>> RUBY_HOME must be set.\n" && exit 11
### Install Packages
set -x
apt-get update
@millisami
millisami / Gemfile
Created April 28, 2012 11:55
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin