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/python3 | |
from sys import argv | |
with open(argv[1]) as f: | |
lines = f.readlines() | |
d = dict() | |
for line in lines: | |
if line[0] != '*' or 'color' not in line: | |
continue |
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/sh | |
/sbin/ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up | |
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE | |
echo "1" | /usr/bin/tee /proc/sys/net/ipv4/ip_forward |
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
def meme(f): | |
memes = {} | |
def inner(*args, **kwargs): | |
key = (args, tuple(sorted(kwargs.items()))) | |
if key in memes: | |
return memes[key] | |
ret = f(*args, **kwargs) | |
memes[key] = ret | |
return ret | |
return inner |
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, permutations | |
from pyaccum import accumulate | |
class Proposition: | |
def __invert__(self): | |
return Impl(self, bottom) | |
def __or__(self, other): | |
return Disj(self, other) |
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 sequences import * | |
class ai_class: | |
def __getitem__(self, items): | |
if items[-1] is not Ellipsis: | |
yield from items | |
return | |
expression = find_sequence(items[:-1]) | |
yield from items[:-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 itertools | |
sum = lambda x: list(itertools.accumulate(x)).pop() | |
len = lambda x: sum(1 for _ in x) | |
range = lambda n, step=1: itertools.accumulate(itertools.repeat(step, times=n-1), lambda x, y: x + y) | |
# Full implementation | |
range = lambda min, max=None, step=1: itertools.accumulate(itertools.chain((min if max is not None else 0,), | |
itertools.repeat(step, (max-min-1)//step if max is not None else None))) |
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
user="louisswarren" | |
github="https://api.github.com" | |
pyjsonlines="'\n'.join(r[sys.argv[-1]] for r in json.loads(sys.stdin.read()))" | |
pycmd="import sys, json; print($pyjsonlines)" | |
curl -s "$github/users/$user/repos" | python3 -c "$pycmd" git_url | | |
while read x; do | |
git clone "$x" | |
done |
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
front = 16,1,14,3,12,5,10,7 | |
back = 4,13,2,15,8,9,6,11 | |
for x in range(4): | |
print("Sheet", x + 1) | |
for side in front, back: | |
print(',\t'.join(str(p + 16*x) for p in side)) | |
print() | |
# Sheet 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
for f in *.mp4; do | |
target="${f%.mp4}.mp3" | |
ffmpeg -i "$f" -vn -acodec libmp3lame -ac 2 -ab 320k -ar 48000 "$target" | |
done |
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 util import * | |
class Obj: | |
@constructor | |
def __init__(self, name): | |
pass | |
def __str__(self): | |
return str(self.name) |