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 and store secrets without exposing them to our git repository. 1. flake-parts The easiest way t...| Mitchell Hanberg's Blog
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 Gookin (did you know he wrote the very first "For Dummies" book??). A little unusual for me, I'm ...| Mitchell Hanberg's Blog
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. 1. Install home-manager Let's start with a basic home-manager configuration to our flake from last tim...| Mitchell Hanberg's Blog
I've joined the official Elixir language server team!| www.mitchellhanberg.com
I've recently seen talk of similar libraries to Schematic so I figured I'd share my take on the problem space!| www.mitchellhanberg.com
noun informal| www.mitchellhanberg.com
Gotcha! The click bait worked!| www.mitchellhanberg.com
Formatting on save is a popular workflow and is builtin to 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", { -- 3 buffer = args.buf, callback = function() -- 4 + 5 vim.lsp.buf.format {async = false, id = args.data.client_id } end, }) end }) We create a ne...| Mitchell Hanberg's Blog
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 all of the shortcuts and have so many apps that I use that enhance my workflow. I have never remot...| Mitchell Hanberg's Blog
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!| Mitchell Hanberg's Blog
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 with text editors via the Language Server Protocol. This initial release comes with project wide di...| Mitchell Hanberg's Blog
lazyasdf is my first real* 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 terminal and for those who prefer a graphical application, but the TUI is so much more approachable in ...| Mitchell Hanberg's Blog
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 variable. You may have heard this before as "statement vs expression". last_names=forfriend<-friends...| Mitchell Hanberg's Blog
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. # config/dev.exsesbuild=Path.expand("../assets/node_modules/.bin/esbuild",__DIR__)config:my_app,MyAppWeb.Endpoint,ht...| Mitchell Hanberg's Blog
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 # cd into the directory $ cd foobar # create our database $ mix ecto.create # start the server $ mix ...| Mitchell Hanberg's Blog
Normally, our terminal git diffs look like this. {: .bg-transparent } 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. {: .bg-transparent} This looks great, but I think we can do even better. Let's configure delta to use the same theme as our terminal. delta uses bat for syntax highlighting...| Mitchell Hanberg's Blog
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 application to Gigalixir. Note: This article will assume that you already know how to install Elixir/...| Mitchell Hanberg's Blog
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 GUI tools for me, as well as configure my shell environment. Installing everything still took at le...| Mitchell Hanberg's Blog
{: class="mx-auto my-16 bg-transparent" style="filter: invert(100%);"} 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...| Mitchell Hanberg's Blog
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 with remembering the link that the user clicked. If you were to write your own auth, this would a...| Mitchell Hanberg's Blog
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 practice is to open the app on my phone and computer side by side, allowing me to make sure that t...| Mitchell Hanberg's Blog
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 quickly. This works great for small things like remembering how division works or grokking a tricky enumer...| Mitchell Hanberg's Blog
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. I read in bed when I'm struggling to fall asleep. I read in the morning when I'm riding my s...| Mitchell Hanberg's Blog
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 be the body of the popover. // index.jsconstattachmentNode=document.querySelector("#attachment-p...| Mitchell Hanberg's Blog
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 retrospective? A retrospective (or "retro") is a recurring meeting used by teams to look back at the last spri...| Mitchell Hanberg's Blog
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 order functions. If you have used either the Array.prototype.reduce or Array.prototype.mapfunctions...| Mitchell Hanberg's Blog
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 between an editor or IDE and a language server that provides language features like auto complete, go to ...| Mitchell Hanberg's Blog
| Mitchell Hanberg's Blog
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 systems. This is definitely a lot, especially if Elixir in Action is the first book on Elixir yo...| Mitchell Hanberg's Blog
| Mitchell Hanberg's Blog
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) is short and to the point. If you're reading this book, you probably are interested in the practic...| Mitchell Hanberg's Blog
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 statement applies to all 3rd-party libraries meant to help reduce complexity of state). You Might Not...| Mitchell Hanberg's Blog
| Mitchell Hanberg's Blog
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 thoroughly test-driven, I wanted to make sure that m...| Mitchell Hanberg's Blog
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 them between computers, making it easy to provision a new computer. Let's get started There's a g...| Mitchell Hanberg's Blog
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 by reading its documentation, which I highly recommend. Keep in mind that the "tokens" that Guard...| Mitchell Hanberg's Blog
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 the ability to create normal cron jobs and, when dealing with a Ruby on Rails application, you coul...| Mitchell Hanberg's Blog
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. defrender("409.json",%{changeset: changeset})do%{status: "failure",errors: changeset.errors# this line causes the error}end This function handles rendering the JSON payload that the control...| Mitchell Hanberg's Blog
_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 choice, let's get started. --- What is Erlang? Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in t...| Mitchell Hanberg's Blog
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. Trying something new Pick something and execute. This is especially important when you are giving a ...| Mitchell Hanberg's Blog
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 and deploy it to a VR headset in only a few days. The Platforms There are a couple of categories: D...| Mitchell Hanberg's Blog
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 code base, 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 mapping, and a team full of seasoned engineers who were all familiar with the code base. Until ...| Mitchell Hanberg's Blog
What does this mean?| www.mitchellhanberg.com
4/12/22 Update: I've started working on a dedicated Neovim plugin for Elixir called elixir.nvim. Please follow me on Twitter for more frequent updates!| www.mitchellhanberg.com
As Temple has aged, my ambition for this little library has grown.| www.mitchellhanberg.com
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.| www.mitchellhanberg.com