# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
View mongo-import-export
* Import database
mongorestore -h host:port -d experimental2 -u <user> -p <password> <input db directory>
* Export database
mongodump -h host:port -d experimental2 -u <user> -p <password> -o <output directory>
* Import collection
mongorestore -h host:port -d experimental2 -u <user> -p <password> <input .bson file>
* Export collection
mongodump -h host:port -d experimental2 -c <collection> -u <user> -p <password> -q <query else will export full collection> -o <output directory>
View gist:6773719
set-window-option -g xterm-keys
set -g mode-mouse on
#Set status Bar
set -g status-bg black
set -g status-fg cyan
set -g status-left '#[fg=green]#H'
View gitio
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
# Turns a URL
# into a URL
# Copies the URL to your clipboard.
url = ARGV[0]
code = ARGV[1]
View Vim cheat sheet
Skipping some of the very basic commands, to use this cheat sheet you need atleast some vim knowledge.
; # repeat last search done using f
, # undo last search done using f
u # undo last change
ctrl+r # redo last change
:%s/t/r/g # replace all 't' by 'r'
:%s/t/r/gc # replace all 't' by 'r' with confirmation
~ # change case
gu # to lower case
View Rails4_with_ruby2
bundle 1.2.3 not compatible with ruby 2.0.0.preview2, do
gem install bundler --pre
to install bundler 1.3.0.pre.4
For any ssl issues
openssl needs to be >= 1.0.1
brew install openssl
brew link openssl
View lambda_to_proc
directory = "app/models"
all_files = Dir.glob(File.join('app/models', '**', '*.rb'))
puts "Potentially modifying #{all_files.size}. Do you want to continue? [y/n]"
reply = gets
exit unless %w(y yes).include? reply.chomp.downcase
all_files.each do |filename|
View gist:3148888
# Convert any YouTube video into an audio file you can listen to on the go, using:
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
{ ~ } > wget
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
View stress testing
#! /usr/bin/ruby
raise "Provide the dir path" unless ARGV[0] =~ /[a-z]*/
to_dir = ARGV[0].strip
raise "Provide the dir path" if to_dir.nil?
site = 'http://url'
print "Processing home page ... "
View before_filter.rb
class A
def self.before_filters
@before_filters ||= []
def self.before_filter(callback, params={})
before_filters << params.merge(:callback => callback)
def self.inherited(child_class)