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 __future__ import print_function | |
# The definitions are in the file "mydirs.dat" which is in the same directory | |
# as this file. Lines of this file may be blank or a label/directory pair, | |
# colon delimited. These can contain just about anything that doesn't confuse | |
# the shell, except colons and newlines, of course. | |
# Into your .bashrc, .profile, .zshrc, or whatever: | |
# cd_() |
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
"%04_ax " | |
2/1 "%02x" " " 2/1 "%02x" " " 2/1 "%02x" " " 2/1 "%02x" "-" 2/1 "%02x" " " 2/1 "%02x" " " 2/1 "%02x" " " 2/1 "%02x" | |
" |" | |
16/ "%_p" | |
"|\n" |
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
_fmtinner = ('',' ') * 3 + ('','-') + ('',' ') * 3 + ('','') | |
_fmtouter = (' ', ' |', '|') | |
def _mkhex(d, i): | |
try: | |
return '%02x' % (ord(d[i]),) | |
except IndexError: | |
return ' ' | |
def _mkchar(d, i): |
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 math import ceil | |
# for example, inc=4 gives ln16, or the number of hexadecimal digits | |
# required to represent n. | |
def ln2(n, inc=1): | |
if n<0: | |
raise ValueError('math domain error') | |
i = 0 | |
n = int(ceil(n)) |
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
// Requires ES5 | |
// Inheritance pattern inspired by http://stackoverflow.com/a/5546053 | |
// instanceOf has the usual straightforward-inheritance-checker problems with iFrames | |
if (typeof classyJS === 'undefined') { | |
var classyJS = (function () { | |
'use strict'; |
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
# Query the current version of maven artifacts at jcenter | |
# Current favorites: | |
# | |
# org=org.jetbrains.kotlin pkg=kotlin-runtime | |
# org=io.kotlintest pkg=kotlintest | |
# org=no.tornado pkg=tornadofx | |
import requests |
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
# Originally from http://logn.org/2009/07/lazy-primes-sieve-in-python.html | |
# Updated for Python3 by Chris Fuller. | |
# The automated 2to3 translation doesn't work. The tricky bit is the heap item. | |
# This is a (int, object) tuple in the original module, but the second element | |
# becomes a map iterator in Python3, which does not compare, so an exception | |
# is raised when the heap is sorted. | |
# It turns out that the object in the original tuple is irrelevant to the sort | |
# (it compares by memory location, which isn't well defined!). The int deter- |
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
"""Presumes that the bitness is a power of two. There have been exceptions, | |
but they are hopefully securely sealed up in the dustbin of history. I | |
am not aware of any port of Python to such a platform. | |
Additionally, systems with fewer than eight bits are not handled correctly. | |
If you find yourself in such a situation, you are presumed to know better | |
than to rely on this module.""" | |
def pyBits(): |
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
# PEP514 defines these registry entries | |
# https://www.python.org/dev/peps/pep-0514/ | |
from __future__ import print_function | |
# https://gist.github.com/sfaleron/6d31cfe2a7188b6bcea5ca67346254a1 | |
import pybits | |
import sys |
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 NewBinds(object): | |
"""Copy a dictionary, while retaining only updates. | |
The intended purpose of this class is to simplify the code | |
creating attribute dictionaries for class factories, but it | |
would also work anywhere else a lot of bindings which include | |
function definitions are bundled into a dictionary. | |
Example usage: the locals dictionary is passed at instantiation, | |
additional bindings are made, and then the instance is called with |
OlderNewer