How to show the current TotalSpaces space name in the menu bar

John Bachir's Code Blog
May 04, 2020

TotalSpaces is great! One flaw is you can't put the name of the current space in the menu bar. Only the number. Here's a workaround, possible because it has an API!

  1. Install the ruby gem sudo gem install totalspaces2
  2. Install TextBar
  3. Set up a TextBar menu item
    1. ruby -r'totalspaces2' -e . . .

Read More

Is there a name for this code design principle?

It's the #1 thing I want to convince my coworkers of

John Bachir's Code Blog
April 14, 2020

Bad

class Animal
 initialize(type)
 @type = type
 end
 def bark
 return unless 'dog' == @type
 puts "woof!"
 end
 def meow
 return unless 'cat' == @type
 puts "meow."
 end
end

Good

class Dog
 def bark
 puts "woof!"
 end . . .

Read More

Linux flock does not provide fair locking

John Bachir's Code Blog
February 01, 2020

The problem I’m trying to solve: 1 machine with X amount of ram. I have to run N tasks on it, each of which take more than X/N memory. So, they can’t run at the same time. Luckily, the time they run is not particularlyimportant, as long as they run regularly.

Via a suggestion from the whenever gem for ruby, I discovered linux lock. . . .

Read More

How to enable Command-E in VS Code on Mac

John Bachir's Code Blog
January 27, 2020

On Mac, Command-E often means "Use Selection for Find", and also puts the selection into the "Global Find Clipboard".

In VS Code, this the feature was implemented in 2017 here, but is off by default (whyyy).

To enable it:

  1. Go to Code preferences (Command-,)
  2. Type "Global Find . . .

Read More

Setting google chrome / chromedriver options correctly in version 75+ with selenium and capybara

John Bachir's Code Blog
November 28, 2019

Problem

Here's one that took me a surprising amount of digging to find an answer deep in a lone comment in a thread.

You're running your chrome/chromedriver-driven test suite and start getting mysterious errors, which might be related to problems that were previously solved by setting particular options. After some . . .

Read More

How to get github pull request commits to be in the correct order

John Bachir's Code Blog
November 28, 2019

Problem

Sometimes after rebasing and force pushing, github will show commits in a different order from what you expect.

Solution

git rebase -i master --exec 'git commit --amend --date="$(date -R)"' 
git push --force origin my-branch

If I remember correctly, some solutions to this problem . . .

Read More

These are a few of my favorite software engineering books and blogs

John Bachir's Code Blog
March 25, 2019

Books

Read More

Archive
   Subscribe by email and never miss a post.