Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
@dominicletz
dominicletz / find_fragmentation.erl
Created June 2, 2020 16:21
Erlang script to show used vs. allocated carrier sizes to find impact of memory fragmentation
f().
Str = fun(X) -> io_lib:format("~p", [X]) end.
Percent = fun
(A, 0) -> "100%";
(A, B) -> [Str(round(100*A/B)), "%"]
end.
Get = fun
@mrspeaker
mrspeaker / org-babel-js-fix.org
Last active November 16, 2022 10:35
"require(...).print is not a function" fix for org-babel:js

Org-babel-js fix

When evaluating this code in an org-mode document:

const sq = x => x * x;
const cube = x => sq(sq(x));
return cube(4);
@avinoamsn
avinoamsn / wslTerminator.vbs
Last active July 3, 2022 16:31
VBScript for quietly launching a Terminator window in WSL with VcXsrv. Code comments link to the guides I referenced while writing the script.
' NOTE: additional discussion & implementations can be found here: https://gist.github.com/ropnop/10800fb5066bd5144d9aaad55a8a4d18
' https://medium.com/@bhupathy/install-terminator-on-windows-with-wsl-2826591d2156
set shell = WScript.CreateObject("Shell.Application")
if not IsProcessRunning("vcxsrv.exe") then
shell.shellExecute "vcxsrv.exe", ":0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto", "C:\Program Files\VcXsrv\", "", 0
end if
shell.ShellExecute "bash", "-c -l ""DISPLAY=:0 terminator""", "", "open", 0
' https://stackoverflow.com/questions/19794726/vb-script-how-to-tell-if-a-program-is-already-running
@g-andrade
g-andrade / decode_erlang_external_term_format.erl
Last active November 1, 2020 03:28
Decoding Erlang's external term format (incomplete)
-module(decode_erlang_external_term_format).
-export([binary_to_term/1]).
binary_to_term(<<131, 80, _UncompressedSize:32, CompressedData/binary>>) ->
Data = zlib:uncompress(CompressedData),
decode(Data);
binary_to_term(<<131, Data/binary>>) ->
decode(Data).
decode(<<82, _AtomCacheReferenceIndex, _Rest/binary>>) ->
@erszcz
erszcz / graph_fsm.erl
Created March 15, 2016 16:34
Vance Shipley's graph_fsm - a tool for drawing Erlang gen_fsm diagrams (http://www1.erlang.org/pipermail/erlang-questions/2001-October/003716.html)
%% graph_fsm.erl
%%
%% Author: Vance Shipley, Motivity Telecom Inc. <vances@motivity.ca>
%% Date: November, 2000
%%
%%
%% This library is free software; you can redistribute it and/or
%% modify it under the terms of the GNU Lesser General Public
%% License as published by the Free Software Foundation; either
%% version 2 of the License, or (at your option) any later
@robertoaloi
robertoaloi / kill-erlang-node.sh
Created February 8, 2014 13:55
Kill an Erlang process by node name
#!/usr/bin/env bash
# Kill an Erlang process by node name
#
# e.g.: kill-erlang-node kred
# Check usage
if [ -z "$1" ]; then
echo "Usage: `basename $0` NODE_NAME"
exit 1
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: