Jacob Rus jrus

View lua-uuid.lua
1 2 3 4 5 6 7 8
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
View gist:3113240
1 2 3 4 5 6 7 8 9 10
decode_macroman = do ->
high_chars_unicode = '''
ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü
†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø
¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl
‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ
'''.replace /\n/g, ''
 
(mac_roman_bytestring) ->
char_array = for idx in [0...mac_roman_bytestring.length]
View gist:2145082
1 2 3 4 5 6 7 8 9
# Accepts a list and a key function to apply to each item,
# and then uses a decorate-sort-undecorate pattern to actually
# do the sorting. Returns a new list. Keeps track of the index
# to make sure the sort is stable.
sort_by = (list, key) ->
cmp = ({key: k_a, index: i_a}, {key: k_b, index: i_b}) ->
if k_a == k_b then i_a - i_b else if k_a < k_b then -1 else 1
decorated = ({item, index, key: key item} for item, index in list)
item for {item} in decorated.sort cmp
Something went wrong with that request. Please try again.