Skip to content

Instantly share code, notes, and snippets.

View osde8info's full-sized avatar

Clive D osde8info

View GitHub Profile
@osde8info
osde8info / .bash_aliases
Created November 17, 2014 12:26
.bash_aliases
# bash diff aliases
#
alias diffr='diff -qrX ~/.di'
alias diffs='diff --suppress-common-lines -y'
@osde8info
osde8info / dbt.php
Created July 31, 2015 13:43
PHP DEBUG_BACKTRACE_IGNORE_ARGS
$dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach($dbt as $d){
echo $d['class'].$d['function'].$d['line'].PHP_EOL;
}
@osde8info
osde8info / simplexmlexport.php
Last active September 3, 2015 13:31
convert php simplexml xml node to consistent array or json for one or more children with values and attributes intact
/*
** 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;
}
@osde8info
osde8info / crontab
Last active November 26, 2015 16:28
use cron to run 2 python scripts and redirect output and errors to 2 logfiles
# crontab
* * * * * python y.py > $(date +\%F-\%H-\%M-\%S).txt 2>&1 ; python z.py > $(date +\%F-\%H-\%M-\%S).txt 2>&1
@osde8info
osde8info / mysqldump tables
Last active December 9, 2015 17:01
mysqldump tables
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
@osde8info
osde8info / mysqldump of specific tables
Last active December 9, 2015 17:09
mysqldump of specific tables
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
@osde8info
osde8info / .htaccess
Created May 13, 2013 21:06
htaccess anti-spam
# block referrer spam
SetEnvIfNoCase Referer ".*(badword1|badword2|badword3|badword4|xxx).*" BadReferrer
order deny,allow
deny from env=BadReferrer
@osde8info
osde8info / .htaccess
Last active December 17, 2015 07:18
htaccess for index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*/[^\./]*[^/])$ $1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?action=$1 [QSA,L]
</IfModule>
@osde8info
osde8info / phpassoc2xml
Created December 20, 2015 13:37
php assoc array to xml and json serialiser
<?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)) {
@osde8info
osde8info / gist:1b0cc8091937f3fb14c46f4b23633fec
Created March 13, 2018 11:43
create a bootable usb from an .iso with dd
# dd status=progress if=linux-lite-3.8-32bit.iso of=/dev/sdb bs=4M