Skip to content

Instantly share code, notes, and snippets.

View tuxfight3r's full-sized avatar
:octocat:
Working from home

Mohan Balasundaram tuxfight3r

:octocat:
Working from home
View GitHub Profile
@tuxfight3r
tuxfight3r / gist:409953c8d9941d36781b
Last active January 6, 2021 16:25
Get IP/MAC from ifconfig using sed
#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 / gist:16d586f125c0e2640f26
Last active February 7, 2023 02:33
Centos-updates x86_64 Mirror via wget behind proxy
#!/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 / pre-commit
Last active August 29, 2015 14:06 — forked from fluxrad/pre-commit
puppet precomit linting
#!/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 August 29, 2023 06:58 — forked from kmorcinek/git commands.txt
Useful Git Commands
# 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.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@tuxfight3r
tuxfight3r / gist:080fe5f0db2c57a9e4b3
Last active August 29, 2015 14:10
ping scan a subnet quickly
#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"
@tuxfight3r
tuxfight3r / gist:be4f930a8b055ac932ea
Last active August 29, 2015 14:10
ruby manipulate array with map
#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"
@tuxfight3r
tuxfight3r / gist:39b9f6b1db38cc617ac0
Last active August 29, 2015 14:10
ruby lambda fun
#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:5e60f3ad662bdfb0f8a3
Created November 27, 2014 17:50
ruby block proc and lambda example
# 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:a350767f32038121d7ee
Created November 27, 2014 17:57
ruby remove nth object by object_id from array
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]