Skip to content

Instantly share code, notes, and snippets.

@oconnor663
oconnor663 / asyncio_contextlib_deadlock.py
Last active December 2, 2015 21:08
asyncio + contextlib deadlock (Python 3.5, but not 3.4)
#! /usr/bin/env python3
# This script reproduces a deadlock that shows up when we mix asyncio,
# generator-context-managers, and an ExitStack. I'm not sure why it happens.
# When the script hangs, it consumes 100% CPU and blocks ctrl-c. To kill it,
# use ctrl-z and then `kill %`.
import asyncio
import contextlib
@oconnor663
oconnor663 / alphabet.py
Last active July 19, 2016 21:43
the alphabet of all Twitter-safe characters
#! /usr/bin/env python3
import sys
import unicodedata
import urllib.request
# We want to use every possible code point we can. That means starting at 0 and
# going all the way up to 0x10ffff, the largest encodable value. Because
# Twitter does NFC Unicode normalization, we need to omit characters that don't
# have NFC_Quick_Check=Yes property. We also need to omit characters that
@oconnor663
oconnor663 / peru_1.0.md
Last active January 25, 2016 04:15
Peru 1.0

Getting peru to 1.0

The peru project has been stable for almost a year now, and it's time we made it official. One Point Oh. Here are some of the highlights from along the way.

Dropping the build field

One of the first features we added to peru was the build field.

@oconnor663
oconnor663 / gist:ea89a98244268e714760
Created March 2, 2016 18:37
example keybase.spec
Name: keybase
Version: 1.0.14.20160302153043.c4729c2
Release: 1
Summary: Keybase command line client
License: BSD
AutoReqProv: no
%description
Keybase command line client
@oconnor663
oconnor663 / pythonic.rs
Last active June 4, 2016 23:40
Pythonic Rust
use std::rc::Rc;
use std::cell::RefCell;
use std::iter::Iterator;
struct PythonicIterator<T> {
list: Rc<RefCell<Vec<Rc<T>>>>,
index: usize,
}
fn pythonic_iter<T>(list: &Rc<RefCell<Vec<Rc<T>>>>) -> PythonicIterator<T> {
@oconnor663
oconnor663 / tango.txt
Last active April 21, 2017 18:10
Japanese vocab
脂肪 しぼう fat
全員 ぜんいん all members
足りない たりない isn't enough
窓側 まどがわ window-side (seat)
通路側 つうろがわ aisle-side (seat)
確認 かくにん confirm
急ぎ いそぎ hurry, emergency
広告 こうこく advertisement
各種 かくしゅ all kinds
実施 じっし enforcement, implementation
INFO:rustc_metadata::loader: lib candidate: C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libstd-e8edd0fd.rlib
INFO:rustc_metadata::loader: lib candidate: C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\std-e8edd0fd.dll
INFO:rustc_metadata::loader: rlib reading metadata from: \\?\C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libstd-e8edd0fd.rlib
INFO:rustc_metadata::loader: reading "libstd-e8edd0fd.rlib" => Duration { secs: 0, nanos: 208127 }
INFO:rustc_metadata::loader: lib candidate: C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libcore-e8edd0fd.rlib
INFO:rustc_metadata::loader: rlib reading metadata from: \\?\C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libcore-e8edd0fd.rlib
INFO:rustc_metadata::loader: reading "libcore-e8edd0fd.rlib" =>
INFO:rustc_metadata::loader: lib candidate: C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libstd-e8edd0fd.rlib
INFO:rustc_metadata::loader: lib candidate: C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\std-e8edd0fd.dll
INFO:rustc_metadata::loader: rlib reading metadata from: \\?\C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libstd-e8edd0fd.rlib
INFO:rustc_metadata::loader: reading "libstd-e8edd0fd.rlib" => Duration { secs: 0, nanos: 248076 }
INFO:rustc_metadata::loader: lib candidate: C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libcore-e8edd0fd.rlib
INFO:rustc_metadata::loader: rlib reading metadata from: \\?\C:\Users\IEUser\.multirust\toolchains\stable-i686-pc-windows-gnu\lib\rustlib\i686-pc-windows-gnu\lib\libcore-e8edd0fd.rlib
INFO:rustc_metadata::loader: reading "libcore-e8edd0fd.rlib" =>
Verifying that "oconnor663.id" is my Blockstack ID. https://onename.com/oconnor663
// This is a construction for encrypting and signing a message, using a
// symmetric encryption key and a signing keypair, in a way that supports safe
// streaming decryption. We need this for chat attachments because we've chosen
// to use signing keys for authenticity in chat, and we don't want one
// participant to be able to modify another's attachment, even with an evil
// server's help. It's *almost* enough that we record the hash of the
// attachment along with the symmetric key used to encrypt it, but that by
// itself doesn't allow safe streaming decryption. Instead, we use this
// construction to sign each chunk of the attachment as we encrypt it. (Note
// that it's still possible for a sender with the server's help to modify their