This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> a = [1, 2] | |
| >>> b = (1, 2) | |
| >>> a < b | |
| True | |
| >>> b > a | |
| True | |
| >>> b < a | |
| False | |
| >>> c = [ | |
| ... (1, 2, 3), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fib(n): | |
| if n <= 1: | |
| return n | |
| else: | |
| return fib(n-1) + fib(n-2) | |
| def main(): | |
| for i in xrange(36): | |
| print "n=%d => %d" % (i, fib(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| renderRecommendations({ | |
| "data": [ | |
| { | |
| "pub_date": "2012-02-17T17:31:33Z", | |
| "link": "http://write.arstechnica.com/published/apple/news/2012/02/mt-preview-83bb1965c86a7f89c5e198f4f8c1582ff21e76c4.ars", | |
| "title": "Week in Apple: Mountain Lion surprise attack", | |
| "thumb_url_medium": "http://c0001566.cdn1.cloudfiles.rackspacecloud.com/medium_d84cc0f61eb70b89d6f65e9e5c790e321354e853.jpg", | |
| "author": "Jacqui Cheng" | |
| }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def to_base(q, alphabet): | |
| if q < 0: raise ValueError, "must supply a positive integer" | |
| l = len(alphabet) | |
| converted = [] | |
| while q != 0: | |
| q, r = divmod(q, l) | |
| converted.insert(0, alphabet[r]) | |
| return "".join(converted) or '0' | |
| def to62(q): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function() { var u = location.href, a = document.createElement('a'); a.href = u; location.href = "http://www.newsblur.com/?url=" + encodeURIComponent(a.hostname); }()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var httpProxy = require('http-proxy'); | |
| var url = require('url'); | |
| httpProxy.createServer(function(req, res, proxy) { | |
| var isHtml = false, | |
| write = res.write, | |
| writeHead = res.writeHead, | |
| params = url.parse(req.url, true).query, | |
| dest = params.dest || 'localhost', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ipython | |
| ipython==0.13.1 | |
| # ipython notebook | |
| pyzmq==13.0.0 | |
| tornado==2.4.1 | |
| # livereload | |
| livereload==0.14 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def calculate_hotclicks(item): | |
| return item.clicks \ | |
| or \ | |
| ((lambda n:\ | |
| reduce(\ | |
| lambda x,y:(x[0]+x[1],x[0]),[(1,1)]*(n-2))[0])\ | |
| (3)-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqlite3 | |
| import sys | |
| conn = sqlite3.Connection("Database.papersdb") | |
| query = "SELECT pub.ROWID, pdf.path, pub.title FROM Publication pub, PDF pdf WHERE pdf.object_id=pub.ROWID" | |
| for row in conn.execute(query): | |
| rowid, path, title = row | |
| newtitle = path.replace("Files/", "").replace(".pdf", "") | |
| sql = ('UPDATE Publication SET title=? WHERE ROWID=?', (newtitle, rowid)) | |
| print sql | |
| conn.execute(*sql) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http://r.duckduckgo.com/l/?kh=-1&uddg=http%3A%2F%2Fwww.journalism.co.uk%2Fnews%2F-dark-social-and-other-mysterious-analytics%2Fs2%2Fa554142%2F |
OlderNewer