This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setSize(w, h) { | |
if (window.name && w && h) { | |
var innerWidth, innerHeight, width = Math.floor(w), height = Math.floor(h); | |
innerWidth = (window.innerWidth || document.documentElement.clientWidth); | |
innerHeight = (window.innerHeight || document.documentElement.clientHeight); | |
window.resizeBy(Math.floor(width-innerWidth), Math.floor(height-innerHeight)); | |
window.moveTo(Math.floor((screen.availWidth/2)-(width/2)), Math.floor((screen.availHeight/2)-(height/2))); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function utime() { | |
list($usec, $sec) = explode(' ', microtime()); | |
return ((float)$usec + (float)$sec); | |
} | |
// Start benchmarking. | |
$start = utime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sprintf(){ | |
var args = Array.prototype.slice.call(arguments), f:Array = [], str = args.shift().split("%s"); | |
while (str.length) { | |
f.push(str.shift(), args.shift() || ""); | |
} | |
return f.join(""); | |
} | |
trace(sprintf("Hello %s, how ya %s?", "motherf*cker", "durin")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function guid() { | |
function hex(len) { | |
var s = '', n = len || 4; | |
while (s.length < n) { | |
s += (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
} | |
return s.substr(0, n); | |
} | |
return [hex(8), hex(4), hex(4), hex(4), hex(12)].join('-'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_http_status_header($url) { | |
preg_match('/[0-9]{3}/', array_shift(get_headers($url)), $matches); | |
return (int) array_shift($matches); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>fles.ch</title> | |
<!--[if IE]> | |
<script src="http://static.fles.ch/js/html5.js"></script> | |
<![endif]--> | |
<link rel="stylesheet" href="http://static.fles.ch/css/reset-min.css" /> | |
<style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('APP_ROOT', pathinfo(implode('/', array_slice(explode('/', $_SERVER['PHP_SELF']), 1, 2)), PATHINFO_DIRNAME)); | |
define('DOCUMENT_ROOT', str_replace('/.', '', sprintf('%s/%s', $_SERVER['DOCUMENT_ROOT'], APP_ROOT))); | |
define('SERVER_NAME', preg_replace('#^www\.#', '', $_SERVER['SERVER_NAME'])); | |
define('SERVER_URL', sprintf('http://%s/%s', SERVER_NAME, APP_ROOT)); | |
function utime() { | |
list($usec, $sec) = explode(' ', microtime()); | |
return ((float)$usec + (float)$sec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/******************************************************************************* | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php [L,QSA] | |
*******************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function async_request($url) { | |
$request = parse_url($url); | |
if (!isset($request['port'])) { | |
$request['port'] = 80; | |
} | |
$fp = @fsockopen($request['host'], $request['port'], $errno, $errstr, 30); | |
if ($fp) { | |
fwrite($fp, implode("\r\n", array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert string to a timestamp. | |
# str_to_time("01:20") = 80 | |
str_to_time = (str) -> | |
str.replace /^([0-9]{1,2}):([0-9]{2})$/, (t, m, s) -> (m* 60) + parseFloat(s) |
OlderNewer