Skip to content

Instantly share code, notes, and snippets.

@eiri
eiri / jo and jg comparison and cheatsheet.md
Created May 8, 2018 13:53
jo and jg comparison and cheatsheet
@eiri
eiri / couch-query-params.md
Created April 28, 2018 03:17
How Couch query parameters work

How Couch query parameters work

This is a table showing a relationship between CouchDB view and _all_docs query parameters start_key, end_key, descending and inclusive_end. Obvious things to notice: 1) Start key always included 2) inclusive_end doesn't affect starting key 3) from A to B asc not equal from B to A desc.

 start_key | end_key | inclusive_end | descending |
                                                    [ 1 | 2 | 3 | 4 | 5 | 6 ]
 null      | null    | true          | false      |   1 ----------------> 6
@eiri
eiri / !README.md
Created April 4, 2018 17:17
Run a native erlang view in CouchDB

Prereq

Running docker, couchdb:2.1.1 image, httpie. Create dir data and etc. Place local.ini in etc

Run

$ docker run --rm -it -d -p 5984:5984 -p 5986:5986 -v $(PWD)/data:/opt/couchdb/data -v $(PWD)/etc:/opt/couchdb/etc/default.d couchdb:2.1.1
250179e806b370fea7cd99e5fa7bfae5a4586b3bfda6bded5f956424346449e2
@eiri
eiri / README.md
Created February 2, 2018 18:40
Bench CPU and disk of VM debian/jessie64

Bench CPU and disk of VM debian/jessie64

Setup

Host: MBP Intel i7 4 cores, RAM 16GB. Guest: 1 cpu, 4096 memory. Surprisingly this is better than more memory and/or more cpu cores setup.

Compare --ioapic and --acpi flags.

TL;DR

Turn both on. Even though ioapic shouldn't be relevant on 1 cpu and acpi said to be better off for perf boost,

@eiri
eiri / DockerSystemPrune.plist
Last active May 20, 2024 15:14
Cleanup after Docker nightly on Mac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>DockerSystemPrue</string>
<key>Program</key>
<string>/usr/local/bin/docker system prune -f</string>
<key>StartCalendarInterval</key>
<dict>
@eiri
eiri / README.md
Created January 17, 2018 20:29
Installing Prometheus on Debian

Install Prometheus on Debian

install gosu

just to not wrestle with sudo and exec

$ sudo apt-get update
$ sudo apt-get install gosu

Create prometheus user

@eiri
eiri / hmac256hex.go
Created November 3, 2017 15:59
Generate hmac256 from a string and present it in hex.
package main
import (
"crypto/hmac"
"crypto/rand"
"crypto/sha1"
"encoding/hex"
"fmt"
)
@eiri
eiri / copy.md
Created October 26, 2017 16:38
How to use COPY in CouchDB (with httpie)

How to use COPY in CouchDB

Create new db

$ http put :5984/names --auth admin:secret
{
    "ok": true
}
@eiri
eiri / Dockerfile
Created October 19, 2017 14:20
minideb with erlang solutions packaged erlang
FROM bitnami/minideb:stretch
MAINTAINER Eric Avdey <[email protected]>
ENV ESL_REPO=http://packages.erlang-solutions.com/debian \
ESL_DIST=esl-erlang \
ESL_VER=1:19.3.6
WORKDIR /tmp
@eiri
eiri / config
Created October 12, 2017 00:52
Example of erln8 (v1) config
[Erln8]
color=true
banner=false
default_config=default
system_default=r20
[Repos]
default=https://github.com/erlang/otp.git
[Erlangs]