Skip to content

Instantly share code, notes, and snippets.

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));
}
@glasserc
glasserc / gist:ab2427c1e1c201ebee30
Created January 11, 2015 02:27
trying to match TLS ciphers
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
@glasserc
glasserc / overload-kinesis-local.gc
Created January 11, 2015 20:00
trying to match runtime characteristics
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 / annex-breakage.py
Created September 14, 2012 02:15
Quick hack to fix my git-annex repo
#! /usr/bin/python
# Quick hack to find and rearrange files from a broken git-annex.
#
# One of my drives with a git annex suffered major filesystem
# corruption, and pretty much all the files got dumped into
# lost+found. Fortunately git-annex symlinks contain all the
# information you need to find your files and see if they're still OK
# -- to wit, the filesize and a SHA.
import os
@glasserc
glasserc / many-tls.hs
Last active November 1, 2015 18:37
many-tls: TlsExceptionHostPort (HandshakeFailed (Error_Packet_unexpected "Alert [(AlertLevel_Fatal,BadRecordMac)]" " expected: change cipher"))
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 / Types.hs
Created December 9, 2015 19:51
running formatters on some code
{-# 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 / funding.org
Last active December 20, 2015 08:19
Tracking the Ubuntu Edge campaign

All times are in NYC time.

TimeAmountNew hrsNew $Est $/hrHrs leftEst total
<2013-07-25 Thu 13:00>5936196nannannan658.99999nan
<2013-07-25 Thu 16:10>60695933.16665613339742125.510655.8333433696907.
<2013-07-25 Thu 17:16>61126291.0999924303639123.921654.7333431728364.
<2013-07-25 Thu 19:52>61910352.6000167840630155.968652.1333325856747.
<2013-07-25 Thu 20:43>62092450.8499841821021423.933651.2833420162296.
<2013-07-25 Thu 23:03>62452072.3333523596215412.162648.9499916246929.
@glasserc
glasserc / Main.hs
Created November 18, 2015 21:16
mongo-bug: ConnectionFailure <socket: 3>: hPutBuf: illegal operation (handle is closed)
{-# 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 / hotfix.diff
Created December 5, 2017 21:23
diff between existing and plausable hotfix
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 / action.js
Created January 18, 2019 18:03
Flow types at module boundary
/* @flow */
export type ActionType = "hello";
export function action(): ActionType {
return "hello";
}