Skip to content

Instantly share code, notes, and snippets.

@tarnacious
tarnacious / parse.hs
Created September 30, 2013 13:49
While writing the same parser in JavaScript and Haskell I found these two snippets illustrated to me why monads and do syntax are awesome.
piece :: Parser Piece
piece = do
many space
t <- pieceType
c <- pieceColour
return $ Piece t c
@tarnacious
tarnacious / gist:6270193
Created August 19, 2013 15:07
Some initial setup to my macbook air. I need to do it twice, so wrote it down to make it quicker.
Download + Install Firefox in English (http://www.mozilla.org/en-US/firefox/all/)
Download + Install XCode and XCode command line tools. (https://developer.apple.com/downloads/)
Download + Install ITerm2
Download Solarized.
Install Solarized for ITerm2: http://michaelheap.com/solarized-with-iterm2/
Download + Install Chrome in English (https://www.google.com/intl/en/chrome/)
Install homebrew http://brew.sh/
brew install vim
brew install tmux
brew install wget
@tarnacious
tarnacious / actual output
Last active December 18, 2015 12:58
Strange elasticsearch search behaviour?
{"acknowledged":true}
{"acknowledged":true}
{"_index":"text-index","_type":"user","_id":"AVG0hasF-Z9PaJz0rP2W","_version":1,"created":true}
{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"text-index","_type":"user","_id":"AVG0hasF-Z9PaJz0rP2W","_score":0.30685282,"_source":
{
"address":
{
"description": "Walked"
}
@tarnacious
tarnacious / tarnbarfordnet
Created February 18, 2013 11:54
Simple nginx config (/etc/nginx/sites-enabled/tarnbarfordnet) for a reverse proxy to a Flask app running on localhost:8000 and to serve the static files directly though nginx.
upstream tarnbarfordnet {
server localhost:8000;
}
server {
root /usr/share/nginx/www;
index index.html index.htm;
server_name localhost;
@tarnacious
tarnacious / gist:4608177
Created January 23, 2013 15:31
Notes on using Python bolts / spouts in Storm
We encountered some issues using python processes with storm.
1) Storm uses the stdin and stdout of the python processes to communicate with them. This makes them almost impossible to debug with pdb.set_trace().
2) The local topology (and the real storm to a lesser extent) has issues killing the Python processes it creates. Some of our rouge processes pin the CPU. I find myself running something like this on my local machine.
ps aux | grep python | awk '{ print $2 }' | xargs kill
3) We didn't want to install python packages in the system packages because it adds dependencies on the system storm is running on and we also have different topologies with different bolts that depend of different versions of packages. We install the dependencies (with buildout or virtualenv) in a relative path before creating the uberjar and deploying it, or you can also make the script storm calls a shell script that installs the dependencies locally then runs the python entry point. Either way, it is a little painful, espe
@tarnacious
tarnacious / make_maildir.py
Created December 3, 2015 18:49
All mail clients suck. This one just sucks less.
import mailbox
import random
import os
# sample messages from my mail archive
sample_maildir = mailbox.Maildir('~/MailDir/private/archive')
sample_messages = sample_maildir.values()
# create a new maildir with two mailboxes
os.mkdir("./TestMaildir")
@tarnacious
tarnacious / Dockerfile
Last active November 16, 2015 15:34 — forked from anonymous/stdin
stdin
# Dockerfile
FROM debian:stretch
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
build-essential \
make \
curl \
boxer \
cpio \
***
***
* *********
**************
***************
******************
***** ******************
***************************
**************************************
@tarnacious
tarnacious / myview.js.coffee
Created March 7, 2012 07:34
backbone example - serialize form + update on change
window.MyView = Backbone.View.extend({
initialize: ->
_.bindAll(this,'render')
this.template = window.JST["MyView"]
this.model.bind('change', this.render)
render: ->
$(this.el).html(this.template(this.model.toJSON()))
events: {
@tarnacious
tarnacious / tdb.hs
Created November 24, 2011 22:50
tdb
$ ghci
GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Prelude> let make = (\a b -> take b (repeat a))
Prelude> ("abc",123) `make` 3
[("abc",123),("abc",123),("abc",123)]