Skip to content

Instantly share code, notes, and snippets.

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
@cuihaoleo
cuihaoleo / a.c
Created Aug 29, 2015
test struct init
View a.c
#include <stdio.h>
struct test {
int a, b, c;
};
int main() {
struct test st = {
.b = 15,
};
View fib_C.c
#include <stdio.h>
int main ()
{
int a = 0, b = 1, c = 1, sum = 0;
while (c < 4000000)
{
if (c % 2 == 0)
sum += c;
View fib
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):
View a.py
#!/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:
View a.py
#!/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:
View gist:3291e94c62a8de5c362a
<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>
View jsff_python_mp.py
#!/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))
View PKGBUILD
# 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)
View r.sh
#!/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
View drawpic.py
#!/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()