Skip to content

Instantly share code, notes, and snippets.

@ppelleti
ppelleti / NoekeonVects.java
Created April 22, 2012 05:48
Generate Noekeon test vectors using BouncyCastle
/*
NoekeonVects.java - Generate Noekeon test vectors using BouncyCastle.
Written in 2011 by Patrick Pelletier <code@funwithsoftware.org>
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.
@ppelleti
ppelleti / hokey-hash.rs
Created August 12, 2012 10:00
list of hokey hash functions in rustc
/* list of hokey hash functions in rustc as of August 12, 2012
* in response to https://github.com/mozilla/rust/issues/3041 */
// libsyntax/ast_util.rs:
pure fn hash_ty(t: &@ty) -> uint {
let res = (t.span.lo << 16u) + t.span.hi;
return res;
}
@ppelleti
ppelleti / strings returned by FormatMessage
Created February 8, 2013 01:30
A comparison of the error strings returned by evutil_socket_error_to_string, versus the error strings returned by the Windows function 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
ppelleti / Diffie.java
Created August 19, 2013 23:35
A simple program which will detect the maximum Diffie-Hellman size supported by the JRE.
import java.security.AlgorithmParameterGenerator;
import java.security.InvalidParameterException;
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
ppelleti / rand-trouble.c
Created August 21, 2013 06:33
This is a simple program which demonstrates that OpenSSL's default random number generator is not fork-safe if the pids wrap.
/* 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:
* https://plus.google.com/+AndroidDevelopers/posts/YxWzeNQMJS2
* and Nikolay Elenkov wrote a program to demonstrate the bug on Android:
* https://gist.github.com/nelenkov/581f9be65dcc0b6b35b9
*
@ppelleti
ppelleti / leak.rb
Last active August 29, 2015 14:09
demonstrate leak in LIFX gem
#!/usr/bin/ruby
gem 'lifx'
require 'lifx'
start_time = Time.now.to_i
prev_objs = ObjectSpace.count_objects
lifx = LIFX::Client.lan
lifx.discover!
@ppelleti
ppelleti / berp-test-failures.txt
Created May 13, 2015 00:22
test suite failures for my ghc783 branch of berp
:../test/regression/features/arithmetic/mult.test: [OK]
:../test/regression/features/arithmetic/mult_float_precision.test: [OK]
:../test/regression/features/arithmetic/plus.test: [OK]
:../test/regression/features/arithmetic/type_conversion.test: [OK]
:../test/regression/features/assignment/assign_multi.test: [OK]
:../test/regression/features/assignment/assign_subscript.test: [OK]
:../test/regression/features/assignment/assign_unpack.test: [Failed]
Expected stdout:
0
@ppelleti
ppelleti / simultaneous-ping.txt
Created August 31, 2015 07:52
ICMP ping and EchoRequest together on my Original 1000 LIFX bulb with 2.1 firmware
WhiteAndNerdy% ping 192.168.10.15 & ; cabal run -- ping -i 0225cd
[1] 39944
PING 192.168.10.15 (192.168.10.15): 56 data bytes
64 bytes from 192.168.10.15: icmp_seq=0 ttl=128 time=51.869 ms
Preprocessing executable 'lifx' for lifx-0.1.0.0...
64 bytes from 192.168.10.15: icmp_seq=1 ttl=128 time=85.007 ms
Running lifx...
64 bytes from 192.168.10.15: icmp_seq=2 ttl=128 time=14.840 ms
64 bytes from 192.168.10.15: icmp_seq=3 ttl=128 time=19.594 ms
64 bytes from 192.168.10.15: icmp_seq=4 ttl=128 time=9.691 ms
@ppelleti
ppelleti / simultaneous-ping-gc.txt
Created August 31, 2015 08:05
using RTS option "-S" to see if Haskell gc is causing hiccups
WhiteAndNerdy% ping 192.168.10.15 & ; dist/build/lifx/lifx ping -i 0225cd +RTS -S
[1] 39977
PING 192.168.10.15 (192.168.10.15): 56 data bytes
Alloc Copied Live GC GC TOT TOT Page Flts
bytes bytes bytes user elap user elap
64 bytes from 192.168.10.15: icmp_seq=0 ttl=128 time=34.718 ms
64 bytes from 192.168.10.15: icmp_seq=1 ttl=128 time=22.805 ms
64 bytes from 192.168.10.15: icmp_seq=2 ttl=128 time=13.410 ms
64 bytes from 192.168.10.15: icmp_seq=3 ttl=128 time=47.288 ms
64 bytes from 192.168.10.15: icmp_seq=4 ttl=128 time=15.934 ms
@ppelleti
ppelleti / table.json
Created September 19, 2015 05:22
LIFX product table in an easy-to-consume format
[
{
"Color": "Yes",
"Name": "Original 1000",
"Product ID": "1",
"Vendor ID": "1"
},
{
"Color": "Yes",
"Name": "Color 650",