Skip to content

Instantly share code, notes, and snippets.

@Pringley
Pringley / xkcdalt
Created February 23, 2011 16:45
Four-letter combinations whose sum is 42 (where a=1, b=2, ..., z=26)
(1) 42=12+11+10+9 (lkji)
(2) 42=13+11+10+8 (mkjh)
(3) 42=13+12+9+8 (mlih)
(4) 42=13+12+10+7 (mljg)
(5) 42=13+12+11+6 (mlkf)
(6) 42=14+11+9+8 (nkih)
(7) 42=14+11+10+7 (nkjg)
(8) 42=14+12+9+7 (nlig)
(9) 42=14+12+10+6 (nljf)
(10) 42=14+12+11+5 (nlke)
@Pringley
Pringley / redditapp.py
Created November 29, 2012 21:28
Reddit Maitred Applicance
import reddit
# Connect to Reddit API.
r = reddit.Reddit(user_agent='maitred-reddit')
while True:
# Get request from user.
words = raw_input().split()
subreddit = words[1]
amount = int(words[2]) if len(words) >= 3 else 5
@Pringley
Pringley / sample.cfg
Created December 7, 2012 02:07
Sample maitred configuration
{
'ears': [
{
'id': 'irc',
'class': 'IrcEar',
'module': 'maitred.prototype.ircear',
'settings': {
'host': 'irc.freenode.net',
'port': 6667,
'nick': 'maitredtest',
@Pringley
Pringley / pingpong.sh
Created December 7, 2012 02:10
Sample maitred pingpong app
#!/bin/bash
while true
do
read
echo "pong"
done
@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)
#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 / 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
@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 / 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:
#!/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: