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 | |
/** | |
* Inline profiler :) | |
* | |
* $time = s(); | |
* for ($i = 0; $i < 100000; $i++) { | |
* $j = $i + 1; | |
* } | |
* s($time); |
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
var page = { | |
scrollAvailable: true, | |
currentPage: 0, | |
init: function() { | |
var _this = this; | |
$(window).scroll(function () { | |
if ($(window).scrollTop() >= $(document).height() - $(window).height() /* - 10 */) { | |
_this.scroll(); | |
} | |
}); |
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(doc) { | |
var viewport = document.getElementById('viewport'); | |
if ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) { | |
doc.getElementById("viewport").setAttribute("content", "width=1024,initial-scale=0.469"); | |
} else if ( navigator.userAgent.match(/iPad/i) ) { | |
doc.getElementById("viewport").setAttribute("content", "initial-scale=1.0"); | |
} | |
}(document)); |
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('TYPEHINT_PCRE', '/^Argument (\d)+ passed to (?:(\w+)::)?(\w+)\(\) must be an instance of (\w+), (\w+) given/'); | |
class TypeHintException extends Exception {} | |
class TypeHint | |
{ | |
private static $Typehints = 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
function dateFormat(daysAgo) { | |
var d = new Date(); | |
daysAgo = daysAgo || 0; | |
d.setDate(d.getDate() - daysAgo); | |
var date = d.getDate(), | |
month = d.getMonth() + 1, | |
year = d.getFullYear(); |
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_client_ip() | |
{ | |
if (isset($_SERVER['HTTP_CLIENT_IP'])) { | |
$ipaddress = $_SERVER['HTTP_CLIENT_IP']; | |
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} else if (isset($_SERVER['HTTP_X_FORWARDED'])) { | |
$ipaddress = $_SERVER['HTTP_X_FORWARDED']; |
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 | |
use PDO; | |
use PDOStatement; | |
/** | |
* Class Db | |
* Small helper for working with native PDO | |
* | |
* $pdo = new Db(new \PDO( |
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 | |
/* | |
* Convert seconds to human readable text. | |
* Found at: http://csl.sublevel3.org/php-secs-to-human-text/ | |
* | |
*/ | |
function secs_to_h($secs) | |
{ | |
$units = [ |
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 | |
namespace App\Utils; | |
/** | |
* Simple curl wrapper | |
* @package Plariumed\Utils | |
* | |
* $curl = new Curl('http://localhost/api'); | |
* $curl | |
* ->set(CURLOPT_USERPWD, 'appKey:appSecret') |
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 csv_to_array($filename, $delimiter = ',') | |
{ | |
if (!file_exists($filename) || !is_readable($filename)) { | |
return false; | |
} | |
$header = null; | |
$data = []; |