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 | |
function csv_to_array($filename, $delimiter = ',') | |
{ | |
if (!file_exists($filename) || !is_readable($filename)) { | |
return false; | |
} | |
$header = null; | |
$data = []; |
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 | |
/** | |
* Depend from csv_to_array and get_in functions | |
* @link https://gist.github.com/nicklasos/11251754 | |
* @link https://gist.github.com/nicklasos/9206376 | |
*/ | |
function t($phrase) | |
{ | |
static $dictionary; |
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 | |
if (!function_exists('array_column')) { | |
function array_column(array $input, $columnKey, $indexKey = null) { | |
$result = array(); | |
if (null === $indexKey) { | |
if (null === $columnKey) { | |
// trigger_error('What are you doing? Use array_values() instead!', E_USER_NOTICE); | |
$result = array_values($input); |
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
public struct MainPage | |
{ | |
public string Threads { get; set; } | |
public List<Pager> Pages { get; set; } | |
} | |
public struct Pager | |
{ | |
private string filename; | |
public string Filename |
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 | |
include __DIR__ . '/vendor/autoload.php'; | |
$faker = Faker\Factory::create(); | |
$randData = [ | |
'gmt_diff' => 'randomDigitNotNull', | |
'ios_id' => 'uuid', | |
'email' => 'email', |
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 variable_name(&$var) | |
{ | |
$old = $var; | |
$var = $new = 'UNIQUE' . mt_rand() . 'VARIABLE'; | |
$vname = false; | |
foreach($GLOBALS as $key => $val) { | |
if($val === $new) { | |
$vname = $key; |
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 mongo_id_from_time($yourTimestamp) | |
{ | |
static $inc = 0; | |
$ts = pack('N', $yourTimestamp); | |
$m = substr(md5(gethostname()), 0, 3); | |
$pid = pack('n', posix_getpid()); | |
$trail = substr(pack('N', $inc++), 1, 3); |
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 | |
/** | |
* Interactively prompts for input without echoing to the terminal. | |
* Requires a bash shell or Windows and won't work with | |
* safe_mode settings (Uses `shell_exec`) | |
* | |
* @see http://us.php.net/manual/en/function.ncurses-noecho.php | |
* @see http://us.php.net/manual/en/function.ncurses-getch.php | |
* | |
* Works only on normal OS, not in windows. |
OlderNewer