Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
{
"name": "onCourseServer",
"version": "__version__",
"origin": "misc/onCourseServer",
"comment": "ish onCourse Server for FreeBSD",
"arch": "freebsd:9:x86:64",
"www": "http://www.ish.com.au",
"maintainer": "[email protected]",
"prefix": "/usr/local",
"licenselogic": "single",
@dch
dch / ansible-gce.sh
Last active August 29, 2015 14:24 — forked from samklr/ansible-gce.sh
#! /bin/sh
### Must have Gcloud sdk installed and configured
###Create a micro instance as ansible master
gcloud compute --project $PROJECT_NAME instances create "ansible" --zone "us-central1-b" --machine-type "f1-micro" --network "default" --maintenance-policy "MIGRATE" --scopes "https://www.googleapis.com/auth/userinfo.email" "https://www.googleapis.com/auth/compute" "https://www.googleapis.com/auth/devstorage.full_control" --tags "http-server" "https-server" --no-boot-disk-auto-delete
###or a centos like in the tutorial
gcloud compute --project $PROJECT_NAME instances create "ansible-master" --zone "us-central1-b" --machine-type "g1-small" --network "default" --maintenance-policy "MIGRATE" --scopes "https://www.googleapis.com/auth/userinfo.email" "https://www.googleapis.com/auth/compute" "https://www.googleapis.com/auth/devstorage.full_control" --tags "http-server" "https-server" --image "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20140926" --no-boot-disk-auto-de
@dch
dch / tweaks.txt
Last active August 29, 2015 14:24 — forked from jlouis/gist:3a2e355354e7f19066a0
erlang 18.x secret tuning sauce from jlouis
## 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
%% @author Masahito Ikuta <[email protected]> [http://d.hatena.ne.jp/cooldaemon/]
%% @copyright Masahito Ikuta 2008
%% @doc UDP Server Behaviour.
%% Copyright 2008 Masahito Ikuta
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%

F1. FS 128k streaming writes

Benchmark: fio write

Command: fio --name=seqwrite --rw=write --bs=128k --size=4g --end_fsync=1 --loops=4 # aggrb tput

Rationale: Measure the performance of a single threaded streaming write of a reasonably large file. The aim is to measure how well the file system and platform can sustain a write workload, which will depend on how well it can group and dispatch writes. It's difficult to benchmark buffered file system writes in both a short duration and in a repeatable way, as performance greatly depends on if and when the pagecache begins to flush dirty data. As a workaround, an fsync() at the end of the benchmark is called to ensure that flushing will always occur, and the benchmark also repeats four times. While this provides a much more reliable measurement, it is somewhat worst-case (applications don't always fsync), providing closer to a minimum rate – rather than a maximum rate – that you should expect.

F2. FS cached 4k random reads

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@dch
dch / remsh.erl
Last active August 29, 2015 14:15 — forked from davisp/remsh.erl
#! /usr/bin/env escript
%%! -hidden -noshell -noinput
-mode(compile).
-export([
init_shell_log/1
]).
#!/usr/bin/env bash
display_usage(){
echo "Usage: $0 PROJECT_NAME [ cowboy ]"
exit 1
}
[[ $# -eq 0 || $# == "--help" || $# == "-h" ]] && display_usage
red='\033[0;31m'
blue='\033[0;34m'
green='\033[0;32m'
@dch
dch / udp_test.erl
Last active August 29, 2015 14:14 — forked from systra/udp_test.erl
-module(udp_test).
-behaviour(gen_server).
-define(SERVER, ?MODULE).
-define(PORT, 9876).
-define(TIMEOUT, 10).
%% ------------------------------------------------------------------
%% API Function Exports
%% ------------------------------------------------------------------
%% Special thanks to Capflam
dbg:tracer(), dbg:p(all, call), dbg:tpl(mod, fun, dbg:fun2ms(fun(_) -> return_trace(), exception_trace() end)).