Skip to content

Instantly share code, notes, and snippets.

View mithrandi's full-sized avatar

Tristan Seligmann mithrandi

View GitHub Profile
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBE2dGz0BEADFA7N0n5DWXBa087KhL/IKMeRKetMmUFCMO/RADJTRUELNgHFY
uS12fqaq/FkdK6RND1EecLw1Rt/k/d2cnpEAUgsP2azYfbQaErt2f9dHGd4Mm1zp
S6W7+VyAph0FCiZyjEa1qk4wirocrdtP1fa8eUv5b5NCCUXeE1iIXe8Kln7YgvSn
SpJ09QJKXy17P84kBfybUegD3bztA/9apQuRaKL5AYfT10RzDPG5Pc5R90xX2Iml
Z682QrG64xq/pAGLs9gRrrLsY6ji0UFrlPFbYdxxN+oTA4/bytdClCUwPzic0LwV
RnSUlSeOfDqX9kb5Qmhzd1oBQ9g36cWMHErOOA5p7/0QAoTp1big8hR7mWVyxO+E
tD4m+CW9um67PJxgOKjfNPONVZX1OqCOogfqHitehz6k9STiLxn/xzZWiE1kKAId
p2xHrWp3vKcfl0Ja667GCwaf59ZW6Jya75iqV/w5ZHuI0mW457BNE4FTd+Y/1BJ8
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
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
@mithrandi
mithrandi / maybe.py
Created September 13, 2017 15:05
maybe
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
mithrandi / mergemaps.py
Created July 12, 2016 05:25
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
mithrandi / bench_nevow.py
Last active April 17, 2016 11:58
twisted.web.template / nevow.page 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 nevow.page import Element, renderer
try:
@mithrandi
mithrandi / bench_builder.py
Created March 30, 2016 15:34
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

First Level

Some text.

Second Level

Some text.

@mithrandi
mithrandi / legacydecl.py
Created February 20, 2016 17:28
Legacy declaration generator
#!/usr/bin/env python
from twisted.python.reflect import namedAny
template = """
declareLegacyItem(
typeName=%r,
schemaVersion=%d,
attributes=dict(
%s))
"""
@mithrandi
mithrandi / init.el
Created February 9, 2016 07:10
Twistedchecker for flycheck (Emacs)
;; 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 https://github.com/flycheck/flycheck/issues/280
source-inplace)
:error-filter
(lambda (errors)
(flycheck-sanitize-errors (flycheck-increment-error-columns errors)))