RSSAmplifier

Blog

Tucker Chapman

Recent content on Tucker Chapman

tuckerchapman.comRSS feed ↗26 posts

Latest posts

Generate Random String with CLI

TIL a few one-liners for generating random strings. date +%s | sha512sum | base64 | head -c 24 ; echo The string is pseudo random and seeded by the current UNIX timestamp. The command should work with most Linux distros and MacOS. If running on Linux a more random command to try uses /dev/urandom and tr . tr -dc A-Za-z0-9 </dev/urandom | head -c 24 ; echo If you need a passphrase you can use the…

Firefox Address Bar Shortcuts

TIL The Firefox Address Bar includes shortcuts for all kinds of things. Use special characters to search your history (^), bookmarks (*), and tabs (%). Type the shortcut character before your search to filter the dropdown entries to tab through. Use the @ to search configured websites, history, bookmarks, and tabs (type @bookmarks, @wikipedia, etc.). Add keywords to your bookmarks to create…

JWTs are Base64URL Encoded Strings

TIL a JWT (JSON Web Token) is a couple Base64URL encoded strings with a signature. A JWT takes the structure <header>.<payload>.<signature> . The header and payload of a JWT aren&rsquo;t secret (they&rsquo;re Base64URL encoded). The magic of JWTs is how the signature is calculated. Calculate the signature by Base64URL encoding the header and payload then hashing with a secret…

Proactively Lazy

Get more done by embracing laziness. Motivation—the fickle beast—doesn&rsquo;t make you productive, your interaction with your environment does. Use your motivation to improve the environment by reducing—or increasing—the energy needed do things. Clean the dishes as soon as you finish your meal, display your guitar on a stand instead of in the closet, log out of all social media accounts when you…

Helpful Vim Ex Mode Commands

Simple patterns to do useful things with the Ex Mode :global command in Vim Delete all lines that match a pattern ( :help pattern ) : g /pattern/ d : global /pattern/ delete Delete all lines that don&rsquo;t match a pattern ( :help :vglobal ) : g ! /pattern/ d : v /pattern/ d : vglobal /pattern/ delete Remove all trailing whitespace with :substitute : % s /\s\+$/ / e Find more info by running…

SQL Simple Pivot Pattern

TIL a simple pattern for pivoting data with an SQL query using FILTER (or a CASE WHEN clause if the FILTER keyword isn&rsquo;t supported by the database ). The example input data is from the Chinook Database and is modeled like this: | InvoiceDate | BillingCountry | Total | | ------------------- | -------------- | ----- | | 2011-02-15 00:00:00 | Belgium | 1.98 | | 2009-10-17 00:00:00 | Brazil |…

Interpolate Environment Variables with Docker Compose

TIL you can use environment variables in your docker compose files. I use environment variables with my homelab setup as a simple way to keep secrets out of version control and reduce repeating common file paths for binded volumes. Docker compose even uses a .env file out of the box. Most shell interpolation features work too. services : web : image : nginx ports : - "8080:${NGINX_PORT:-80}"…

Create multiple nvim configs with $NVIM_APPNAME

TIL you can save multiple nvim config setups with the $NVIM_APPNAME environment variable. Nvim will look for, or create, the config in the $XDG_CONFIG_HOME/$NVIM_APPNAME directory. Easily switch between the configs with aliases in the startup file for your shell (i.e. .bashrc , .zshrc , etc.). # $NVIM_APPNAME defaults to nvim alias avim = 'NVIM_APPNAME="nvim-astro" nvim' alias zvim =…

Exclude Directories using the Find command

TIL you can exclude directories when using the find command. ## Exclude the node modules directory when searching with find find ./ -name "*.css" ! -path "*/node_modules/*" Source: Stack Overflow

Python Http Server

