View main2.py
This file contains 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 itertools import product | |
import re | |
fh = open('input', 'r') | |
lines = {} | |
for line in fh: | |
sx, sy, bx, by = map(int, re.findall('-?\d+', line)) | |
d = abs(bx - sx) + abs(by - sy) + 1 | |
for endpoints, mb, norm in [ |
View anki_def.js
This file contains 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
<div class="row"> | |
{{Front}} | |
<span id="playa" class="hooks hooks-l">{{Playability}}</span> | |
<span id="number" class="hooks hooks-r hooks-u">{{Number}}</span> | |
</div> | |
<script> | |
function $$(id) { return document.getElementById(id); } | |
$$('playa').innerText |= 0; |
View debugger.py
This file contains 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 cProfile, logging, cStringIO, pstats | |
prof = cProfile.Profile() | |
score_list = prof.runcall(model.score, scoring_data) | |
prof.create_stats() | |
stream = cStringIO.StringIO() | |
stats = pstats.Stats(prof, stream=stream) | |
stats.strip_dirs().sort_stats('time').print_stats(20) | |
#print stream.getvalue() | |
logging.getLogger().info(stream.getvalue()) |
View import_mem.py
This file contains 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 gc | |
import os | |
import sys | |
import time | |
import imp | |
import ihooks | |
__PID = os.getpid() | |
def rss(): | |
#gc.collect() |
View gif.py
This file contains 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 struct import pack | |
from random import sample | |
dist = lambda a, b: (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2 | |
nn = lambda rgb, centers: min((dist(rgb, c), i) for i, c in enumerate(centers))[1] | |
class GIF(object): | |
def __init__(self, data, size): | |
self.size = size | |
self.data = data |
View density.py
This file contains 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 multiprocessing.dummy import Pool | |
import os | |
import re | |
from subprocess import Popen, PIPE | |
from threading import RLock | |
DIR = 'go4go' | |
def parse(fn): | |
fh = open(fn, 'r') |
View mysql_unicode_regex.py
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
start, end = u'가힝' # Korean | |
#start, end = u'あゟ' # Japanese | |
def esc(c): | |
if c in '[]\\\'\"': | |
return '\\' + c | |
return c |
View eb.py
This file contains 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
exec'i=0;A=.9987;R=range;C=[ord(x)-1\ | |
12for x in"qppp~dp|zpy~pg~pczpadpdap\ | |
|ap~dpzdpztpvupvjprkprppnqpnlpjmpjwp\ | |
fxpfhpzdp~d"];D=lambda x,y:" E"[sum(\ | |
(F4]-y)*(F7]-y)<0and F5]-x>(F5]-F8])\ | |
*(F4]-y)/(F4]-F7])for j in R(22))&1]\ | |
\nwhile 1:\n r=2-i/140%2\n for j in \ | |
R(24):F0],Fr]=F0]*A-Fr]/20,F0]/20+Fr\ | |
]*A\n Z="\\n".join("".join(D(x*.4-20\ | |
,y*.91-20)for x in R(99))for y in R(\ |
View eb.c
This file contains 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
float*F,S=20,C[72]={1},A=.9987,b,d, | |
x,y;r,i,j;main(s){for(j=23;j--;F[5] | |
="DZ^^ZDAADDTUJKPQLMWXHDD"[j]-80)4[ | |
F=C+j*3]="^[YGCAD[^ZZVVRRNNJJFFZ^"[ | |
j]-80;for(;puts("\e[2J");usleep(99* | |
99)){for(j=24;j--;F[r]=y)y=2[F=C+j* | |
3]/S+A*F[r=++i/4800%2],F[2]=A*F[2]- | |
F[r]/S;for(y=-S;y<S;y+=.9)for(x=-S, | |
printf("\e[38;5;%d66m\n",C[2]<0);x< | |
S;x+=.4,putchar("E "[s%2]))for(s=j= |
View synth.pl
This file contains 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
$SPS = 16000; | |
$PI = 3.14159265359; | |
$PITCH_ROLL = 1; | |
$BPM = 170; | |
%FREQS = ( | |
A => 440.000, | |
B => 493.883, | |
C => 261.626, |
NewerOlder