Skip to content

Instantly share code, notes, and snippets.

@insipid
insipid / combine-harvester.py
Created April 25, 2014 15:02
Demo automated cropping using PIL
#
# "I've got a brand-new combine harvester, and I'll give you the key."
#
# ("Combine harvester"... 'cause it does the cropping for you...
# ... http://i1.kym-cdn.com/photos/images/newsfeed/000/234/772/71e.jpg
# ...
# ... http://i3.kym-cdn.com/photos/images/original/000/234/807/f3a.jpg )
#
#
# This is a quick demo, so works a bit clunkily: pass a list of files
# shuffles.py
#
# Written for the following /r/math post:
#
# > Hi all. I've got a programming problem that distills down to choosing
# > a permutation, B, of a sequence A, with uniform probability such that
# > no two pairwise sums are the same. For example:
# >
# > A = [ 0 1 2 3 4 ]
# > B = [ 2 4 1 3 0 ]
class Colouring(object):
def __init__(self, colouring):
self.colouring = colouring
def __eq__(self, other):
# Two colourings are "equal" (read: "equivalent") if one is a
# rotational-shift of the other. (I'm sure there are smarter
# ways to do this (this may not even be *right*), but I was in
# a hurry, and it seems to work.)
# Where to keep your ssh-agent environment details
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
<?php
$target = $_GET['target'];
$watermark = $_GET['watermark'];
if ((strlen($target) == 0) || (strlen($watermark) == 0)) {
exit;
}
if (!file_exists($target) || !file_exists($watermark)) {
@insipid
insipid / color-theme-wombat.el
Created September 24, 2009 14:32
color-theme version of the emacs version of the vim color theme Wombat
(eval-when-compile (require 'color-theme))
(defun color-theme-wombat ()
"Color theme 'wombat', taken from http://dengmao.wordpress.com/2007/01/22/vim-color-scheme-wombat/#comment-1051, created 2009-06-23."
(interactive)
(color-theme-install
'(color-theme-wombat
((background-color . "#242424")
(background-mode . dark)
(border-color . "#888a85")
(cursor-color . "#656565")