Skip to content

Instantly share code, notes, and snippets.

View cuihaoleo's full-sized avatar
:octocat:
͜͡w͜͜͡͡o͜͜͡͡w͜͜͡͡,͜͜͡͡ ͜͜͡͡G͜͜͡͡i͜͜͡͡t͜͜͡͡H͜͜͡͡u͜͜͡͡b͜͡!

CUI Hao cuihaoleo

:octocat:
͜͡w͜͜͡͡o͜͜͡͡w͜͜͡͡,͜͜͡͡ ͜͜͡͡G͜͜͡͡i͜͜͡͡t͜͜͡͡H͜͜͡͡u͜͜͡͡b͜͡!
View GitHub Profile
#!/bin/bash -e
if [[ $IFACE == "vlan95" ]]; then
ip route add 202.38.95.0/25 dev vlan95 table 1000
ip route add default via 202.38.95.126 table 1000
ip rule add from 202.38.95.110 table 1000
fi
if [[ $IFACE == "vlan10" ]]; then
ip route add 202.141.160.0/25 dev vlan10 table 1001
@cuihaoleo
cuihaoleo / a.c
Created August 29, 2015 03:04
test struct init
#include <stdio.h>
struct test {
int a, b, c;
};
int main() {
struct test st = {
.b = 15,
};
#!/usr/bin/env python3
from PIL import Image
import concurrent.futures
from colorfinder import hex2term_accurate, hex2term_quick
from lolcat import get_terminal_size
import argparse
if __name__ == "__main__":
default_size = get_terminal_size()
import concurrent.futures
with concurrent.futures.ProcessPoolExecutor() as executor:
for ans in executor.map(lambda x: 2**x, range(10)):
print(ans)
@cuihaoleo
cuihaoleo / Hello.g4
Created January 26, 2016 14:27 — forked from mattmcd/Hello.g4
Simple ANTLR4 grammar example
// define a grammar called Hello
grammar Hello;
r : 'hello' ID;
ID : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;
#!/usr/bin/env python3
import binascii
import string
from collections import Counter
total_chars = 0
lines = []
result = []

Keybase proof

I hereby claim:

  • I am cuihaoleo on github.
  • I am cuihao (https://keybase.io/cuihao) on keybase.
  • I have a public key whose fingerprint is AA0C BF38 59E5 80B9 7D9F 0463 8FDE 3D8F C99F 40AE

To claim this, I am signing this object:

#!/bin/bash
DOMAIN=$1
KEY=$2
IPV4=$(ip route get 1 | grep -Po '(?<=src )[^ ]+')
IPV6=$(ip route get 2001:: | grep -Po '(?<=src )[^ ]+')
if [[ -n $IPv4 ]]; then
echo "Update IPv4: $IPV4"
execve("/usr/bin/git", ["git", "config", "test.test", "test"], [/* 18 vars */]) = 0
brk(NULL) = 0x7fffb909c000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5e08070000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=52542, ...}) = 0
mmap(NULL, 52542, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5e08063000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
execve("/home/cuihao/temp/a.out", ["/home/cuihao/temp/a.out"], [/* 18 vars */]) = 0
brk(NULL) = 0x7fffc7a79000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2bd2fc0000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=52542, ...}) = 0
mmap(NULL, 52542, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2bd2fb3000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)