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/env python3 | |
"""Print a random number of lines in response to each input line. | |
Terminate each response with 'END'. | |
""" | |
import sys | |
import random | |
def log(msg): |
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/env python | |
"""Play Youtube video on remote VLC. | |
Usage: play-youtube-video-on-remote-vlc <webpage-url> | |
Send media url to remote (desktop) VLC using (Lua) http interface | |
https://wiki.videolan.org/VLC_HTTP_requests/ | |
""" | |
import base64 | |
import os |
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
/** Convert Roman numerals given on the command line to decimals. | |
$ ragel -F0 -o roman_numerals.c roman_numerals.rl | |
$ gcc -finput-charset=utf-8 -fexec-charset=utf-8 -o roman_numerals roman_numerals.c | |
$ ./roman_numerals IX Ⅻ CCCC | |
9 | |
12 | |
400 | |
$ ./roman_numerals IIX && exit 1 || echo invalid | |
invalid |
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
/scheme.png |
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
# $ grako -o kv_parser.py KV.ebnf | |
@@grammar :: KV | |
# whitespace inside a string excluding the start/end of the line | |
@@whitespace :: /((?!^)(?![\r\n])\s)+/ | |
@@eol_comments :: /#[^\r\n]*/ | |
@@left_recursion :: False | |
# input is zero or more assignments |
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/env python3 | |
r"""Parse space-separated key=value pairs. | |
Format from http://ru.stackoverflow.com/a/635295/23044 | |
>>> from pprint import pprint | |
>>> pprint(parse(r'a=1 b="2" c=3.123 d=[1, 2, 3] e={"Ke\n":["h=4"],"Key2":{" ":1}}')) | |
{'a': 1, | |
'b': '2', | |
'c': 3.123, |
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/env python3 | |
"""Collatz conjecture.""" | |
def collatz(n): | |
assert n > 0 | |
while n != 1: | |
yield n | |
if n & 1: # odd | |
n = 3*n + 1 | |
else: |
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
.cache* |
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
/.cachedir/ | |
/sites.json |
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/env python | |
"""Beep PC Speaker using Linux evdev API. | |
To make /dev/input/by-path/platform-pcspkr-event-spkr device available, run: | |
root# modprobe pcspkr | |
""" | |
import ctypes | |
import math | |
import os |