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
// ESCAPE HTML CHRACTERS WHEN OUTPUTTING DATA FROM DB | |
function html_escape($raw_input) | |
{ | |
return htmlspecialchars($raw_input, ENT_QUOTES, 'UTF-8'); | |
} |
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
// CREATE SECRET TOKEN | |
function generate_secure_token($length = 16) | |
{ | |
return bin2hex(openssl_random_pseudo_bytes($length)); | |
} |
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
// PRODUCE A 2D ARRAY FROM CSV | |
function get2DArrayFromCsv($file, $delimiter) | |
{ | |
if (($handle = fopen($file, "r")) !== false) { | |
$i = 0; | |
while (($lineArray = fgetcsv($handle, 4000, $delimiter)) !== false) { | |
for ($j = 0; $j < count($lineArray); $j++) { | |
$data2DArray[$i][$j] = $lineArray[$j]; | |
} | |
$i++; |
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
// DIFFERENCE BETWEEN TWO TIMESTAMPS | |
// Time format is UNIX timestamp or PHP strtotime compatible strings | |
function dateDiff($time1, $time2, $precision = 6) | |
{ | |
// If not numeric then convert texts to unix timestamps | |
if (!is_int($time1)) { | |
// $time1 = strtotime($time1); | |
} | |
if (!is_int($time2)) { | |
// $time2 = strtotime($time2); |
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
//RMEOVE ALL EMPTY VALUES FROM ARRAY | |
function arrayNonEmptyItems($input) | |
{ | |
// If it is an element, then just return it | |
if (!is_array($input)) { | |
return $input; | |
} | |
$non_empty_items = array(); | |
foreach ($input as $key => $value) { |
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
// REPLACE CURL'S DEFAULT exec_follow | |
function curlExecFollow($ch, &$maxredirect = null) | |
{ | |
// we emulate a browser here since some websites detect | |
// us as a bot and don't let us do our job | |
$user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5)"." Gecko/20041107 Firefox/1.0"; | |
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); | |
$mr = $maxredirect === null ? 5 : intval($maxredirect); |
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
Set phpmyadmin timeout | |
add line to config.inc.php | |
$cfg['LoginCookieValidity'] = 28800; |
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
Capslock::Esc ; Remap Capslock to Esc and shift + CapsLock for normal CapsLock | |
+Capslock:: | |
if GetKeyState("CapsLock", "T") = 1 | |
{ | |
SetCapsLockState, off | |
} | |
else if GetKeyState("CapsLock", "F") = 0 | |
{ | |
SetCapsLockState, on | |
} |
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 didScroll = false; | |
var html = document.body.parentNode; | |
var scrollOffset = 500; | |
var scrollingClass = 'scrolling'; | |
window.onscroll = addClassToHtml; | |
function addClassToHtml() { | |
didScroll = true; |
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
@echo off | |
setlocal EnableExtensions EnableDelayedExpansion | |
echo. | |
echo ============================================================ | |
echo. | |
echo RANDOM FILE RENAMER | |
echo. | |
echo by Ifor Waldo Williams ^<ifor@designedbywaldo.com^> | |
echo. | |
echo. |
OlderNewer