This file contains hidden or 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 | |
// using generators (yield) to recursively read files from a source path | |
// more: http://www.php.net/manual/en/language.generators.php | |
foreach (readFileSubDir('~/testdir') as $fileItem) { | |
echo($fileItem . "\n"); | |
} | |
function readFileSubDir($scanDir) { |
Example /etc/nginx/nginx.conf
using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.
Will need to create a directory to hold cache files, for the example given here that would be:
$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
This file contains hidden or 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 | |
$testExpression = '/(?i)te(?-i)st/'; | |
testPCRESectionOnly($testExpression,'test'); | |
testPCRESectionOnly($testExpression,'TEst'); | |
testPCRESectionOnly($testExpression,'teST'); | |
testPCRESectionOnly($testExpression,'TEST'); | |
/* | |
Should return: |
PHP script that takes a mysqldump file and brute force replaces URLs into an output dump file.
Ensure to dump the source SQL database using the --skip-extended-insert
switch to ensure INSERT INTO()
statements don't end up on singular and very long lines, which won't help the script crunch all the replacements.
E.g.
$ mysqldump \
-hlocalhost -uUSERNAME -p \
This file contains hidden or 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
#!/bin/bash -e | |
if [[ -z $1 ]]; then | |
echo "Usage: $(basename "$0") [Gist ID/SHA1]" | |
exit 1 | |
fi | |
# create temp directory, clone Gist | |
gitTempDir=$(mktemp --directory "/tmp/gistreset.XXXXX") | |
git clone "[email protected]:$1" "$gitTempDir" |
This file contains hidden or 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
IgnoreAgent +http://www.baidu.com/search/spider.html) | |
IgnoreAgent ; 360Spider | |
IgnoreAgent ; Claritybot) | |
IgnoreAgent ; Google Web Preview) | |
IgnoreAgent ; Googlebot | |
IgnoreAgent Aboundex/* | |
IgnoreAgent Apache-HttpAsyncClient/* | |
IgnoreAgent Apache-HttpClient/* | |
IgnoreAgent AppEngine-Google* | |
IgnoreAgent Baiduspider* |
This file contains hidden or 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
// creates a window.nextTick(handler) method with support for IE8+ | |
// emulating Node.js process.nextTick() method | |
// http://nodejs.org/api/process.html#process_process_nexttick_callback | |
// note: IE8 will use a zero time setTimeout, which should fire within 4-10ms | |
(function(win) { | |
var NEXT_TICK_MESSAGE_NAME = 'next-tick', | |
nextTickHandlerList = []; | |
if (win.addEventListener) { |