Skip to content

Instantly share code, notes, and snippets.

@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
@eiri
eiri / gist:92ceceb090c251aa4e46
Created March 28, 2016 16:08
Listing for _compact, _rev_limit and _purge in Couch
$ curl $db/neato -XPUT
{“ok”:true}
$ curl $db/neato -XPOST -H’Content-Type: application/json’ -d’{“key”: 1}’
{“ok”:true,”id”:”b24a8da105719f433651feabff001d5d”,”rev”:”1-c77eb5d5af83163c996ea42b61a9f0d8”}
$ curl $db/neato/b24a8da105719f433651feabff001d5d -G -s | jq .
{
“_id”: “b24a8da105719f433651feabff001d5d”,
“_rev”: “1-c77eb5d5af83163c996ea42b61a9f0d8”,
@eiri
eiri / README.md
Created March 28, 2016 15:38
Simple python CLI url encoder

Drop it in ~/bin and use as following

vagrant@karas:~/git$ echo voluptatem%:doloribus | urlencode 
voluptatem%25%3Adoloribus