Skip to content

Instantly share code, notes, and snippets.

View ahmoin's full-sized avatar
:shipit:

Ahsan Moin ahmoin

:shipit:
View GitHub Profile
@nanis
nanis / random_real.c
Created August 14, 2015 21:12
Originally at http://mumble.net/~campbell/tmp/random_real.c Saved here for reference (as allowed by the copyright statement)
/*
* Uniform random floats: How to generate a double-precision
* floating-point number in [0, 1] uniformly at random given a uniform
* random source of bits.
*
* Copyright (c) 2014, Taylor R Campbell
*
* Verbatim copying and distribution of this entire article are
* permitted worldwide, without royalty, in any medium, provided
* this notice, and the copyright notice, are preserved.
@jrus
jrus / lua-uuid.lua
Created July 29, 2012 09:26
quick lua implementation of "random" UUID
local random = math.random
local function uuid()
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
end)
end