Blog

Exit Python REPL (on Mac) with Control-D

Quick tip that I just learned (from a Pluralsight video) is that you can exit the Python REPL in Mac’s Terminal by pressing Control and D instead of having to type exit() and hit enter, which is a bit clumsier. Control and C halts any process that might be taking a while so I’m hoping it’ll be easy to remember Control + D for exiting the REPL.

Read More

Pyenv and Venv / Virtualenv wrapper settings

I’ve had a hell of a time wrapping my head around managing Python versions on my machine with pyenv, and individual project dependencies with venv (/ virtualenv) and an even harder time getting them to work on my (Mac) machine. The issue I had with pyenv was finally resolved when I just moved the declaration in my .bash_profile from the beginning of the file to the end. My favored way of editing it (with Nano) is done by invoking nano ~/.bash_profile in terminal, although I also discovered I could edit it directly in VSCode when I found the .bash_profile in my home (Scott in my case) folder (I think you have to unhide hidden files, which hides all system/ dotfiles by default). I don’t exactly understand what is happening in the code below but the reason it needs to be toward the end of .bash_profile is that pyenv apparently intercepts and redirects PATH listings you may have earlier in the file.

Read More

Storing JSON 'File' in Heroku Config Vars

It seems like a problem ripe for <vomet>disruption</vomet> but for a junior dev who still doesn’t know best practices around storing private API keys I think I came up with a clever workaround for this particular thorny situation. The problem is that I was trying to deploy to Heroku a (Flask / Python site) that writes to a Google Sheet and therefore needs OAuth authentication. Heroku has “Config Vars” in which you can store a private key as a string that won’t be accessible to the public and you can keep out of your Git/ GitHub/ source control. The problem in this case is that OAuth gives you a JSON file of about 8 values, at least two of which are needed for authentication, if not more. The solution seemed obvious - to store that JSON as text in a Config Var but implementation proved anything but easy for me. After more than a day of fiddling, I think I finally have it working.

Read More

Left Right Navbar

My thanks go out to W3Schools who helped me finally solve my navbar layout after fumbling with it for way too long. It was the simplest of changes that I wanted to make - to make my name on the left side of the navbar just a little bit bigger than all of the links that are on the right. That then threw off the formatting, particularly the responsiveness as the page shrunk for smaller screens. I played around with every CSS property I could think of, dove into reformatting it with Flexbox and Grid and then finally found the fix on W3Schools (https://www.w3schools.com/howto/howto_css_topnav_right.asp). They just put a div for the navigation links - floated right - within the nav element, just after the title link. It’s so simple that I’m not sure why it took several different google searches for me to find. If you want to see how I adapted it for this site, the HTML is at https://github.com/Scott-Larsen/Scott-Website/blob/master/_includes/header.html and the CSS adjustments to the Jekyll-Swiss theme are at https://github.com/Scott-Larsen/Scott-Website/blob/master/assets/style.scss.

Read More

Nuxt - Google Lighthouse - noopener Breaking Links

I ran Google Lighthouse on a Nuxt site that I built and implemented their performance tuning and accessibility hints and was actually able to get 100% scores across the board (Woohoo!). It wasn’t until the next day that I realized that I had crippled all of the external links that I had on the site opening in a new tab (with target="_blank"). Lighthouse recommends always adding rel="noopener" or rel="noreferrer" to prevent the new website from manipulating the redirect elsewhere. I dutifully searched through all my site files (thanks VSCode) for target="_blank" and replaced it with target="_blank" rel="noopener". It turns out that was the problem and when I went back and did the same operation replacing all the rel="noopener" with rel="noreferrer", everything seems to be working again.

Read More

Jekyll CSS Not Rendering

I had a problem with this here Jekyll install/ blog in that I couldn’t get the CSS to render and nearly abandoned Jekyll because it was the third major issue I’d encountered in the few short weeks of trying to get it going. Thankfully a guy named Gungor on the Jekyll Gitter forum pointed out to me that my css was being served at http while my site was at https (It’s possible that I have those reversed). I spent the next three hours trying to figure out what I needed to change and, after trying every iteration of http/s in the url and baseurl variables in my _config.yml file, I finally commented them both out and it suddenly worked. I wish I could explain why but if you’re running Jekyll on GitHub Pages with a custom domain see if that doesn’t fix your problem.

Read More

Roof Drip Edge Spacing

Here’s a quick diversion from tech just to get this info online because I couldn’t find it when I was re-roofing a porch two years ago. This comes from good ol’ Tom Silva on a recent episode of Ask This Old House in which he says to space the lower lip of drip edge a finger’s width away from the roof’s edge. Then space the shingle’s edge 3/8” - 1/2” over the drip-edge. In fact, in trying to link to the Ask This Old House site I’ve found that the video is online, along with the text transcription stating as much so hopefully my linking to it will give it a little boost in Google’s rankings. Also, yes, run the drip edge on the side of a ‘shed’ roof and make sure that descending edge laps over the edge at the base/ eve….

Read More

Linking to a PDF (CV / Resume) from your Jekyll Header / Nav

This seems like the most basic task but I finally had to resort to writing every link structure combination I could conceive of (~10, in all) and copy my Resume.pdf file into multiple folders to figure out how to do this. In the end I put my Resume.pdf file in a folder titled static in my home folder. From there I added a link to the header.html file amongst the list of other navigation links as follows. The key part is that it have a leading forward slash after the baseurl - ”{{ site.baseurl }}/static/Resume.pdf”

Read More

index.md not building into index.html on a Jekyll Site

I had an issue setting up this Jekyll site/ blog where I wanted to replace the default blog page that was at index.html with the about page and have the listing of abreviated blog entries on a separate page that you have to click through to from the home page. I swapped the default Jekyll about.md and index.html files for index.md and blog.html, respectively. The problem was that the index.md wouldn’t build into an index.html as it should. I’m not sure of the exact problem but it was all in the header markdown that you see at the top of every markdown page. I think it was that I didn’t change the titles of the pages to reflect the changes in the filenames and there was a naming conflict. Anyway, after revisiting them index.html is being properly built from index.md.

Read More