Skip to content

Instantly share code, notes, and snippets.

# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
output_format = i3bar
@hkolbeck
hkolbeck / collector.go
Created February 11, 2014 01:07
Collector
package main
import (
"flag"
"fmt"
"log"
"net/http"
"io"
"io/ioutil"
"encoding/json"
The Challenge
-------------
Given the following riddle, write a regular expression describing all possible answers,
assuming you never make a move which simply undoes the last one you made.
The Riddle
----------
You are on your way somewhere, taking with you your cabbage, goat, and wolf, as always.
You come upon a river and are compelled to cross it, but you can only carry one of the
three companions at a time. None of them can swim because this isn't THAT kind of riddle.
@hkolbeck
hkolbeck / AppTest.java
Created January 30, 2014 23:47
TDD, YO
package com.urbanairship;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
declare -A ignoredCommands
ignoredCommands=( 'ls' 1 'cd' 1 'echo' 1 'rmdir' 1 'mkdir' 1 'touch' 1 'man' 1 'ln' 1 'pwd' 1 )
function pre_exec {
COMMAND=$(cut -f1 -d' ' <(echo $1) )
if [ ! "${ignoredCommands[$COMMAND]}" ]; then
date
fi
}
add-zsh-hook preexec pre_exec
type ThingPool struct {
pool chan *Thing
generator func() *Thing
destructor func(*Thing)
}
func NewThingPool(poolSize int, generator func() *Thing, destructor func(*Thing)) *ThingPool {
p := &ThingPool{
pool : make(chan *Thing, poolsize),
generator : generator,
@hkolbeck
hkolbeck / gist:6966069
Last active December 25, 2015 10:59
A <s>quick</s> stab at an explanation of Regular Expressions

Regular expressions are often very intimidating, in part because they are so information-dense and because a symbol's meaning can depend entirely on context. Unlike many things in computer science, regular expressions actually get easier (at least in my opinion) when you go back to the backing theory.

Regular expressions (regexes for short) are like equations for text. Specificaly they describe some number of similar pieces of text such that if we have some text and a regular expression we can ask "Does this text contain the pattern described by this regex?" We'll assume the text we want to examine is some basic english, which strangely has only the letters 'a', 'b', and 'c'. I'll surround regular expressions with forward slashes (/), and text with double quotes (") To start of with, we'll have only a few tools for doing that:

@hkolbeck
hkolbeck / Reading Topics
Created September 24, 2013 16:37
Reading Topics
Lattice Consensus
Causal Consistancy
@hkolbeck
hkolbeck / json.go
Last active December 22, 2015 14:49 — forked from chrisdickinson/json.go
package main
/*ck imports are usually in one block, like`import (...)`, each import still on its own line */
import "math"
import "container/list"
import "strconv"
/*ck There are automated tools for adding/removing imports as you dev, v. worthwhile */
//import "fmt"
import "os"
import "encoding/json"
#include "stdio.h"
void turrible(int a, int b) {
int* ptr = (&a);
while (*++ptr != a);
*ptr = b;
}
int main() {
int i = 125;