Skip to content

Instantly share code, notes, and snippets.

View Tzrlk's full-sized avatar

Peter Cummuskey Tzrlk

View GitHub Profile
@Tzrlk
Tzrlk / git-purge
Last active January 28, 2016 03:07
Simple scripts to purge merged branches from your git server.
#!/bin/sh
echo "Switching to $1."
git symbolic-ref HEAD refs/heads/$1
echo "Removing all merged branches."
git branch --merged | grep -i '$2' | xargs -n 1 git branch -d
echo "Switching back to master."
git symbolic-ref HEAD refs/heads/master
@Tzrlk
Tzrlk / mergesortirator.js
Created November 24, 2015 03:08
Lazy merge sort based on iterator.
/* global Symbol */
'use strict';
/**
* @param {?} iterable_a
* @param {?} [iterable_b]
*/
export function mergesortirator(iterable_a, iterable_b) {
// Grab the iterator from the provided iterable.
@Tzrlk
Tzrlk / DivideTask.java
Created August 12, 2015 05:23
Merge sort function using fork/join pool.
package nz.co.aetheric.tools.async;
import java.util.List;
import static com.google.common.collect.Lists.transform;
import static com.google.common.collect.Lists.partition;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Iterables.mergeSorted;
public class DivideTask<E> extends RecursiveTask<List<E>> {
@Tzrlk
Tzrlk / ServletContextBundleControl.java
Created December 3, 2014 01:15
A ResourceBundle Control for reading files off a ServletContext.
package nz.co.aetheric.web.servlet;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.ServletContext;
import java.io.IOException;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@Tzrlk
Tzrlk / inject.js
Last active August 29, 2015 14:07
Angular injection adapter
function inject(deps, target) {
var list = _.keys(deps);
list.push(function() {
var context = arguments;
var resolved = {};
_.each(list, function(value, index) {
resolved[deps[value]] = context[index];
});
@Tzrlk
Tzrlk / version.sh
Last active August 29, 2015 14:03
Generates a version number from your maven version, adding on commits since branching, and the hash of the commit. Good for continuous integration.
#!/bin/bash
export args="$*"
# Check whether in quiet mode.
export quiet=false
if grep -q '\-q' <<<$args; then
export quiet=true
fi
@Tzrlk
Tzrlk / on_korashur.adoc
Created November 12, 2013 08:02
A manifesto on what to expect from the Korashurans of Sarradar.

On Korashur

First, let me be perfectly clear; I do not hate or fear the people of Korashur, and have neither been particularly wronged by said people or their society. No, this text is a dispassionate warning to anyone who would interact or draw the attention of members of Korashuran society.

As I do not hate or fear Korashur, neither should you; both these emotions cloud the mind and leave you open to exploitation. What you should be, however is uncompromisingly aware, that at any given time, you may be a pawn in their endless quest for power.

Understand, Korashuran society is set up specifically to cultivate a particular brand of callous and selfish evil. The only goal in Korashur is to be the most powerful mage, ruling over all the rest, no matter the cost to anyone concerned. If for one moment that you think that this is untrue, you are naiive beyond reckoning and either are almost certainly caught in one of their schemes already, or have never heard of Korashur. Hyperbole aside,

@Tzrlk
Tzrlk / EbeanQuery.java
Last active December 23, 2015 09:49
An idea I had for a query proxy pattern.
public abstract class EbeanQuery<ResultType>
extends Query<ResultType> {
protected ExpressionList<ResultType> expressionList;
public ResultType getResult() {
return expressionList.findUnique();
}
public ResultType getFirstResult() {
@Tzrlk
Tzrlk / robot.js
Created December 4, 2012 21:32
Reaver
var robots = {
mine: {},
theirs: {}
};
var routines = {
searching: function(robot) {
robot.turn(1);
robot.rotateCannon(1);
},