Skip to content

Instantly share code, notes, and snippets.

Mohan Balasundaram tuxfight3r

Block or report user

Report or block tuxfight3r

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
@tuxfight3r
tuxfight3r / gist:16d586f125c0e2640f26
Last active Aug 29, 2015
Centos-updates x86_64 Mirror via wget behind proxy
View gist:16d586f125c0e2640f26
#!/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/'
@tuxfight3r
tuxfight3r / gist:409953c8d9941d36781b
Last active Aug 29, 2015
Get IP/MAC from ifconfig using sed
View gist:409953c8d9941d36781b
#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
@tuxfight3r
tuxfight3r / pre-commit
Last active Aug 29, 2015 — forked from fluxrad/pre-commit
puppet precomit linting
View pre-commit
#!/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
@tuxfight3r
tuxfight3r / git commands.txt
Last active Aug 29, 2015 — forked from kmorcinek/git commands.txt
Useful Git Commands
View git commands.txt
# 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.
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@tuxfight3r
tuxfight3r / gist:5e60f3ad662bdfb0f8a3
Created Nov 27, 2014
ruby block proc and lambda example
View gist:5e60f3ad662bdfb0f8a3
# 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 }
@tuxfight3r
tuxfight3r / gist:be4f930a8b055ac932ea
Last active Aug 29, 2015
ruby manipulate array with map
View gist:be4f930a8b055ac932ea
#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"
View gist:39b9f6b1db38cc617ac0
#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)
@tuxfight3r
tuxfight3r / gist:a350767f32038121d7ee
Created Nov 27, 2014
ruby remove nth object by object_id from array
View gist:a350767f32038121d7ee
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]
@tuxfight3r
tuxfight3r / gist:080fe5f0db2c57a9e4b3
Last active Aug 29, 2015
ping scan a subnet quickly
View gist:080fe5f0db2c57a9e4b3
#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"
You can’t perform that action at this time.