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
#!/Hello world! |
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
bind \co sudo-execute |
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
# alike https://github.com/lihaoyi/macropy#string-interpolation | |
In [23]: class Interpol: | |
def __getitem__(self, str): | |
import inspect | |
return str.format(**inspect.currentframe().f_back.f_locals) | |
....: | |
In [24]: s = Interpol() |
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 | |
censor = lambda s: re.sub('[acemnopqrsuvwxyz]', '▄', re.sub('[bdfhijkltABCDEFGHIJKLMNOPQRSTUVWXYZ]', '█', s)) | |
# censor('This is a test.') → '███▄ █▄ ▄ █▄▄█.' |
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
#ifdef TEST | |
#include <stdint.h> | |
#include <stdio.h> | |
uint8_t LCDDR0=0, | |
LCDDR1=0, | |
LCDDR2=0, | |
LCDDR3=0, |
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
# Modified cd that also displays the directory's contents if the listing is less than 5 lines long | |
function cd | |
if test -n "$argv" | |
if test -e $argv -a ! -d (realpath $argv) | |
set argv (dirname $argv) | |
end | |
end | |
builtin cd $argv | |
and test (ls -C -w $COLUMNS |wc -l) -le 5; and ls | |
end |
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
body | |
{ | |
/* font-family: Sazanami Mincho; */ | |
font-family: Source Han Sans JP; | |
font-weight: 100; | |
font-size: 16px; | |
} | |
h3 | |
{ |
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 | |
import unicodedata, textwrap | |
print('\033[38;5;250m ニホンゴ\n\033[0m日本語', end='\n\n') | |
# I could not find any terminal actually rendering this. urxvt just ignores the escapes, which is kind of sane. gnome terminal et al. print it literally, replacing the \e with a replacement character which looks garbage. | |
print('foo\033[1\\bar\033[2\\baz\033[0\\fnord', end='\n\n') | |
FW_TO_HW_MAP = { |
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 pathlib | |
import itertools | |
import lzma | |
import threading | |
import functools | |
class Blobstore: | |
def __init__(self, path, create_if_missing=False, validate=True, blobid_len=4): | |
p = self._path_obj = pathlib.Path(path) | |
self._blobid_len, self._fmt_blobid = blobid_len, lambda blobid: ('{:0'+str(self._blobid_len)+'x}').format(blobid) |
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 sqlite3 | |
import itertools | |
import lzma | |
import threading | |
import functools | |
class Stringstore: | |
def __init__(self, dbfile, max_block_size=262144): | |
self.db = sqlite3.connect(dbfile) |