Python comes with a simple http server you can use to serve a directory of files as a web server. I use it all the time to serve code coverage reports and various other static web projects that don&rsquo;t come with a server. Start the server using this command: $ python -m http.server Serving HTTP on :: port 8000 ( http:// [ :: ] :8000/ ) ... Once this is running you can now access the files in…

Python Context Manager

TIL you can write your own functions to use in a python with statement. These functions are called context managers. A context manager is a simple way to wrap a try/except/finally block in a reusable function. Writing your own context manager is simple. from contextlib import contextmanager @contextmanager def random_number (): """ https://xkcd.com/221/ """ try : # do any setup yield 4 # Yielded…

Podman Pods

TIL the POD in Podman is the same idea as Pods in Kubernetes. Pods are collections of containers that share resources (i.e. volumes, networks, etc.). Create a pod with the podman pod create --name [pod-name] command. You will need to expose ports and setup other resources with the pod create command. podman pod create --name my-new-pod --infra --publish 8080:80 --network bridge Add a container to…

Special tld &#39;.home.arpa&#39;

TIL about the special-use *.home.arpa tld. The .home.arpa tld is reserved for &ldquo;non-unique residential home networks&rdquo;. If you use Adguard Home, Pi-Hole, or any other DNS server you can freely use .home.arpa for all your local assets (printers, self-hosted server, etc.)!

Slash or Not to Slash with rsync

TIL an easy way to remember if you want a slash or not when you run rsync . A trailing slash will copy the contents of the directory while just the directory name will copy the directory itself. For example # copies everything in dir into new-dir rsync -r dir/ new-dir # copies dir into new-dir rsync -r dir new-dir

Python List Comprehensions

TIL about Python List Comprehensions. I came across code that looked like this in a codebase. baz = [ foo . bar for foo in foos ] I could see what was happening ( baz is now a list of bar for each object in foos ). I didn&rsquo;t know this was called list comprehension but now I understand the data structure. List comprehensions are useful for lots of things when you want to create lists from…

Hugo Debug Jsonify

TIL that you can output all the data in &ldquo;the dot&rdquo; from a Hugo template using jsonify < pre > {{ . | jsonify (dict "indent" " ") }} </ pre > Here is the output of the .Params value for this post < pre > {{ .Params | jsonify (dict "indent" " ") }} </ pre > { "date" : "2022-11-13T16:54:29-05:00" , "draft" : false , "iscjklanguage" : false , "lastmod" : "2022-11-13T16:54:29-05:00" ,…

cal and ncal

TIL about ncal (most Linux distros) or CAL (on MacOS). I have used cal for quite a while which is a convenient calendar tool in the terminal. However, I hit CAPS LOCK on accident and ran CAL instead of cal , to my surprise it output November 2022 Mo 7 14 21 28 Tu 1 8 15 22 29 We 2 9 16 23 30 Th 3 10 17 24 Fr 4 11 18 25 Sa 5 12 19 26 Su 6 13 20 27 (the normal cal output)

How to Open Files with Vim

How exactly do you open a new file without closing and reopening vim? Read on to learn more about how to open files (or buffers) in vim using various included tools or external plugins. Vim uses the word &ldquo;buffer&rdquo; instead of &ldquo;file&rdquo;. When you :wq you write the current buffer to a file.

Getting started with vim-airline

The default vim status line can work well but vim-airline inhances it in many ways. Vim-airline is a simple lightweight plugin that integrates with many other popular plugins out of the box (but they are not required). In this post you will learn how to get vim-airline setup with some basic settings and a theme.

Vim Plugin Audit

Vim is my daily driver for text editing. I keep my plugin list curated to only what I use on a regular basis. In this post I&rsquo;m going to go over each plugin currently in my plug file , write a sentence about it, and determine whether is stays or goes.

Roland FP-30 and Bluetooth

This may work on other Roland digital piano models but I only tested it on an FP-30 with my Motorola X4. After spending about an hour trying to figure out why my system Bluetooth could not find my piano I figured out how to actually connect. (Hint: it&rsquo;s not through the system Bluetooth) Download the Roland Piano Partner 2 App Turn on your piano Enable Bluetooth on your phone Turn on the…

Vim Has Spell Check!?

Did you know vim has a build in spell check system? The built in spell system will ignore code variable names and functions by default but it does detect spelling mistakes in your comments and doc blocks (you do write helpful comments right?).

A Better Way to Organize Your .vimrc

Vim is a powerful customizable editor. Configuration is stored in custom text files often found in a Unix home directory (ie ~/.vimrc). This vimrc file can get to be rather large the longer one uses vim. Break the file into parts The number of files you use is infinite but it works best to keep things simple and organized. I use five files: plugin loader, general settings, leader key settings,…

How to Use the Vim <leader> Key

Vim is a keyboard driven text editor which means there are a lot of keyboard shortcuts and commands. The <leader> key is a vim tool that can be used to create personalized shortcuts. Let’s discuss a few different ways to create our own shortcuts.

Refactoring a Rails View

Have you ever looked back on your code and thought “Who wrote this! …. <git blame> …oh…it was me.” We are all constantly learning new things and frankly our past self is just not as smart as our current self (or so we think). So today I want to walk through a simple refactor I did on a Rails project I have worked on over the years. (Source code found on my GitHub )

Qgis Tutorial – Earthquakes in Oklahoma

Download your own copy of QGIS from qgis.com (works on Windows, MacOS X, and Linux) Overview of the Interface Welcome to QGIS! Quantum GIS (now just known as QGIS) is a cross-platform, free, and open source GIS application. It has all of the features one needs in a GIS and many more can be added simply using the community hosted plugin repository. The QGIS UI Reference Image can be used to get…