Skip to content

Instantly share code, notes, and snippets.

View oozzal's full-sized avatar
🇳🇵
learning

Uzzal Devkota oozzal

🇳🇵
learning
View GitHub Profile
class Mutex
def self.busy?
@busy ||= false
end
def self.engage
@busy = true
end
#!/Users/cloudfactory001/.rvm/rubies/ruby-2.1.2/bin/ruby
require 'colorize'
path = ARGV[0]
unless path
print "Usage:".colorize(:red)
puts "\tvinstall <username>/<repo-name>".colorize(:green)
print "Example:".colorize(:red)
puts "vinstall tpope/vim-rails".colorize(:green)
require 'delegate'
class Person
attr_accessor :fname, :lname
def category
'manav'
end
end
@oozzal
oozzal / open_gem.sh
Last active August 29, 2015 14:06
Open bundler gem in vi.
# open gem specified by bundler in vim
# Usage: gopen activemerchant
function gopen() {
gem_path=`bundle show $1`;
cd $gem_path && vim $gem_path;
cd -;
}
@oozzal
oozzal / clean_git_branch.sh
Last active August 29, 2015 14:06
Clean up merged git branches.
# cleanup merged git branches
function cleanlocal() {
echo "Before cleanup:";
git branch;
echo "----";
git branch --merged | grep -v "\*" | xargs -n 1 git branch -D;
echo "----";
echo "After cleanup:";
git branch;
}
@oozzal
oozzal / cross_compile_go.sh
Created September 5, 2014 09:01
Cross Compiling Go Scripts.
# install go
go get github.com/laher/goxc
# build cross-compilers
goxc -t
# create a project in $GO_PATH/src/<project-dir>
# inside project-dir
# build binaries for different platforms
goxc
@oozzal
oozzal / mac_mail.sh
Created August 12, 2014 11:31
Send mail from mac terminal.
mail -s "Cool Subject" [email protected] <<EOF
map <silent> <C-i> :NERDTreeToggle<CR>
EOF
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@oozzal
oozzal / jr_erb_fix.rb
Created August 5, 2014 11:58
.js.erb file not executing solution
# http://stackoverflow.com/questions/18936633/rails-update-js-erb-not-executing-javascript
# http://stackoverflow.com/questions/3412375/jquery-ajax-haml-js-erb-files-not-firing
# IN SHORT:
# use the following code in controller:
respond_to do |format|
format.html
@oozzal
oozzal / you_complete_me_fix.sh
Created June 26, 2014 05:50
Fix Valloric/YouCompleteMe
alias vi="DYLD_FORCE_FLAT_NAMESPACE=1 vim"
alias vim="DYLD_FORCE_FLAT_NAMESPACE=1 vim"