Skip to content

Instantly share code, notes, and snippets.

:octocat:
I may be slow to respond.

Karl Chen kn007

:octocat:
I may be slow to respond.
Block or report user

Report or block kn007

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kn007
kn007 / cwebp.lua
Created Jan 8, 2019
Add convert image to webp support for nginx
View cwebp.lua
--------------------------- Function ---------------------------------
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
------------------------------------------------------------------------
if ngx ~= nil then
@kn007
kn007 / test.php
Last active Dec 11, 2017
get EXTENSION performance: preg_match vs pathinfo
View test.php
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
@kn007
kn007 / test.php
Last active Oct 8, 2017
performance: mt_rand vs openssl_random_pseudo_bytes vs random_bytes vs uniqid vs uuid
View test.php
<?php
define('LOOP_COUNT',100000);
function create_uuid_v4(){
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
You can’t perform that action at this time.