Skip to content

Instantly share code, notes, and snippets.

View incredimike's full-sized avatar
🦉

Mike Walker incredimike

🦉
View GitHub Profile
@incredimike
incredimike / json_decode_nice.php
Last active July 15, 2017 04:34
I added a 3rd regex to the json_decode_nice function by "colin.mollenhour.com" to handle a trailing comma in json definition. Original function here: http://www.php.net/manual/en/function.json-decode.php#95782
<?php
function json_decode_nice($json, $assoc = FALSE){
$json = str_replace(array("\n","\r"),"",$json);
$json = preg_replace('/([{,]+)(\s*)([^"]+?)\s*:/','$1"$3":',$json);
$json = preg_replace('/(,)\s*}$/','}',$json);
return json_decode($json,$assoc);
}
// Example:
@incredimike
incredimike / config.inc.php
Last active November 15, 2019 22:41
PHPMyAdmin - Export Zipped & Drop Tables / Databases by default
<?php # Add the following to config.inc.php
$cfg['Export']['sql_drop_database'] = true;
$cfg['Export']['sql_drop_table'] = true;
$cfg['Export']['compression'] = 'zip';
@incredimike
incredimike / gist:3087059
Created July 11, 2012 00:05
Change permissions on files and directories separately
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
@incredimike
incredimike / gist:2380043
Created April 13, 2012 20:43
Convert MS Word documents to HTML, Markdown
# textutil -convert html file.doc -stdout | pandoc -f html -t markdown -o file.md
see also: https://gist.github.com/2380036
@incredimike
incredimike / any2pandoc.sh
Created April 13, 2012 20:43 — forked from dsanson/any2pandoc.sh
any2pandoc.sh: script that tries to convert documents thrown at it to pandoc's extended markdown
#!/bin/sh
# A shell script that tries its best to convert documents thrown at it
# to pandoc's extended markdown.
#
# Depends on:
#
# + textutil: an OS X only command line utility
# + odt2pandoc.py: a tweaked version of odt2txt.py
# + pdftohtml: a utility for converting pdf to html
@incredimike
incredimike / variousCountryListFormats.js
Last active April 12, 2025 05:30
List of Countries in various Javascript data structures: Alphabetical country lists & Country data objects.
// Lists of countries with ISO 3166 codes, presented in various formats.
// Last Updated: July 30, 2020
// If you're using PHP, I suggest checking out:
// https://github.com/thephpleague/iso3166
// or Laravel: https://github.com/squirephp/squire
//
// JS developers can check out:
// https://www.npmjs.com/package/iso3166-2-db
//