Skip to content

Instantly share code, notes, and snippets.

Avatar

Boris Okner bokner

  • Barrie, ON, Canada
View GitHub Profile
View gist:7ac36dd96d1409fee3e7881d593ff900
cd minisearch
## Note the path for solver executable
minisearch --stdlib-dir ./share/minizinc --solver /snap/minizinc/254/bin/fzn-gecode n_queens.mzn
Solution 1:
8 queens, CP version:
. Q . . . . . .
. . . Q . . . .
. . . . . Q . .
. . . . . . . Q
View Load script into the JS console
async function loadScript(url) {
let response = await fetch(url);
let script = await response.text();
eval(script);
}
loadScript("https://cdn.jsdelivr.net/pako/1.0.3/pako.min.js")
View LTTng: create session and channel
## Commands to create lttng session/channel, start, stop and view results
### Create session 'test-0131' and channel 'ejabberd', specify the buffer size (4M)
lttng create test-0131
sudo lttng enable-channel ejabberd -u --subbuf-size=4M --session=test-0131
## Enable tracepoints (function_call and function_return)
sudo lttng enable-event -u org_erlang_dyntrace:function_return -c ejabberd
sudo lttng enable-event -u org_erlang_dyntrace:function_call -c ejabberd
@bokner
bokner / LTTng+erlang:trace
Last active Feb 10, 2017
LTTng+erlang:trace for tracing function calls/returns
View LTTng+erlang:trace
1> l(dyntrace).
{module,dyntrace}
2> Match = [{'_', [], [{return_trace}]}]. %% Enable return trace for functions of any arity
[{'_',[],[{return_trace}]}]
3> erlang:trace_pattern({'_','_','_'}, Match, []). %% Trace all functions
2411
4> erlang:trace(all, true, [call,{tracer,dyntrace,[]}]). %% Trace function calls with dyntrace (i.e. LTTng)
@bokner
bokner / erl
Created Dec 20, 2015 — forked from sideshowcoder/erl
debug erlang nif code with lldb
View erl
#!/bin/sh
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 1996-2012. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
@bokner
bokner / gist:b46f89c76d078b83ecf9
Last active Aug 29, 2015
Function call with attempts of recovery on failure
View gist:b46f89c76d078b83ecf9
%% @author bokner
%% @doc Implementation of function call with recovery
-module(recovery_test).
%% ====================================================================
%% API functions
%% ====================================================================
-export([test/1]).
View gen_client_test.erl
#!/usr/bin/env escript
main([]) ->
{ok, Client} = gen_client:start("some_user@woow.com", "localhost", 5222, "password"),
%% We can add any number of handlers (callbacks) to the session
%% Message handler
gen_client:add_handler(Client,
fun(#received_packet{packet_type = message, type_attr = "chat", from = Jid}, _Session) ->
@bokner
bokner / digest_auth.erl
Created Apr 10, 2010
Erlang module implementing HTTP digest auth on client side
View digest_auth.erl
%% Author: bokner
%% Created: Apr 10, 2010
%% Description: HTTP digest authentication
%% Note: the code follows the informal explanation given on Wikipedia.
%% Note: the test/0 function doesn't intend to send a proper data to webdav service,
%% it just shows how to pass the authorization.
%% Disclaimer: Use on your own risk. The author disclaims any liability
%% with regard to using this code.
-module(digest_auth).