macOS Setup

Draft

This is a draft article, so it’s incomplete!

Table of contents

  1. Finder Preferences

    Finder Preferences

    Finder -> Preferences

    • General
      • Show these items on the desktop – Click all
    • Advanced
      • Show file extensions.
      • Show Folders on Top -> In windows when sorting by name

    macOS Setup iTerm2 + Homebrew + ZSH

    This guide is my setup on my macOS laptop with iTerm + Homebrew + ZSH.

    Step 1 – Install iTerm2

    Pretty self explanatory! Go get iTerm2 at https://iterm2.com and install it!

    Step 2 – Install Homebrew

    Again, another easy step! Install Homebrew at https://brew.sh/ at the time of this posting the following command works.

    Also note that you can use MacPorts it’s really your choice! I can’t recall why I switched to Homebrew 🙂

    Shell

    This will install the Xcode Command Line Tools as well!

    Windows 10, ZSH, Putty, Powerline Fonts and Screen

    I recently was setting up my Windows 10 desktop machine with Putty so I could access some servers. I use the ZSH shell with OMZ and the Powerline9k theme. I use the following article to set up Putty and grab the appropriate fonts for Windows 10 that were patched.

    http://mschulte.nl/posts/using-powerline-in-PuTTY.html

    There were some additional options on the following blog article that were required.

    Oh My ZSH! with PuTTY

    Everything was working great until I was having issues with powerline font’s not showing correctly when using screen.

    Running the powerline echo test below resulted in hashed blocks.

    echo “\ue0b0 \u00b1 \ue0a0 \u27a6 \u2718 \u26a1 \u2699”

    echo "\ue0b0 \u00b1 \ue0a0 \u27a6 \u2718 \u26a1 \u2699"

    Turns out I didn’t have my locale set in my shell environment.

    export LANG=”C.UTF-8″

    export LANG="C.UTF-8"

    Once I had the appropriate locale set, everything worked fine.

    WP-CLI Cheat Sheet

    WooCommerce

    wp wc update – Updated WooCommerce database from command line.

    LiteSpeed

    wp lscache-purge all – Purge all cache.

    WordPress Speed Up Analysis 2019-06-03

    The following was a post I made on the WordPress Speed Up FaceBook Group. I thought it was worth posting here in-case someone else might be looking for something similar.

    Olly Bee Excellent! First load for me was a white page without CSS being applied. Which is weird, I haven’t gone to the site before. So you might want to watch out for that, or maybe you were just making changes.

    You’re not loading many assets which is great, mostly due to breeze combining css and js (assumption here since I see breeze.css). Just to note minification isn’t required for a great experience for customers. It’ll get you get you good scores on GTMetrix/PageSpeed but you’ll have to way usability for great gtmetrix scores.

    Ue the built in Dev Tools in Chrome and look specifically at the Network page and waterfalls. Find items that are taking a long time to load, and see if they have any cache headers. Reload the page and see if they’re loading faster and if the cache headers appear.

    When looking at all the items loading, the document items are usually html or PHP. This is where server resources come into play. If you’re getting higher load times on documents, it’s most likely due to caching not being in-play. Or it’s just a dynamic page (PHP) that can’t be cached (WooCommerce checkout, but even then LiteSpeed can use ESI blocks which makes it easier). If you can’t cache a page, then the server resources come into play. Specifically CPU, PHP its a CPU hog. Facebook tried to fix this by implementing compiled PHP using HHVM, but ditched PHP all together. Each time you have to load a PHP page, it has to be compiled by the server. You want to limit this as much as possible. WordPress deals with this fine as a vanilla installation. Once you add plugins, load times start to increase.

    When I first loaded your portfolio page, I noticed it took about 3ms to load all assets. I looked at all the headers of each request and found that the main request for /portfolio had a x-cache miss and a high load time. Once I refreshed the page this load time went down. So it’s possible caching was put into play here either through Varnish or NGiNX fastcgi cache. Hard to tell, would have to look at your stack more.

    If there’s caching in play, a header should appear. Most of the time this is configured, but not always.

    Once your cache is filled, it looks like your pages load faster. So you might need to tweak your cache TTL. Which just tells the cache how long to keep things. This is great for static pages, but for anything dynamic it might cause issues. Most caching plugins deal with this automatically. Even CloudFlare does well with this if you setup the proper page rules. CloudFlare by default doesn’t do well with a WordPress site.

    Aside from that, I see that .tff files aren’t being cached and have 400ms load tims where all your images are loading within 20ms which is great. That’s because most of them are from your StackPath CDN. And they’re small, which helps!

    Another issue I noted is that your query stringed static assets aren’t being cached. Which is a common issue, so you can either enable this in CloudFlare via a rule. Or you can look at a plugin like Clearfy or Perf Matters. If you want to save money, there is code out there to simply just do this specific task.

    Also, with the above plugins you can remove the wp-emoji-release.min.js and dashicons.min.css from loading. Again you most likely aren’t using them, but test anyways.

    Hope that helps, Cheers!

    MySQL 8 and Persona 8 Tuning for WordPress

    If you’re running MySQL 8 or Percona 8, then you’ll probably see lots of guides online that reference some out of data configuration that really only deals with functions in MySQL 5 that have been deprecated in MySQL 8 and Percona 8

    Query Cache

    No longer used, and removed from MySQL 8 and Percona 8, alternative is ProxySQL as per the following Percona article https://www.percona.com/blog/2018/02/07/proxysql-query-cache/

    Creating Users and Databases in MySQL 8 and Percona 8

    If you’ve started using MySQL 8, you’ll notice your usually commands for creating a user no longer function. That’s because it’s changed in MySQL 8, you need to now create a user, then grant privileges.

    Let’s create a user

    CREATE USER ‘newuser’@'localhost' IDENTIFIED WITH mysql_native_password BY ‘user_password';

    The critical part here is the “mysql_native_password” if you don’t have this portion, you’ll get errors like the following.

    PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in mysql_test.php on line 8
    PHP Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in mysql_test.php on line 8

    This is due to the default authentication plugin being set to sha2, you can change it back to native by adding the following into your my.cnf

    default-authentication-plugin=mysql_native_password

    Now let’s grant the user privileges.

    GRANT ALL ON database_name.* TO ‘newuser’@'localhost';

    Now confirm the privileges.

    SHOW GRANTS FOR 'newuser’@'localhost';

    Maybe you want to Update a Password

    ALTER USER ‘root'@'localhost' IDENTIFIED BY 'MyNewPass';

    Searching WordPress MySQL Dump Files

    From time to time, you’ll need to look at data within MySQL dump files, specifically I do it mostly with WordPress. There isn’t an easy way to search the dump unless you use grep. Here are some useful grep commands.

    Pull out a table.

    [enlighter linenumbers=”true”] grep ‘INSERT INTO `wp_bspr_users`’ dump.sql > /tmp/users.sql [/enlighter]

    Format a table in a readable format.

    [enlighter linenumbers=”true”]cat dump.sql | grep ‘INSERT INTO `wp_users`’ | sed ‘s/),/’$’n/g’ [/enlighter]

    Now if you run a popular shell like csh, you can add the following function.

    [enlighter linenumbers=”true”]msd () { grep “INSERT INTO \`$2\`” $1 | sed “s/),/\’$’\n/g” }[/enlighter]

    [enlighter linenumbers=”true”]Then run the following[/enlighter]

    msd dump.sql wp_users

    This might work, don’t know!

    Experience with Thunderbolt 3 USBC Docking Stations for macOS

    Current Setup

    I had a request from a client to purchase dual monitors for their Macbook Pro Late 2013 (or Macbook11,1). I also wanted to sort out my own setup Macbook Pro 2016 (Macbook13,2). Currently I’m using the following, an Apple USB-C Digital AV Multiport Adapter and a generic ArkTek branded adapter. Both come with a USB-C Power passthrough, HDMI and a USB Port, I can power both monitors. I tried to daisy chain the adapters, power pass through works but the second display doesn’t. I don’t know if that’s even possible, perhaps if I need to use two Apple based adapters. Anyways, this is a great, but ultimately I’d like one cable to rule them all.

    Using a Single Cable Docking Station, or we thought

    Enter Wavlink, I saw their product simply by searching Amazon, they seemed to be well reviewed. It’s a pretty standard dock, as you can see below. Insert front and rear ports. Insert Wavlink Amazon The connection to the computer is via a USB-C port, however the box includes a two cables. One USB-C to USB-C and one USB-C to USB Type A. So you can pretty much use it on anything, however you need to make sure you can install the drivers.

    Drivers? Why do I need Drivers?

    So this is something I forgot completely when ordering. The Wavlink has a DisplayLink chipset inside, which is used to push the external monitors. So in-fact you’re not use your on-board graphics card to Although it doesn’t support charging, there is a model available. It’s just not listed on Amazon. Insert Wavlink charging from Website But there’s one big issue I have with both of the above docking stations. They use the DisplayLink chipset that powers the monitors plugged into the dock station. http://www.displaylink.com/integrated-chipsets/dl-1×5  

    Installing Debian on BeagleBone Black MicroSD Card

    First step is to grab the BeagleBone Debian image that you can drop on your SD card. http://beagleboard.org/latest-images Now you will need to flash this image to your MicroSD card, I’m using Mac OSX so here’s a fly by.  

    sudo su - diskutil list diskutil unmountDisk /dev/diskN dd if=myImage.dd of=/dev/diskN