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
| # -*- coding: utf-8 -*- | |
| # <nbformat>3.0</nbformat> | |
| # <codecell> | |
| import requests, bs4, re | |
| # <codecell> | |
| re_date = re.compile(r'(?P<date>13[0-1]{1}[0-9]{1}[0-9]{1}[0-9]{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
| %pylab inline --no-import-all | |
| import matplotlib.pyplot as plt | |
| def prob_samebirthday(n): | |
| prob_days = [ (1.0-(i/365.0)) for i in xrange(1,n+1) ] | |
| return 100.0*(1.0-reduce(lambda x,y: x*y, prob_days)) | |
| def draw(): | |
| plt.figure() | |
| plt.grid(True) |
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
| git log --date=iso --pretty=format:"%h|%an|%ad|%s" \ | |
| | awk '{ split($0,a,"|"); split(a[3],b," "); print b[1]; }' \ | |
| | uniq -c \ | |
| | awk '{ print $2,$1 }' \ | |
| | sort -r |
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
| #!/bin/sh | |
| echo "================================" | |
| echo "YYYY-MM-DD The number of commits" | |
| echo "================================" | |
| echo | |
| git log --date=iso --pretty=format:"%h|%an|%ad|%s" | awk '{ split($0,a,"|"); split(a[3],b," "); print b[1]; }' | sort | uniq -c | python -c "import sys; print '\n'.join(map(lambda x:x[1]+' '+'*'*int(x[0])+' '+x[0], map(lambda x:x.strip().split(' '), sys.stdin.readlines())))" | sort -r | |
| echo |
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
| from functools import wraps | |
| class TraceMeta(type): | |
| def __new__(meta, name, bases, dct): | |
| for name,func in dct.items(): | |
| print "\"%s\"" % name, "-->", "\"%s\"" % func | |
| if name[0]!="_" and len(repr(func))>10: | |
| if repr(func)[:5] == "<func": | |
| dct["_"+name] = dct[name] | |
| dct[name].func_name = "_"+dct[name].func_name |
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
| { | |
| "metadata": { | |
| "name": "" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { |
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 sublime, sublime_plugin, json, traceback, sys, re | |
| class PrettifyJsonCommand(sublime_plugin.TextCommand): | |
| def run(self, edit): | |
| # Get the current selection | |
| if self.view.sel()[0].empty(): | |
| region = sublime.Region(0L, self.view.size()) | |
| source = self.view.substr(region).encode('utf-8') |
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://code.activestate.com/recipes/578019/ (r15) | |
| #!/usr/bin/env python | |
| """ | |
| Bytes-to-human / human-to-bytes converter. | |
| Based on: http://goo.gl/kTQMs | |
| Working with Python 2.x and 3.x. | |
| Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com> | |
| License: MIT |
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
| #!/bin/sh | |
| while [ 1 ] | |
| do | |
| clear | |
| date +%T |toilet -F gay -f mono12 | |
| sleep 0.91; | |
| done |
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
| """ | |
| This example requires the body-streaming tornado fork at https://github.com/nephics/tornado. | |
| Refer to http://groups.google.com/group/python-tornado/browse_thread/thread/791c67cb86c2dea2. | |
| Supports uploading an unlimited number/size of files in a single | |
| PUT multipart/form-data request. Each file is processed as the stream | |
| finds the part in the form data. | |
| ==USAGE== |