Prevent iCloud from Syncing /node_modules/ Folder »

Update: This was too hard to maintain, and things “got weird” sometimes. I’ve moved to Dropbox instead, very happy.


I have my localhost server on iCloud. Cloud syncing, in my opinion, is the most reliable way to ensure what you’re working on is backedup to the second.

However, 18,000+ file folders like /node_modules/ is just ridiculous to have syncing. I have nothing to prove this, but I’m certain having one or more folders like this would at some point negatively effect syncing and/or indexing.

So, as far as I’ve found the best way to prevent folders like /node_modules/ from syncing is appending .nosync to the end, then symbolically linking to.

This gives you a nice little “Ineligible” tag on your huge folder, and your symbolic link sits there.

To setup, in your project folder, just run

npm install
mv node_modules node_modules.nosync
ln -s node_modules.nosync/ node_modules

Atom – RemoteFTP More Visual Indicator »

Atom – RemoteFTP More Visual Indicator

Really enjoying using Atom now (instead of Panic Coda). The ability to customize and hack is just, mind blowing.

Right out the gate this became useful. Not keeping tree view open, knowing if RemoteFTP was connected was slightly annoying – there is a setting within RemoteFTP to show icons in the status bar, but visually, it did nothing.

Tiny amount of LESSCSS in my stylesheet gave me some very obvious icons.

Switching PHP Versions Localhost, Keep phpMyAdmin Working »

When switching localhost php versions for testing, nothing interrupts the workflow more than phpMyAdmin failing because you’re on php 5.4.

The single line of code, to be your index.php in /phpmyadmin/ simply routes you to either the phpmyadmin/new/ (v4.7 – supports php 5.5-7.2) and phpmyadmin/old/ (4.0 – supporting php 5.2 – 5.4):

Simple.

Check If Current Page Uses Gutenberg or Classic Editor »

If you’re themes like most themes, and you have to fix your main elements CSS to accommodate Gutenbergs edge-to-edge capabilities on gutenberg-only pages, it’s good to know which pages are actually using Gutenberg. The follow will add a CSS body class for Gutenberg pages.

Add conditions like !is_home(), get_post_type() != 'post', etc., to accommodate your theme setup.

CSS Menu/Nav Hamburger Animation »

CSS Menu/Nav Hamburger Animation

While finally buying a Keurig today, I (oddly) decided to do my research on my phone instead of desktop, and also (oddly) decided to go to Keurig.ca instead of my normal stomping ground of Amazon.ca. While there, I was distracted in a nerdy daze by the animation they added to their hamburger navigation, immediatly stoped everything and went to code it myself.

A very polished touch to a now very common element:

I used CSS3 var for easy line weight changing. Playing around with EASE also gives the button much more life. (It took two cups of coffee to write and refine that).

On Img Upload, Create New Post, Set as Featured Img »

I used to manually do everything for the Images section of my site. Adding an image would involve: save photo after editing, renaming it, uploading, creating new post, setting the title and date, assigning the featured image as the upload, then setting the category to Images so it’s added to the page. So, 8 steps, usually done over-and-over again to a dozen or so images in a batch. We’re talking over 96 steps to get a batch of images online – it took a bit of time, and was slightly demotivating, becoming a chore instead of a hobby.

Able to scratch my own itch – I came up with a way to automate everything. Instead of 96 steps, I now publish an entire batch of images in just 2 simple steps. Yes Two. Too. To. You read correctly, just 2! How’d I do it?

After editing the photos in Lightroom, I use Lightroom’s file-rename feature during bulk export that automatically sets the filename to the images meta timestamp, so YYYYMMDD.jpg.

I then use the following script tapping into the add_attachment hook during bulk upload that does the other 7 steps for each image. Everything in just 1 step, for the entire bulk.

https://gist.github.com/davidsword.ca4a6ec6cde878a8a47fde35feecab69

So, all I have to do after exporting from Lightroom, is drag-and-drop upload to the site.

WordPress Dynamically Write Number of Years Since With Shortcode »

As the lengthy title says, the follow simple script allows you to use a shortcode to dynamically output the number of years since a specified date. I wrote this for my own bio, which I used to have to update the number of years since the start of my employment once a year. The simple’r solution would be to write, “blah blah blah since 2010” instead of “blah blah blah for 7 years“. But hey, why not.

Simple usage is []years since="2010-07-01"[] would output something like 7.

Add All Super Admins To All Sites On WordPress »

One of the most annoying features of WordPress Multisites (besides domain mapping) is adding a Super Admin a few years after your network is established and grown. Sure, being a Super Admin allows said user to access any site on the network, but the user is technically not added to the site – so the Super Admins users My Sites tab will only have sites that s/he has been manually added to. The user is then forced to jump between sites with a headache of manually typing.

The follow script solves the problem, it runs through all super admins and adds them to all sites in the network they’re not yet added to.

The function needs to be run once to get everyone up to date. For the future it can be wrapped in a $_GET conditional to fire manually, a cronjob to run in background, or like I did, a transient, so that you can run it as often as you need. Mind you this isn’t a network plugin or intended to run on all sites, it just needs to run once on a single site. All the multisite data and blog_switching annoyance happens within the functions themselves.