Skip to content

Instantly share code, notes, and snippets.


Dave Cottlehuber dch

View GitHub Profile

Settable via /etc/sysctl.conf:

integer kern.maxvnodes

Target for maximum number of vnodes

integer kern.maxfiles

Maximum number of files

integer kern.securelevel

Current secure level

View openssh.erl
#!/usr/bin/env escript
main([Port]) ->
{ok, _} = application:ensure_all_started(ssh),
  • plan for code that is easy to delete/replace rather than code that is easy to extend or reuse. As needs change, you're more likely to change the assumptions about what the system should do than in how many ways it should do it. If the code needs extending, it's then easy to replace it with a bit that's easy to extend
  • planning for code that is easy to throw away is the best way I've found to properly bake in abstraction and isolation. The question is always "if I take this shit out or change its implementation entirely, do I need to replace anything else?". If the answer is "yes", then you may be leaking into other components. Fix it. turns out when you have that, it's also suddenly easier to reuse code.
  • write a prototype of whatever significant task you have to do, and consider it a draft. Use it to figure out requirements or to make your first mistakes in. Throw it away. Try again. As I gain more experience I find my prototypes smaller and individually more solid, but anything where I lack experience t
#!/usr/bin/perl -w
# recover rsyslog disk queue index (.qi) from queue files (.nnnnnnnn).
# See:
# runtime/queue.c: qqueuePersist()
# runtime/queue.c: qqueueTryLoadPersistedInfo()
# 2012-03-14
use strict;
View kraihlight.vim
set background=dark
hi clear
if exists("syntax_on")
syntax reset
let colors_name = "kraihlight"
dch / mcorbin_config.clj
Last active May 24, 2017 — forked from faxm0dem/riemann-config.clj
riemann collectd watchdog
View mcorbin_config.clj
(with {:service "heartbeat" :ttl 120 } (index))
(where (service "heartbeat")
(by :host (...))))
dch /
Created Jan 9, 2017 — forked from johnko/
Installing FreeBSD on a USB drive with ZFS using bsdinstall unattended

Installing FreeBSD on a USB drive with ZFS using bsdinstall unattended

I typically wrap all these commands into a shell script that I can reuse, but here they are in steps.

Please read through all the instructions before actually performing the commands, just to avoid any surprises


  • careful typing and copy/paste skills
  • USB drive (8 GB+ ?) Make sure you don't need anything on that drive
dch / config.ex
Created Oct 17, 2016 — forked from bitwalker/config.ex
Useful config wrapper for Elixir
View config.ex
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.
View bin_to_beam.erl
#!/usr/bin/env escript
%%% This script converts an arbitrary binary file to an Erlang module with a
%%% single exported 'bin/0' function that returns the original binary.
%%% See the end of the file for how I figured out the correct terms.
main(["+debug_info" | Files]) ->
io:format("Embedding binaries with debug_info...\n"),
lists:foreach(fun(X) -> embed_file_in_beam(X, [debug_info]) end, Files);
dch / gh-dl-release
Created Aug 16, 2016 — forked from maxim/gh-dl-release
Download assets from private Github releases
View gh-dl-release
#!/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.