Skip to content

Instantly share code, notes, and snippets.

"""Looking for collisions in Mooltipass "TRNG" output.
The "TRNG" outputs 32 bit blocks whitened with Jenkins one at a time hash,
keeping no state between samples. Running ent or diehard on the output stream
produces a predictable "pass" result, since these tests do not take the 32 bit
block structure into account.
Excessive collisions found by the following test would disprove the null
hypothesis that each 32 bit sample from the "TRNG" is uniformly distributed.
@amtal
amtal / cpuid.py
Created April 1, 2015 06:54
Poke CPUID from Python via AmihaiN's GetThreadContext wrapper
"""Poke interesting instructions from Python.
Uses the nifty trick in https://github.com/AmihaiN/pyAsm to run snippets then
inspect registers. (Use at own risk, nasm.exe source not verified, etc.)
"""
from pyAsm import pyAsm, A_32BIT
def regs(reg, sep='\n', txt=''):
txt = txt.strip()
acc = []
-- S D O
fp_1 :: (src -> i -> o) -- interpreter
-> src -- + source code
-- partial application magic happens here
-> (i -> o) -- = executable
-- Static Dyn Output
fp_2 :: ((src -> i -> o) -> src -> (i -> o)) -- fp_1
-> (src -> i -> o) -- + interpreter
-- partial application magic happens here
@amtal
amtal / gist:669875
Created November 9, 2010 21:43
*.erl
::::::::::::::
t.erl
::::::::::::::
-module(t).
-export([go/0, l/0, run/1]).
%% @doc load
l()->
net_adm:ping('a@ak-desktop'),
net_adm:ping('b@ak-desktop'),
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
import Data.Vector as V
import Data.Word
import Data.Bits
data Instr = Seed Word32
| Mutate Word32
| JmpFwd Word16
| JmpRev Word16
@amtal
amtal / gist:873987
Created March 17, 2011 08:02
Augment code with tracing capability!
> (c 'trace)
#(module trace)
> (l 'trace)
(#(module trace))
> (: trace start)
IN [ myfunc, x=0 ]
IN [ myfunc, x=1 ]
IN [ myfunc, x=2 ]
IN [ myfunc, x=3 ]
OUT[ myfunc, x=3 => 0 ]
%% @doc Function description.
-spec f( Item::type() % description of item
, Action::type() % yet another description
...
) -> type() % blah
f(Item,Action) ->
We couldn’t find that file to show.
ak@rifter:~/code/erl/erlang_rebar_example_project$ rebar generate-upgrade previous_release=dummynode_first -v
DEBUG: Rebar location: "/home/ak/bin/rebar"
DEBUG: Entering /home/ak/code/erl/erlang_rebar_example_project
DEBUG: Available deps: []
DEBUG: Missing deps : []
DEBUG: Predirs: ["/home/ak/code/erl/erlang_rebar_example_project/apps/dummy_app",
"/home/ak/code/erl/erlang_rebar_example_project/rel"]
DEBUG: Entering /home/ak/code/erl/erlang_rebar_example_project/apps/dummy_app
DEBUG: Available deps: []
DEBUG: Missing deps : []
{excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)",
"^.git/.*"]},
{excl_archive_filters, [".*"]},