Skip to content

Instantly share code, notes, and snippets.

-module(pecypc_session).
-author('Vladimir Dronnikov <dronnikov@gmail.com>').
-include_lib("stdlib/include/qlc.hrl").
%% -----------------------------------------------------------------------------
%% API exports
%% -----------------------------------------------------------------------------
-export([
@dvv
dvv / start.sh
Created June 1, 2013 14:53
Start Erlang
#!/bin/sh -x
# windows
if test "x$USERPROFILE" != x; then
DIRSEP=';'
ERL='start werl'
# *nix
else
DIRSEP=':'
ERL=erl
fi
@dvv
dvv / .erlang
Created March 28, 2013 18:59
Erlang shortcuts
code:load_abs(os:getenv("HOME") ++ "/.ebin/user_default"),
io:format("You may use r() to recompile the code, t() to recompile templates under priv/templates.~n", []).
@dvv
dvv / ua.erl
Created January 13, 2013 10:39
A draft of user agent determination
-spec user_agent_platform(binary()) -> undefined | atom().
user_agent_platform(Header) ->
user_agent(cowboy_bstr:to_lower(Header), [
{<<"windows">>, windows},
{<<"linux">>, linux},
{<<"os x ">>, osx},
{<<"android">>, android},
{<<"ipod">>, ipod},
{<<"iphone">>, iphone},
@dvv
dvv / peectp.erl
Created January 12, 2013 07:54
Process registrar -- gproc wrapper
%%
%% @doc Generic process registrar and operating primitives.
%% Basically, gproc wrapper.
%%
-module(peectp).
-author('Vladimir Dronnikov <dronnikov@gmail.com>').
%%
%% -----------------------------------------------------------------------------
@dvv
dvv / handler.erl
Created December 18, 2012 12:13
An attempt at hiding cookie session details in cowboy handler
-module(handler).
-author('Vladimir Dronnikov <dronnikov@gmail.com>').
-define(INFO, error_logger:info_report).
-define(ERROR, error_logger:error_report).
%%
%% ------------------------------------------------------------------
%% cowboy HTTP handler API
%% ------------------------------------------------------------------
@dvv
dvv / gist:4181331
Created December 1, 2012 09:44
naive moonslice-luv performance test
Latest moonslice-luv hello world:
[dvv@dvv take6]$ wrk -c20k -r1000k http://localhost:8080/greet
Making 1000000 requests to http://localhost:8080/greet
2 threads and 20000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 268.44ms 334.12ms 2.37s 81.42%
Req/Sec 6.51k 1.99k 8.00k 88.55%
1000160 requests in 1.02m, 132.58MB read
Socket errors: connect 0, read 8774, write 0, timeout 257854
@dvv
dvv / gist:2501729
Created April 26, 2012 18:33
package.searchpath experiment
#!/usr/bin/env luajit2
local Util = require('utils')
local p = Util.prettyPrint
local resolve
do
local ffi = require('ffi')
local C = ffi.C
ffi.cdef[[
@dvv
dvv / gist:1610685
Created January 14, 2012 08:01
MoonScript + CoffeeScript syntax
is, isnt
====
is, isnt ---> ==, ~=
else if
====
if 1
p(1)
@dvv
dvv / gist:1507626
Created December 21, 2011 20:45
Adding Luvit Worker
1.
Install https://github.com/luvit/luvm
It's basically creationix/nvm ported to luvit.
The only change is the absence of 'v' prefix for versions. I found it redundant.
Nothing surprising should happen, it should require nothing beyond build-essentials.
So after vanilla sourcing luvm with `cd ~/.luvm ; . luvm.sh` and running `luvm install 0.1.4` you should have on the PATH:
- luvit binary
- lui: headless dependency fulfiller
- luvit-config: a pkg-config surrogate