Skip to content

Instantly share code, notes, and snippets.

View eiri's full-sized avatar
🐈‍⬛
Diving into Rust

Eric Avdey eiri

🐈‍⬛
Diving into Rust
View GitHub Profile
@eiri
eiri / syslog.md
Created August 23, 2018 14:08
Two formats of syslog message

Formats of syslog

rfc 5424

<PRI>VER TIMESTAMP HOSTNAME APP-NAME PROCID MSGID [SOURCETYPE@NM_IANA key1="val1" key2="val2" etc.]

example: <34>1 2003-10-11T22:14:15.003Z mymachine.example.com su ID47 d25c5bf1 - BOM'su root' failed for lonvick on /dev/pts/8

rfc 3164

TIMESTAMP HOSTNAME APP-NAME[PROCID]: sourcetype="SOURCETYPE" key1="val1" key2="val2" etc.

@eiri
eiri / rand_json
Last active May 30, 2018 16:10
Bash script to generate random json objects. (Mac version)
#!/bin/bash
# prereq `brew install coreutils jo`
defcount=1
display_usage() {
echo -e "Generate NUMBER of random json objects."
printf " Usage: %s [NUMBER] (DEFAULT: %s)\n\n" $(basename "$0") $defcount
}
@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
}