Skip to content

Instantly share code, notes, and snippets.

View heshiyou's full-sized avatar
🖖
Working on magic

Ernest He heshiyou

🖖
Working on magic
View GitHub Profile
import urllib2
url = "http://download.thinkbroadband.com/10MB.zip"
file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'wb')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
print "Downloading: %s Bytes: %s" % (file_name, file_size)
@heshiyou
heshiyou / mousewheelcapture.js
Created February 19, 2013 04:51
capture mouse wheel ( touch pad included) event.
/** This is high-level function.
* It must react to delta being more/less than zero.
*/
function handle(delta) {
if (delta < 0)
…;
else
…;
}
@heshiyou
heshiyou / prettyprint-diandian.html
Created March 20, 2012 16:14
code-hightlight-prettyprint
<link rel="stylesheet" type="text/css" href="http://x.libdd.com/farm1/23fcf3/8571658f/D7C90.css"></link>
<script type="text/javascript" src="http://x.libdd.com/farm1/23fcf3/d40262ff/932EF.js"></script>
</head>
<body onload="prettyPrint()">
自定义css
/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */
@heshiyou
heshiyou / photo_upload.py
Created December 5, 2011 12:59
Posting photo to wall using Facebook Graph API
import sys
import os
import itertools
import mimetypes
import mimetools
import urllib
import urllib2
import cgi
try: