Skip to content

Instantly share code, notes, and snippets.

@eiri
eiri / README.md
Last active December 9, 2016 17:22
Sequence diagram of CouchDB 2.0 compaction
@eiri
eiri / README.md
Last active December 9, 2016 14:21
Example of using js-sequence diagram in gist

Example of using js-sequence diagram in gist

How to share

Bl.ocks is a nice way for sharing code examples hosted on gitHub gist. All that needed is just to replace “gist.github.com” with “bl.ocks.org” in the URL, e.g. http://bl.ocks.org/eiri/073a9e12f8246927ef997bf6f3ab5561

Sequence file loading

Sequence is just a simple text file loaded with syncronious ajax call.

@eiri
eiri / .gitignore
Last active December 20, 2016 06:48
Ubuntu 14.04 for Swift 3.0.2 - simple dev environment
.vagrant/
git/
@eiri
eiri / config tree
Created August 5, 2016 17:45
httpie configuration
$ tree ~/.httpie/
/Users/eiri/.httpie/
├── config.json
└── sessions
└── localhost_5984
└── default.json
@eiri
eiri / gist:7bbc28244b6f88a33b2a7003c43dd9b8
Created August 5, 2016 16:59
open_revs with httpie example
$ http :5984
{
“couchdb”: “Welcome”,
“uuid”: “6c77bce10369b93fa79b8488f1e25444”,
“vendor”: {
“name”: “Homebrew”,
“version”: “1.6.1_6”
},
“version”: “1.6.1”
}
@eiri
eiri / oldstate.hrl
Created July 19, 2016 19:55
universal detector of changed state (useful for hot upgrades)
-define(IS_OLD_STATE(S), tuple_size(S) /= tuple_size(#state{})).
@eiri
eiri / String+emoji.swift
Created June 29, 2016 15:33 — forked from iandundas/String+emoji.swift
Random Emoji
// Returns a random Emoji 🌿
extension String{
func randomEmoji()->String{
let range = 0x1F601...0x1F64F
let ascii = range.startIndex + Int(arc4random_uniform(UInt32(range.count)))
let emoji = String(UnicodeScalar(ascii))
return emoji
}
}
@eiri
eiri / demo.erl
Created May 24, 2016 13:16
Use io_lib_pretty to pretty print records
-module(demo).
-export([print/0]).
-record(magic_record, {
alpha = 1,
beta = b,
gamma = [x, y, z],
psy,
omega = "done"
@eiri
eiri / mardear.erl
Created April 19, 2016 01:21
Write and read in ram file in erlang
-module(mardear).
-export([readram/0]).
readram() ->
{ok, Fd} = file:open([], [ram, write, read]),
IoData = io_lib:format("~s", [[$r, $a, $m]]),
ok = file:write(Fd, IoData),
{ok, Str} = file:pread(Fd, 0, 8192),
ok = file:close(Fd),
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then