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
set nocompatible | |
set timeout timeoutlen=500 ttimeoutlen=0 | |
syntax enable | |
filetype on | |
augroup filetypedetect | |
au! BufRead,BufNewFile *.jsx setfiletype javascript | |
augroup END | |
set t_Co=256 background=light |
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/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 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 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
J=1;exec'''z="";b=-1.6;exec' | |
x=y=0;exec"x,y=2*x*y+J,y*y-x | |
*x+b;"*20;z+=" O"[x*x+y*y<2] | |
;b+=.040;'*60;print z;J-=.10 | |
;'''.replace('\n','')*20#Jay |
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 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 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
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 |
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
sub Y{$p=$_;for$i(1..4){$p=join'',map{substr+($k&&$k-$i?$p:join'',map{s/@//g;s | |
/(.)\1/++($a=$1)/eg;$_|'@'x4}$p=~/.{4}/g),3+$_%4*4-($_/4|0),1}0..15}$p}$_='@'x | |
16;for(`stty cbreak`;print"\e[2J\e[H";$_=Y map{$k=index+JDACB,getc}0..2){$k=0; | |
1until$r=0|rand 16,!/@/||s/(?<=^.{$r})@/rand>.1?A:B/e;printf'%4s|%s',/\w/&&1<< | |
(ord)-64,++$g%4?'':$/for/./g;last if$e=WIN x/K/||Y!~/@/&&LOSE}print$e # [2048] |
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
/* 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 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/bash | |
:|((read f g h | |
[[ -f .$g&&$g != *..* ]]&&echo "$h 200 O | |
"&&cat .$g)|nc -q0 -lp$1)>/dev/fd/0;$0 $1 |
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 sys,os;M=[0]*30000;A=[] | |
p=k=x=0;S=open(sys.argv[1]).read() | |
while x<len(S):exec"""M[p]+=1 | |
M[p]-=1 M[p]=ord(os.read(0,1)or"\\0") | |
os.write(1,chr(M[p])) p-=p>0 p+=1 | |
k=A.append(x)if+M[p]else+1 x=A.pop()-1 | |
k+=1 0 k-=1 0""".split()['+-,.<>[][+]+' | |
.find(S[x]+'+'*(k>0))];M[p]&=255;x+=1 |
OlderNewer