Skip to content

Instantly share code, notes, and snippets.

View li-ch's full-sized avatar
:shipit:
Focusing

Li Chen 陈 力 li-ch

:shipit:
Focusing
View GitHub Profile
@li-ch
li-ch / System Design.md
Created April 18, 2016 15:28 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@li-ch
li-ch / serve-start.py
Created July 22, 2016 05:05
start servers
#!/usr/local/bin/python
import subprocess
procs = []
pids = []
i = 0
for size in [5, 20, 93]:
proc = subprocess.Popen(["./ver-{}/cloud_burst/target/release/server".format(size), "127.0.0.1:1000{}".format(i)],
shell=True)
i += 1

list all tcpdump process:

pgrep tcpdump

kill all tcpdump process:

pkill tcpdump
tcpdump -ttttt -w temp.pcap -i eth2 -s 100 dst 192.168.16.1
#!/bin/bash
nmap 192.168.2.0/24 -n -sP | grep report | awk '{print $5}'
@li-ch
li-ch / sing_ip_route.log
Last active October 19, 2016 06:27
Correctly conifgured ssh tunneling.
li@sing:~$ sudo ssh -S /var/run/ssh-tun2-tunnel-control -M -f -w 2:2 143.89.191.40 true
li@sing:~$ ip route show
default via 143.89.244.126 dev eth0
10.2.0.1 dev tun2 proto kernel scope link src 10.2.0.2
10.8.0.0/24 via 10.8.0.2 dev tun0
10.8.0.2 dev tun0 proto kernel scope link src 10.8.0.1
143.89.244.64/26 dev eth0 proto kernel scope link src 143.89.244.107
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.254
192.168.2.0/24 via 10.2.0.1 dev tun2
#!/bin/bash
cat after.log | egrep '(r|t)x_pause_dur' | tr -s ' ' | cut -d ' ' -f 3
# print log file to std
# filter out the insterested part
# trim out the unnecessary parts
# cut the output into parts, and select the column.
mount 192.168.2.254:/srv/nfs4/home /home
mount 192.168.2.254:/srv/nfs4/opt /opt
@li-ch
li-ch / pedantically_commented_playbook.yml
Created December 14, 2016 06:18 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.

Sample playbook for getting shell output from stdout at distributed clients.

---
-
  hosts: all
  gather_facts: no
  tasks:
    - shell: nmap 192.168.101.0/24 -n -sP | grep report | awk '{print $5}'
      register: regnmap
 
import networkx as nx
import random
import numpy as np
for k in range(5,64,10):
for m in range(1000,10001,2000):
mean_time_between_failure = m # unit is hour
failRate = 1/mean_time_between_failure
time_quantum = 1 # hour