• Tech Tips

    Backing up a File Before Overwriting It (in Drupal 7)

    I’m communicating with a 3rd party SOAP API to pull some data into a CSV file. The CSV file will be used by Feeds and/or Migrate so it’s important to have the file named exactly the same for each run. I want the generated CSV to always be named “mdb_interests.csv” but I want to “backup” the existing “mdb_interests.csv” to “mdb_interests_N.csv” if one already exists. This will ensure that we always have the latest data in “mdb_interests.csv” but will have backups from all previous API pulls. Using some built-in Drupal functions it’s pretty simple:

  • Development,  Tech Tips

    Triggers in iTerm – Watching For Specific Strings

    I was recently performing a git-add in patch mode (  git add -p ) as I normally do, and realized there were a few lines I needed to make sure I didn’t commit. These lines were sandwiched between other lines that I did want to commit, and there were hundreds of changes, so it was hard to spot them. I wondered if iTerm2 had a way of highlighting or alerting when a specific word shows up in the terminal. To my surprise I found a “Triggers” section under the “Profiles » Advanced” tab in the settings for the app. iTerm2 really can do everything!

  • Tech Tips

    Microphone Enable/Disable with Alert – Keyboard Maestro Macro

    In the past I’ve used Shush to achieve a push-to-talk or push-to-silence setup on my Mac. It works alright but more often than not I forget which mode I’m in, or whether I’m silenced or not. This leads to awkward moments in meetings.

    I’ve solved the problem using Keyboard Maestro. This macro, triggered via CTRL-m simple enables or disables the current “input” device (whatever is selected in the Sound preferences) by setting its level to 0 or 100. It’s a toggling macro so you can use the same hotkey to flip between the two states. Most importantly, though, is the nice popup alert that appears when you go into “disabled” mic mode. This window is hide-able if it gets in the way, and it also disappears if you re-enable (via hotkey OR the RE-ENABLE button). You can safely disable the “Custom HTML Prompt” action if you don’t want to see the prompt. Here’s what the popup looks like:

    MicDisable

  • Tech Tips

    Random Mouse Distance in Keyboard Maestro

    Here’s one way to choose a random item in a select list using just mouse movements and a random number. If you’re trying to do this in a browser there are cleaner ways to do it (javascript, chrome/safari actions, etc.), but for general usage across many applications this is a pretty universal solution.

    2016-03-03_20-04-27

    I was surprised to find that you can type variables into the tiny coordinate text fields. They get bigger when you do.

    When executed, this will select a random item (excluding “- None -“) from the select list.

  • Tech Tips

    Use Keyboard Maestro to Hide Instead of Close an Application

    I use SnagIt to capture screenshots. The editor window that appears after you capture takes a few seconds to open if the application isn’t running. I realized that, while the capture tools remain open, the editor goes away when I hit ⌘W to close the window. Instead of using ⌘W to close the editor window, I sometimes remember to use ⌘H to hide the window, which hides the window but leaves the application open. The editor window pops open much quicker if the application is still open.

    Using Keyboard Maestro I’m able to intercept the ⌘W that I do all the time (muscle memory), and turn that into a ⌘H.

  • Tech Tips

    Launch Center Pro actions for Day One

    Here are my Launch Center Pro actions for the Day One app on iOS. I’m not here to teach you how to use Launch Center Pro (a huge topic), so if you need to learn that I suggest a lot of Googling and perhaps a visit to their official documentation and FAQs. Basically LCP will step you through prompts as it builds the output to move into a new Day One journal entry. Day One supports markdown, so you can make entries that look nice, like this:

    2016-02-15_06-15-13

    Use this LCPEncoder to convert the templates you see below into URLs. After you generate the URL, get it into the “url” field of the LCP action.

  • Tech Tips

    Keyboard Maestro “Insert text by pasting” Quick Tip

    “Insert text by pasting” is faster than “Insert text by typing” (which is rarely necessary in my experience).

    Unfortunately, using the paste method results in unwanted junk in your clipboard (unless of course this is also your intention). You can insert by pasting without having it store the text into your clipboard by adding a “Delete Past Clipboard” action just after the insert. Despite the name of the action, this will only remove the last item from your clipboard (not the entire contents of the clipboard).

    Screenshot_2015-11-23_05-21-34

  • Tech Tips

    Installing ElasticSearch on Webfaction

    You read everywhere that setting up and running elasticsearch is very simple. In fact, it is. There are some hurdles to clear when you’re setting it up on Webfaction, however. These instructions will hopefully provide some guidance.

  • Tech Tips

    Automatic Dropshadow and Border on Mac OS X Screenshots

    If you’re like me, you take lots of screenshots. I probably average 20 a day. Primarily I use CMD-SHIFT-4 and drag a box around what I want to capture. The result is exactly what I highlighted. Here’s an example:

    Screenshot_2015-10-09_09-53-06_original

    That looks fine, except there’s nothing that really helps the image stand out. It’s not ready for blog posts, documentation, or wherever else you’d like to use an image. I’ve approached the problem a few different ways in the past, but I’ve finally settled on a Keyboard Maestro-based solution for “Automatic” processing of these screenshots. I also have created a “Drop shadow” Service so you can apply a dropshadow to any image by right-clicking and using the Services menu.

  • Development,  Tech Tips

    Automatic Screenshots of Drupal Content

    In an earlier post I recommended webkit2png for automatically screenshotting a list of URLs. A lot of time has passed since that post, and I’ve discovered a more robust tool. Pageres is incredible, and it has a CLI and an api.

    I’ll let you discover, on your own, what the Pageres tool can do. I needed to take screenshots of all of the content types on a site, at all of the important resolutions. Here’s a quick Drupal function I threw together to get N number of random nodes per content type: