This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
modprobe dummy | |
lsmod | grep dummy | |
ip link set name eth2 dev dummy0 | |
ip addr add 192.168.100.199/24 brd + dev eth2 label eth2:0 | |
ip addr add 192.168.100.200/24 brd + dev eth2 label eth2:1 | |
ip addr add 192.168.100.201/24 brd + dev eth2 label eth2:2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ip addr show | grep "scope global" | egrep -o "inet ([0-9\.]+){4}" | cut -d' ' -f2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install nodejs > 5.0 | |
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash - | |
sudo apt-get install -qy nodejs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Create a socket, bind to port 0, kernel assigns a free port. Read port number, close socket | |
* This works *mostly* because the kernel tries hard to avoid re-using ports. So the port returned | |
* by this function should remain available for a bit after this process has terminated. | |
*/ | |
echo "Available local port: " . getFreeLocalTcpPort(); | |
function getFreeLocalTcpPort() { | |
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
st = status | |
co = checkout | |
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
br = branch -v | |
dt = difftool --dir-diff | |
gshow = !f() { git difftool --dir-diff $1^..$1; }; f | |
llg = !f() { git lg $(git branch --column | tr -d '*' | tr -s ' '); }; f | |
[user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#paranoid (in case the langguage-pack-en is not installed, which is rare) | |
sudo apt-get -q install language-pack-en.* | |
#write to /etc/default/locale | |
#changes only take effect after logout | |
sudo update-locale --reset LANG=en_US.UTF-8 LC_MESSAGES=POSIX LC_ALL=en_US.UTF-8 | |
#generate locale files if required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read p; do | |
(svn list -R "$p" | xargs -I{} echo $p{} | tee -a allfiles.txt) & | |
done < repos.txt | |
wait #for above jobs to finish... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat /etc/apache2/sites-available/* /etc/nginx/sites-available/* | perl -ne 'print if (!m/^\s*#/ && m/ServerName|ServerAlias/i);' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# May not work if filename have spaces | |
# Inspired by this answer on StackOverflow | |
# http://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s | |
find . -type f -printf '%T@ %P\n' | sort -nr | cut -d ' ' -f2- | head | |
## Windows Version ## | |
# gfind . -type f -name "clean*.php" -printf "%T@ \"%P\"\n" | gsort -nr | cut -d ' ' -f2- | |
# Assumes gfind = Gnu find and gsort Gnu sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//GetPass for a website | |
//getpass(sitename.com) returns a XORed version of the sitename + salt | |
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { | |
$homeDir = realpath(getenv("USERPROFILE")); | |
} else { | |
$homeDir = realpath("~"); | |
} | |
$salt = file_get_contents("$homeDir/.salt"); |