Skip to content

Instantly share code, notes, and snippets.

View Laymer's full-sized avatar
:shipit:
Looking for cool C, TCL & Erlang things to test

Igor K Laymer

:shipit:
Looking for cool C, TCL & Erlang things to test
View GitHub Profile
@Laymer
Laymer / gist:23905df49f787533aebb4a57fc3080a4
Created August 10, 2018 01:53 — forked from chrissimpkins/gist:5bf5686bae86b8129bee
Atom Editor Cheat Sheet (Sweetmeat)

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@Laymer
Laymer / refc_leak.erl
Created August 16, 2018 17:30 — forked from ferd/refc_leak.erl
Find Erlang processes that may be leaking refc binaries
f(MostLeaky).
MostLeaky = fun(N) ->
lists:sublist(
lists:usort(
fun({K1,V1},{K2,V2}) -> {V1,K1} =< {V2,K2} end,
[try
{_,Pre} = erlang:process_info(Pid, binary),
erlang:garbage_collect(Pid),
{_,Post} = erlang:process_info(Pid, binary),
{Pid, length(Post)-length(Pre)}
@Laymer
Laymer / gist:af1e3bcf4dcc0e81cb456c2bb5d86091
Created November 20, 2018 13:08 — forked from toraritte/gist:2eddbbddddc4841d403c
net_kernel:connect/1 VS net_kernel:connect_node/1

=== CALL TRACE OF net_kernel:connect\1

% otp/lib/kernel/src/net_kernel.erl
connect(node_name@machine) -> do_connect(node_name@machine, normal, false). ->
  %          Node,              Type,   WaitForBarred
  do_connect(node_name@machine, normal, false           ) -> %% Type = normal | hidden
    case catch ets:lookup(sys_dist, Node) of
        % [{connection, ...}] if node is in sys_dist
        % []                  if not
	{'EXIT', _} ->
@Laymer
Laymer / binaries.erl
Created November 20, 2018 13:09 — forked from toraritte/binaries.erl
Erlang binaries and unicode
% because 256 needs 9 bits to represent it
% although it is 2^8
62> <<256>>.
<<0>>
% because the segments of an Erlang binary
% has to be divisible by 8. Hence
% 1000 0000, 0
57> <<256:9>>.
<<128,0:1>>
@Laymer
Laymer / client_eqc.erl
Created November 26, 2018 18:53 — forked from jlouis/client_eqc.erl
EQC Cluster example
-module(client_eqc).
-compile(export_all).
-include_lib("eqc/include/eqc.hrl").
-include_lib("eqc/include/eqc_component.hrl").
api_spec() ->
#api_spec {
language = erlang,
modules = [
@Laymer
Laymer / eqc.md
Created November 26, 2018 19:13 — forked from efcasado/eqc.md
A gentle introduction to (Erlang) QuickCheck

Erlang QuickCheck

What is QuickCheck?

QuickCheck is a language for stating properties of programs.

?FORALL(X, nat(), X*X >= 0)
@Laymer
Laymer / test.erl
Created December 18, 2018 13:07 — forked from yjh0502/test.erl
Simple erlang messaging benchmark
-module(test).
-compile([export_all]).
waitdown(0) -> ok;
waitdown(Count) ->
receive
{'DOWN', _, process, _, normal} ->
waitdown(Count-1)
end.
@Laymer
Laymer / crash_safari.html
Created January 27, 2019 20:24 — forked from captbaritone/crash_safari.html
Crash Safari
<script>
var context = new (window.AudioContext || window.webkitAudioContext)();
function start () {
var source = context.createOscillator();
var chanMerge = context.createChannelMerger(2);
var filter = context.createBiquadFilter();
source.connect(chanMerge, 0, 0);
source.connect(chanMerge, 0, 1);
#!/usr/bin/python
# Credit to frogor for the objc
from Foundation import NSBundle
import json
import objc
import os
import plistlib
import subprocess
bool checkCert(JNIEnv *env, jobject contextObject) {
jclass contextTemp = env->FindClass("android/content/Context");
jclass contextClass = (jclass) env->NewGlobalRef(contextTemp);
jmethodID getPackageManager = env->GetMethodID(contextClass,
"getPackageManager",
"()Landroid/content/pm/PackageManager;");
jobject share = (jobject) env->CallObjectMethod(contextObject, getPackageManager);
jmethodID getPackageName = env->GetMethodID(contextClass, "getPackageName",
"()Ljava/lang/String;");