Skip to content

Instantly share code, notes, and snippets.

@glasserc
glasserc / monitor.vala
Created September 14, 2011 09:40
why Vala is not my favorite programming language
// monitor.vala: why Vala is not my favorite programming language.
//
// A program to walk the filesystem tree and install FileMonitors on
// every directory found, in order to test a limit on notifications.
// This will do a TON of I/O. On my machine it takes almost an hour
// to chew through my hard drive. The good news is that it doesn't
// hit a limit.
//
// FileMonitor is implemented I think using inotify, so if you're
// running Linux, the easier way to discover these limits is:
@glasserc
glasserc / redate-photos.py
Created September 14, 2011 09:52
Program to adjust dates on EXIF tags for a bunch of JPEG files using python-exif and exiftool
#! /usr/bin/python
"""Program to fix my screwed up camera date/time settings.
At some point, some children adjusted the date on my camera as well as
the locale settings. Photos were henceforth marked as being one day
earlier than they should have been (i.e. the 28th instead of the 29th).
Later, I noticed that the camera date was wrong, but because the
equivalent of LC_DATE was different, I thought it was one MONTH early
instead of one DAY. I "fixed" it by putting the date on the camera
@glasserc
glasserc / .babelrc
Last active October 16, 2020 15:51
Trying to figure out transform-builtin-extend, transform-runtime, etc.
{
"env": {
"development": {
"plugins": [
["transform-builtin-extend", {
"globals": ["Error"]
}],
"transform-runtime",
"transform-es2015-classes",
"transform-es2015-modules-commonjs"
@glasserc
glasserc / benchmarks.py
Created October 15, 2019 17:53
Benchmarking fastecdsa vs. cryptography
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 January 18, 2019 18:03
Flow types at module boundary
/* @flow */
export type ActionType = "hello";
export function action(): ActionType {
return "hello";
}
@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 / 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 / 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 / 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 / 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}