Skip to content

Instantly share code, notes, and snippets.

View erkiesken's full-sized avatar

Erki Esken erkiesken

  • @StarshipRobots
  • Tallinn, Estonia
View GitHub Profile
@erkiesken
erkiesken / gist:c34b0d7d1c1d847efa4f
Created June 2, 2014 13:57
haproxy local node dev
global
daemon
maxconn 256
defaults
log global
maxconn 256
mode http
option forwardfor
option http-server-close
@erkiesken
erkiesken / gist:f498f5b943a40d71ea04
Last active August 29, 2015 14:07
Example of Mori lazy_seq
In Clojure (from Clojur Programming book, p94):
(defn random-ints
"Returns a lazy seq of random integers in the range [0,limit)."
[limit]
(lazy-seq
(cons (rand-int limit)
(random-ints limit))))
(take 10 (random-ints 50))
@erkiesken
erkiesken / app.js
Created January 14, 2015 15:31
Node cluster worker blocking send test
var cluster = require("cluster");
var blocked = require("blocked");
var debug = require("debug");
var workers;
if (cluster.isMaster) {
debug = debug("master-"+process.pid);
workers = {};
@erkiesken
erkiesken / zmq-test.js
Created January 14, 2015 16:22
Node cluster IPC with ZMQ
brew install zeromq
npm install debug blocked zmq
DEBUG=* node zmq-test.js
@erkiesken
erkiesken / node_string_primitive_test.js
Created February 3, 2015 13:44
Node string primitive copy test
$ node --expose-gc node_string_primitive_test.js
before var a mem_rss=11.9MB mem_heap_total=3.9MB mem_heap_used=2.1MB
typeof a string
before making array mem_rss=12.5MB mem_heap_total=5.9MB mem_heap_used=1.8MB
after making array mem_rss=12.6MB mem_heap_total=5.9MB mem_heap_used=1.9MB
after gc mem_rss=12.6MB mem_heap_total=5.9MB mem_heap_used=1.9MB
@erkiesken
erkiesken / gist:6bb756f7e166f8459eae
Created February 12, 2015 12:25
secure_random.js
function secure_rand(min, max) {
var rval = 0;
var range = max - min;
if (range < 2) {
return min;
}
var bits_needed = Math.ceil(Math.log2(range));
if (bits_needed > 53) {
throw new Exception("We cannot generate numbers larger than 53 bits.");
@erkiesken
erkiesken / ETV stream request 1
Created April 26, 2015 18:42
ETV iOS app 404
GET /live/smil:etv.smil/playlist.m3u8 HTTP/1.1
Host: wowza4.err.ee
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-us
Connection: keep-alive
User-Agent: ERR/1.3 CFNetwork/711.3.18 Darwin/14.0.0
HTTP/1.1 200 OK
@erkiesken
erkiesken / heka-output
Created May 8, 2015 16:02
Simple Heka HttpListenInput debug output
2015/05/08 19:01:30 Input 'http-input': Listening on 127.0.0.1:1234
2015/05/08 19:01:36
:Timestamp: 2015-05-08 16:01:36.03994348 +0000 UTC
:Type: heka.httpdata.request
:Hostname: Erki-Mac.lan
:Pid: 83675
:Uuid: 0ad67214-8f54-4793-8e33-ba1563071db7
:Logger: http-input
:Payload: {"foo": "bar"}
:EnvVersion: 1
@erkiesken
erkiesken / README haproxy letsencrypt
Last active January 5, 2016 10:01
haproxy letsencrypt automation
From article:
https://blog.brixit.nl/automating-letsencrypt-and-haproxy
@erkiesken
erkiesken / node-repl-inspect-customInspect.md
Last active February 24, 2016 20:51
Disabling node repl util.inspect customInspect

When objects implement inspect method but its not meant for inspection then problems might occur.

For example with rxjs package:

> Rx = require("rxjs/Rx")
{ Subject: { [Function: Subject] create: [Function] },
  Observable:
…