Skip to content

Instantly share code, notes, and snippets.

View mizner's full-sized avatar

Michael Mizner mizner

View GitHub Profile
@mizner
mizner / dircheckexample.sh
Created March 17, 2018 22:59
Bash, if directory exists (with fake ternary)
#!/bin/bash
source ./.env
themes_path=./$dir_wp_content/themes
has_theme_subdirectories=`find $themes_path -maxdepth 1 -type d | wc -l`
[[ has_theme_subdirectories -eq 1 ]] && themes_installed=false || themes_installed=true
@mizner
mizner / fsjson.js
Created March 11, 2018 11:31
Node write to JSON Example
fs.readFile(
'./config.json',
(err, data) => {
let json = JSON.parse(data);
json.externalURL = bs.utils.devIp.shift();
fs.writeFile('./config.json', JSON.stringify(json), err => {
if (err) {
throw err;
}
})
<?php
array_reduce($arr, function ($result, $item) {
$result[$item->term_id] = $item->name;
return $result;
}, []);
@mizner
mizner / iterm.scpt
Created January 14, 2018 19:24
Fix docker quickstart terminal for iTerm2 version 2.9 and later
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
@mizner
mizner / WP-CLI-Commands
Created January 14, 2018 19:24
WP-CLI - Handy Commands
Search and replace
https://wp-cli.org/commands/search-replace/
wp search-replace
wp search-replace 'http://example.dev' 'http://example.com'
Optmize database
https://wp-cli.org/commands/db/optimize/
wp db optimize
Repair database
@mizner
mizner / expecting.md
Created January 14, 2018 19:22
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@mizner
mizner / 0Option2ConstructorSummary.md
Created January 14, 2018 19:22
New ES6 constructor features and semantics: Alternative 2 manual super in derived classes

New ES6 Constructor Semantics and Usage Examples

Manual super: Alternative Design where subclass constructors do not automatically call superclass constructors

This Gist presents a new design of class-based object construction in ES6 that does not require use of the two-phase @@create protocol.

One of the characteristics of this proposal is that subclass constructors must explicitly super invoke their superclass's constructor if they wish to use the base class' object allocation and initialization logic.

An alternative version of this design automatically invokes the base constructor in most situations.

@mizner
mizner / wp_mail.md
Created January 14, 2018 19:21
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.8, and includes some upcoming changes in WordPress 4.9.

There are a few TODOs left. Please bear with me.

@mizner
mizner / osx_setup.md
Created January 14, 2018 18:34 — forked from millermedeiros/osx_setup.md
Mac OS X setup.

Setup Mac OS X Mountain Lion or Mavericks

Edit: I few months ago I got a new laptop and did the same thing on Mavericks.

I just replaced the hard drive of my mbp and decided to do a clean install of Mountain Lion (10.8.5) since I was still using Snow Leopard (10.6.8).

I kinda regret for not using Boxen to automate the

@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