Skip to content

Instantly share code, notes, and snippets.

View incredimike's full-sized avatar
🦉

Mike Walker incredimike

🦉
View GitHub Profile
@incredimike
incredimike / variousCountryListFormats.js
Last active April 30, 2024 11:10
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
//
@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 / 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 / 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 / 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 / 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('/(,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uYW1l

Keybase proof

I hereby claim:

  • I am incredimike on github.
  • I am incredimike (https://keybase.io/incredimike) on keybase.
  • I have a public key whose fingerprint is 0C61 4943 5490 2401 09CE E3EA 0035 5C1D F3BB 04CA

To claim this, I am signing this object:

<?php
/**
* Media renamer for Obfuscated file names sometimes found when downloading from usenet.
* This script will find scan all directories in $in_path.
* For each directory, it will search for a media file.
* If a media file is found, it will copy that file into the "output path" while also renaming the file to the "basepath" of the containing directory.
*/
$find_extensions = ['mkv','avi'];
$remove_from_filename = ['-Obfuscated','-postbot'];
// Minimidi Teensy Midi Controller
// Mike Walker (http://incredimike.com)
// Based on code originally by Philip Cunningham (http://philipcunningham.org)
// Smoothing hacked from http://www.arduino.cc/en/Tutorial/Smoothing
// Set midi channel to send to 1
int channel = 1;
// Smoothing amount
const int numReadings = 10;