Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@dch
dch / GITHUB-COMPARE-LINKS.md
Created July 2, 2012 09:04 — forked from mbbx6spp/GITHUB-COMPARE-LINKS.md
This Gist is worth a million beers. So buy me one (or send me a really cool t-shirt, make sure it is REALLY cool though)! :)
@dch
dch / a-spidermonkey-test.js
Created July 3, 2012 07:52 — forked from jimklo/a-spidermonkey-test.js
OpenPGP.js with SpiderMonkey example
// make check for navigator properties not fail.
var navigator = {};
// support some basic HTML5 localStorage operations
function _localStorage() {
this.ls = {};
this.getItem = function(key) {
<!DOCTYPE html>
<html>
<head>
<title>Simple Address Book</title>
<link rel="stylesheet" href="style/main.css" type="text/css">
<script src="/_utils/script/json2.js"></script>
<script src="/_utils/script/jquery.js?1.3.1"></script>
<script src="/_utils/script/jquery.couch.js?0.9.0"></script>
<script type="text/javascript">
$db = $.couch.db("addressbook");
@dch
dch / README.md
Created July 31, 2012 01:22
CouchDB Docs

Pandoc meets CouchDB Docs

Get the source, or just clone this gist instead.

mkdir /tmp/couchdocs && cd /tmp/couchdocs
git clone git://github.com/dch/couchdb.git
git checkout docs
cd share/docs

Install Pandoc

@dch
dch / latency.markdown
Created August 10, 2012 11:36 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@dch
dch / zfs_notes.md
Last active August 10, 2018 01:44
zfs notes

pool management

  • create a new pool by first creating an empty partition space using diskutil or Disk Utility
  • use cgdisk from homebrew if needed to reset the zpool partition id to a504 & then reboot

create a pool

zpool create -f \
 -o ashift=12 \
@dch
dch / appdotnet.py
Created August 13, 2012 08:23
app.net command line app
#!/usr/bin/env python
"""appdotnet
Usage:
appdotnet authenticate <client_id>
appdotnet set-accesstoken <access_token>
appdotnet global
appdotnet
appdotnet -h | --help
@dch
dch / store.pl
Created August 23, 2012 13:36
load docs from files using Store::CouchDB
#!/usr/bin/env perl
use Modern::Perl;
use Store::CouchDB;
use JSON;
use File::Slurp;
# unbuffer output to line up stderr/stdout
$|=1;
-module(echo_supervisor).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
-module(echo_server).
-behaviour(gen_server).
%% Server API
-export([start_link/3, stop/1]).
%% Client API
-export([echo/1, assassinate/1]).
%% gen_server callbacks