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
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)

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"
#!/usr/bin/env python3
import binascii
import string
from collections import Counter
total_chars = 0
lines = []
result = []
@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 ;
ed2k://|file|%5B%E5%91%BD%E8%BF%90%E7%9F%B3%E4%B9%8B%E9%97%A8%5D.%5BSC-OL%26SGS%26KFC%5D%5BSteins%3BGate%5D%5B01%5D%5B720p%5D%5BH.264_AAC%5D%5B72D12000%5D.mkv|329526361|bcd3e0959b49bc467dc04a446840b384|h=ioafvgqq2ogy4fkf6jlxiwf65nzbie6b|/
ed2k://|file|%5B%E5%91%BD%E8%BF%90%E7%9F%B3%E4%B9%8B%E9%97%A8%5D.%5BSC-OL%26SGS%26KFC%5D%5BSteins%3BGate%5D%5B01%5D%5B720p%5D%5BH.264_AAC%5D%5B72D12000%5D.sc.ass|42695|52bcfb9c9df5c4720d72e82fda44d71b|h=sut6wt7vbfyjah2x5orckfjsevl3vbiw|/
ed2k://|file|%5B%E5%91%BD%E8%BF%90%E7%9F%B3%E4%B9%8B%E9%97%A8%5D.%5BSC-OL%26SGS%26KFC%5D%5BSteins%3BGate%5D%5B02%5D%5B720p%5D%5BH.264_AAC%5D%5BB133D4E3%5D.mkv|280374228|e628d3300c16709046239a8567c1c71a|h=4zspfaldm46qcm7enc2lbhivr42j3vte|/
ed2k://|file|%5B%E5%91%BD%E8%BF%90%E7%9F%B3%E4%B9%8B%E9%97%A8%5D.%5BSC-OL%26SGS%26KFC%5D%5BSteins%3BGate%5D%5B02%5D%5B720p%5D%5BH.264_AAC%5D%5BB133D4E3%5D.sc.ass|53208|f2077ca6984cf60515a0c91c7aa76113|h=xmojr7lmtbwjwicycrx43gphdo44nbsp|/
ed2k://|file|%5B%E5%91%BD%E8%BF%90%E7%9F%B3%E4%B9%8B%E9%97%A8%5D.%5BSC
#!/bin/bash
# 使用:replace.sh <替换列表> <被替换的文件>
# 忽略大小写,单词后加一个s会被当成复数视为同一单词,空格要用"\ "转义
# 示范:https://gist.github.com/4660920
cat $1 | while read src dest do sed -i -r "s/(\<${src}s?\>)/\1($dest)/ig" $2 done
cuihao-tp430-arch $ cat buncho /dev/shm
While the woman teacher was eating an apple, other apples called the Leopard.
The leopard was so angry that he ate the woman who is eating an apple.
cuihao-tp430-arch $ ./replace.sh list buncho /dev/shm
cuihao-tp430-arch $ cat buncho /dev/shm
While the(啊哈) woman teacher(女教师) was eating an apple(苹果), other apples(苹果) called the(啊哈) Leopard(豹子).
The(啊哈) leopard(豹子) was so angry that he ate the(啊哈) woman who is eating an apple(苹果).
import concurrent.futures
with concurrent.futures.ProcessPoolExecutor() as executor:
for ans in executor.map(lambda x: 2**x, range(10)):
print(ans)
#!/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()