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
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(苹果).
#!/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
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
@cuihaoleo
cuihaoleo / fib
Created September 28, 2014 01:34
def fib (m):
a, b, c = 0, 1, 1
yield 1
while a+b <= m:
c = a + b
yield c
a, b= b, c
s = 0
for i in fib(4000000):
#include <stdio.h>
int main ()
{
int a = 0, b = 1, c = 1, sum = 0;
while (c < 4000000)
{
if (c % 2 == 0)
sum += c;
#!/usr/bin/env python3
import re
import sys
prog = re.compile(r"\\N(?:{[^{}]*})?")
prog2 = re.compile(r"(Dialogue: \w*,\w*:\w*:\w*.\w*,\w*:\w*:\w*.\w*,\w*,\w*,\w*,\w*,\w*,\w*,)(.*)")
for line in sys.stdin:
#!/usr/bin/env python3
import re
import sys
prog = re.compile(r"\\N(?:{[^{}]*})?")
prog2 = re.compile(r"(Dialogue: \w*,\w*:\w*:\w*.\w*,\w*:\w*:\w*.\w*,\w*,\w*,\w*,\w*,\w*,\w*,)(.*)")
for line in sys.stdin:
<html>
<body>
<select id="s1">
<option value="CN">China</option>
<option value="JP">Japan</option>
</select>
<select id="s2">
<option value="Beijing" data-country="CN">Beijing</option>
<option value="Shanghai" data-country="CN">Shanghai</option>
<option value="Tokyo" data-country="JP">Tokyo</option>
#!/usr/bin/env python3
from itertools import count
from math import sqrt
from concurrent.futures import ProcessPoolExecutor
def factory (x):
f = lambda k: 1.0/(k*(k+x))
return (f(k) for k in range(1, 1000000))
# Maintainer: CUI Hao <cuihao.leo@gmail.com>
pkgname=toxvpn-git
pkgver=20150710
pkgrel=1
pkgdesc="toxvpn is a powerful tool that allows one to make tunneled point to point connections over Tox."
arch=(i686 x86_64)
url=https://github.com/cleverca22/toxvpn
license=(GPL3)
depends=(tox)