Skip to content

Instantly share code, notes, and snippets.

@csm
csm / snippet.diff
Last active November 26, 2022 20:46
Apple's SSL bug; diff between last known-good (OS X 10.8.5) and known-bad (OS X 10.9)
@@ -596,8 +597,8 @@
dataToSignLen = SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN;
hashOut.data = hashes;
hashOut.length = SSL_MD5_DIGEST_LEN;
-
- if ((err = ReadyHash(&SSLHashMD5, &hashCtx, ctx)) != 0)
+
+ if ((err = ReadyHash(&SSLHashMD5, &hashCtx)) != 0)
goto fail;
if ((err = SSLHashMD5.update(&hashCtx, &clientRandom)) != 0)
@csm
csm / README
Created January 24, 2021 23:30
Start a in-memory S3-compatible (kinda...) server.
Uses https://github.com/csm/s4
(defn distinct-by
"Like distinct, but uses f to consider what duplicate values are."
([f]
(fn [rf]
(let [seen (volatile! #{})]
(fn
([] (rf))
([result] (rf result))
([result input]
(let [v (f input)]
@csm
csm / recyclable.clj
Last active September 14, 2017 19:29
(import '[io.netty.util Recycler])
(defprotocol Recyclable
(recycle! [this] "Recycles this object."))
(defprotocol Init
(init! [this values]))
(defmacro defrecyclable
[name fields & {:keys [max-capacity] :or {max-capacity 8096}}]
(defn js-engine
[]
(if-let [engine (.getEngineByName (ScriptEngineManager.) "JavaScript")]
engine
(throw (Exception. "no JavaScript engine found. Sorry"))))
(defn run-slides-js
[s]
(let [engine (js-engine)
script (str "(function() {\n"
@csm
csm / lintest.py
Created October 4, 2012 22:53
Linear hashing example
import collections
import random
i = 0
n = 0
d = [collections.OrderedDict()]
def lin(k):
global i
@csm
csm / gist:2483382
Created April 24, 2012 20:22
CouchDB invocation error
Command line invocation:
/Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/bin/erl +Bd -noinput -os_mon start_memsup false start_cpu_sup false disk_space_check_interval 1 disk_almost_full_threshold 1 -sasl errlog_type error +K true +A 4 -env ERL_LIBS /Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/lib/couchdb/erlang/lib -couch_ini /Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/etc/couchdb/default.ini /Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/etc/couchdb/local.ini /Users/csm/Library/Application Support/Memeo\ C1/local.ini -s couch
Output:
{"init terminati
@csm
csm / xkcd.py
Created August 10, 2011 22:57
Random passphrase generator.
# RE: http://xkcd.com/936/
import random
n = 4
f = open('/usr/share/dict/words', 'r')
w = f.readlines()
print " ".join(map(lambda x : x.strip(), random.sample(w, n)))
@csm
csm / lion-airdrop.txt
Created July 25, 2011 04:43
Lion ifconfig -- airdrop on
p2p7: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX
inet6 fe80::1855:caff:fef2:5bc7%p2p7 prefixlen 64 scopeid 0x8
media: autoselect
status: active
@csm
csm / lion-ifconfig.txt
Created July 25, 2011 04:28
Lion ifconfig -- new interface
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether XX:XX:XX:XX:XX:XX
media: autoselect
status: inactive