DevOps

Drush: Setting up and Leveraging Site Aliases

If you haven't yet set up site aliases for Drush, what are you waiting for?!?--Life is so much easier once your localhost can start communicating with your remote: bring site files and databases straight from production to local without logging into your CPanel or PHPMyAdmin; clear site cache on Production without logging into the site and navigating the admin UI. It can be tricky to set up, but once you have, you'll wonder how you ever developed without site aliases.

Background: Why Site Aliases Rock

My main client is hosted on Acquia; despite the tendency to be both pedantic and overly optimistic in regards to all things Drupal, Acquia, as a company, can be extremely considerate to the developers on its platform. One of the perks of being with Acquia is having out-of-the-box support for Drush Site Aliases.

Nano: Forgot Sudo and Need to Save A File You Don't Have Permissions to Save

You've opened a file from the root system without using sudo and you're editting it without realizing you don't have write permissions. After all your edits, what do you do? Don't lose your file!--you just need to change the save path! You can do that in Nano's save prompt!

So I'm racing to get a LAMP stack up and going on one of my computers. I need to update the php.ini file which resides in the root file-system at /etc/php/7.4/cli/php.ini. In my haste, I opened up the document from within its file path using $ nano php.ini and started any number of edits. I hit ctl-o to save, and Nano gives me an unsurprising line about how I don't have permissions to save the file. Ever seen something like this?

Git Merges Gone Wild: When Sass Compiler Settings Diverge

Here's one of those problems you can file away under the umbrella of DevOps problems nobody really wants to think about. In my case, I stumbled accross this problem while looking at two branches with respective SASS changes--although, this can logically happen with any code that needs to be compiled to an output file and has different standards for how to do that. Today I hit a merge conflict, and my merge tool was telling me that every line of local and remote were completely different. It turned out my coworker and I were compiling our SASS to different output standards; the end result was that my merge tool (GitKraken) crashed and I was effectively unable to see which lines of code had actually diverged. Here's how to stop this from happening to you!

Background: Git Merge Gone Awry

There's not a lot to this: my coworker has been working on her branch; I've been working on my own. The time has come for me to merge my branch into my coworker's. I checkout my coworker's branch to run a git merge and this is what happens: the _overrides.scss file merges successfully but the output files fail. Those output files are compiled by a little program I run called Koala--a SASS compiler.

Bash: Interactive Script to Bring Window to Front or Open App

Ever find yourself rotating between multiple applications within the same single workflow? For me, I like to call it the holy trinity: VS Code, GitKraken and Firefox. When I'm working on a site, I'll inevitably spend almost as much time cycling from one of these applications to the other as I do writing code. I finally got so sick and tired of this that I decided to write a little Bash script to make rotating between applications just a little less cumbersome. Since VS Code has a terminal emulator, I can run the script from there to jump quickly to the next application(s) in my workflow.

Background: Multitasking Wears You Down!

Web development is a conglomeration of tasks; there's really no way around it. Having two monitors is a good way to get a bird's-eye view of everything going on within your workflow. If you like to maximize your windows, though, you're only ever going to get two applications to work with at any given time. On an average day, I'll have roughly 3 Firefox windows, a terminal, VS Code (with its own terminal emulator), GitKraken, Koala (SASS compiler) and maybe Virtual Box--all open at the same time.

SASS Compilers: When Your Drupal Theme Won't Update Even After Clearing Cache

Ever feel like you basically spend the entire day hitting your head against a wall? It happens to the best of us--particularly when it comes to elements of DevOps we don't deal with on a daily basis. I spent far longer than I care to admit today trying to assess why my Drupal site theme wasn't updating despite holding my code to a microscope, and despite any number of cache clears. The culprit: the output path on my SASS compiler was set to the wrong folder. Seems like a novice mistake... which is why I'm commemorating it with a blog post: sometimes brain farts are just part of the job.

Background: A New Computer

