Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@dch
dch / gh-dl-release
Created August 16, 2016 17:51 — forked from maxim/gh-dl-release
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@dch
dch / forwarding-example.md
Created June 15, 2016 07:08 — forked from f1sherman/forwarding-example.md
Port Forwarding Example in OS X El Capitan

Add the following to /etc/pf.anchors/myname:

rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 4000
rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001

Add the following to /etc/pf-myname.conf:

rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/myname"
@dch
dch / refind.conf
Created May 23, 2016 19:35 — forked from anonymous/dpaste.de_snippet.py
FreeBSD & Ubuntu-based refind.conf
# textmode 2
#resolution 2880 1800
resolution 1440 900
timeout 5
# ignore FreeBSD loader in native FAT EFI partition
dont_scan_dirs /boot /EFI/freebsd /EFI/ubuntu
dont_scan_files boot1.efi
menuentry "FreeBSD 11.0-current" {
loader \EFI\freebsd\current.efi
@dch
dch / update-ip.sh
Created January 18, 2016 07:25 — forked from audy/update-ip.sh
#!/bin/bash
set -euo pipefail
hostname="test.austinfanclub.com"
# use -s6 and -s4 to ensure that a failed curl causes the script to bail correctly
ip6=`curl -s6 http://ipv6.icanhazip.com/`
ip4=`curl -s4 http://ipv4.icanhazip.com/`
curl \
--user "harekrishna@gmail.com:`pass iwantmyname`" \
"https://iwantmyname.com/basicauth/ddns?hostname=${hostname}&myip=${ip6}"
curl \
@dch
dch / mix.exs
Created October 6, 2015 08:29 — forked from jeffweiss/mix.exs
Retrieving application version number in mix.exs from git describe
defmodule MyApp.Mixfile do
use Mix.Project
def project do
[app: :my_app,
version: get_version,
elixir: "~> 1.0",
elixirc_paths: elixirc_paths(Mix.env),
compilers: Mix.compilers,
build_embedded: Mix.env == :prod,
@dch
dch / websockets-with-gun.ex
Created September 15, 2015 21:52 — forked from ashneyderman/gist:5eca8b1bed16a7b6f4be
Use of gun from elixir
defmodule Transport do
def connect(params) do
hostname = params.hostname
port = params.port
path = params.path
timeout = params.connection_timeout
{:ok, conn} = :gun.open(hostname, port)
{:ok, :http} = :gun.await_up(conn)
:gun.ws_upgrade(conn, path)
@dch
dch / xmerl_demo.ex
Last active September 15, 2015 06:54 — forked from sasa1977/xmerl_demo.ex
Simple xmerl usage demo in Elixir
defmodule XmlNode do
require Record
Record.defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl")
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")
def from_string(xml_string, options \\ [quiet: true]) do
{doc, []} =
xml_string
|> :binary.bin_to_list
|> :xmerl_scan.string(options)
@dch
dch / unbound-osx-homebrew.md
Last active August 29, 2015 14:27 — forked from denji/unbound-osx-homebrew.md
Install unbound DNS(SEC) resolver on OS X, on the basis of https://www.spatof.org/blog/unbound-dns-resolver-on-osx.html
To install unbound you can use homebrew
$ brew install unbound ldns
Now we can edit the configuration file of unbound which by default is located in /usr/local/etc/unbound/unbound.conf:
#!/bin/bash
ERLANG=18.0
SQLITE=amalgamation-3071700
cd /root
SSLV=1.0.1o
[ -f /usr/bin/gcc ] || (apt-get update && apt-get install -y build-essential)
@dch
dch / mmc.erl
Last active August 29, 2015 14:25 — forked from colefichter/mmc.erl
A multi-master (AKA distributed) counter implemented as a Conflict-free Replicated Data Type.
-module(mmc).
% A multi-master counter implemented as a CRDT. Each server holds an array of counters (implemented as a dict here...)
% and Strong Eventual Consistency is acheived by using commutive increments on each of the counters. The current
% value read at any server is the sum of all the counter values (again, one per server) stored on that machine.
% As updates are synced between servers, all servers will eventually converge on a counter sum value with no
% conflicts possible. Also note that this does not use any consensus algorithm, so it remains fast as the number of
% servers scales. See http://research.microsoft.com/apps/video/default.aspx?id=153540&r=1
-behaviour(gen_server).