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
// Source: http://jonasjohn.de/snippets/php/dl-speed-limit.htm | |
// local file that should be send to the client | |
$local_file = 'test-file.zip'; | |
// filename that the user gets as default | |
$download_file = 'your-download-name.zip'; | |
// set the download rate limit (=> 20,5 kb/s) | |
$download_rate = 20.5; |
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
# up 4 -> go up 4 directories | |
up() | |
{ | |
dir="" | |
if [[ $1 =~ ^[0-9]+$ ]]; then | |
x=0 | |
while [ $x -lt ${1:-1} ]; do | |
dir=${dir}../ | |
x=$(($x+1)) | |
done |
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 | |
ip=attr.val(), | |
ipPatt=/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/; | |
// If invalid ip | |
if(!ipPatt.test(ip)) | |
alert('invalid ip'); | |
else | |
alert('valid ip'); |
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
""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" @date 2013-08-12 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set number | |
set nowrap | |
set backupdir=/var/tmp/vimtmp | |
set nobackup | |
set noswapfile | |
set autoindent |
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
$dt = DateTime::createFromFormat('y', '12'); | |
echo $dt->format('Y'); // output: 2012 |
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
date_default_timezone_set('Europe/Istanbul'); | |
$date=date('Y-m-d h:i:s'); | |
list($year,$month,$day,$hour,$minute,$second)=preg_split('/[- :]/',$date); |
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
$patt='/^([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]){1}(\.|\.[1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]){0,3}$/'; | |
/** | |
* Valid IP address examples: | |
* | |
* 192.168.1.1 | |
* 192.168. | |
* 192.168 | |
*/ |
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
URL Encoded Characters | |
backspace %08 | |
tab %09 | |
linefeed %0A | |
creturn %0D | |
space %20 | |
! %21 | |
" %22 | |
# %23 |
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 | |
/** | |
* Cipher Class | |
* | |
* Ciphers text by user defined key. | |
* @date 2013-11-21 | |
* @require php5-mcrypt | |
* @http://www.php.net/manual/en/function.mcrypt-encrypt.php#78531 | |
* @http://stackoverflow.com/questions/1289061/best-way-to-use-php-to-encrypt-and-decrypt-passwords |
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 | |
class SampleClass | |
{ | |
static private $instance; | |
/** | |
* This implements the 'singleton' design pattern | |
*/ | |
static function getInstance() |
OlderNewer