Skip to content

Instantly share code, notes, and snippets.

View mizner's full-sized avatar

Michael Mizner mizner

View GitHub Profile
@mizner
mizner / element-creation.js
Created April 30, 2017 00:04
Element Creation Example in JavaScript
const app = document.getElementById('app');
const createElement = (el, text, newEl) => {
let textNode = document.createTextNode(text),
newElement = document.createElement(newEl),
module = newElement.appendChild(textNode);
el.appendChild(module)
};
// We're using a document fragment to group things up
@mizner
mizner / webpack.config.js
Created June 20, 2017 17:00
Weback HMR for WP Plugin Example
const {resolve} = require('path');
const webpack = require('webpack');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const CONFIG = require('./config.json');
const APP_DIR = resolve(__dirname, 'src');
const BUILD_DIR = resolve(__dirname, 'dist');
module.exports = {
@mizner
mizner / AdditionsXML.php
Created September 5, 2017 16:16
Basic WooCommerce MailChimp Setup
<?php
class AdditionsXML {
public function __construct() {
add_action( 'rss2_item', [ $this, 'attach_to_rss' ] );
add_action( 'rss2_ns', [ $this, 'add_media_namespace' ] );
}
public function add_media_namespace() {
@mizner
mizner / new-ubuntu.md
Last active September 11, 2017 17:09
New Ubuntu Server
  • Connect: ssh root@SERVER
  • Add User: adduser USERNAME
  • Root Privileges: usermod -aG sudo USERNAME
  • Copy Key: ssh-copy-id USERNAME@SERVER
  • Basic Firewall: sudo ufw allow OpenSSH
  • Enable Firewall: sudo ufw enable
  • Update Packages: sudo apt-get update

Apache

  • Install: sudo apt-get install apache2
@mizner
mizner / preferences.default.js
Created September 13, 2017 20:24
Mizner's Sublime Settings
// Place your settings in the file "Packages/User/Preferences.sublime-settings",
// which overrides the settings in here.
//
// Settings may also be placed in syntax-specific setting files, for
// example, in Packages/User/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overridden in the platform
@mizner
mizner / helper.php
Last active October 20, 2017 02:33
WordPress Inline SVG Function
<?php
function wp_svg_icon( $icon = '' ) {
if ( ! $icon ) {
return;
}
$path = get_template_directory() . '/icons/' . $icon . '.svg';
$args = array(
'css_class' => 'icon icon-' . $icon,
);
return wp_get_svg( $path, $args );
@mizner
mizner / svg-functions.php
Created October 20, 2017 02:25 — forked from kingkool68/svg-functions.php
SVG helper functions for WordPress
<?php
// Throw this in your theme and include it in your functions.php file
/**
* Helper function for fetching SVG icons
*
* @param string $icon Name of the SVG file in the icons directory
* @return string Inline SVG markup
*/
function wp_svg_icon( $icon = '' ) {
@mizner
mizner / functions.php
Created October 30, 2017 06:04 — forked from tripflex/functions.php
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@mizner
mizner / user-profile-editing.php
Created December 8, 2017 00:51
User Profile Editing
<?php
function remove_extra_field_profile()
{
$current_file_url = preg_replace( "#\?.*#" , "" , basename( $_SERVER['REQUEST_URI'] ) );
if( $current_file_url == "profile.php" )
{
add_action( 'wp_loaded', function(){ ob_start("profile_callback"); } );
add_action( 'shutdown', function(){ ob_end_flush(); } );
@mizner
mizner / docker.md
Created January 4, 2018 04:16
Docker Commands

Stop all containers

docker stop $(docker ps -a -q)

Delete all containers

docker rm $(docker ps -a -q)

Delete all images

docker rmi $(docker images -q)

Kill all volumes

docker volume prune