Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Zhangerr / README.md
Last active November 20, 2017 06:38
rotate web pages (in chrome/safari only for now)
@Zhangerr
Zhangerr / rnd.py
Created January 2, 2013 04:09
simple script for generating random numbers in python
#!/usr/bin/python
import sys
import getopt
n = 1
src = "urandom"
def Usage():
print """a simple script to generate random numbers. syntax is as follows:
""" + sys.argv[0]+ """ [options] <number of random numbers to print>
There are only 2 options:
@Zhangerr
Zhangerr / factorial.py
Created April 4, 2013 05:28
factorial functional style?
>>> g = lambda x: reduce(lambda y,z:y*z,range(x,0,-1))
>>> g(2)
2
>>> g(3)
6
>>> g(4)
24
>>> g(5)
120
>>> g(6)
@Zhangerr
Zhangerr / todo
Last active December 17, 2015 10:49
sc2
forward pylons/pylon spread
stay calm and a move to drops/counter attacks
macro & throw down production even while focusing on army
throw down a lot of gateways in late game
expand, counter attack, drop
probe production
avoid supply block, check supply & make pylons
rally points
chronoboost production
scout
@Zhangerr
Zhangerr / less
Created July 6, 2013 07:23
LESS frameworks
Lesshat - http://lesshat.com/
helpess - http://www.m6tt.com/2011/09/21/helpless-a-less-library
3L - http://mateuszkocz.github.io/3l/
preboot - http://markdotto.com/bootstrap/
clearless - http://clearleft.github.io/clearless/
lesselements - http://lesselements.com/
dss less - http://mrkrupski.github.io/LESS-Dynamic-Stylesheet/
bootstrap - http://twitter.github.io/bootstrap/
@Zhangerr
Zhangerr / main.py
Created July 8, 2013 07:21
test sieve of eratosthenes
max = 10000000
rm = max+1
primes = range(0,rm)
primes[0]=-1
primes[1]=-1
p = 2
pold = 2
while 1:
#print p
i = 0
@Zhangerr
Zhangerr / binary.py
Last active December 19, 2015 19:19
cool little snippet in python to generate binary string (and recursive multiply)
binary = lambda n: n>0 and binary(n>>1)+[n&1] or []
"".join(map(str,binary(10)))
def multiply(base, times):
if times == 0:
return 0
return base + multiply(base, times-1)
@Zhangerr
Zhangerr / fcntl.h
Created July 17, 2013 17:10
Flags for the linux syscall open in /usr/include/bits/fcntl.h
#define O_ACCMODE 0003
#define O_RDONLY 00
#define O_WRONLY 01
#define O_RDWR 02
#define O_CREAT 0100 /* not fcntl */
#define O_EXCL 0200 /* not fcntl */
#define O_NOCTTY 0400 /* not fcntl */
#define O_TRUNC 01000 /* not fcntl */
#define O_APPEND 02000
#define O_NONBLOCK 04000
@Zhangerr
Zhangerr / quine.py
Created July 31, 2013 18:34
a simple little quine in python.
s = "s = {0}{1}{0};{2}print s.format(chr(34),s,chr(10))"
print s.format(chr(34),s,chr(10))