Skip to content

Instantly share code, notes, and snippets.

View m-2k's full-sized avatar
🌴
On vacation

Andy m-2k

🌴
On vacation
View GitHub Profile
@m-2k
m-2k / mou.md
Last active August 29, 2015 14:14 — forked from zhenyi2697/mou.md

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

@m-2k
m-2k / site.conf
Last active August 29, 2015 14:16 — forked from paskal/site.conf
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
@m-2k
m-2k / observer.md
Last active August 29, 2015 14:16 — forked from pnc/observer.md

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@m-2k
m-2k / dist.erl
Last active September 11, 2015 06:57 — forked from 5HT/dist.erl
#!/usr/bin/env escript
-module(dist).
-compile([export_all]).
% optimized combinators
int(true) -> 1;
int(_) -> 0.
rev(L) -> lists:reverse(L).
rtr(L) -> rev(tl(rev(L))).
@m-2k
m-2k / index.html
Created January 17, 2016 23:53 — forked from campsjos/index.html
Paper.js canvas responsive resizing
<html>
<head>
<style>
#canvas {
width:100%;
}
</style>
</head>
<body>
<canvas id="canvas" width="800" height="600" resize />
@m-2k
m-2k / gist:39084f48340e1ba1be7a
Created February 4, 2016 23:47 — forked from anvaka/gist:3815296
JavaScript Function Serialization
function functionReplacer(key, value) {
if (typeof(value) === 'function') {
return value.toString();
}
return value;
}
function functionReviver(key, value) {
if (key === "") return value;
@m-2k
m-2k / pipe.erl
Created March 5, 2016 12:54 — forked from kagami-ryuuji/pipe.erl
Elixir-like pipe in Erlang
-module(pipe).
-compile(export_all).
parse_transform(Forms, Options) ->
Forms2 = replace(Forms),
io: format("~p~n", [Forms2]),
Forms2.
replace({lc, Line, {atom, Line2, '|>'}, Path}) ->
pipe(Path);
-define(IS_ALPHA(C),
(C =:= $a) or (C =:= $b) or (C =:= $c) or (C =:= $d) or (C =:= $e) or
(C =:= $f) or (C =:= $g) or (C =:= $h) or (C =:= $i) or (C =:= $j) or
(C =:= $k) or (C =:= $l) or (C =:= $m) or (C =:= $n) or (C =:= $o) or
(C =:= $p) or (C =:= $q) or (C =:= $r) or (C =:= $s) or (C =:= $t) or
(C =:= $u) or (C =:= $v) or (C =:= $w) or (C =:= $x) or (C =:= $y) or
(C =:= $z) or
(C =:= $A) or (C =:= $B) or (C =:= $C) or (C =:= $D) or (C =:= $E) or
(C =:= $F) or (C =:= $G) or (C =:= $H) or (C =:= $I) or (C =:= $J) or
(C =:= $K) or (C =:= $L) or (C =:= $M) or (C =:= $N) or (C =:= $O) or
@m-2k
m-2k / read_write_fifo_erlang.md
Created July 10, 2016 14:45 — forked from jaredmorrow/read_write_fifo_erlang.md
Reading and Writing to Fifo (named pipes) in Erlang

Erlang and Named Pipes

The intention of this post is to provide a solution (with examples) to a somewhat uncommon issue in Erlang. I hate searching for answers to the same problems over and over, and I had a hard time finding answers to this particular problem, so I wrote it all down once I figured it out. If one day you decide to read and write data through fifo's (named pipes) and then decide you want to read or write the other end of the pipe from Erlang, this post is for you.

The Problem

I wanted to read and write to a fifo from a C/C++ app and have an Erlang app communicate over the other end of that fifo. Put simply, Erlang doesn't really support what I was trying to do. You cannot just file:open/2 a fifo, or any special device for that matter, in Erlang and expect it to work. This is documented in Erlang's FAQ.

The Solution! ... ???

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person