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
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^(.*/[^\./]*[^/])$ $1/ | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ index.php?action=$1 [QSA,L] | |
</IfModule> |
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
# block referrer spam | |
SetEnvIfNoCase Referer ".*(badword1|badword2|badword3|badword4|xxx).*" BadReferrer | |
order deny,allow | |
deny from env=BadReferrer |
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
# bash diff aliases | |
# | |
alias diffr='diff -qrX ~/.di' | |
alias diffs='diff --suppress-common-lines -y' |
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 | |
/* From: http://www.php.net/manual/en/function.str-getcsv.php#88773 and http://www.php.net/manual/en/function.str-getcsv.php#91170 */ | |
if(!function_exists('str_putcsv')) | |
{ | |
function str_putcsv($input, $delimiter = ',', $enclosure = '"') | |
{ | |
$csv = fopen('php://temp','r+'); |
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
$dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
foreach($dbt as $d){ | |
echo $d['class'].$d['function'].$d['line'].PHP_EOL; | |
} |
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
assuming user and pass are defined in .my.cnf | |
$ mysqldump -h myhost --skip-lock-tables --compact --max_allowed_packet=64M \ | |
mydb $(mysql -h myhost mydb -N -e "show tables like 'myprefix%'") \ | |
> db.sql |
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
/* | |
** http://stackoverflow.com/questions/23766159/php-simplexml-arrays-generated-differently-for-single-child-and-multiple-child | |
*/ | |
$out = array(); | |
foreach ($xmlobj->MainNode as $childnode) { | |
foreach ($childnode as $n) { | |
$e = new \SimpleXMLElement($n->asXML()); | |
$out[] = $e; | |
} |
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
# crontab | |
* * * * * python y.py > $(date +\%F-\%H-\%M-\%S).txt 2>&1 ; python z.py > $(date +\%F-\%H-\%M-\%S).txt 2>&1 |
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
mysqldump tables into separate files | |
assuming user and pass are defined in .my.cnf | |
$ mysqldump -h myhost --skip-lock-tables --compact --extended-insert --max_allowed_packet=64M --tab=dir_name |
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 | |
// SETUP PHP ARRAY USING HARDCODED JSON INSTEAD OF HARDCODED PHP | |
include 'q.php'; | |
// ACTUAL ASSOC ARRAY TO XML & JSON SERIALISATION STARTS HERE | |
function aatoxml($xml,$ele) { | |
if (is_array($ele)) { |
OlderNewer