RSSAmplifier

Blog

Mitchell Hanberg's Blog

Mitchell Hanberg's Blog

mitchellhanberg.comRSS feed ↗49 posts

Latest posts

Using Agenix with devShells

Tip This article is part of the Agenix series Getting Started with Agenix Using Agenix with Home Manager 👉 Using Agenix with devShells Nix with Flakes allows you to easily centralize project environments and setup right in your repository. Often, your README will tell the reader "get an API key for FOOSERVICE from a teammate" Just like NixOS modules and home-manager , we can use Agenix to encrypt…

Compiling C with Zig

I'm relatively new to systems programming, having not done any since college (go Boilermakers! ), and back then we weren't really taught anything about build systems. I think the most we did was manually calling gcc or were given a Makefile that no one comprehended... or was that just me 🤔. I recently read through Modern C by Jens Gustedt and I'm currently reading through Tiny C Projects by Dan…

Using Agenix with Home Manager

Tip This article is part of the Agenix series Getting Started with Agenix 👉 Using Agenix with Home Manager Using Agenix with devShells Home Manager (also styled as home-manager) allows you to configure your programs and configuration with Nix code, similar to NixOS modules. Just like NixOS modules, we can use Agenix to encrypt and store secrets without exposing them to our git repository. Install…

Getting Started with Agenix

Tip This article is part of the Agenix series 👉 Getting Started with Agenix Using Agenix with Home Manager Using Agenix with devShells NixOS modules make it easy to configure many services with a consistent interface (the Nix language), but configuring confidential options like passwords and API keys this way has two major problems. Secrets should not be committed to source control in plain text.…

Code BEAM America 2025

