Skip to content

Instantly share code, notes, and snippets.

View arcusfelis's full-sized avatar

Michael Uvarov arcusfelis

View GitHub Profile
@arcusfelis
arcusfelis / ejabberd.cfg.erl
Last active October 13, 2015 23:05
ejabberd.cfg
{loglevel,3}.
{hosts,["token.get.interval.pl","timeout.get.token.org","timeout.pl",
"interval.org","token.get.user.ru","interval.io","get.pl",
"password.get.interval.ru","get.ru"]}.
{listen,[{60223,mod_queries_sasl_auth_node,[]},
{27640,mod_disco,[]},
{35684,mod_node_open_websockets_metrics,[]},
{52226,mod_vcard_elastic_graphite_metrics_event,[]},
{15125,mod_bosh_mnesia_linux,[]},
{6204,mod_websockets_muc_core_privacy,[]}]}.
@arcusfelis
arcusfelis / nomatch.erl
Created September 28, 2015 12:53
No match
10> <<1>> = <<-2:1, 1:7>>.
<<1>>
11> <<-2:1, 1:7>> = <<1>>.
** exception error: no match of right hand side value <<1>>
@arcusfelis
arcusfelis / wtf.erl
Created September 8, 2015 10:33
wtf
make_element(Src) ->
<img src={Src} />.
digits_only(Src) ->
MP = /^\s*\d+\s*$/,
re_test(Str, MP).
digits_only2(Src) ->
Re = "^\\s*\\d+\\s*$",
time ss -s
Total: 35195 (kernel 35290)
TCP: 34809 (estab 34057, closed 698, orphaned 27, synrecv 0, timewait 73/0), ports 195
Transport Total IP IPv6
* 35290 - -
RAW 0 0 0
UDP 15 11 4
TCP 34111 34106 5
INET 34126 34117 9
@arcusfelis
arcusfelis / portable_fun.erl
Created March 30, 2015 19:46
portable_fun.erl
-module(portable_fun).
%% API
-export([call/2,
call/3]).
%% private
-export([eval_and_apply/3]).
%% Examples
-export([plus_one_f/0,
@arcusfelis
arcusfelis / portable_tracer.erl
Created March 25, 2015 17:16
portable_tracer.erl
-module(portable_tracer).
%% API
-export([spawn_remote_tracer/3,
spawn_tracer/3]).
%% Private
-export([tracer_cycle/1]).
-compile(debug_info).
@arcusfelis
arcusfelis / sad.erl
Created December 3, 2014 21:49
erlang binary performance
-module(sad).
-export([sad1/3,
sad2/3]).
sad1(<<H1,T1/binary>>, <<H2,T2/binary>>, Sum) ->
sad1(T1, T2, Sum + abs(H1-H2));
sad1(<<>>, <<>>, Sum) ->
Sum.
sad2(<<H1,A1,B1,C1,T1/binary>>, <<H2,A2,B2,C2,T2/binary>>, Sum) ->
@arcusfelis
arcusfelis / gist:23f2222d35751b22c2eb
Last active August 29, 2015 14:03
Update cowboy settings runtime

Check, if compression is enabled:

proplists:get_value(compress, ranch:get_protocol_options(http), false).
true

Enable compression:

ranch:set_protocol_options(http, lists:keystore(compress, 1, ranch:get_protocol_options(http), {compress, false})).
@arcusfelis
arcusfelis / tim
Created March 25, 2014 13:30
Vim integration with tmux
#!/bin/bash
filename="$1"
basename="$(basename $1)"
curpath="$(pwd)"
cd "$(dirname $filename)"
pid="$(vim -r 2>&1 | fgrep "$basename.sw" -A 5 | grep 'still running' | sed 's/[^0-9]//g')"
cd "$curpath"
if [ -n "$pid" ]; then
@arcusfelis
arcusfelis / mam-filter-by-id-proposal.md
Last active January 1, 2016 04:49
MAM with filtering messages by id

To limit amount of inspected messages we can use "start" and "end" elements.

<iq type='get'>
  <query xmlns='urn:xmpp:mam:tmp'>
      <start>2010-06-07T00:00:00Z</start>
      <end>2010-07-07T13:23:54Z</end>
  </query>
</iq>