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
| 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= |
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
| 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(\ |
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
| #!/usr/bin/perl | |
| =pod | |
| A simple script to display a pretty histogram based on values read from STDIN. | |
| =cut | |
| use strict; | |
| use Getopt::Long qw(:config bundling); | |
| use List::Util qw(first max maxstr min minstr reduce shuffle sum); | |
| binmode(STDOUT, ':utf8'); |
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 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') |
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 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 |
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 os,tty;tty.setcbreak(0);M=['']*16 | |
| def G(v): | |
| p=['']*4;u=list(filter(str,v));i=3 | |
| while u:z=u.pop();p[i]=u and z==u[-1]and 2*u.pop()or z;i-=1 | |
| return p | |
| def Y(M,k):i=1;M=zip(*[iter(M)]*4);exec'M=map([list,G][i*k==k*k],zip(*M))[::-1];i+=1;'*4;return sum(M,[]) | |
| while 1: | |
| r=id(M)%71+17 | |
| while M[r%16]*r:r-=1 | |
| if r:M[r%16]=r%7%2*2+2 |
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 gc | |
| import os | |
| import sys | |
| import time | |
| import imp | |
| import ihooks | |
| __PID = os.getpid() | |
| def rss(): | |
| #gc.collect() |
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
| /* 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 |
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
| #define _+o[~$&1][O | |
| o[2][992],$;main(O){ | |
| for(;gets(o);$++)for | |
| (puts("\e[H"),O=32;O | |
| ++<960;)putchar(O%32 | |
| ?" O"[o[$&1][O]=3==( | |
| _-33]_-32]_-1]_-31]_ | |
| +1]_+31]_+32]_+33]|_ | |
| ])|O%9&!$]:10);} |
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 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()) |
OlderNewer