Nasir Jamal nas

View mongo-import-export
1 2 3 4 5 6 7 8 9 10
Binary
======
* 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
1 2 3 4 5 6 7 8 9 10
==========
.tmux.conf
==========
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
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
 
url = ARGV[0]
code = ARGV[1]
View Vim cheat sheet
1 2 3 4 5 6 7 8 9 10
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
1 2 3 4 5 6 7 8 9
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
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/ruby
 
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
1 2 3 4 5 6 7 8 9 10
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
 
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
 
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
 
# Pick which video format you want to download.. (use any YT video link)
View stress testing
1 2 3 4 5 6 7 8 9
#! /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
1 2 3 4 5 6 7 8 9 10
class A
def self.before_filters
@before_filters ||= []
end
 
def self.before_filter(callback, params={})
before_filters << params.merge(:callback => callback)
end
 
def self.inherited(child_class)
View roman_numeral_calculator.rb
1 2 3 4 5 6 7 8 9 10
class RomanNumeralCalculator
def calculate(numeral)
if numeral =~ /^\d+$/
arabic_to_roman(numeral)
else
roman_to_arabic(numeral)
end
end
 
private
Something went wrong with that request. Please try again.