Skip to content

Instantly share code, notes, and snippets.

View public's full-sized avatar
🏠
Working from home

Alex Stapleton public

🏠
Working from home
View GitHub Profile
async function awaitReturn() {
return await Promise.resolve('awaited this promise').then((x) => {
throw new Error(x);
});
}
async function noAwaitReturn() {
return Promise.resolve('did not await this promise').then((x) => {
throw new Error(x);
});
@public
public / early.py
Last active June 6, 2021 16:07
early binding in Python
from types import FunctionType, CellType
from typing import Any, Callable, TypeVar, Union
F = TypeVar("F", bound=Union[FunctionType, Callable[..., Any]])
def bind(wrapped: F) -> F:
new_globals = wrapped.__globals__.copy()
from __future__ import absolute_import
from django.conf import settings
from django.template import Library, engines
from django.template.base import Node, TemplateSyntaxError, token_kwargs
import six
register = Library()
(CRYPT3)alexs@alexs-thinkpad:~/code/cryptography$ pip install typing
You are using pip version 6.0.3, however version 7.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting typing
Downloading typing-0.0.tar.gz
file t.py (for module t) not found
file y.py (for module y) not found
file p.py (for module p) not found
file i.py (for module i) not found
file n.py (for module n) not found
>>> b64encode(b'\xbe'.encode('utf-8'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbe in position 0: ordinal not in range(128)
class PrefetchBatches(batches.Batches):
def Strategy(self, task, app, consumer):
handler = super(PrefetchBatches, self).Strategy(task, app, consumer)
def task_handler(*args, **kwargs):
if consumer.qos.value < self.flush_every:
diff = self.flush_every - consumer.qos.value
consumer.qos.increment_eventually(diff)
return handler(*args, **kwargs)
import pytest
def pytest_generate_tests(metafunc):
if "fixA" in metafunc.fixturenames:
metafunc.parametrize("fixA", [])
def test_fixA(fixA):
print fixA
@public
public / gist:9597507
Last active August 29, 2015 13:57
Why opportunistic encryption is useless

Cisco estimate that in 2017 the internet will be doing about 1.4 zettabytes/year. This is around 355 Tb/s. Obviously it'll be spiky though, so let's round that up to 1000 Tb/s.

A Nvidia GTX 295 can decrypt AES-128 at about 50 Gb/s and originally retailed for about $500 giving you about 100 Mb/s per 2009 $1. It has a TDP of about 300W, lets call it 500W for a full system. You have the rest of the computer to purchase too so let's call it 50 Mb/s per $1 after assembly of a $1000 node.

1,000 Tbps / 50 Mbps = 20,000 GTX 295 in $1000 computers.

20,000 * $1000 = $20,000,000 USD

20,000 * 500 W = 10 MW 10 MW * 0.17 USD / KW/h = ~$15,000,00 USD/year

Keybase proof

I hereby claim:

  • I am public on github.
  • I am public (https://keybase.io/public) on keybase.
  • I have a public key whose fingerprint is E9D0 B58A 03D6 2827 94FD AEE0 289C 606A 39BE B6A8

To claim this, I am signing this object:

import sys
import time
import hotshot
import hotshot.stats
import ipdb
import openpyxl
def get_process_rss():
procstat = open("/proc/self/status").readlines()