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/env python | |
| import argparse | |
| import sys | |
| def tokenize(source): | |
| return list(source) | |
| def parse(tokens): |
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
| #include <signal.h> | |
| void stop_self() | |
| { | |
| raise(SIGSTOP); | |
| } | |
| int main() | |
| { | |
| struct sigaction act; |
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 weakref | |
| class Object(object): pass | |
| l = [Object()] | |
| l[0].l = l | |
| REFS = weakref.WeakKeyDictionary() | |
| REFS[l[0]] = 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
| %{ | |
| #include "units.tab.c" | |
| %} | |
| %option noyywrap | |
| int -?[0-9]+ | |
| %% | |
| [ \t] /*empty*/ |
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 sys | |
| vowels = set('aeiouy') | |
| consonants = set('bcdfghjklmnpqrstvwxz') | |
| impossible_digraphs = ['aa', 'bg', 'bh', 'bk', 'bq', 'bw', 'bx', 'bz', 'cb', 'cf', 'cg', 'cj', 'cm', 'cp', 'cv', 'cw', 'cx', 'cz', 'dx', 'dz', 'fc', 'fd', 'fg', 'fj', 'fk', 'fn', 'fp', 'fq', 'fv', 'fw', 'fx', 'fz', 'gc', 'gj', 'gk', 'gq', 'gv', 'gx', 'gz', 'hj', 'hk', 'hq', 'hv', 'hx', 'hz', 'ij', 'iy', 'jb', 'jc', 'jd', 'jf', 'jg', 'jh', 'jj', 'jk', 'jl', 'jm', 'jn', 'jp', 'jq', 'jr', 'js', 'jt', 'jv', 'jw', 'jx', 'jy', 'jz', 'kq', 'kv', 'kx', 'kz', 'lj', 'lx', 'md', 'mj', 'mk', 'mq', 'mx', 'mz', 'pg', 'pj', 'pq', 'pv', 'px', 'pz', 'qa', 'qb', 'qc', 'qd', 'qe', 'qf', 'qg', 'qh', 'qi', 'qj', 'qk', 'ql', 'qm', 'qn', 'qo', 'qp', 'qq', 'qr', 'qs', 'qt', 'qv', 'qw', 'qx', 'qy', 'qz', 'rx', 'sx', 'sz', 'tq', 'tx', 'uj', 'uq', 'uw', 'uy', 'vb', 'vc', 'vd', 'vf', 'vg', 'vh', 'vj', 'vk', 'vl', 'vm', 'vn', 'vp', 'vq', 'vr', 'vs', 'vt', 'vv', 'vw', 'vx', 'vz', 'wj', 'wk', 'wp', 'wq', 'wv', 'ww', 'wx', 'wz', 'xb', 'xf', 'xg', 'xj', 'xk', 'xm', |
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 veri import Verified | |
| class Something(metaclass=Verified): | |
| # a single type | |
| some_int = int | |
| some_str = str | |
| # a 'struct' using tuples | |
| some_tuple = (int, int, str) | |
| # a list of integers |
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
| last = None | |
| with open('index.txt') as f: | |
| for line in f: | |
| new = int(line.decode('utf-8').split('\t', 1)[0]) | |
| if last is not None: | |
| if last - new > 1: | |
| if last - new == 2: | |
| print new + 1 | |
| else: |
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
| function love.graphics.roundrect(mode, x, y, width, height, xround, yround) | |
| local points = {} | |
| local precision = (xround + yround) * .1 | |
| local tI, hP = table.insert, .5*math.pi | |
| if xround > width*.5 then xround = width*.5 end | |
| if yround > height*.5 then yround = height*.5 end | |
| local X1, Y1, X2, Y2 = x + xround, y + yround, x + width - xround, y + height - yround | |
| local sin, cos = math.sin, math.cos | |
| for i = 0, precision do | |
| local a = (i/precision-1)*hP |
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
| class LinkedList: | |
| next = None | |
| val = None | |
| def __init__(self, val): | |
| self.val = val | |
| def add(self, val): | |
| if self.next is None: | |
| self.next = LinkedList(val) |
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 random import choice | |
| with open('/usr/share/dict/nederlands') as f: | |
| words = f.read().split('\n') | |
| def get_random_pair(): | |
| w1 = choice(words) | |
| w2 = choice(words) | |
| return len(w1) + len(w2), w1, w2 |