Skip to content

Instantly share code, notes, and snippets.

ppelleti / leak.rb
Last active Aug 29, 2015
demonstrate leak in LIFX gem
View leak.rb
gem 'lifx'
require 'lifx'
start_time =
prev_objs = ObjectSpace.count_objects
lifx = LIFX::Client.lan!
ppelleti / rand-trouble.c
Created Aug 21, 2013
This is a simple program which demonstrates that OpenSSL's default random number generator is not fork-safe if the pids wrap.
View rand-trouble.c
/* Patrick Pelletier, public domain / cc0
* OpenSSL's default random number generator (RAND_SSLeay) is not
* fork-safe in the case where the child pids wrap around without the
* parent having used or reseeded the RNG in the interim. Which makes
* this a rare problem, but one which recently cropped up on Android:
* and Nikolay Elenkov wrote a program to demonstrate the bug on Android:
ppelleti /
Created Aug 19, 2013
A simple program which will detect the maximum Diffie-Hellman size supported by the JRE.
public class Diffie {
public static void main (String[] args) throws Exception {
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator . getInstance ("DiffieHellman");
int good = 0;
for (int i = 512 ; i <= 16384 ; i += 64) {
try {
apg . init (i);
ppelleti / strings returned by FormatMessage
Created Feb 8, 2013
A comparison of the error strings returned by evutil_socket_error_to_string, versus the error strings returned by the Windows function FormatMessage.
View strings returned by FormatMessage
WSAEINTR -> "A blocking operation was interrupted by a call to WSACancelBlockingCall."
WSAEACCES -> "An attempt was made to access a socket in a way forbidden by its access permissions."
WSAEFAULT -> "The system detected an invalid pointer address in attempting to use a pointer argument in a call."
WSAEINVAL -> "An invalid argument was supplied."
WSAEMFILE -> "Too many open sockets."
WSAEWOULDBLOCK -> "A non-blocking socket operation could not be completed immediately."
WSAEINPROGRESS -> "A blocking operation is currently executing."
WSAEALREADY -> "An operation was attempted on a non-blocking socket that already had an operation in progress."
WSAENOTSOCK -> "An operation was attempted on something that is not a socket."
WSAEDESTADDRREQ -> "A required address was omitted from an operation on a socket."
ppelleti /
Created Aug 12, 2012
list of hokey hash functions in rustc
/* list of hokey hash functions in rustc as of August 12, 2012
* in response to */
// libsyntax/
pure fn hash_ty(t: &@ty) -> uint {
let res = (t.span.lo << 16u) + t.span.hi;
return res;
ppelleti /
Created Apr 22, 2012
Generate Noekeon test vectors using BouncyCastle
/* - Generate Noekeon test vectors using BouncyCastle.
Written in 2011 by Patrick Pelletier <>
To the extent possible under law, the author(s) have dedicated all
copyright and related and neighboring rights to this software to
the public domain worldwide. This software is distributed without
any warranty.