Skip to content

Instantly share code, notes, and snippets.

View mahmoud's full-sized avatar
Back on the grid!

Mahmoud Hashemi mahmoud

Back on the grid!
View GitHub Profile
title
Zatoichi

Starting on March 26, 2017, I started watching the amazing film series, Zatoichi. ~30 films, 25 of which were released between 1962 and 1973. An astonishing rate, considering these are already some of my favorite films. I didn't start taking notes until I'd seen a few, but here are my brief notes for the majority.

monumental@17.7.1 /home/hatnote/monumental
├── angular@1.5.9
├── angular-animate@1.5.9
├── angular-aria@1.5.9
├── angular-file-upload@2.5.0
├── angular-formly@4.2.5
├─┬ angular-leaflet-directive@0.10.0
│ └── leaflet@0.7.7
├── angular-local-storage@0.5.2
├── angular-material@1.1.4
from lithoxyl import (Logger,
StreamEmitter,
SensibleSink,
SensibleFormatter)
logger = Logger('log')
fmt = ('{status_char}+{import_delta_s:.3f}'
' - {duration_s:>8.3f}s'
' - {parent_depth_indent}{event_message}')
@mahmoud
mahmoud / a.py
Created June 18, 2017 18:46
Usually circular imports are fine. Not great maybe, but ok. This pair of tiny files demonstrates how prematurely using a value is where the problem really manifests.
import b
# print(b.val)
"""
If left commented, this pair of module is perfectly fine, no exceptions are raised.
If uncommented, you'll see a stack trace like:
Traceback (most recent call last):
@mahmoud
mahmoud / trial_debug_failure.txt
Created May 7, 2017 01:05
one expects a pdb on failure, but only gets it on start. (produced by changing one character in the test_queryAdd test to simulate a failure)
$ python -m twisted.trial --debug twisted.python.test.test_url
> /home/mahmoud/projects/twisted/src/twisted/trial/runner.py(229)run()
-> try:
(Pdb) c
twisted.python.test.test_url
TestURL
test_alreadyIRIAsIRI ... [OK]
test_alreadyURIAsURI ... [OK]
test_asIRI ... [OK]
test_asURI ... [OK]
@mahmoud
mahmoud / homemake_libs.txt
Created March 24, 2017 16:46
on ubuntu 16
$ ldd ./homemake_beta_linux.x86
linux-gate.so.1 => (0xf7768000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf773c000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf771f000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf7715000)
libGL.so.1 => /usr/lib/i386-linux-gnu/mesa/libGL.so.1 (0xf76a6000)
libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xf755b000)
libXcursor.so.1 => not found
libXrandr.so.2 => not found
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf73e3000)
@mahmoud
mahmoud / scheme_port_map.json
Last active December 12, 2022 17:42
A big mapping url schemes to their protocols' default ports. See comments below for notes. Painstakingly assembled by crossreferencing https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml and https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
{
"acap": 674,
"afp": 548,
"dict": 2628,
"dns": 53,
"file": null,
"ftp": 21,
"git": 9418,
"gopher": 70,
"http": 80,
def research(root, query=lambda p, k, v: True, reraise=False):
ret = []
def enter(path, key, value):
try:
if query(path, key, value):
ret.append((path + (key,), value))
except Exception:
if reraise:
raise
@mahmoud
mahmoud / normalize_whitespace.py
Created January 18, 2017 20:02
find nonstandard (unicode) whitespace (everything but \n\t and space) and replace it with normal stuff (space by default)
import os
import re
import argparse
# match all nonstandard whitespace
# negative lookahead to simulate character class exceptions
_patt_re = re.compile(r'(?![ \t\n])(\s+)', re.UNICODE | re.MULTILINE)
class _Replacer(object):
@mahmoud
mahmoud / jsonl_splitter.py
Created January 8, 2017 00:55
for when jsonl doesn't go right
import json
def main():
inp = open('briefings.jsonl').read()
out_f = open('briefings.real.jsonl', 'wb')
start = 0
cur_token_beg = 0
end = None
while start < len(inp):