Skip to content

Instantly share code, notes, and snippets.

View pichuang's full-sized avatar

Phil Huang pichuang

View GitHub Profile
@pichuang
pichuang / ChangWWWPerm.sh
Created February 7, 2015 03:55
Easy Change WWW Permission
#!/bin/bash
USER="http"
GROUP="http"
DIR_PERMISSION="750"
FILE_PERMISSION="640"
DIRPATH="$1"
if [ $# == 0 ]; then
echo "Usage: changePerm.sh DIR"
@pichuang
pichuang / nat
Created March 18, 2015 10:38
nat and ip forwarding
#!/bin/sh
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -Z
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -A INPUT -i eth4 -s <PRIVATE_IP_SUBNET> -j ACCEPT
iptables -A INPUT -i eth0 -s <PUBLIC_IP_SUBNET> -j ACCEPT
@pichuang
pichuang / set-fail-mode.py
Created April 27, 2015 03:36
regular l2 switch on mininet
#!/usr/bin/env python2
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.log import setLogLevel, info
from mininet.node import Controller, RemoteController
from mininet.cli import CLI
from mininet.link import Intf
from mininet.util import dumpNodeConnections
@pichuang
pichuang / clusterdemo.py
Last active August 29, 2015 14:23
mininet clusterdemo.py by pichuang
#!/usr/bin/python
"clusterdemo.py: demo of Mininet Cluster Edition prototype"
from mininet.examples.cluster import MininetCluster, SwitchBinPlacer
from mininet.topolib import TreeTopo
from mininet.log import setLogLevel
from mininet.examples.clustercli import ClusterCLI as CLI
from mininet.node import Controller, RemoteController
#!/usr/bin/python
from mininet.examples.cluster import MininetCluster, SwitchBinPlacer
from mininet.topolib import TreeTopo
from mininet.topo import LinearTopo
from mininet.log import setLogLevel, info
from mininet.examples.clustercli import ClusterCLI as CLI
from mininet.net import Mininet
from mininet.node import Controller, RemoteController
from mininet.util import dumpNodeConnections
@pichuang
pichuang / yield.py
Last active August 29, 2015 14:24
Research fab
#!/usr/bin/env python3
'''
Research yield
http://www.ibm.com/developerworks/cn/opensource/os-cn-python-yield/
'''
import time
import logging
@pichuang
pichuang / counter.py
Created July 1, 2015 11:50
Research counter
#!/usr/bin/env python3
'''
Research counter
'''
'''
Use dict()
'''
data = ['a', '2', 2, 4, 5, '2', 'b', 4, 7, 'a', 5, 'd', 'a', 'z']
count_freq = dict()
#!/bin/sh
APP_PATH=~/ryuInstallHelper/ryu/ryu/tests/switch
TEST_TARGET_SWITCH="0000000000000001"
AUXILIARY_SWITCH="0000000000000002"
TEST_PATTERN="of13"
ryu-manager --test-switch-target $TEST_TARGET_SWITCH \
--test-switch-tester $AUXILIARY_SWITCH \
--test-switch-dir $APP_PATH/$TEST_PATTERN \
$APP_PATH/tester.py
<?php
$arr = array(0=>1,"aa"=>2, 3, 4);
foreach($arr as $key=>$val){
print($key == "aa" ? 5 : $val);
}
?>
@pichuang
pichuang / 0_reuse_code.js
Created November 2, 2015 18:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console