Skip to content

Instantly share code, notes, and snippets.

Avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@josephg
josephg / README.md
Created Feb 4, 2019
Foundationdb C API example
View README.md

This is a simple example program using the foundationdb C API. Its written & tested on macos; but it should be easy to adapt to work on BSD / linux.

This also demonstrates using libuv to integrate foundationdb into a run loop. Promises are run in the main libuv loop.

Compile with

$ clang test.c -Wall -lfdb_c -I/usr/local/include -luv
@maxlapshin
maxlapshin / systemd.erl
Last active Oct 15, 2021
Systemd support
View systemd.erl
-module(systemd).
% This is what you need to adopt systemd in erlang
%
% Do whatever you want license. If you want, you can take this code under terms of MIT license.
-export([ready/0, reloading/0, stopping/0, watchdog/0]).
-export([start_link/0]).
-export([init/1, handle_info/2, terminate/2]).
View gist:af9abf6b3600d2d7f08dba58fdfb514a
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html
For a safe and fast Erlang SSL server, there's a few
configuration values you might want by default:
[{ciphers, CipherList}, % see below
{honor_cipher_order, true}, % pick the server-defined order of ciphers
{secure_renegotiate, true}, % prevent renegotiation hijacks
{client_renegotiation, false}, % prevent clients DoSing w/ renegs
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must
@assafmo
assafmo / couchimport-jq-json-zip.sh
Last active Jun 14, 2020
Import an archive full of JSONs into CouchDB
View couchimport-jq-json-zip.sh
#!/bin/bash
#json per line (same result, but for example can use jq to set _id)
7z x -so $1 | jq -c . | couchimport --db mydb --type jsonl
@jadeallenx
jadeallenx / discussion.md
Last active Sep 16, 2021
When does terminate/2 get called in a gen_server?
View discussion.md

When does terminate/2 get called in a gen_server?

This is what the [official documentation][1] says about the terminate/2 callback for a gen_server:

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Reason is a term denoting the stop reason and State is the internal state of the gen_server.

Reason depends on why the gen_server is terminating. If it is because another callback function has returned a stop tuple {stop,..}, Reason will have the value specified in that tuple. If it is due to a failure, Reason is the error reason.

@maxim
maxim / gh-dl-release
Last active Jan 12, 2022
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.
#
# PREREQUISITES
#
@jeffweiss
jeffweiss / mix.exs
Last active Dec 18, 2018
Retrieving application version number in mix.exs from git describe
View mix.exs
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,
View openssh.erl
#!/usr/bin/env escript
%%
%%
-mode(compile).
-compile(export_all).
main([Port]) ->
{ok, _} = application:ensure_all_started(ssh),
View gist:3a2e355354e7f19066a0
## Enable kernel poll and a few async threads
+K true
+A 5
+Q 64000
+P 128000
+sbt db
+sbwt very_long
+swt very_low
+sub true
+Mulmbcs 32767
@denji
denji / unbound-osx-homebrew.md
Last active Apr 14, 2021
Install unbound DNS(SEC) resolver on OS X, on the basis of https://www.spatof.org/blog/unbound-dns-resolver-on-osx.html
View unbound-osx-homebrew.md
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: