I recently wrote and distributed a Python package for a project, and I wanted a web interface to go with it. Naturally, I chose React to build it, but I had never called Python from a React app before, so I had to figure things out. After a quick search, I stumbled across Pyodide , which is a port of CPython to WebAssembly / Emscripten . It allows users to install and use any pure Python package…
treesitter is a tool that can build a concrete syntax tree for a source file and incrementally update the tree as the file is modified. Recently, I’ve been experimenting more and more with treesitter’s query DSL and an abstraction layer in the form of a neovim plugin , and found a configuration option to be particularly useful when editing code: incremental selection . When you write a treesitter…
just is a command runner written in Rust. Commands, or recipes in just lingo, are populated in a file called ‘justfile’, and are expressed in a make-like syntax. I’ve been using just as my command runner for all of my projects, big or small, and find it extremely useful to have a file in the projects root that contains every command needed to interact with the project. There are quite a few…
I recently wrote yet another command-line utility in Rust called present that lets you interpolate the standard output of arbitrary commands that get interpreted by the shell into a markdown file, and I thought I’d share a bit about it here. Problem The main problem I kept running into that pushed me to write this tool was having to manually update the outputs of command line utility help messages…
I recently ran the following command to get my top 5 most used Bash commands: $ history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5 and here is what came up: 20793 lt 10124 lv 9328 v 8686 j 7243 gst These are, for the most part – ordinary, everyday commands: lt : alias for tree -L 1 v : alias for nvim j : alias for just , the fabulous command runner gst : alias for git status What I…
There are many ways you can handle errors in Rust programs: panic at every fallible situation, propagate foreign errors up the call stack, craft your own error type. I’ve recently fallen into a comfortable pattern when dealing with errors in Rust and believe it serves great for small or large projects. This post will walk through a few different ways to handle errors and then ultimately introduce…
The higher-order function is one of the many powerful and important concepts I have run into when dabbling in the world of functional programming. Before diving into the details, it’s worth mentioning that in certain languages like Python or Javascript, functions are treated as first-class citizens. What does this mean? It means that functions can be stored in variables, passed around to functions…
I recently encountered a build failure in a dependency of a Rust crate I was trying to install which led me to be introduced to a git command called bisect . From the official docs found over at git-scm.com , the small description under the name heading reads: Use binary search to find the commit that introduced a bug Sounds super cool right? Using this feature I was able to track down the commit…
I have recently gotten into the habit of reading more blogs, in particular, ones featured on HackerNews . Reading books, personally, has been a difficult habit to cultivate over time, which I mainly attribute to the periodic feelings of being “stuck” or bored on a certain set of books. Blogs, however, offer a condensed read making them efficient and often amusing sources of information. My typical…
I really enjoy using aliases for git commands because a) I’m lazy and b) it makes me feel more productive. Some basic ones I use alias ga="git add" alias gc="git commit" alias gd="git diff" alias gch="git checkout" alias gst="git status" alias gp="git push -u origin master" alias gpo="git push origin" alias gb="git branch" alias gcb="git checkout -b" These ones are set up in my .bashrc file so…
I recently came across this lesser known feature in Python and started to play around with it. Being able to chain comparison operators is a rarity among most modern programming languages, which is a shame considering how elegant and intuitive it turns out to be. Here are some examples: a, b, c = 5 , 10 , 15 print (a < b < c) # True The code above is equivalent to: a, b, c = 5 , 10 , 15 print (a <…