Skip to content

Instantly share code, notes, and snippets.

@eiri
eiri / acounter.escript
Created March 24, 2020 15:07
Demo on how foundationdb atomic counters update in one transaction cancels all the read transactions
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -s -pa src/erlfdb/ebin
-define(CLUSTER_FILE, <<"/usr/local/etc/foundationdb/fdb.cluster">>).
-define(DIR, <<"test">>).
-define(KEY, <<"counter">>).
-define(TIMEOUT, 1000).
@eiri
eiri / README.md
Created February 28, 2020 17:31
Slash and transform json file with jq

Grab a data file. "American movies scraped from Wikipedia" is a nice condence set at size 3.4M wget https://raw.githubusercontent.com/prust/wikipedia-movie-data/master/movies.json -O movies.json

Slice movies made from 1920 till 1930 and output them line by line

jq -cr '.[] | select(.year >= 1920 and .year <= 1930)' movies.json

Pass the output to reducer to group by year, calculate total movies per year and accumulate movies into "movies" array in each block

@eiri
eiri / README.md
Created January 14, 2020 15:37
Using `cheat` - command line helper tool
@eiri
eiri / Makefile
Created November 22, 2019 06:27
Testing facilities for removing of view_changes from CouchDB
sub.DEFAULT_GOAL := check
.EXPORT_ALL_VARIABLES:
CURL_HOME = $(CURDIR)
JAR = $(CURDIR)/jar
DB = http://localhost:15984
ADM_CRD = '{"username":"admin", "password": "admin"}'
USR_CRD = '{"name":"eiri", "password": "eiri"}'
@eiri
eiri / README.md
Created April 16, 2019 22:23 — forked from magnetikonline/README.md
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set. Value will be returned.

Couple with : no-op if return value is to be discarded.
${variable="value"}
: ${variable="value"}
@eiri
eiri / Dockerfile
Created March 21, 2019 23:51
gitbook in docker
FROM node:8.11-alpine
RUN npm install --global gitbook-cli && \
gitbook fetch 3.2.2 && \
gitbook install && \
npm cache clear --force && \
rm -rf /tmp/*
# Fixes https://github.com/GitbookIO/gitbook/issues/1309
RUN sed -i.bak 's/confirm: true/confirm: false/g' \
@eiri
eiri / fix.md
Created February 21, 2019 15:13
Fix 500 login error on new App Store in macOS Mojave
@eiri
eiri / .kerlrc
Created January 29, 2019 15:07
kerl config, saved for posterity
KERL_DEFAULT_INSTALL_DIR=/opt/erlang
KERL_CONFIGURE_OPTIONS="--enable-debug --without-javac --enable-shared-zlib --enable-dynamic-ssl-lib --disable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --with-wx --with-ssl=/usr/local/opt/openssl"
@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
}