That's right... I got tired of lugging my laptop between home and the office, so I setup a new computer over at the coworking space. Okay, technically, it's not a new computer at all; it's a 2011 Mac Mini Server running Xubuntu 20.04--still a perfectly reasonable computer for web development in 2021. But, that means "provisioning" the computer for my workflow. Thanks to Git, this is a pretty easy task: install a LAMP stack, clone the repository, setup drush aliases, import a DB, and we're basically good to go...

Except, not really.

Tag Manager: Fire Tag Only if CSS Class is Absent

I finally stepped away from Google Analytics and implemented Plausible's cookie-free tracking on the blog. Ironically, to implement Plausible's code, I used Google's Tag Manager (this doesn't compromise Plausible's code in any way; I just think it's sad that Google is still a crutch for my dev-ops). Since Plausible doesn't gather Personally Identifiable Information (PII), though, excluding my own usage on the site becomes a slight challenge; Google Analytics let's you exclude data based on IP--but, that's not an option with Plausible. With the help of Tag Manager, however, I can prevent Plausible's code from loading based on whether a CSS class is present on a DOM Element. When logged into Drupal, there are any number of CSS classes that are unique in the DOM. This provides a simple solution to excluding my own usage from Plausible's analytic data. Here's how to do that.

Step 1: Finding Unique Classes in the DOM

This technique isn't limited to excluding analytics tags. By finding unique classes in the DOM, you can setup both exclusion and inclusion rules for Tag Manager to fire a tag of any type. This is actually a pretty powerful ability. In my case, though, I need to find a CSS class (or classes) in the DOM that only appears when I'm logged into the blog. Drupal adds these kinds of classes throughout the DOM, but the most logical candidate, for me, is a class in the <body> tag.

Bash: A Simple Script for Copying Files and Directories with SCP

This is a followup, of sorts, to an earlier post on file sharing in Xubuntu--which can be kind of a pain. I never looked seriously at SCP as a solution for file sharing because it's honestly tedious--true for both in-network and out-of-network sharing. With a little Bash scripting, though, SCP can be made a lot more practical. Here are a couple of short scripts that take the edge off.

Background

SCP is a command-line tool for passing files from one computer to another with SSH. That makes it a valuable tool no matter where those computers are: inside your home network, or off on some remote. The trouble I've always had with it, though, is remembering addresses: I can never remember the IP address of each and every device on my network, and some of the remotes I work with have really convoluted sub-domains. If it weren't for this, SCP would be a really great way to pass files from one place to another.

Web Developer Workflow: Useful Linux Bash Aliases

If you spend a lot of time on the command line, like I do, an important part of your workflow is getting things done both quickly and efficiently. Bash aliases can be extremely helpful in saving you time. This isn't a comprehensive list by any means, but hopefully it serves as a starting point--allowing you to optimize your terminal-based development work.

Intro

I recently talked about bash aliases for managing XAMPP more efficiently. Here are a few more fun ways you can optimize your development workflow on the command-line using aliases. None of this is rocket science, by any measure. Still, if you're new to bash aliases this brief article will hopefully act as an introduction to a new way of using the command-line (and a new way of thinking about workflow, hopefully).

Weekly Recap: .htaccess Fun, Ubuntu Encrypted Drive Fun, Xubuntu Password Fun

Just a quick recap of all the fun I had this week. No great revelations here, but sometimes it just feels good to vent.

Don't Try This at Home, Kids

As a general rule I don't like to push changes to a client's .htaccess file during business. If you've ever had the pleasure of working with regular expressions (regex), you'd know why. This is largely a holdover, however, from my earlier days as a developer--when regex seemed about as intuitive as ancient Chinese.

Git: Previewing Multiple Branches in a Single Environment

One of the most difficult aspects of web development has little to do with code: it's called workflow management--and it can mean the difference between hitting Go-Live and adding days or weeks to a project. Things can turn uggly quickly when a finite number of development environments come to odds with exponential requests for code changes. When things get ugly like this, though, Git shines not just as a version control system but as a workflow management tool.

Before I dive hard into the meat of this post, let's get some basic assumptions out of the way--I'm gonna assume that: