Skip to content

Instantly share code, notes, and snippets.

@wbingli
wbingli / migration.erb
Last active December 19, 2015 06:49
Chef migration template for Windows
cmd.exe /C del C:\chef\validation.pem
cmd.exe /C del C:\chef\client.rb
cmd.exe /C del C:\chef\client.pem
> C:\chef\validation.pem (
<%= validation_key %>
)
> C:\chef\client.rb (
@wbingli
wbingli / winrm-https.bat
Created July 12, 2013 00:03
Windows: Import certificate and configure WinRM HTTPS and IIS HTTPS bindings
REM Check certificates
certutil -store MY
REM Import cert
certutil -p PASSWORD -ImportPFX CERT_PATH
REM Check winrm listners
winrm e winrm/config/listener
REM delete if it exists
@wbingli
wbingli / renmae_lowercase_recursive
Created July 24, 2013 03:53
Change all file and directory name to lowercase
find . -name '*[A-Z]*' -print0 | xargs -0 rename 'y/A-Z/a-z/'
@wbingli
wbingli / mod_security_get_only
Created March 25, 2014 04:45
Mod security rule to only allow GET for specified request path
SecRule REQUEST_URI "/getonly" "chain,log,deny,status:403,phase:2,id:1234567010"
SecRule REQUEST_METHOD "!@rx ^(?:GET)$"
@wbingli
wbingli / merge_repos.sh
Created April 1, 2014 20:28
Merge multiple repositories into one, keep all commit history
mkdir ~/tdv-core
cd ~/tdv-core
#clone all repos
git clone git@bitbucket.org:tdigital-ondemand/tdv-core.git
#Clone parent firstly
git clone git@bitbucket.org:tdigital-ondemand/parent.git
cd parent
git checkout dev
@wbingli
wbingli / add_search_to_resolv.sh
Last active August 29, 2015 13:58
Append a search path to /etc/resolv.conf
if ! grep -q 'test.com' /etc/resolv.conf
then
sed -i "s/`grep search /etc/resolv.conf`/`grep search /etc/resolv.conf` test.com/" /etc/resolv.conf
fi
@wbingli
wbingli / setup-bridge.sh
Created April 15, 2014 20:52 — forked from ismell/setup-bridge.sh
To change the default network for docker
#!/bin/bash -e
IFADDR="192.168.3.1/24"
if [[ ! ip link show docker0 ]]; then
ip link add docker0 type bridge
ip addr add "$IFADDR" dev docker0
ip link set docker0 up
iptables -t nat -A POSTROUTING -s "$IFADDR" ! -d "$IFADDR" -j MASQUERADE
fi
@wbingli
wbingli / download_big_file.rb
Created May 1, 2014 22:32
Download big file with ruby and basic authentication
require 'net/http'
require 'uri'
def downloadFile(filePath, url,username, password)
uri = URI(URI.encode(url))
Net::HTTP.start(uri.host,uri.port) do |http|
request = Net::HTTP::Get.new uri.path
request.basic_auth username,password
@wbingli
wbingli / README.md
Last active August 29, 2015 14:01
Get how many pictures you have in Google plus

Below JavaScript Code will help you calculate total pictures you have in Google Plus.

Go to your google plus pictures albums page, run the script in the browser developer console. You will get your total pictures number.

@wbingli
wbingli / ipsec.conf
Created June 25, 2014 02:37
Configure L2TP/IPSec
conn L2TP-PSK-noNAT │
authby=secret │
pfs=no │
auto=add │
keyingtries=3 │
rekey=no │
ikelifetime=8h │
keylife=1h │
type=transport