Skip to content

Instantly share code, notes, and snippets.

@astadmistry
astadmistry / RollingProbability.jl
Created June 11, 2021 22:28
Rolling probability
function bitarr_to_int(arr, val = 0)
v = 2^(length(arr)-1)
for i in eachindex(arr)
val += v*arr[i]
v >>= 1
end
return val
end
function bitvec_to_pos(bvec)
import Pkg
import Base: SHA1
using SHA, UUIDs
function uuid5(namespace::UUID, key::String)
data = [reinterpret(UInt8, [namespace.value]); codeunits(key)]
u = reinterpret(UInt128, sha1(data)[1:16])[1]
u &= 0xffffffffffff0fff3fffffffffffffff
u |= 0x00000000000050008000000000000000
return UUID(u)