Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Jacob Wen wenjianhn

🏠
Working from home
Block or report user

Report or block wenjianhn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pktgen_neigh.sh
/sbin/modprobe pktgen
neigh_ip=$1
ping -c 1 ${neigh_ip}
DST=${neigh_ip}
DST_MAC=$(ip neigh | grep ${neigh_ip} | awk '{print $5}')
# DEVICE=$(ip neigh | grep ${neigh_ip} | awk '{print $3}')
DEVICE=eth0
@wenjianhn
wenjianhn / prometheus.yaml
Created Aug 25, 2015
For monitoring MidoNet
View prometheus.yaml
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
rule_files:
- /prometheus.rules
scrape_configs:
View rejoin-dev-midonet.sh
#!/bin/bash
SESSIONNAME="MidoNet"
tmux has-session -t $SESSIONNAME &> /dev/null
if [ $? != 0 ]
then
tmux new-session -s $SESSIONNAME -n script -d
tmux send-keys -t $SESSIONNAME "tailf /var/log/midolman/midolman.log" C-m
tmux new-window -t $SESSIONNAME '/bin/bash'
@wenjianhn
wenjianhn / pm-suspend
Created Jul 14, 2015
Suspend my workstation at 8pm everyday. /etc/cron.daily/pm-suspend
View pm-suspend
#!/bin/bash
/usr/bin/echo '/usr/sbin/pm-suspend' | /usr/bin/at 8pm
@wenjianhn
wenjianhn / DivideByThree.tla
Created Jul 14, 2015
Prove (x + y) % 3 = 0 => (10*x + y) % 3 = 0
View DivideByThree.tla
---------------------------- MODULE DivideByThree ----------------------------
EXTENDS Integers
VARIABLES x, y
vars == <<x, y>>
Init == /\ x \in 1..9
/\ y \in 0..9
Next == \//\ x' = x + 1
@wenjianhn
wenjianhn / GCD.tla
Created Jun 26, 2015
The Greatest Common Divisor
View GCD.tla
-------------------------------- MODULE GCD --------------------------------
EXTENDS Integers
Divides(p, n) ==
\E q \in -n..n : n = q * p
DivisorsOf(n) == {p \in -n..n : Divides(p, n)}
SetMax(S) ==
CHOOSE i \in S : \A j \in S : i >= j
@wenjianhn
wenjianhn / append_KBps.sh
Last active Aug 29, 2015
Append KBps for DataNode.clienttrace
View append_KBps.sh
awk '/org.apache.hadoop.hdfs.server.datanode.DataNode.clienttrace/{printf "%s, KBps: %d\n", $0, $10/($NF/10**9)/1024}' ${datanode_log}
View set_static_ip.sh
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$1
DEVICE=$1
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=$2
ONBOOT=yes
EOF
@wenjianhn
wenjianhn / test_socket_prio_and_tos.c
Created Jan 29, 2015
Test if setsockopt(SO_PRIORITY) sets the IP type-of-service (TOS) field or not.
View test_socket_prio_and_tos.c
#include <assert.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
void test_setsockopt()
{
int priority = 6;
@wenjianhn
wenjianhn / test_setsockopt.c
Created Jan 29, 2015
Test setsockopt with SO_PRIORITY and IP_TOS. It shows that order matters.
View test_setsockopt.c
#include <assert.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
void test_setsockopt(int priority_first)
{
int priority = 6;
You can’t perform that action at this time.