Skip to content

Instantly share code, notes, and snippets.

View xream's full-sized avatar

xream xream

View GitHub Profile
@xream
xream / ssh.c
Created December 30, 2011 05:12
Multiple SSH Tunnels
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <signal.h>
@xream
xream / vpndown.sh
Created January 4, 2012 07:12
restore routes
#!/bin/bash
oldgw=10.211.55.1
vpngw=10.100.0.1
poff
route del default gw $oldgw
route del default gw $vpngw
route add default gw $oldgw
@xream
xream / MacVPN.sh
Created January 9, 2012 12:27
Mac VPN auto reconnect script
#!/bin/bash
#set the VPN service name
VPN=""
function xxre () {
echo "VPN is not connected!"
echo "Reconnecting!"
networksetup -connectpppoeservice $VPN
sleep 5
}
ifconfig|grep ppp0||xxre
@xream
xream / gist:1808672
Created February 12, 2012 13:54
zeller week
#!/bin/bash
year=2010
mon=01
day=01
case $mon in
01) monname="Jan" ;;
02) monname="Feb" ;;
03) monname="Mar" ;;
04) monname="Apr" ;;
@xream
xream / tc.rb
Created March 26, 2012 10:26 — forked from lexrus/tc
Epoch / Unix Timestamp Converter
#!/bin/bash
# sudo chmod +x tc;sudo mv tc /usr/bin
if [[ -z "$1" ]]
then
printf %s "\
Nifty Timestamp Convertor by Lex Tang
tc 2012/12/12
tc 1355283413
"
exit
@xream
xream / ssh.tcl
Created April 10, 2012 08:35
ssh.tcl
#!/usr/bin/expect
set timeout 60
while {1} {
spawn /usr/bin/ssh -NCD :7070 [email protected]
expect {
"password:" { send "111111\r" }
}
interact {
timeout 60 { send " " }
eof { exp_continue }
@xream
xream / evernoteAdBlock.sh
Created April 11, 2012 09:31
evernoteAdBlock
#!/bin/bash
# sh evernoteAdBlock.sh
cd ~/Library/Application\ Support/Evernote/promos/
rm `ls|grep -v stats.plist`
chmod 555 ../promos
@xream
xream / adbInstallApk.sh
Created April 22, 2012 14:19
adbInstallApk
#!/bin/bash
PATH=$PATH:/usr/local/sbin:/Volumes/data/stuff/code/android-sdk-macosx/platform-tools
for file in `ls|grep .apk`
do
echo $file
adb install $file
done
@xream
xream / flora_pac.py
Created April 24, 2012 03:58
flora_pac.py
#!/usr/bin/env python
#
# Refined by @phuslu
# Flora_Pac by @leaskh
# www.leaskh.com, [email protected]
#
# based on chnroutes project (by [email protected])
#
import re
@xream
xream / changeDefaultDns.sh
Created April 26, 2012 03:01
changeDefaultDns
#!/bin/bash
function changeDns () {
networksetup -setdnsservers $1 $2
sleep 1
dns=`grep nameserver /etc/resolv.conf|head -1|cut -f2 -d " "`
echo $dns
}
changeDns Wi-Fi empty
echo "server=$dns" > /usr/local/etc/dnsmasq/dns.conf