Skip to content

Instantly share code, notes, and snippets.

View JaheMerah's full-sized avatar

Mindaugas JaheMerah

View GitHub Profile
@JaheMerah
JaheMerah / file_get_cached.php
Last active April 6, 2017 17:29
file_get_contents file_put_contents
<?php
function file_get_cached($url)
{
//config
$dir = 'cache';
$day = 86400; //seconds
$file = $dir . DIRECTORY_SEPARATOR . md5($url);
if (file_exists($file) && filemtime($file) > (time() - $day)) {
@JaheMerah
JaheMerah / lua-uuid.lua
Created March 23, 2017 20:31 — forked from jrus/lua-uuid.lua
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