Skip to content

Instantly share code, notes, and snippets.

View mrenouf's full-sized avatar

Mark Renouf mrenouf

View GitHub Profile
@mrenouf
mrenouf / gist:845403
Created February 26, 2011 17:25
HTML skeleton -- Pretty me up!
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" language="javascript" src="demo/demo.nocache.js"></script>
</head>
<body>
<input type="text" id="passphrase">
<input type="key" id="key">
<textarea id="plaintext"></textarea>
@mrenouf
mrenouf / PluralsTest.java
Created February 1, 2011 11:45
Test cases for Plurals.java
package com.bitgrind.text;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeNotNull;
@mrenouf
mrenouf / Plurals.java
Created February 1, 2011 11:44
Pluralization rules for english
/*
* Original code from:
* Mattias Fagerlund
* http://lotsacode.wordpress.com/2010/03/05/singularization-pluralization-in-c/
* Matt Grande
* http://mattgrande.wordpress.com/2009/10/28/pluralization-helper-for-c/
*
* Converted Java by Mark Renouf
*/
@mrenouf
mrenouf / Paths.java
Created January 30, 2011 11:46
Filesystem iterator, implemented with a stack instead of recursion. Returns only files.
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
public class Paths implements Iterable<File> {
@mrenouf
mrenouf / gwt-jso-generator
Created January 2, 2011 13:38
GWT JSO generator from JSON-Schema
// Input snippet of JSON-Schema:
{
"name": "email"
"type":"object",
"properties":{
"type":{"type":"string"},
"value":{"type":"string","format":"email"}
}
}
@mrenouf
mrenouf / simdir
Created November 12, 2010 15:38 — forked from Daenyth/simdir
Fuzzy directory match using simhash
#!/bin/bash
shingle_size=4
feature_count=1024
if [[ ! -d $1 || ! -d $2 ]]; then
echo "Usage: <dir1> <dir2>"
exit 1
fi;
# make sure we don't simhash simhash files
@mrenouf
mrenouf / compiz-grid-hotcorners.sh
Created November 1, 2010 01:08
Substitute for Aero Snap using Compiz Grid plugin, with hot corners and sides
#!/bin/sh
apt-get install compizconfig-settings-manager compiz-fusion-plugins-extra xautomation
gconftool-2 --set --type list --list-type string /apps/compiz/general/allscreens/options/active_plugins [grid,commands]
gconftool-2 --set --type string /apps/metacity/keybinding_commands/command_1 "xte 'keydown Control_L' 'keydown Alt_L' 'key KP_4' 'keyup Control_L' 'keyup Alt_L'"
gconftool-2 --set --type string /apps/metacity/keybinding_commands/command_2 "xte 'keydown Control_L' 'keydown Alt_L' 'key KP_6' 'keyup Control_L' 'keyup Alt_L'"
gconftool-2 --set --type string /apps/metacity/keybinding_commands/command_3 "xte 'keydown Control_L' 'keydown Alt_L' 'key KP_7' 'keyup Control_L' 'keyup Alt_L'"
gconftool-2 --set --type string /apps/metacity/keybinding_commands/command_4 "xte 'keydown Control_L' 'keydown Alt_L' 'key KP_9' 'keyup Control_L' 'keyup Alt_L'"
gconftool-2 --set --type string /apps/metacity/keybinding_commands/command_5 "xte 'keydown Control_L' 'keydown Alt_L' 'key KP_1' 'keyup Control_L' 'keyup Alt_L
@mrenouf
mrenouf / xstream
Created October 28, 2010 13:49
Like xargs, but for STDIN (run a command for each line, piping the line to STDIN)
#!/usr/bin/python
import sys, subprocess
def main(args=sys.argv):
if len(args) < 2:
print "Usage: %s <command>" % (args[0])
exit 1
while True:
try: line = raw_input(None)