Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am pringley on github.
  • I am pringle (https://keybase.io/pringle) on keybase.
  • I have a public key ASCNyhQcf8iNgwvmQv-3tE9FQX4cbH4JqJGQRWOPMBohugo

To claim this, I am signing this object:

from itertools import permutations
colors = ["Red", "Green", "Ivory", "Yellow", "Blue"]
nations = ["England", "Spain", "Ukraine", "Norway", "Japan"]
drinks = ["Coffee", "Tea", "Milk", "Orange Juice", "Water"]
pets = ["Dog", "Snail", "Fox", "Horse", "Zebra"]
smokes = ["Old Gold", "Kool", "Chesterfield", "Lucky Strike", "Parliament"]
middle = lambda xs, x: xs[2] == x
first = lambda xs, x: xs[0] == x
import Data.List (permutations, zip5)
2
3 main = do
4 putStrLn $ head [n | (n, _, _, "Water", _) <- answer] ++ " drinks Water"
5 putStrLn $ head [n | (n, _, "Zebra", _, _) <- answer] ++ " has the Zebra"
6 putStrLn "\nFull answer:"; mapM_ print answer
7
8 where
9 colors = ["Red", "Green", "Ivory", "Yellow", "Blue"]
10 nations = ["England", "Spain", "Ukraine", "Norway", "Japan"]
@Pringley
Pringley / breakdeterministicpaillier.py
Created May 6, 2014 06:22
Proof-of-concept showing that Paillier with a non-random (and public) noise value is insecure.
import collections
import gmpy
from Crypto.Util.number import getPrime
PublicKey = collections.namedtuple('PublicKey', ('modulus', 'generator'))
Key = collections.namedtuple('_Key', ('modulus', 'generator', 'lambda_', 'mu'))
Key.public = lambda self: PublicKey(self.modulus, self.generator)
# Generated by atmospheric noise
#!/usr/bin/env python
"""Pandoc filter to add include syntax.
Usage::
pandoc --filter ./pandoc-includes.py
The Markdown syntax to include documents is as follows:
@Pringley
Pringley / proxy.py
Last active December 30, 2015 15:59
Python rewrite of the proxy from https://github.com/Pringley/secure-atm for easier packet manipulation.
#!/usr/bin/env python3
#
# Copyright (c) 2013 Ben Pringle
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@Pringley
Pringley / grisbr.markdown
Created October 27, 2013 13:29
Proof-of-concept bridge between Ruby and Python to perform matrix multiplication.

Grisbr: proof of concept

Code for this project is available at Pringley/grisbr-concept.

This is a proof-of-concept bridge between Ruby and Python to perform matrix multiplication.

Motivation: The power of a scripting language lies partially in its community-developed libraries. Different languages have different strengths -- for example, Python has excellent numeric and scientific packages that Ruby

@Pringley
Pringley / todo.vim
Last active December 19, 2015 15:59
todo list highlighting
" Vim syntax file
" Language: Todo file
" Maintainer: Ben Pringle
" Latest Revision: 11 July 2013
if exists("b:current_syntax")
finish
endif
" Define line types
#include <iostream>
#include <algorithm>
#include <vector>
/*
* permute() - print all permutations of each bin
*/
void permute(std::vector<std::vector<int> > bins);
// Helper funtions
@Pringley
Pringley / Makefile
Last active December 13, 2015 23:29
Generic C++ makefile
EXECUTABLE=main
CC=g++
CXXFLAGS=-Wall
SOURCES=$(wildcard *.cpp)
OBJECTS=$(SOURCES:.cpp=.o)
.PHONY: all test clean
all: $(EXECUTABLE)