Skip to content

Instantly share code, notes, and snippets.

View TMaYaD's full-sized avatar

Subhash Chandra TMaYaD

View GitHub Profile
@TMaYaD
TMaYaD / prep_optware
Created April 18, 2012 18:17
prep_optware
#!/bin/sh
# Script for installing optware on DD-WRT
# Written by frater
#
export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
SCRIPTVER="Fri Apr 22 17:08:38 CEST 2011"
export SITES='http://ipkg.nslu2-linux.org http://ftp-osl.osuosl.org/pub/nslu2'
export dom=wd.mirmana.com
@TMaYaD
TMaYaD / remove_merged_branches.sh
Created March 21, 2012 12:57
Remove merged branches
function rmb {
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then
module Tester
def Tester.hello
print 'hello'
end
extend Module.new {
def world
print 'world'
end
}
I18n.extend Module.new {
def translate(*args)
print args.to_yaml
super
end
}
@TMaYaD
TMaYaD / gist:835223
Created February 19, 2011 17:57
nested attributes with validate parent
#app/models/parent.rb
class Parent < ActiveRecord::Base
accepts_nested_attributes_for :children
validate :children_are_less_than_two
private
def children_are_less_than_two
errors.add(:base,
"shouldn't have more than two children"
) if children.count > 2