Skip to content

Instantly share code, notes, and snippets.

<?php
function array2table( $expression, $return = false ) {
$expression = (array)$expression;
$keys = array_keys($expression[0]);
$html = "<table class=\"arr2tbl\">";
//headers
$html .= "<thead>";
$html .= "<tr>";
@triple-j
triple-j / .gitconfig
Created September 10, 2014 16:16
The "git tree" command is an alias I defined in my ~/.gitconfig: (http://feeding.cloud.geek.nz/posts/cherry-picking-range-of-git-commits/)
[alias]
tree = log --oneline --decorate --graph
@triple-j
triple-j / use-albums.md
Last active August 29, 2015 14:06
Direct links to the albums put together by [Ubuntu Satanic Edition](http://ubuntusatanic.org/music.php)
@triple-j
triple-j / Readme.md
Last active August 29, 2015 14:10 — forked from endolith/Readme.txt
@triple-j
triple-j / command_prompt.php
Created February 24, 2015 16:38
Get access to the command prompt through PHP (for testing purposes only)
<?php
if ( isset($_POST['cmd']) ) {
$_POST['cmd'] = stripslashes($_POST['cmd']);
#$output = shell_exec( escapeshellcmd($_POST['cmd']) );
$out_arr = array();
$exitcode = null;
exec( $_POST['cmd'], $out_arr, $exitcode );
$output = "exitcode: {$exitcode}".PHP_EOL;
$output .= implode( $out_arr, PHP_EOL );
/*if ( isset($_POST['ignoreHTML']) ) {
@triple-j
triple-j / console.js
Created March 5, 2015 23:16
console "polyfill" -- http://stackoverflow.com/a/11638639 (Edgar Villegas Alvarado)
//Ensures there will be no 'console is undefined' errors
window.console = window.console || (function(){
var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function(s){};
return c;
})();
@triple-j
triple-j / mobileBlueLinksFix.css
Last active August 29, 2015 14:18
Mobile IE and iOS blue phone and address links fix
/* override phone auto link colors (IE Mobile & iOS) */
a[href^="maps:"],
a[href^="tel:"] {
color: inherit;
text-decoration: none;
}
function my_sql_regcase($str){
$res = "";
$chars = str_split($str);
foreach($chars as $char){
if(preg_match("/[A-Za-z]/", $char))
$res .= "[".mb_strtoupper($char, 'UTF-8').mb_strtolower($char, 'UTF-8')."]";
else
$res .= $char;
@triple-j
triple-j / unlinkRecursive.php
Created April 22, 2015 20:45
Remove files and directories recursively.
unlinkRecursive( $filepath ) {
if ( is_file($filepath) ) {
unlink($filepath);
} elseif ( is_dir($filepath) ) {
$files = array_diff(scandir($filepath), array('.','..'));
foreach ( $files as $fpath ) {
self::unlinkRecursive($fpath);
}
rmdir($filepath);
}
@triple-j
triple-j / email_regex.txt
Last active August 29, 2015 14:20
Simple Email Name Extract REGEX
/(?:\"?([^\"]*)\"?\s+<?)?([^<>]*)(?:>)?/