Skip to content

Instantly share code, notes, and snippets.

@glasserc
glasserc / benchmarks.py
Created Oct 15, 2019
Benchmarking fastecdsa vs. cryptography
View benchmarks.py
import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec as cryptography_ec
from cryptography.hazmat.primitives.asymmetric.utils import encode_dss_signature
from cryptography.hazmat.primitives.hashes import SHA384
from cryptography.hazmat.primitives.serialization import load_pem_public_key
import ecdsa.util
import ecdsa.curves
import fastecdsa.ecdsa
from fastecdsa.encoding.der import DEREncoder
@glasserc
glasserc / action.js
Created Jan 18, 2019
Flow types at module boundary
View action.js
/* @flow */
export type ActionType = "hello";
export function action(): ActionType {
return "hello";
}
@glasserc
glasserc / hotfix.diff
Created Dec 5, 2017
diff between existing and plausable hotfix
View hotfix.diff
diff --git a/kinto/core/storage/postgresql/migrations/migration_019_hotfix.sql b/kinto/core/storage/postgresql/migrations/migration_019_hotfix.sql
index 1795b55a..bab9234d 100644
--- a/kinto/core/storage/postgresql/migrations/migration_019_hotfix.sql
+++ b/kinto/core/storage/postgresql/migrations/migration_019_hotfix.sql
@@ -5,29 +5,36 @@ RETURNS trigger AS $$
DECLARE
previous TIMESTAMP;
current TIMESTAMP;
+ is_bucket BOOLEAN;
BEGIN
@glasserc
glasserc / .babelrc
Last active Oct 16, 2020
Trying to figure out transform-builtin-extend, transform-runtime, etc.
View .babelrc
{
"env": {
"development": {
"plugins": [
["transform-builtin-extend", {
"globals": ["Error"]
}],
"transform-runtime",
"transform-es2015-classes",
"transform-es2015-modules-commonjs"
@glasserc
glasserc / Types.hs
Created Dec 9, 2015
running formatters on some code
View Types.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module SumAll.Eureka.Types (
EitherStyleListeners(..),
) where
import Canteven.Listen.HTTP (ListenerConfig,
ListenHTTPConfig(ListenHTTPConfig), otherthing, moyonthetnh)
import qualified Canteven.Listen.HTTP as CLH (ListenHTTPConfig(listeners))
@glasserc
glasserc / Main.hs
Created Nov 18, 2015
mongo-bug: ConnectionFailure <socket: 3>: hPutBuf: illegal operation (handle is closed)
View Main.hs
{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
import Database.MongoDB
import Control.Exception
import Control.Monad.Trans (liftIO)
main = do
pipe <- connect (host "127.0.0.1")
e1 <- access pipe master "baseball" badQuery `catch` recover
e2 <- access pipe master "baseball" goodQuery
close pipe
@glasserc
glasserc / many-tls.hs
Last active Nov 1, 2015
many-tls: TlsExceptionHostPort (HandshakeFailed (Error_Packet_unexpected "Alert [(AlertLevel_Fatal,BadRecordMac)]" " expected: change cipher"))
View many-tls.hs
import Control.Concurrent
import Control.Concurrent.STM
import Control.Monad
import Network.HTTP.Client
import Network.HTTP.Client.TLS
numThreads = 250
main = do
manager <- newManager tlsManagerSettings {managerConnCount=1000}
@glasserc
glasserc / overload-kinesis-local.gc
Created Jan 11, 2015
trying to match runtime characteristics
View overload-kinesis-local.gc
370,542,843,752 bytes allocated in the heap
148,840,615,752 bytes copied during GC
846,536,984 bytes maximum residency (2404 sample(s))
109,145,520 bytes maximum slop
2159 MB total memory in use (1109 MB lost due to fragmentation)
Tot time (elapsed) Avg pause Max pause
Gen 0 502428 colls, 0 par 72.80s 73.09s 0.0001s 0.0261s
Gen 1 2404 colls, 0 par 281.63s 282.21s 0.1174s 0.1935s
@glasserc
glasserc / gist:ab2427c1e1c201ebee30
Created Jan 11, 2015
trying to match TLS ciphers
View gist:ab2427c1e1c201ebee30
ethan@thunder:~/Jobs/SumAll/haskell-twitter-worker:upgrade-aes$ openssl s_client -msg -connect kinesis.us-east-1.amazonaws.com:443
CONNECTED(00000003)
>>> TLS 1.2 Handshake [length 012c], ClientHello
01 00 01 28 03 03 e7 19 0d 06 97 c4 cb bb 7e f0
d7 ed c8 ed 59 ea 28 db f9 4a 4e bd 35 7d 0b 62
fc b7 d1 a9 b7 bc 00 00 92 c0 30 c0 2c c0 28 c0
24 c0 14 c0 0a 00 a3 00 9f 00 6b 00 6a 00 39 00
38 00 88 00 87 c0 32 c0 2e c0 2a c0 26 c0 0f c0
05 00 9d 00 3d 00 35 00 84 c0 12 c0 08 00 16 00
13 c0 0d c0 03 00 0a c0 2f c0 2b c0 27 c0 23 c0
View gist:f885789186d7d68fbf65
public String generateKey(String id) {
// this should be unique: userId + currentTime + 5 digit random number
return Base62Converter.encodeString(id + "-" +
String.valueOf(System.currentTimeMillis()) + "-" +
RandomStringUtils.randomAlphanumeric(5));
}