Skip to content

Instantly share code, notes, and snippets.

@yyl
yyl / lxml_error
Created March 18, 2014 00:02
The error when installing lxml with pip
Installing collected packages: lxml
Running setup.py install for lxml
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.3.3.
Building without Cython.
Using build configuration of libxslt 1.1.28
Building against libxml2/libxslt in the following directory: //anaconda/lib
...
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@yyl
yyl / gettimeofday.c
Created October 7, 2012 17:33
os hw1
#include <sys/time.h>
/* will return current time in second format */
double get_seconds() {
struct timeval tim;
gettimeofday(&tim, NULL);
double t1=tim.tv_sec+(tim.tv_usec/1000000.0);
return t1;
}
@yyl
yyl / gist:3819836
Created October 2, 2012 15:00
cgi python
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
print "Content-type:text/html\r\n\r\n"
print "# of data fields: %s" % len(form)
@yyl
yyl / der.bash
Last active January 30, 2017 14:17
keytool
openssl x509 -outform der -in res/raw/cert.pem -out res/raw/cert.der
@yyl
yyl / iter1.py
Created August 23, 2012 02:29
iterates
a = [1,2,3]
i = iter(a)
i.next()
@yyl
yyl / gist:3195607
Created July 29, 2012 01:24
twitterface
select users.username, users.location from users where users.user_id in(
select tweet_mentions.target_user_id from tweet_mentions where tweet_mentions.target_user_id in (
select users.user_id from users,tweets where tweets.user_id=users.user_id and tweet_text like '%Cancer%' and users.location in ('NY')
)
union select users.user_id from users,tweets where tweets.user_id=users.user_id and tweet_text like '%cancer%' and users.location in ('NY') and users.followers_count > 1000);
@yyl
yyl / gist:3173978
Created July 25, 2012 02:13
euler 28
def approach1(size):
diagonal = 0
current = 1
for i in range(1, size+1):
current += i
diagonal += current
# decrease the sum if it is the first odd turn
if i%2 != 0:
diagonal -= 1
current += i
@yyl
yyl / fuzzer.py
Created July 22, 2012 17:49
fuzzer
#!usr/bin/python
############ constants
apps = ["/Applications/Adobe Reader.app/Contents/MacOS/AdobReader",
"/Applications/Preview.app/Contents/MacOS/Preview"
]
file_list = ["sample1.pdf"]
fuzz_output = "fuzzed.pdf"
@yyl
yyl / awesome.py
Created July 16, 2012 03:50
fibonacci generator
def fibo_gen():
a = 1
b = 1
while 1:
yield a
a, b = b, a+b
a = fibo_gen()
f = a.next()
count = 1
@yyl
yyl / sudoku_checker.py
Created July 15, 2012 16:41
My solution for sudoku checker in online course Software testing
def check_sudoku(grid):
###Your code here.
if isIllFormed(grid):
return None
elif isInvalid(grid):
return False
else:
return True
# return True if the grid is ill_formed