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
# "Of being lazy" February 2, 2013 by Paul Masurel | |
# http://fulmicoton.com/posts/lazy/ | |
class LazyObject(object): | |
__slots__ = [ "_recipe", "_result", "_evaluated" ] | |
def __init__(self, recipe): | |
object.__setattr__(self, "_recipe", recipe) | |
object.__setattr__(self, "_result", 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
try: | |
import builtins | |
except ImportError: | |
# PY2 compat | |
import __builtin__ as builtins | |
import re | |
import math | |
from functools import partial |
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 operator import itemgetter | |
def multisort(vals, sort_spec, in_place=False): | |
comparers = [] | |
for i, spec in enumerate(sort_spec): | |
if isinstance(spec, tuple): | |
key, polarity = spec | |
elif isinstance(spec, (str, unicode)): | |
key = spec.replace("-", "", 1) | |
polarity = 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
# coding: utf-8 | |
""" | |
Pretty print replacement for timeit | |
pp_timeit.auto_timeit runs a statement and automatically | |
determines the number of repetitions required to gain | |
satisfactory accuracy (similar to timeit.main). | |
pp_timeit uses auto_timeit and prints the result so that the | |
different magnitudes of results are visible by their alignment. |
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
cd rust-nightly-x86_64-unknown-linux-gnu | |
cd $HOME/rust-nightly-x86_64-unknown-linux-gnu | |
bash install.sh | |
cd $HOME | |
chown -R $USER:$USER rust-nightly-x86_64-unknown-linux-gnu | |
git clone https://github.com/murarth/rusti.git | |
chown -R $USER:$USER rusti | |
cd $HOME/rusti | |
cargo build |
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 | |
import itertools as it | |
PY2 = sys.version_info.major == 2 | |
if PY2: | |
range = xrange | |
def unchain(elems, chain_size): |
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 datetime as dt | |
import sublime_plugin | |
DEV_NAME = "mb" | |
class TODOCommand(sublime_plugin.EventListener): | |
def _todo_str(self): |
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 | |
from __future__ import print_function | |
import os | |
import sys | |
import json | |
from zlib import compress | |
from httplib import HTTPSConnection | |
from urllib import urlencode | |
COMPILER_JAR_PATH = os.path.expanduser("~/closure-compiler/compiler.jar") |
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
DIGITS = ( | |
string.digits + | |
string.ascii_lowercase + | |
string.ascii_uppercase + | |
string.punctuation | |
) | |
def int2str_converter(base): | |
assert 2 <= base <= len(DIGITS) |
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
""" | |
Failed attempt at a performant SortedCounter based on | |
sortedcontainers.SortedDict and defaultdict | |
At least it is not useful for my use case which is insertion | |
heavy, YMMV. | |
Since the collections.Counter class doesn't keep the sort order | |
of its items, it has to recalculate the order for every call | |
to most_common is done. Also it doesn't provide any function |
OlderNewer