Using use in Gleam Recently, a colleague checked out Gleam’s language tour . They liked what they saw, but they were confused by Gleam’s use syntax. I like Gleam’s syntax a lot I even wrote an article about Gleam’s syntax . , but I was also confused by use when I first encountered it. Here’s how I use use : The use expression was introduced in Gleam v0.25 , as a more…
Tools I Use: firefox Firefox is my daily use browser. I’ve tried a number of browsers over the years, but I keep coming back to Firefox. Here’s a bunch of tools and features I use in Firefox: Bookmark Keywords Firefox allows me to add keywords to bookmarks. I can type these abbreviated shortcuts into the address bar instead of the full link. I can add keywords to bookmarks from the…
Things I like about Gleam’s Syntax Gleam is a Type-Safe programming language that transpiles to Erlang And javascript . , so you can run its code on the BEAM. I’ve slept on Gleam for a while because its syntax. It was too much Rust and not enough Elixir for me. Recently, I was reminded of Gleam when someone mentioned that Gleam doesn’t have an if statement, but instead uses case…
How to Embed an SVG in CSS Recently, I needed to use an SVG as a background image in CSS. I didn’t want to host the SVG somewhere, so I couldn’t just link to it. I did have access to the SVG source, so I wondered if I could embed it. As I quickly found out, you can use a data URL. I use CSS data URLs to embed the fonts I use for this website. I didn’t know they could be used for…
How to Count Unique Lines Using Unix Pipes Sometimes I want to take a command line output and count the unique lines from that output. I can do this with a combination of standard unix tools and pipes: Read more about sort , uniq , and head in the linked GNU docs. Alternatively, use man sort , etc. to see what the available flags are on your system of choice. I always find new things when I read…
I created a little webring in Gleam Recently, my friends have been building cool web 1.0 features for their websites, such as this hit counter . Inspired by web 1.0, I decided to create a web ring for me and my friends. What is a webring? A webring is a way of adding discoverability for sites in the ring. On a technical level, it’s a doubly linked list of websites Diagram made with…
My Favorite Gleam Feature I found myself liking Gleam’s syntax more than any other language that I’ve used. With the specific exception of Elixir, where many of these insights took root. I chose to focus this article on Gleam, but both Elixir and Gleam share this feature. This article follows the path of logic as I tried to unravel why. My journey to understanding started with a simple…
Embedding Gleam in my blog with Vite My interest in Gleam came primarily from the idea of having Erlang with Static types. Gleam is able to transpile to Javascript, so I wanted to try embedding it in my blog. I might want to add interactive explanations to my blog in the future, and it would be neat to be able to write them in Gleam. Update 2024-01-06: I now recommend using esgleam instead of…
Embedding Gleam in my blog with esgleam Previously in Embedding Gleam in my blog with Vite , I used the vite-gleam plugin to bundle my compiled Gleam JS and embed it into my blog. Since then, the creator of the vite-gleam plugin has created esgleam As of the time of writing, the most recent version of esgleam is 0.3.0. which allows me to bundle my Gleam JS without needing Node installed. esgleam…
Using Regex in Erlang Recently, I was helping someone port some code to Erlang that involved a Regex. I hadn’t worked with Regex in Erlang before, so here are some notes on what I learned. re - Perl-like regular expressions for Erlang The Erlang standard library has the re module, which supports regular expression matching for Erlang strings and binaries. Both Gleam and Elixir use String to…
Tools I Use: codespell codespell is a command line spellcheck tool that is code-aware. Codespell allows me to spellcheck my software projects without getting stuck on all the jargon that software projects use. Usage and Tips I often use codespell to spellcheck the markup for this blog. It’s nice to have a tool that doesn’t get stuck on the code blocks I use in my articles. It does…
Serve a Static Directory with Erlang For a long time, I’ve been serving static files to locally test this website using python3 -m http.server . Actually, I used a custom script that overrode the Handler class to set the mimetype for files without an extension to "text/html" , since I use that to get clean urls without .html on the end. I’ve wanted to do this with Erlang for a long…
Always Show Scrollbars in Firefox (and Thunderbird) I use the scrollbar to gauge how far I’ve read through an article or webpage. But the default of hiding the scrollbar after a few moments makes this frustrating. Prior to figuring out how to do this, I would wiggle the mouse over the bar every time I wanted to check. This quickly became frustrating. Firefox has a setting for this, which…
When is an Erlang process a shell? Recently, I was trying to port an Erlang function to Elixir, with the goal of answering one question: “When is an Erlang process a shell?” Answering that question involved source diving Erlang, learning new things about git , and reading mailing lists. The Original Code The code I wanted to port was this function Erlang’s syntax might seem a bit…
Git Spelunking with Bisect Today, I continued on the git spelunking that prompted the post from yesterday . I’ve been diving deeper in the Erlang codebase today, and so I needed some new tools. git bisect git-bisect lets you search for a commit using binary search. I wanted to find the last commit that contained a particular Erlang function in the otp codebase. My process looked something…
Git Checkout Tag You can checkout a tag in a git repo by using This is pretty useful for exploring historical version of code bases. “What was this codebase like at release X?” I needed this in order to find a removed function in Erlang. : $ git checkout <tag> Simple as that. Note that running this command without a branch will put you in “detached HEAD” state, meaning that…
Firefox Has a Built-In Screenshot Tool Today I learned that Firefox has a built-in screenshot tool. It’s bound to ctrl+shift+S and allows you to easily select an element of the screen or a selection of the screen. Firefox then gives you the option to copy that selection to clipboard or save it as an image. Example Here I took a screenshot multiple times to get the recursive effect. : Firefox…
Paper: Four Concepts for Resilience Engineering Today’s paper is by David Woods: Four concepts for resilience and the implications for the future of resilience engineering . I found this paper through Fred Hebert’s excellent summary . Resilience has been used a number of different ways in Resilience Engineering literature. This conflation of different definitions makes it difficult to…
Configure IEx to Show Lists as Lists Charlists are a holdover from Erlang as an alternate form of string. In Erlang, strings are syntax sugar on a list of binary characters that make up that string. In Elixir, strings are syntax sugar over UTF-8 encoded binaries. Erlang also has the concept of binaries (called a bitstring), they just aren’t the default string implementation. Elixir chose to…
Just Add Water Or, Using Partial Application In Elixir for Better Errors. Today, I was adapting the generator for a recipe website written by Hundred Rabbits into Elixir. While adapting their idiomatic C code into Elixir, I needed a way to pass a predefined list of ingredients to the builder API for Recipes. To do this, I defined a function that returned a keyword list The cheese: cheese syntax…
Parsing TSVs in Go I’m building a terminal application to learn Go, and I wanted to persist data using Tab Separated Values. Here are some of the things I learned while figuring out how to do that. CSV Reader in Standard Library Go has a CSV reader in their standard library. You can import it like this: import ( "encoding/csv" ) Once it’s imported, you can create a CSV Reader by…
Customizing Fonts in Various Places Notes on how I’ve customized fonts in various places. I like to use Atkinson Hyperlegible You’re reading it now , unless you’ve overridden this websites fonts. where I can for the ability to distinguish characters. Firefox Firefox uses the system font by default. Adding the following to my NixOS configuration.nix did the trick:…
A Joy to Work With Today, I’ve been playing Joy , a purely functional concatenative programming language. Thanks to Shae for reminding me of Joy, and for suggesting that it might be useful for systems programming. Everything in Joy is a function that takes a stack and returns a stack. Hello world looks like this Sourced from here : "Hello, world!\n" putchars . Piece by piece, "Hello,…
Writing From a Learning Firehose I’m attending the Recurse Center (remotely). I value writing things down because I don’t trust my memory to retain the information that I’ve learned. Writing everything down from the diversity of people and the pace of learning from the recurse center is difficult. I had a great conversation about how to write about the things that you’re…
Percent Encoding URLs I use djot for the markup on my static site generator. In djot, the link syntax looks like this: [link text](http://example.com) This works fine for most links, but certain links that include parenthesis, it breaks. This is mostly a problem for Wikipedia, which uses parenthesis for disambiguation of topics. For example:…
Include Diff in Git Commit Editor Running git commit with the --verbose flag allows me to include the diff that’s being applied by the commit inside the editor where I’m writing my commit message. This makes it easier for me to describe the changes that were being made, since I can scroll down in my editor to see them Read more in the documentation for git-commit . Even though the…
Temporary Short Names When writing code, I prefer to use the full name of something to retain context and design decisions established by that name. However, there are cases where using a name many times in rapid succession becomes tedious, bordering on line noise. In those situations, it may make sense to use a temporary alias or short name to keep code legible. Here are a couple examples, one in…
Legible Timeouts with Erlang’s timer By convention, timeouts in Erlang (and Elixir) are set in units of milliseconds. However, this isn’t type checked by either language, so you end up with magic integers for timeouts throughout a codebase. While both Erlang and Elixir support underscores in numbers for readability: 5_000 , you’re still expected to know that timeouts are in…
Set null Placeholder in PostgreSQL psql By default, psql outputs null as nothing, which is easily mistaken for an empty string. You can use Read more about the available psql commands here : \pset null '<chosen alternative>' This seems to be tied to a particular session of psql as it was reset when I restarted the psql session. Unicode tangent The impetus for finding this command came…
My Favorite Elixir Discovery - Access A while ago, I read Hillel Wayne’s source suggestion to “Search less, browse more”. Specifically to systemically go through the the information available for your chosen tools, rather than searching for specific answers to questions as they arise. This is the story of what I found when I started browsing through Elixir’s documentation.…
i3 Window Manager Space Mode When I tried Spacemacs , the one thing I really liked was the “leader” key setup they had around the spacebar. i3 window manager supports arbitrary modes, which can have their own keybinds. This is how I currently have a small “space-mode” setup in my i3 config The $reset is vital here, otherwise you’ll be stuck in “space-mode”…
Adding RSS Feed Link Tag Recently, I added some Atom (RSS) https://stackoverflow.com/questions/3489578/which-is-most-used-rss-or-atom-and-which-one-is-better-to-build-from feeds to my website. I wanted to make sure that I appropriately linked them in my website’s header. The solution is to use a <link> Link documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link…
Edit the Clipboard I recently wanted to write some code in a Github issue, but while Github Flavored Markdown supports code snippets, the web editor has a variable spaced font that makes writing formatted code difficult. Enter vipe vipe is a tool from moreutils that allows you insert an editor into a unix pipe. vipe will create a temporary file with anything passed from standard input (empty if…
An Unlinked Adventure I’ve been working on my new tool maru , to get it polished for release. To that end, I decided to look at cargo-dist a tool that aims to help with release engineering for Rust projects. Since maru is a Rust CLI, it seemed like a great fit. This is the story of how the interaction between cross-compilation and NixOS led to a rabbit hole of dynamic linking on linux. Thank…
Playing with SVG This week I had a chance to play with SVGs. Previously, I’ve felt intimidated by generatin graphics with code, but I found working with SVGs to be delightful. Basics - Path <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"> <path d="M 10 10 H 90 V 90 H 10 Z" fill="transparent" stroke="black"/> <!-- Points --> <circle cx="10" cy="10" r="5" fill="red"/> <circle…
Mix Completions I’ve released mix_completions , a mix task that allows you to add shell completions for mix . mix_completions supports completions for bash and zsh . fish already had community contributions adding completions for mix : fish completions How it works mix_completions adds three tasks to work with shell completions: mix complete mix complete caches the available completions from…
zsh Completion Today I continued my exploration of shell completion with zsh completion. And it’s a lot simpler than bash completion . Enabling zsh Completion I learned that you can enable zsh completion to autostart by adding these two lines to your .zshrc : autoload -Uz compinit compinit Both were added by the zsh configuration wizard when I opened the shell for the first time. The first…
Bash Completion This week, I’ve been exploring how tab completion works in Bash. I knew that it was possible to generate bash completions for command line utilities, but I never knew how it worked. So I cracked open the source code for click , a python framework for command line applications that had shell completion as a feature. Helpfully, the shell completions were contained in…
YouTube RSS Feeds I’m trying to get back into using RSS feeds. YouTube used to make it easy to follow channels by RSS, but they’ve removed that ease in favor of what seems to be channeling you into creating a Google account. YouTube feeds do still generate an RSS feed though. It can be found at: https://www.youtube.com/feeds/videos.xml?channel_id=<channel_id> Where <channel_id> is…
Does Go Have Enums? As I continue to explore Go for my new project, I wondered if there was a way to do Enums in Go. Enums are important for the way I write code, because I try to avoid overloading identifiers. That is, I want each identifier to capture as much of its own context as possible. Booleans are the worst Okay, that’s not fair nil or null is also semantically anemic, and provide…