Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@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 / http_proxy.go
Created December 7, 2023 18:47 — forked from jim3ma/http_proxy.go
Register Dialer Type for HTTP&HTTPS Proxy in golang
package main
import (
"bufio"
"fmt"
"net"
"net/http"
"net/url"
"crypto/tls"

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

@dch
dch / atkin.erl
Created November 27, 2013 14:27 — forked from nox/atkin.erl
-module(atkin).
-export([primes_smaller_than/1]).
primes_smaller_than(Limit) ->
primes_smaller_than(Limit, sieve(Limit), []).
primes_smaller_than(0, _, Acc) ->
Acc;
primes_smaller_than(N, Bin, Acc) ->
@dch
dch / gist:4148379
Created November 26, 2012 14:07 — forked from ajohnstone/gist:4148292
graphite internal performance
Carbon relay - performance
alias(color(sumSeries(group(carbon.agents.*.updateOperations)), "blue"),"Updates")
alias(color(sumSeries(group(carbon.agents.*.metricsReceived)), "green"), "Metrics Received")
alias(color(sumSeries(group(carbon.agents.*.committedPoints)),"orange"),"Committed Points"))
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.pointsPerUpdate)),"yellow")),"PPU")
alias(secondYAxis(color(averageSeries(group(carbon.agents.*.cpuUsage)),"red")),"CPU (avg)")
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.creates)),"purple")),"Creates")
Metrics received
carbon.agents.*.metricsReceived
@dch
dch / openssh.erl
Created February 27, 2018 13:19 — forked from maxlapshin/openssh.erl
#!/usr/bin/env escript
%%
%%
-mode(compile).
-compile(export_all).
main([Port]) ->
{ok, _} = application:ensure_all_started(ssh),
@dch
dch / tips.md
Created February 26, 2018 08:33 — forked from ferd/tips.md
  • 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()
#
# kaiwang.chen@gmail.com 2012-03-14
#
use strict;
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "kraihlight"
@dch
dch / mcorbin_config.clj
Last active May 24, 2017 18:08 — forked from faxm0dem/riemann-config.clj
riemann collectd watchdog
(streams
(with {:service "heartbeat" :ttl 120 } (index))
(where (service "heartbeat")
(by :host (...))))