How to Change Vim Colors – Highlights, Backgrounds, Foregrounds, etc.

I just spent quite a lot of time figuring out how to change popup background colors. I use coc.vim so I incorrectly thought coc was setting the color. Then I accidentally typed :hi and it displayed ALL my colors, and there discovered my Pmenu was set to magenta. I don’t know how it got set to that, but to change it all I had to add in my vimrc was highlight Pmenu guibg=#808080 or whatever color you want. You may need to set ctermfg, ctermbg, gui, guisp, or cterm depending on if you’re using the gui or not, and if you’re trying to set a foreground or a background.

Automatically Add Issue URL to Commit Message

I’ve spent too much time, twice, figuring this out, so I’m writing it here so future me won’t waste so much time. There are a lot of ways to do this, feel free to comment on your solution. I like my commit messages to contain the issue URL because 1) it tends to link the commit to the issue and vice versa in most git managers like github and gitlab 2) when searching git logs it makes it trivial to find the original issue.

We will be using a global gitmessage file and using a prepare-commit-msg hook. This assumes that your git branch will contain a group of digits which is the gitlab issue number. If your branch contains multiple groups of digits (jason/6456/description-stuff-343) then it assumes the first group of digits is the issue number

  1. Navigate to your project’s git hooks directory (ProjectDirectory/.git/hooks), and rename prepare-commit-msg.sample to prepare-commit-msg. By removing ‘sample’ you are telling git to actually use the file.

  2. Add this to your prepare-commit-msg. Note that this is for macOS, and if you’re using a different operating system your grep and sed commands might work differently.

# gets digits in current branch name. `head -1` gets just the first group. Note that this assumes you are adding your git issue numbers to your branches.

issueNumber=$(git symbolic-ref HEAD | grep -oE '\d+' | head -1)
# of course you need to change this URL to match your project's URL.

# if there's a digit in branch name
if [ -n "$issueNumber" ]; then
# replace #gitlabIssueURL with the value above
    sed -i '' -e "s/\#gitlabURL/$gitlabIssueURL/" "$1"

# delete the line containing #gitlabIssueURL
    sed -i '' -e "/\#gitlabURL/d" "$1"
  1. Create a file (if you don’t have one already) named .gitmessage somewhere. Usually you should create it in your home directory, $HOME. Add #gitlabURL to wherever you want to add the url. Mine looks like this, to remind me how to make a decent commit message:
when applied, this commit will...



Co-authored-by: username 

  1. Modify your global .gitconfig file, usually located in your home directory, $HOME, to add these two lines:
    template = ~/.gitmessage

Putting all this together, whenever you do git commit, git runs the prepare-commit-msg hook, which will take your git message template (created in #3 above) and modify it with the fancy bash scripting we did in #2 above.

Fix Inconsistent JS Selenium Tests with element.isEnabled()

I’ve been writing automated regression tests at work over the past month, using Jest and Selenium WebDriver, and have really been struggling to get my tests to pass consistently. I began to suspect that methods like wait(until.elementIsVisible... and wait(until.elementTextIs... did not actually do what I expected since I was getting so many inconsistent failures. I began searching for a way to determine if an element is clickable with Selenium WebDriverJS. This is possible in other languages (I think Python and Java at least), but it’s not available for JavaScript. But it turns out you can make it work. Continue reading

Project Euler 13

This one was a bit confusing.  The wording of the problem is, “Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.”  I assumed that they wanted the ones place through the billionths place, but they wanted the first ten digits starting from the left side of the number. Continue reading

Project Euler 14

I haven’t written any code in almost 2 weeks, but I did read a few pages of Eloquent Javascript (I highly recommend it, along with Javascript: The Good Parts).  I started Euler 14 on 7/30, felt a bit overwhelmed, wrote a rough sketch, and left it.  I felt inspired tonight (read: nothing else to do) so I revisited the problem.   Continue reading

Project Euler 11

I just finished this one.  My code is incredibly huge, over 100 lines.  I’ve seen a few solutions that were far shorter than mine, but I found the answer.  It took me a half hour to realize this, but for those who are trying to solve this and are stuck, don’t forget to check the correct diagonal directions.  I was checking diagonally down from left to right, and then checking diagonally up from right to left, which is the exact same thing.  That produced the exact same results, so I had to change one of those checks.

Here are a couple other hints, that most of you probably understood right away: Continue reading

Inserting dates in increments of X, based on dates in other cells

 I’m working with an old spreadsheet that has nearly 1500 rows of data.  This spreadsheet has been in existence since late 2009 and has been maintained by several different people, with no one providing Excel-minded, future-proofing leadership to unify what they were maintaining and how they were maintaining it.  As such, the data is incomplete and dirty.  Here’s how I fixed over 300 empty cells with estimated expiration dates within a few minutes (it can be done much quicker if you know exactly what you’re doing). Continue reading