Skip to content

Instantly share code, notes, and snippets.

View sanmiguel's full-sized avatar

Michael Coles sanmiguel

View GitHub Profile
@sanmiguel
sanmiguel / gen_ale_drinker.erl
Created June 19, 2013 23:36
-behaviour(gen_ale_drinker).
-module(gen_ale_drinker).
%% There are 2 types of drink:
-type style() :: ale | not_ale.
%% Need to support imperial measurements (not US pints though)
-type volume() :: {imperial_pint, non_neg_integer()} | {litre, non_neg_integer()}.
-type beverage() :: {style(), volume()}.
-callback drink(beverage()) -> ok | {error, ebeeroverflow}.
@sanmiguel
sanmiguel / 0_reuse_code.js
Created October 7, 2013 10:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am sanmiguel on github.
  • I am sanmiguel (https://keybase.io/sanmiguel) on keybase.
  • I have a public key whose fingerprint is E346 988E D68C 32E7 F548 0BDB 766F 38AD 53E6 6115

To claim this, I am signing this object:

function! s:CleanExport(start)
let end = search(']', 'W')
let pos = getpos('.')
call search(',', 'bW', a:start)
if pos != getpos('.')
s/\_\s*,\_\s*\([^]]\+\)\_\s*/]).\r-export([\1/
call s:CleanExport(a:start)
endif
endfunction
  1. {token} = http post {deviceid, ssoid}
  2. {stun-host} = find stun server host/ip
  3. {contents} = build stun
  4. {message} = sha1({contents}, key={token})
  5. {stun-host} ! {message}
  6. receive {response} from {stun-host}
  • if {response} = ok; sleep ; goto 3.
  • else goto 1.
import os
import powerline.lib.vcs as plvcs
import pygit2 as git
name = os.getcwd()
repo = git.Repository(name)
@sanmiguel
sanmiguel / kairosdb.plist
Created June 2, 2015 15:00
OSX launchctl plist file for kairosdb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>kairosdb</string>
<key>EnvironmentVariables</key>
<dict>
<key>KAIROS_PID_FILE</key>
<string>/usr/local/var/run/kairosdb.pid</string>
sh-3.2$ find lib -name "*ex"
lib/bar baz.ex
lib/foo.ex
sh-3.2$ wc -l `find lib -name "*ex"`
wc: lib/bar: open: No such file or directory
wc: baz.ex: open: No such file or directory
19 lib/foo.ex
19 total
sh-3.2$ find lib -name "*ex" | xargs wc -l
wc: lib/bar: open: No such file or directory
syntax on
set laststatus=2
set showtabline=2
set background=dark
set ignorecase
set smartcase
set clipboard+=unnamed " Copy to/paste from system clipboard
-module(stung_op).
-type weight() :: non_neg_integer(). %% Non-normalised weight
-type nweight() :: float(). %% Internal use only - normalised weight
%% Inputs
%% Op :: {Name, Args :: list(any())}.
%% Choice :: {Op, Weight, NextChoices}.
%%