git init
or
| import httplib, urlparse, socket | |
| def http_get_headers_and_truncated_body( | |
| url, max_redirects=5, body_length=2048, timeout=5, | |
| allowed_content_types = ('text/html',), num_redirects_followed=0, | |
| redirect_chain = None | |
| ): | |
| redirect_chain = redirect_chain or [] | |
| # Returns {'ok':True,'headers':{},'redirected':False,'url':'','body': '', | |
| # 'max_redirects_reached': False, 'num_redirects_followed': 0, |
| # wtf8.py | |
| import codecs | |
| def encode(input, errors='strict'): | |
| return input.encode('utf-8', errors).decode('latin-1', errors).encode('utf-8', errors), len(input) | |
| def decode(input, errors='strict'): | |
| return input.decode('utf-8', errors).encode('latin-1', errors).decode('utf-8', errors), len(input) | |
| class StreamWriter(codecs.StreamWriter): |
| #!/usr/bin/env python | |
| # liuw | |
| # Nasty hack to raise exception for other threads | |
| import ctypes # Calm down, this has become standard library since 2.5 | |
| import threading | |
| import time | |
| NULL = 0 |
| package main | |
| import ( | |
| "container/list" | |
| "flag" | |
| "fmt" | |
| "io" | |
| "io/ioutil" | |
| "log" | |
| "net/http" |
| gifify() { | |
| if [[ -n "$1" ]]; then | |
| if [[ $2 == '--good' ]]; then | |
| ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
| time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
| rm out-static*.png | |
| else | |
| ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
| fi | |
| else |
| import collections | |
| from mock import patch | |
| MethodCall = collections.namedtuple( | |
| 'MethodCall', | |
| ('args', | |
| 'kwargs', | |
| 'return_value', | |
| ), |
| import rtree | |
| import cPickle | |
| import osgeo.ogr | |
| import shapely.wkb | |
| import shapely.speedups | |
| shapely.speedups.enable() | |
| class FastRtree(rtree.Rtree): | |
| def dumps(self, obj): |
| M[16],X=16,W,k;main(){T(system("stty cbreak") | |
| );puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i | |
| ,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M | |
| [w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<< | |
| (l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k) | |
| ]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d | |
| -1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X] | |
| *i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4; | |
| )s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4|| | |
| puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2 |
| /* Annotated version of 2048.c */ | |
| M[16], // The board | |
| X=16, // Shorthand for 16 | |
| W, // Game over bit mask: 1=won, 2=not lost | |
| k; | |
| main(){ | |
| T( // Call main game logic | |
| system("stty cbreak") // Set tty mode to not wait for enter key |