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 eval_sexpr(sexpr): | |
fn = sexpr[0] | |
args = sexpr[1:] | |
args = tuple(eval_sexpr(e) if isinstance(e, tuple) else e for e in args) | |
return fn(*args) | |
import operator as op | |
eval_sexpr((op.add, (op.mul, 3, 4), (op.mul, 2, 5))) |
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
/* KSON: Keyless Schemafied Object Notation | |
* | |
* Version: 0.1 Alpha | |
* | |
* A serialization format with two goals in mind: | |
* 1. Easily parsable using minimal javascript. | |
* 2. Reduce serialized size compared to JSON. | |
* | |
* 1. is accomplished by using the (comparativly fast) JSON parse/stringify | |
* functions, thus reducing the task of KSON to packing/unpacking the values |
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 re | |
import json | |
ONELINE_COMMENT_RE = re.compile(r""" | |
^ # comment must be at the start of the line | |
\s* # arbitrary whitespace | |
// # start of the comment | |
(.*) # the comment | |
$ # until the end of line | |
""", re.MULTILINE | re.VERBOSE) |
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
# -*- coding: utf-8 -*- | |
# "Writing Python 3 code that's compatible with Python 2 is | |
# much more rewarding than the opposite. Not only does that | |
# make your code more future-proof, but Python 3’s advantages | |
# (like the saner string handling) start shining quickly. | |
# Dealing with Python 2 becomes a backwards compatibility | |
# requirement" – "Porting to Python 3" from the Django Project | |
# This file provides boilerplate for scripts to run in both | |
# python2.7 and python3.4. As much as possible it attempts |
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
class Memoizer(object): | |
"""Memoizer for pure functions with positional hashable arguments. | |
Eviction from cache is done more or less at random, which | |
in practice is surprisingly close to a LRU strategy. | |
""" | |
def __init__(self, func, maxsize=10000): | |
self.func = func | |
self.maxsize = maxsize |
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] | |
name = Manuel Barkhau | |
email = mb@nexttuesday.de | |
[push] | |
default = simple | |
[alias] | |
co = checkout | |
amend = commit --amend | |
sts = status --short | |
stt = status --untracked-files=no |
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
[global_config] | |
inactive_color_offset = 0.92 | |
[keybindings] | |
close_window = None | |
group_tab = <Primary><Alt>t | |
broadcast_group = <Super>g | |
broadcast_all = <Super>b | |
broadcast_off = <Shift><Super>b | |
new_tab = <Primary><Shift>t | |
ungroup_tab = <Primary><Shift><Alt>t |
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
イërnâ七iônàنلzætiøn |
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
# -*- coding: utf-8 -*- | |
"""Prettify JSON | |
Usage: | |
pjson --help | |
pjson --test | |
cat my.json | pjson | |
""" |
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
// ==UserScript== | |
// @name PlacePaintBot | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Domination of Place! | |
// @author mbarkhau | |
// @match https://www.reddit.com/place?webview=true | |
// @grant none | |
// ==/UserScript== |