My first conference of 2025 was Code BEAM America and I had the honor of attending with a great crew from DraftKings ( we're hiring! ) and to give my second ever conference talk! On the Elixir community Reflecting on this year's conference, I realized how comfortable I was the entire time. After 7 years in the Elixir community, I've accumulated a number for friends and acquaintances, something I…

I've Joined the Official Elixir LSP Team

I've joined the official Elixir language server team! This is the culmination of the efforts from Jonatan Kłosko (of LiveBook), Steve Cohen (of Lexical), Łukasz Samson (of ElixirLS), and myself ( Mitchell Hanberg of Next LS). You can read more about it on elixir-lang.org . We are currently working on merging the three projects (Lexical, ElixirLS, and Next LS) into a single official project, so in…

Validate and Transform Your Data with Schematic

I've recently seen talk of similar libraries to Schematic so I figured I'd share my take on the problem space! Schematic Schematic is a library for validating and transforming data in Elixir, similar to Ecto Changesets and Norm . I created Schematic early in 2023 while developing the GenLSP library, which I developed to build Next LS . I needed to be able to consume and produce data structures…

Pet Peeves

btw I update this periodically as I find new things things that bother me. noun informal something that a particular person finds especially annoying: one of my biggest pet peeves is poor customer service. Here's a list of minor things I find irritating. Calling software "dead" or "abandoned" Complaining about too many choices, especially when C=2 Complaining about what other people are doing when…

Create Your Own Neovim Distribution

Gotcha! The clickbait worked! We're not really in the market to create an actual "distribution", but we are going to explore how to extract your Neovim configuration into it's own plugin. Other real distributions actually employ this trick themselves like LazyVim and AstroVim , the main requirement is that you use the lazy.nvim package manager. Let's get into the code! Converting your current…

Modern Format on Save in Neovim

Formatting on save is a popular workflow and is built into many text editors and IDEs. In Neovim, you must create this manually, but it is very easy using autocmds . -- 1 vim . api . nvim_create_autocmd ( "LspAttach" , { group = vim . api . nvim_create_augroup ( "lsp" , { clear = true } ) , callback = function ( args ) -- 2 vim . api . nvim_create_autocmd ( "BufWritePre" ,…

Ergonomic Remote Development

I recently built a new PC (you can see the specs on my /uses page!) and installed Linux on it. The way I have been using it mostly has been through an SSH connection, even though its sitting underneath my desk, plugged into my monitor, and all my peripherals plugged into a nifty USB hub splitter thing! I simply couldn't live without the macOS desktop environment. I have so much muscle memory for…

OTP Process Abstractions with proc_lib

In November of 2022, I had the privilege to speak at Code BEAM America . You can check out the video below, let me know what you think!

Credo Language Server and the birth of elixir-tools

Last year I started working on gen_lsp , an abstraction for writing language servers in Elixir. I gave a presentation on gen_lsp and writing OTP process abstractions at CodeBEAM America 2022. You can watch my talk on YouTube . Today I'd like to announce the release of the first language server built with gen_lsp . Credo Language Server Credo Language Server is a persistent server that communicates…

Introducing lazyasdf: An Elixir-based TUI for the asdf version manager

lazyasdf is my first real 1 attempt at making a TUI with Elixir ! asdf is normally used through a command line interface (CLI), lazyasdf presents you with a terminal user interface (TUI) for working with asdf . I recently fell in love with lazygit and have since dreamed of writing my own TUI programs, but with Elixir. The TUI provides a quick and intuitive interface for those familiar with the…

The Comprehensive Guide to Elixir's List Comprehension

What is it? The for special form, also known as a list comprehension, is a construct designed for concise and powerful enumerable transformation in Elixir. It looks very similar to a "for loop" in other languages like JavaScript and C, but rather than being a language construct, it is an expression (like everything else in Elixir). This means that it evaluates to a value that can be bound to a…

How EEx Turns Your Template Into HTML

EEx is a templating language and module built into the Elixir standard library, often used by web servers to render dynamic content for a web application. The same concept exists in other language ecosystems, ERB for Ruby, Blade for Laravel/PHP, Pug/Jade for JavaScript. A couple features of EEx that make it stand out are: Templates can be compiled into functions ahead of time, avoiding needing to…

How I Handle Static Assets in my Phoenix apps

I no longer use Webpack . Now I use esbuild , postcss-cli , and cpx . esbuild bundles and transpiles my JavaScript files extremely fast. postcss-cli processes my CSS and can run the TailwindCSS JIT mode without any problems. cpx copies other static files from the assets directory into the priv directory. Running each of these tools in development is just as easy as running Webpack. #…

How to Set Up Neovim for Elixir Development

Update 4/12/22: I've started working on a dedicated Neovim plugin for Elixir called elixir-tools.nvim . Please follow me on Twitter for more frequent updates! This article is the spiritual successor to How to use Elixir LS with Vim . Since then, I've switched from Vim to the nightly release of Neovim as well as how I integrate linters, formatters, and LSPs. This article will cover: Installing…

Announcing Temple v0.6!

v0.6 of Temple has been released! 🎉 This release is the result of a few architecture changes that allows for faster rendering as well as many new features. If you'd like to follow along with the code in this article, it's available here . Compile time output of EEx Temple now outputs EEx at compile time, allowing us to piggy back on the power of existing EEx Engines, such as the engines included…

Temple, AST, and Protocols

As Temple has aged, my ambition for this little library has grown. Temple started with the ability to produce HTML at runtime, but now includes: EEx output target LiveView support (it's just EEx after all!) Basic component functionality (essentially just partials) If my goals for this project are going to evolve, so does the code base. So far I've been able to accomplish this with a rather naive…

How to Deploy a Phoenix App to Gigalixir in 20 Minutes

This is a quick screencast to demonstrate how easy it is to deploy an Elixir application to Gigalixir , a hosting platform built specifically for Elixir. I included a condensed text version of the video for those who prefer it, but you can find the full guide here . Create the Phoenix App # install the generator $ mix archive.install hex phx_new 1.5.6 # generate the project $ mix phx.new foobar #…

Better Terminal Git Diffs

Normally, our terminal git diffs look like this. Let's improve our experience by adding syntax highlighting! To accomplish this, we're going to replace the pager that git uses with a tool called delta . Add the following to ~/.gitconfig . [core] pager = "delta" Let's see what our git diffs look like now. This looks great, but I think we can do even better. Let's configure delta to use the same…

CI/CD with Phoenix, GitHub Actions, and Gigalixir

I like to start my side projects by immediately configuring them with a CI pipeline and automatic deployments. I normally go with Heroku, but Heroku has some drawbacks when deploying Elixir applications. Luckily, another PaaS solution exists and is designed specifically for Elixir, Gigalixir ! Let's build a project called "Pipsqueak" and learn how to automatically test and deploy a new Phoenix…

Setting up my new computer

I started a new job last week, so I naturally received a new computer that required some set up. Usually this could take hours or even days, as there's always an app I forget to download or some random setting that I can't remember how to configure. Luckily, I have automated most of the process! In my dotfiles repository, I wrote (some parts borrowed ) a shell script to install all of my CLI and…

Introducing Temple: An elegant HTML library for Elixir and Phoenix

Temple is a macro DSL for writing HTML markup in Elixir and a template engine for Phoenix . Conventional template languages like EEx use a form of interpolation to embed a programming language into a markup language, which can result in some ugly code that can be difficult to write and debug. Temple is written using pure elixir. Let's take a look. use Temple @ items [ "eggs" , "milk" , "bacon" ]…

Implementing link following with OAuth

Link following is the process for dynamically redirecting a user after successful authentication. Disclaimer: I'm not sure what this is actually called, so I made up "Link following." If you know the actual name, let me know! If you are new to using OAuth to handle authentication, implementing link following won't be as intuitive as it would be if you were hand rolling your own. The trouble comes…

Tools I use for mobile web development

It's never been easier to write web applications for mobile and I want to share some of the tools I use everyday that help me do so. ngrok ngrok is a tool used to create encrypted web tunnels to your computer in order to expose a local development server to the internet. While modern web browsers have "mobile mode" dev tools, they don't perform as well as actually using the app on your phone. My…

Experiment in the REPL

A technique I've picked up for learning new tools is experimenting with them in the REPL . A read–eval–print loop (REPL), is a simple, interactive computer programming environment that takes single user inputs, evaluates them, and returns the result to the user. * Elixir ( iex ), Ruby ( irb ), and Node.js ( node ) all have interactive shells that allow you to evaluate expressions easily and…

Tips for Reading More

In 2017, I challenged myself to read 20 books and I was able to read 22 books. In 2018, I raised the bar to 30 books, but I was only able to read 16. In 2019, I'm still aiming for 30 books; how can I make this happen? So far in 2019 I've already read 7 books and have found good strategies for frequent and consistent reading. I've started reading during boring activities that don't require my eyes…

Creating Responsive Popovers with Popper.js

Making simple popovers is pretty easy. Making popovers that position themselves based on the available screen real estate so they're always visible is not. Luckily Popper.js will do the math for us and is straight forward to implement given the proper instructions. JavaScript The JavaScript portion is simple. The Popper constructor takes a DOM node to attach the popover to and a DOM node that will…

Conducting Good Retrospectives

Every team experiences moments of success or failure, moments of working like a well oiled machine, and moments of not being able to stand the sound of each other's voices. But many teams let these moments pass by without taking time to ponder "why did these things happen"? A structured way to make sure your team doesn't miss asking that question is to hold a retrospective . What is a…

Reducers: Exploring State Management in React (Part 2)

In a previous post , we demonstrated how the Container/Presenter pattern is a solid approach to managing your React state. This time we are going to look into using Reducer functions as the method to managing change in state of your components. Reduce Reduce (also known as a fold ) is a functional programming concept that deals with the transformation of data structures using recursion and higher…

How to use Elixir LS with Vim

What is Elixir LS? Elixir LS by Jake Becker (now maintained by the elixir-lsp organization) is the language server implementation for Elixir. What is a language server? If you've been following the story of Visual Studio Code , there is a chance you've heard of another recent creation from Microsoft: the Language Server Protocol . The Language Server Protocol (LSP) defines the protocol used…

Announcing PlanetEx: an open source blog aggregator written in Elixir

Elixir in Action: Book Review

Who is the target audience? The book is intended for beginner and intermediate Elixir developers. As the book progresses, the author dives into topics that get more complex, which might not be suitable unless you already understand the basics of Elixir. Review Elixir in Action covers the full breadth of all that is Elixir, from the basic syntax to building distributed, fault tolerant, and scalable…

How to Subscribe to SharePoint RSS Feeds Without NTLM Authentication

Metaprogramming Elixir: Book Review

Who is the target audience? Advanced beginner to intermediate Elixir developers who have mastered the syntax and basic structure of Elixir applications who want to add advanced language features to their skill set. Review Chris McCord (creator of the Phoenix Framework ) introduces you to the power of macros with the Elixir programming language. This book (a member of the Pragmatic exPress series)…

Container Components: Exploring State Management in React (Part I)

At what level of complexity will my React application require Redux? React developers have been asking this question for a long time, and answers still vary wildly. The truth is there is quite a bit we can do before needing to pull in Redux, and even then, Redux isn't our only option! Even the creator of Redux, Dan Abramov thinks that we might not need Redux (although, I think the spirit this…

Building with Elm at SEP:Makes

Integrate and Deploy React with Phoenix

You've just finished your lightning fast Phoenix JSON API, what's next? Motivation My most recent side project, Contact , is a JSON REST API written with Elixir and Phoenix , designed to be the backend to an instant messaging application (e.g., Slack). There was a hackathon coming up at work, and I thought it'd be fun to make a frontend for Contact during it, and although Contact's development was…

Version Your Dotfiles for Great Good

What are dotfiles? Your dotfiles are the hidden files or folders that live in your home directory, for example your .vimrc and your .bashrc . What do I mean by version? By "version", I mean to track your dotfiles using a version control system, like git, and a hosting service, like Github. Why would you want to version them? Versioning your dotfiles allows you to track them and to be able to share…

Implementing API Authentication with Guardian in Phoenix

Most applications need some sort of authentication and authorization, and REST API's are no different. If you are familiar with web development but have never worked on one that does not have a front end (like me), then the authentication functionality might stump you at first. What is Guardian? Guardian is a token based authentication library for use with Elixir applications. More can be learned…

Scheduling Cron Jobs on Heroku with Ruby on Rails

A common practice is to create a cron job whenever you have a task you need done periodically. The software utility Cron is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. [^1] On something like AWS, you would have…

Encoding Ecto Validation Errors in Phoenix 1.3

Problem I recently ran into this error while implementing the first endpoint of my Phoenix JSON API. ** (Poison.EncodeError) unable to encode value: {:username, {"has already been taken", []}} After a bit of googling and detective work, I found the offending piece of code, located in my error_view.ex file. def render ( "409.json" , % { changeset: changeset…

Installing Erlang and Elixir with asdf

Caution ASDF has changed a lot since this was written, you'll want to consult the documentation first. Let's set the scene You've been fully entrenched in the Ruby and Rails world for 10 months You've just tied a bow on your latest side project You're already bored and excited to start something new For the sake of this post, you work on a mac So you've decided to mess around with Elixir! Nice…

Habits of Successful Projects

Over the course of a project, it is easy to become jaded and to lose track of why your team has certain processes. It's important to stay vigilant to keep those processes from degrading, because you will have trouble finding the cause of a reduction in velocity or quality due to the misunderstanding of how the team is operating. This post details some habits that I've noticed to be invaluable.…

First Dive into Development for VR

Intro Having some free time, I was asked to investigate the current state of Virtual Reality (hardware, development kits, etc) and to attempt build a prototype in order to start building our chops. Going into this, I didn't have any prior experience with VR, 3D modeling, or physics engines and I wasn't sure if I would be able to even get anything to compile, yet I was able to build a small game…

Leaving Your Legacy

Introduction At one point or another, we all will work on a legacy project. You're between projects and you get put on an internal effort, you're starting a new project with a client and inherit the old codebase, or something or another. I was fortunate enough to get placed directly on a project when I joined my company, rich with modern coding practices. Code review, scrum-style backlog and story…

If You Don't Have Anything Valuable To Say... Say It Anyways

What does this mean? In the professional world, feedback is incredibly important and can vastly beneficial, but sometimes our fear of criticism can stop you from sharing, which then inhibits you from learning. There's nothing I hate more than being wrong, more so than others knowing I was wrong. Being able to leverage others knowledge to accelerate your own growth is a key to success (in my…