Skip to content

Instantly share code, notes, and snippets.

@mxmader
mxmader / wp_plugin_provides_shortcode.php
Created May 18, 2017 15:30
WP Plugin with shortcode example
<?php
/*
* Plugin Name: Pro Soccer Kids Video Player
* Description: Displays static HTML so that TinyMCE can't corrupt our video player code
* Version: 1.0
* Author: jmader@jmader.com
* Author URI: http://jmader.com
*/
function psk_homepage_video(){
@mxmader
mxmader / mysql_to_gdrive.py
Created April 11, 2017 11:08
Upload a gzip-compressed mysql dump to google drive via pipes, generate an email on any failure
#!/usr/bin/env python
import datetime
import mandrill
import os
import subprocess
import sys
import time
class GDriveUploadError(Exception):
@mxmader
mxmader / android_studio_wrapper
Created April 7, 2017 17:48
android studio for linux start script (fedora)
#!/bin/bash
# This script assumes you've installed the Oracle JDK on a Fedora system.
# Copy the script into the bin/ directory of your Android Studio installation base directory.
studio_script="`dirname $0`/studio.sh"
JAVA_HOME=/usr/java/latest
# In the event you want to use the OpenJDK distribution on Fedora, uncomment the below
#JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk.x86_64
@mxmader
mxmader / github_api_example.py
Created April 6, 2017 21:12
Simple GitHub API example using python and personal access token
import requests
import json
####
# inputs
####
username = ''
# from https://github.com/user/settings/tokens
token = ''
@mxmader
mxmader / foreman_mac_validation_testing.rb
Last active April 4, 2017 20:28
analyzing mac addresses rejected by foreman v1.14's new validation logic (excluding non-unicast MAC addresses)
require 'ipaddr'
require 'socket'
IP_REGEXP ||= /\A((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\z/
MAC_REGEXP ||= /\A([a-f0-9]{1,2}:){5}[a-f0-9]{1,2}\z/i
MAC_REGEXP_64BIT ||= /\A([a-f0-9]{1,2}:){19}[a-f0-9]{1,2}\z/i
HOST_REGEXP ||= /\A(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\z/
MASK_REGEXP ||= /\A((255.){3}(0|128|192|224|240|248|252|254))|((255.){2}(0|128|192|224|240|248|252|254).0)|(255.(0|128|192|224|240|248|252|254)(.0){2})|((128|192|224|240|248|252|254)(.0){3})\z/
#!/bin/bash
domain=$1
if [ ! "$domain" ]; then
domain=acedemo.us
fi
echo "installing bind"