• Tech Tips

    Editing Web Content in VS Code

    Okay, so it’s not quite as amazing as the title suggests, but this solution is worth sharing.

    I work a lot in Bookstack. It’s a fantastic documentation system built with Laravel. I edit all pages in markdown. There is a markdown pane on the left and a preview on the right. I love the UI (shown below) but unfortunately I cannot move around in the editor like I can in PHPStorm or VS Code, where I have Vim support.Bookstack edit screen

    I have a Chrome extension called Wasavi, which is incredible for editing text areas in an inline virtual Vim window. Unfortunately, though, it doesn’t show realtime feedback in the preview pane until I save and close out of the virtual editor.

    It occurred to me it’d be useful to just pop into VS Code quickly to edit the doc, then bring those edits back into the Bookstack editor in Chrome. At first I dismissed the idea as being “too much work.” After thinking about it for a moment, though, I realized I could MacGyver this relatively quickly with my favorite Mac application, Keyboard Maestro.

    Here’s what I came up with. As with most things, I am sure I’ll tweak this over time to make it better, faster, less “error”-prone, etc. I have added a README comment and renamed most actions so it’s (hopefully) easy to understand the approach.

    Bookstack VS Code Macro

     

  • Tech Tips

    One-handed Gmail Inbox Culling with Keyboard Maestro

    Keyboard Maestro proves, once again, why it’s at the top spot on my most recommended Mac applications list.

    My normal procedure for culling (deleting unwanted) emails in Gmail is (with list on left and email preview on right):

    1. Open the first email (opens in right pane)
    2. If deleting, press “#” (⇧3)
    3. Else, if skipping, press “j” to move down to the next email (standard Gmail behavior, I think; and it’s intuitive if you’re used to Vim)
    4. Repeat steps 2 and 3.

    I realized today how much I dislike hitting “#” with my left hand while browsing with my right.

  • Development,  Tech Tips

    PERT Estimates – Using Three-Point Estimation to Improve Accuracy

    Background & Method

    I’ve long been a promoter of using three-point estimates for improved accuracy when estimating tasks.

    When I estimate how long a task will take to execute, I imagine three separate circumstances in an effort to improve the accuracy of my estimate:

    1. Optimistic: How quickly could I get this task done if everything went perfectly. What if I realize some unexpected “wins” that get me to the finish line faster?
    2. Realistic: When I think about my performance executing similar tasks in the past, what’s my best guess at an average amount of time needed?
    3. Pessimistic: Sometimes nothing seems to go well. If things do not come together as expected, what’s the longest (within reason) you can imagine this task taking?

    If I’ve truly thought about each of these, I can use them as variables in a simple formula, and can get a more accurate time estimate as a result.

    This formula, (Best+(Real*2)+(Worst*3))/6 , puts more emphasis on the worst-case scenario (#3 above) as things seem to always take longer than expected to execute. Sometimes I use two versions of the formula (one that puts even more emphasis on pessimistic).

    One more thing worth noting: You’ll see I used “I” and “my” a lot above; I do not recommend estimating tasks you are not executing, personally. I recommend having the responsible party estimate the task whenever possible. Explain the PERT process to them.

    Usage

    While this formula is simple, and adjustable (alter the weights as you see fit), it would take some time to manually calculate the result for each task.

    I utilize a few tools to generate PERT estimates at the speed of thought.

    First, I’ve written an Alfred plugin to make the process simple. This is my most used method of generating PERT estimates. Here’s a screenshot to give you a taste:

    I’ve also created many spreadsheets over the years. These often look similar to this:

    Here are a few templates you can use: XLSX | ODS

  • Tech Tips

    Monitoring APFS Drive Decryption Progress

    I recently decided to [permanently] decrypt an APFS volume via Finder (Right click the drive, choose Decrypt).

    There wasn’t any indication that it was actually working. After some web searches, I pieced together a one-liner to monitor the progress of the decryption operation. This will refresh every 60 seconds. If your setup is anything like mine this will be an exceptionally slow operation.

  • Development,  Tech Tips

    Switch Audio Input/Output Device using Alfred

    My top two must-have Mac apps are Keyboard Maestro and Alfred. If you know me, you’ve likely heard me say this, ad nauseum. I use these two apps countless times each day. Often I use them to run command line scripts via hotkey. This is one such implementation.

    Recently I picked up a Jabra Evolve 65 headset. I keep it connected to my Mac via USB. Also, I have some speakers hooked up via the external speaker jack. You can only send output to one of these devices at a time (speakers OR headset). I desired a way to quick-switch between the two. I chose to use Alfred for this.

    The steps below show how to create some quick switchers like this:

    Alfred sound switchers

    Switch to speakers

    Requirements and Initial Setup

  • Development,  Tech Tips

    Automatically Put Files Into a YYYY/MM Directory Structure

     

  • Development,  Tech Tips

    Using PHPStorm for Git Diff and Merge tools (Mac)

    You love git-difftool, right? Of course! You also love PHP Storm, right? Of course! This easy procedure lets you use PHP Storm as your git-difftool.

    1. Open a project in PHP Storm
    2. Click Tools » Create Command-line Launcher…
    3. Edit your ~/.gitconfig file:
    4. Open the project in PHP Storm (see notes below)
    5. Open iTerm2 (or any other terminal emulator)
    6. Use git difftool as you normally would (e.g., git difftool .htaccess)

    Observations

    1. If you don’t have PHPStorm open when you try to use git difftool it doesn’t seem to work. I need to see if I can get it to open non PHP Storm projects, and/or I need to figure out how to switch on-the-fly between vimdiff and PHP Storm as my difftool.
    2. If you have PHP Storm open but the project itself isn’t open, “Annotate” is not available on right-click. Other functionality may be missing too. If you project is already open in PHP Storm you can annotate the diff!

    Thank you to JohnAlbin for the configuration snippet above.

  • Development,  Tech Tips

    Find and Open (in vim) Multiple Files

    This is a quick set of examples for finding and opening multiple files in Vim.

     

  • Tech Tips

    Mac High CPU Usage – WindowServer

    DISCLAIMER: I’m writing about my personal experience here. I am by no means doing some exhaustive investigation. The changes I explain below seem to make a difference, at least according to what Activity Monitor is showing for CPU usage.

    My laptop (3.1GHz i7 MacBook Pro with 16GB of RAM) has enough of power, so why has it been such a dog since starting from scratch with a fresh OS? A colleague posted an animated Gif today in Slack and my MacBook fans kicked in and it sounded like it was getting ready to fly away. This was the last straw in what has been weeks of wondering why my laptop has been slow.

    I opened Activity Monitor and found that my WindowServer process was using a significant amount of CPU resources (up to 77% when the animated gif was visible on my screen), and that it has used significantly more than the next heaviest process since I last rebooted.

    I understand that it’s probably a pretty heavy process, but it got me thinking, and Googling. As it turns out, when something is being drawn to the screen it takes processing power; go figure! One of the top suggestions was removing or disabling things from the menu bar that are constantly updating. The suggestions included CrashPlan and Little Snitch Network Monitor. Wow. I use the latter! I opened the Little Snitch preferences and unchecked “Show network activity in menu bar” and voila! the WindowServer process memory dropped about 15%. Then I closed the animated gif my colleague posted in Slack (the only other thing on the screen that was moving) and voila! it dropped again.

    Now, as I’m looking at my CPU Time in Activity Monitor I’m thinking through what I really need running. Is the “Next Meeting” (which shows the name and time of my next meeting in the menu bar) application really worth running 24/7? I don’t think so; especially if I have more important things for my CPU to be doing. After quitting this application my WindowServer CPU usage dropped to 6.6%.

    I’m going to continue to trim the fat to see how lean I can make my machine. Obviously it doesn’t stop at just trimming out running applications, but I’m blown away by the impact of small changes like these.

  • Tech Tips

    Python Faker with the Fake App (Mac OS)

    Fake App is a fantastic way to automate form filling, especially for folks without coding skills. The click-and-drag to target an element lets you quickly build your macros.

    Python Faker is a utility library that I leverage with tools like Fake App, Alfred, Keyboard Maestro, etc. to generate realistic dummy text. This blog post shows one method of how to get Python Faker data into Fake App; I imagine there might be a simpler way but this works well and is fairly intuitive.

    The idea is to just write the Faker output to a file and read that file into a variable for use in Faker. With this method you could even store variables for re-use. For example, if you had three fields: First Name, Last Name, and Full Name, you could easily store the first and last names to separate files and use both values for the Full Name field. With the power of Faker your dummy text options are extensive; you can generate very realistic values for your form filling. See all of the “providers” here.

    This example below took just minutes to setup (and it was the first time I’ve used this technique).