Skip to content

Instantly share code, notes, and snippets.


Tristan Seligmann mithrandi

View GitHub Profile
View gist:6c03ece47ba2dfd2ec339634855f1ab2
cryptography-rust v0.1.0 (/home/mithrandi/code/cryptography/src/rust)
├── asn1 v0.6.4
│ ├── asn1_derive v0.6.4
│ │ ├── proc-macro2 v1.0.29 (in debian)
│ │ ├── quote v1.0.10 (in debian)
│ │ └── syn v1.0.80 (in debian)
│ └── chrono v0.4.19 (in debian)
├── chrono v0.4.19 (in debian)
├── lazy_static v1.4.0 (in debian)
├── ouroboros v0.12.0
View Polling.hs
import Control.Concurrent
import Control.Concurrent.STM
import Control.Exception.Safe
import Data.Time.Units
pollT :: TimeUnit t => t -> IO a -> IO (STM (Maybe a), Async b)
pollT delay act = do
tv <- newTVarIO Nothing
as <-
async . forever $ do
def maybe(f, v, default=None):
Return C{f(v)} if C{v} is not C{None}, otherwise return C{default}.
if v is None:
return default
return f(v)
mithrandi /
Created Jul 12, 2016
Script to merge hg shamaps
import sys
revmap2 = {}
with open(sys.argv[2]) as fMap2:
for line in fMap2:
a, b = line.rstrip('\n').split(' ')
revmap2[a] = b
with open(sys.argv[1]) as fMap1:
for line in fMap1:
a, b = line.rstrip('\n').split(' ')
mithrandi /
Last active Apr 17, 2016
twisted.web.template / optimization stuff
import time
from StringIO import StringIO
from nevow import tags
from nevow.context import WovenContext
from nevow.flat.twist import deferflatten
from nevow.loaders import stan, xmlstr
from import Element, renderer
mithrandi /
Created Mar 30, 2016
Cryptography X509 builder benchmark
from __future__ import print_function
import time
from datetime import datetime, timedelta
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.x509.oid import NameOID
View test.rst

First Level

Some text.

Second Level

Some text.

mithrandi /
Created Feb 20, 2016
Legacy declaration generator
#!/usr/bin/env python
from twisted.python.reflect import namedAny
template = """
mithrandi / init.el
Created Feb 9, 2016
Twistedchecker for flycheck (Emacs)
View init.el
;; Define the checker
(flycheck-define-checker python-twistedchecker
"A Python syntax and style checker using twistedchecker."
:command ("twistedchecker"
;; Need `source-inplace' for relative imports (e.g. `from .foo
;; import bar'), see
(lambda (errors)
(flycheck-sanitize-errors (flycheck-increment-error-columns errors)))
View gist:2b0fa115203001edd1b4
==2124==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4676669 at pc 0x085c7b84 bp 0xffbfa928 sp 0xffbfa920
WRITE of size 4 at 0xf4676669 thread T0
#0 0x85c7b83 in cell_dealloc /tmp/Python-3.5.1/Objects/cellobject.c:49
#1 0x85e971d in frame_dealloc /tmp/Python-3.5.1/Objects/frameobject.c:433
#2 0x83b8341 in _PyEval_EvalCodeWithName /tmp/Python-3.5.1/Python/ceval.c:3977
#3 0x838d60d in PyEval_EvalCodeEx /tmp/Python-3.5.1/Python/ceval.c:3987
#4 0x85f19f6 in function_call /tmp/Python-3.5.1/Objects/funcobject.c:632
#5 0x819c887 in PyObject_Call /tmp/Python-3.5.1/Objects/abstract.c:2165
#6 0x839d917 in ext_do_call /tmp/Python-3.5.1/Python/ceval.c:4983
#7 0x83b842a in _PyEval_EvalCodeWithName /tmp/Python-3.5.1/Python/ceval.c:3966