Skip to content

Instantly share code, notes, and snippets.

View incredimike's full-sized avatar
🦉

Mike Walker incredimike

🦉
View GitHub Profile
@incredimike
incredimike / eggs_ids.json
Last active April 7, 2020 20:47
Generate a DTLTraders shop in Minecraft with PHP
{
"bat_spawn_egg": {"id":"bat_spawn_egg", "legacy_id":"spawn_egg"},
"blaze_spawn_egg": {"id":"blaze_spawn_egg", "legacy_id":"spawn_egg"},
"cave_spider_spawn_egg": {"id":"cave_spider_spawn_egg", "legacy_id":"spawn_egg"},
"chicken_spawn_egg": {"id":"chicken_spawn_egg", "legacy_id":"spawn_egg"},
"cow_spawn_egg": {"id":"cow_spawn_egg", "legacy_id":"spawn_egg"},
"creeper_spawn_egg": {"id":"creeper_spawn_egg", "legacy_id":"spawn_egg"},
"donkey_spawn_egg": {"id":"donkey_spawn_egg", "legacy_id":"spawn_egg"},
"elder_guardian_spawn_egg": {"id":"elder_guardian_spawn_egg", "legacy_id":"spawn_egg"},
"enderman_spawn_egg": {"id":"enderman_spawn_egg", "legacy_id":"spawn_egg"},
item-0:
id: 38
type: commands
item:
==: org.bukkit.inventory.ItemStack
v: 2230
type: PHANTOM_SPAWN_EGG
meta:
==: ItemMeta
meta-type: SPAWN_EGG
@incredimike
incredimike / hsts-localhost-fix-firefox.sh
Last active November 14, 2019 22:27
Small script that will delete the localhost entry in the Firefox SiteSecurityServiceState.txt file, then prompt you to restart your browser using about:restartrequred. Restarting this way should preserve your tabs.
#!/bin/bash
# Path to the Firefox Profiles directory
FF_PROFILE_PATH="$HOME/Library/ApplicationSupport/Firefox/Profiles"
# Get the "Default" path for your profile.
# Alternatively look for '*.dev-edition-default'
FF_PROFILE_DIR=`cd $FF_PROFILE_PATH; find . -maxdepth 1 -name '*.default' | cut -sd / -f 2-`
# Remove the localhost line in the file, and create a backup
#!/usr/bin/jq -jf
# Original Author: jolmg on HN (https://news.ycombinator.com/item?id=20246727)
#
#
#
# Author notes:
# You whitelist against what the syntax allows for identifiers and then you blacklist reserved keywords.
# Writing it this way makes it easier to verify for correctness when comparing with the ECMAScript Specs.
# This is still a non-exhaustive blacklist and the whitelist regex lacks allowed unicode characters.
@incredimike
incredimike / wp_query_orderby_taxonomy_term_name.php
Last active November 15, 2019 22:39 — forked from jnlsn/functions.php
WP Query Orderby Taxonomy Term Name
add_filter('posts_clauses', 'posts_clauses_with_tax', 10, 2);
function posts_clauses_with_tax( $clauses, $wp_query ) {
global $wpdb;
//array of sortable taxonomies
$taxonomies = array('example-taxonomy', 'other-taxonomy');
if (isset($wp_query->query['orderby']) && in_array($wp_query->query['orderby'], $taxonomies)) {
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb->term_relationships} AS rel2 ON {$wpdb->posts}.ID = rel2.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} AS tax2 ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
// 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;
<?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'];

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:

eyJlbmFibGVDb250ZXh0TWVudSI6dHJ1ZSwiaWdub3JlRmllbGRzV2l0aENvbnRlbnQiOmZhbHNlLCJ0cmlnZ2VyQ2xpY2tFdmVudHMiOnRydWUsImlnbm9yZUhpZGRlbkZpZWxkcyI6dHJ1ZSwiaWdub3JlZEZpZWxkcyI6WyJjYXB0Y2hhIiwiaGlwaW5wdXR0ZXh0Il0sImNvbmZpcm1GaWVsZHMiOlsiY29uZmlybSIsInJlZW50ZXIiLCJyZXR5cGUiLCJyZXBlYXQiXSwicGFzc3dvcmRTZXR0aW5ncyI6eyJtb2RlIjoiZGVmaW5lZCIsInBhc3N3b3JkIjoiUGEkJHcwcmQhIn0sImVtYWlsU2V0dGluZ3MiOnsidXNlcm5hbWUiOiJyYW5kb20iLCJ1c2VybmFtZUxpc3QiOlsiamFjayIsInNwYXJyb3ciLCJmcm9kbyIsImJhZ2dpbnMiXSwiaG9zdG5hbWUiOiJsaXN0IiwiaG9zdG5hbWVMaXN0IjpbImhvdG1haWwuY29tIiwiZ21haWwuY29tIiwieWFob28uY29tIl19LCJmaWVsZE1hdGNoU2V0dGluZ3MiOnsibWF0Y2hMYWJlbCI6ZmFsc2UsIm1hdGNoSWQiOmZhbHNlLCJtYXRjaE5hbWUiOnRydWUsIm1hdGNoQ2xhc3MiOmZhbHNlfSwiZmllbGRzIjpbeyJ0eXBlIjoidXNlcm5hbWUiLCJuYW1lIjoiVXNlcm5hbWUiLCJtYXRjaCI6WyJ1c2VyaWQiLCJ1c2VybmFtZSJdfSx7InR5cGUiOiJmaXJzdC1uYW1lIiwibmFtZSI6IkZpcnN0IE5hbWUiLCJtYXRjaCI6WyJmaXJzdG5hbWUiLCJuYW1lZmlyc3QiXX0seyJ0eXBlIjoibGFzdC1uYW1lIiwibmFtZSI6Ikxhc3QgTmFtZSIsIm1hdGNoIjpbImxhc3RuYW1lIiwic3VybmFtZSIsInNlY29uZG5hbWUiLCJuYW1l
@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: