As configured in my dotfiles.
start new:
tmux
start new with session name:
| #ifconfig | head -n2 | tr -d '\n' |sed -n 's/.*addr\s\([0-9]\{2\}:[^ ]*\).*addr:\([^ ]*\).*/mac:\1 - ip:\2\n/p' | |
| mac:08:00:27:89:8b:8f - ip:157.203.249.51 |
| #!/bin/bash | |
| #Purpose:To Mirror Centos Updates x86_64 repo to local folder via | |
| #squid proxy and also to update it periodically | |
| #Author:Mohan | |
| #export the squid proxy server | |
| export http_proxy=192.168.2.100:3128 | |
| REPO_URL='http://mirror.centos.org/centos-6/6.5/updates/x86_64/Packages/' |
| #!/bin/bash | |
| # pre-commit git hook to check the validity of a puppet manifest | |
| # | |
| # Prerequisites: | |
| # gem install puppet-lint puppet | |
| # | |
| # Install: | |
| # /path/to/repo/.git/hooks/pre-comit | |
| # Source RVM if needed |
| # good git book | |
| http://git-scm.com/book | |
| # Discard uncommitted changes in a specific file | |
| git checkout file_name | |
| # Clear everything not in repo | |
| git checkout -- . | |
| # A way to quickly move to the previous commit in a git branch. This also way for "deleting" last commit. |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| #Ping scan a subnet | |
| seq 254 | xargs -P255 -I% sh -c "ping -q -c1 -w1 192.168.0.% > /dev/null || echo 192.168.0.% DOWN" |
| #ruby manipulate array values with map | |
| irb(main):040:0> array=%w(one two three four five) | |
| => ["one", "two", "three", "four", "five"] | |
| irb(main):042:0> array.map{|item| "ldap://#{item}" }.join(',') | |
| => "ldap://one,ldap://two,ldap://three,ldap://four,ldap://five" |
| #Basic lambda Hello World | |
| irb(main):122:0> test=lambda{"Hello World"} | |
| => #<Proc:0x00000001393e28@(irb):122 (lambda)> | |
| irb(main):123:0> test.call | |
| => "Hello World" | |
| #lambda function to remove nth object from an array | |
| irb(main):115:0> str=lambda {|arr,div| arr.each_with_index.map{|x,i| i+=1; next if i % div == 0; x}.compact } | |
| => #<Proc:0x00000001570a70@(irb):115 (lambda)> | |
| irb(main):116:0> str.call((0..20).to_a, 3) |
| # Block Examples | |
| [1,2,3].each { |x| puts x*2 } # block is in between the curly braces | |
| [1,2,3].each do |x| | |
| puts x*2 # block is everything between the do and end | |
| end | |
| # Proc Examples | |
| p = Proc.new { |x| puts x*2 } |
| str=lambda {|arr,div| arr.each_with_index.map{|x,i| i=i+1; next if i % div == 0; x}.compact } | |
| => #<Proc:0x000000015a7138@(irb):138 (lambda)> | |
| irb(main):139:0> str.call((0..20).to_a, 3) | |
| => [0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19] | |
| irb(main):140:0> str.call((1..20).to_a, 3) | |
| => [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20] |