Skip to content

Instantly share code, notes, and snippets.

Vijay Dev vijaydev

Block or report user

Report or block vijaydev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hide_aws_green_status.js
Array.prototype.forEach.call($$("#NA_block img"), function(el) {
if (el.attributes.src.value.indexOf("status0") !== -1)
el.parentNode.parentNode.style.display = 'none';
});
View gist:713678
Use ssh-copy-id to install your public key in a remote machine's authorized_keys. Also takes care of the permissions of the remote user's .ssh and .ssh/authorized_keys.
ssh -t reachable_host ssh unreachable_host. Enables to connect to a host unreachable from current network but reachable from reachable_host's network.
To navigate to a directory, run a command and get back: (cd /to/dir && cmd_to_run)
To rip audio out of a video file: mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile <out_file> <in_file>
Rsync: rsync --recursive -avz -e "ssh -p 2020" user@machine:/path dest
@vijaydev
vijaydev / gist:755496
Created Dec 26, 2010 — forked from lifo/gist:31208
An Example Rails 3 Application Template
View gist:755496
run "rm public/index.html"
generate(:scaffold, "item name:string")
route "root :to => 'items#index'"
rake("db:migrate", "production")
gem 'ruby-openid'
gem 'will-paginate', :git => 'git://github.com/mislav/will_paginate.git'
add_source "http://code.whytheluckystiff.net"
gem "hpricot", :version => '0.6'
View gist:766944
"ensure" makes sure code is run regardless of begin-rescue outcome. (equivalent of Java finally)
Pass a number parameter to Array#first and Array#last to get the first n or the last n values.
http://rubyquicktips.tumblr.com/post/870337608/grep-anything-from-your-enumerables
View RVM%20Rails%20Installs
rvm use ree-1.8.7-2010.02@global
rvm gemset create rails2310
gem install rails -v=2.3.10
View deploy.rb
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
$: << File.join(vendored_notifier, 'lib')
end
View subdomain_fu.rb
SubdomainFu.configure do |config|
config.tld_size = 1
config.mirrors = %w( support blog www billing help api )
config.preferred_mirror = 'www'
end
View Vim Tricks
.s@\(\d\+\)@\=(submatch(1) + 17)@
Search for numbers and replace them with results of expressions involving them. submatch(1) is \1 (groups in regexes)
View process.rb
#@data = Hash.new { |h,k| h[k] = Hash.new { |h1,k1| h1[k1] = Array.new(8) {0} } } #Interesting
View users_controller.rb
allotments = []
params[:roles_divisions].map do |rd|
rd[2].each do |d|
allotments << Allotment.create(:user_id => @user.id, :division_id => d.to_i, :role_name => rd[0])
end
end
@user.allotments = allotments
You can’t perform that action at this time.