RSSAmplifier

Blog

Blog Posts on Shreve Labs

Recent content in Blog Posts on Shreve Labs

shreve.ioRSS feed ↗11 posts

Latest posts

Finding the current Git branch in CodeBuild

Skip to the code I want to use the name of the current git branch in nearly every automated build I run on CodeBuild, usually for tagging docker images. CodeBuild doesn’t make this value available, just the commit hash it fetched. No problem! There’s a command that’s pretty commonly seen for grabbing the branch name yourself: git rev-parse --abbrev-ref HEAD The command rev-parse…

Creating a generic set type in Go

tl;dr: map[interface{}]struct{} gives us the properties we want with a low memory overhead. There’s a great implementation of this idea (including thread safety) at dekarep/golang-set . First things first, if you’re not familiar, a set is a data structure that maintains a unique collection of elements. They work similarly to other collection types like vectors, but with a few special…

Obfuscating your email on the web

I really like having my email address publicly available on my website. Email is a great medium for feedback or discussions about the articles I post here, and making it accessible increases the chance readers will think to reach out with it. The problem is, I don’t like getting email from robots, and that is an inevitable consequence of this publicity. The solution to this is to not include…

Creating a website theme that respects user preference

A neat website theming option I’ve seen used more frequently lately is the use of the prefers-color-scheme media query. It allows the user’s browser to specify if they want a light or a dark theme, or if they have no-preference . If the user went through the trouble of requesting a theme, you might as well give it to them, right? Here’s what I came up with to do that. The…

The Juice

A former coworker of mine used to talk about “the juice” and “juicing up” our work. What he meant was making sure all our individual interests were aligned along our work. Having a job means you’re getting paid and that’s at least one interest being fulfilled, but what else could your work be doing for you? Do you enjoy working on what you’re working on?…

IEEE-754 Floating Point Numbers

Many programmers are aware of floating point numbers, typically called floats, and their value for storing decimal values. Most of them are also aware of some vague danger in using them which can cause some really bizarre-seeming results. For example, in Ruby, 0.1 + 0.2 = 0.30000000000000004 This is due to the way we store these decimal values. Floats use scientific notation in binary format,…

Calculating current CPU usage on Linux

tl;dr: The code I use a tool called i3blocks to script my own status bar, which includes a CPU usage indicator. Recently, I noticed something odd about it. The output would change for a while, but eventually stick right around 41%. I had previously just copied this script from Stack Overflow, so I decided it was time to dig in and learn about this in order to fix it. I was able to relocate the…

A Gentle Introduction to Kubernetes

Manually managing servers is a pain. Setting up a server you already know the desired configuration for feels like a huge waste of time. There are tools available to help automate this process, like capistrano, puppet, and chef, but they don’t solve the whole problem, and to me felt quite brittle. There has to be A Better Way™. That’s where Docker and Kubernetes come in. Docker makes…

Hex Color Scales

I recently created a battery module for my i3blocks bar. For this project, I wanted the icon to have a color representing the fullness of the battery — 100% green for full, 100% red for empty, and gradients in-between. i3blocks renders text using pango so it supports hexadecimal colors codes via an HTML-like markup. The desired process can be outlined as: Calculate the battery percentage…

Fixing xbacklight

I recently decided to upgrade from Ubuntu 16.04 LTS to 16.10. This was unfortunate for a couple reasons: 1. The upgrade broke some dependencies leading to apt no longer working and 2. I made the decision at midnight on a worknight. I ended up reinstalling 16.04 and trying to restore a backup of my home folder. In this process, I ended up breaking plenty of my configuration. The most frustrating of…

How to download large files on crappy connections with bash and curl

For some reason, my home internet connection has always been terrible, and seems like it always will be. That doesn’t change the fact that I like the internet, and downloading things from it, like video games I purchased from The Humble Bundle . Until recently, I just dealt with the fact that I’d need to pay a visit to my local library or McDonald’s to use their WiFi. No More!…