-
vhs themes
I've been working on ninesui , inspired by k9s see thoughts-633 . I want a good flow for making video for the readme and I am using charm.sh 's vhs for this. Its running in an archBTW distrobox and looks gawdaweful. sort.mp4 The over saturated colors give it a really retro look, seems fine, but not my cup of tea. I tried to change the textual theme to and it might have made it a bit better, but still over-saturated. After What I found is that vhs has themes, setting it to made everythin
-
grafana dashboards as k8s configmap
I'm trying to learn proper logs, monitoring, otel, and grafana. Today I imported a bunch of pre-made k8s dashboards and made a few of my own for specific apps, and it made me want to know how I can turn my own custom dashboards into infrastructure as code. Turns out grafana makes it pretty easy to do this, if you have the grafana dashboard sidecar running. It will pick up any ConfigMap with the grafana_dashboard label and import it. Go to Dashboards -> Pick a Dashboard -> Export -> JSON. imag
-
ruff single line import
I've been using ruff to lint my python code for quite awhile now, I was pretty early to jump on it after release. Some of my projects have had a nice force-single-line setting and some have not. I dug into the docs and it was not clear what I needed to make it work. Turns out I was missing I sort in the select list.
-
Markata list posts by year
I was looking back at my [[analytics]] page today and wondered what were my posts about back at the beginning. My blog is managed by [[markata]] so I looked at a few ways you could pull those posts up. Turns out it's pretty simple to do, use the markata map with a filter. !!! Note the filter is python eval that should evaluate to a boolean, all of the attributes of the post are available to filter on. Result You could use the command as well right within your shell and the same map and filte
-
pre-commit exclude
I run tailwind for my personal blog, whenever I update it, pre-commit goes in and fixes end of file. I'm sick of these things fighting each other, since it is a generated app it is going to et ignored from pre-commit from now on.
-
newlines in css before
I'm building in a [[ fragmentions ]] implementation into my blog, I wanted to add some text before the fragment to indidate that it was the highlighted fragment that someone may have intended to share with you. To get a newline in a I need to use and . Here is what it looks like on my not yet live implementation of fragmentions. screenshot-2025-02-15T15-43-06-372Z.png
-
testing nvim installs
Testing fresh nvim installs can be a pain, and hard to di without borking your known good install. I've been using to run a test nvim in a sandbox that wont bork my main install. This usually runs for me in under a minute, can be down under 15s if I remove some of the TreeSitter installs at the end. This beats a full docker build of my full devtainer to test out nvim packaging woes. I've started to use this as a recipe to run before deploying a new version of my dotfiles. So far its pairi
-
vim date
When I want to put a date in a document like a blog post from vim I use !!date from insert mode. Note that entering from normal mode puts you in command mode with filled out. This runs a shell command, i.e. for this example. It outputs the following Fri Jan 31 08:46:11 PM CST 2025 You can also pass in a date such as tommorrow by pasdding in the -d . It outputs the following Sat Feb 1 08:53:20 PM CST 2025 codeium just taught me this one with autocomplete This outputs the following 2025-
-
aptitude why
Today I ran into an interesting question, why am I being asked to configure tzdata while installing npm. Turns out that the cli has a why command that very handily nails down why you have something installed on a debian based system. Install aptitude Why tzdata Now we can query why we need tzdata and see the full chain with the root package being .
-
configure timezone
Today I ran into this interactive prompt on ubuntu while installing node and npm, and I do not want to manually configure this interactively every time I run an install, moreso in docker I do not have the interactive terminal to do so. Why tzdata Checking aptitude why tzdata it shows that the chain goes back through npm. The solution, configure tzdata !!! TIP DEBIAN_FRONTEND=noninteractive This is required, because apt installing tzdata will trigger the interactive prompt. You will manually con
-
bc
https://www.youtube.com/watch?v=03KsS09YS4E&t=610s Today I learned about the basic calculator, bc. At the very end of this video prime uses it to add numbers in vim. REPL You can start a calculator repl at the command line, by running bc. Vim Since bc supports standard unix pipes you can easily pipe data from vim into bc and back out using . All you need is a string of math on the line you want to calculate, go to normal mode and run to get the answer. Traditionally I will open my system ca
-
tailwind aspect
I've been back to putting some images on my blog lately and thinking about making them a bit thinner through the use of aspect ratio for simplicity. I'm leaning pretty heavy on tailwindcss these days due to some weird quirks of markdown-it-attrs I cannot have slashes in classes from markdown so I made a class to achieve this. Example screenshot-2025-01-31T14-50-00-094Z.png {.cinematic}
-
markdown it attrs with slashes dont work
Attrs does not like '/' characters in its classes, so to use some tailwind classes with custom values we must make new classes in our tailwind input css. Given the following markdown with attrs added to the image and to the paragraph block. We get the following output with only the middle one working correctly. screenshot-2025-01-31T14-50-00-094Z.png {.aspect-[2.39/1]} screenshot-2025-01-31T14-50-00-094Z.png {.cinematic} {.cinematic} screenshot-2025-01-31T14-50-00-094Z.png !!! Note The inline ve
-
setting up nvim-manager starship prompt
I built out a tool for myself to manage my nvim configuration, and I wanted to quickly see which one I am running in my starship prompt. Here's the config I ended up with. It warns if the environment variable is not set, and it shows which nvim I am using if it is set.
-
emoji in headless chrome in docker
I recently noticed that my og images were missing emoji. They were taken using headless chrome in a container. I fixed it by adding an emoji font in the containerfile / dockerfile. Before Here's what they were looking like with broken emoji fonts. image After And now with the fixed emoji font. image I put thought bubbles on my thoughts posts and stars on my github stars posts
-
postiz-file-upload
Today I learned that the docs in postiz are a bit behind, (fantastic docs btw, they are to the point, and cover almost all of what you need). The docs state that you need to include an R2 bucket to handle uploads. This issue shows that more work has been done, one of which is local storage. The compose file they use in the quick start has the required env variables to set this up. looking into my running instance I can see my images there.
-
Links rely on color to be distiniquishable
Today i got hit by this accessibility issue on my site. Low contrast links are not distiniquishable. I had not seen this error title before it was new to me, maybe I have bad memory or maybe it's new to me. screenshot-2024-12-18T02-25-53-014Z.png I ended up dropping the background color of the site down a notch as I didn't really care for the semi-dark brown anyways. I'm liking the near black much better now. screenshot-2024-12-18T02-45-53-807Z.png Now I got that 100 A11y score in lighthouse
-
urllink
Today I discovered the function in bash from the ujust tool from ublue.it . Seems like a cool trick, but might not work everywhere.
-
debug cloudflared tunnel
I've been debugging a cloudflared tunnel issue in my homelab all day today, and getting really frustrated. My issue ended up being that it was running twice, once without the correct config file and another with it. I believe that cacheing may have compounded the issue. In yesterday's post I setup a cloudflared tunnel on my ubuntu server to expose applications running on the server to the internet. I'm setting up a new server and running cloudflared in its own vm. [[ setup-cloudflared-tunnel-
-
setup cloudflared tunnel on ubuntu
I run a cloudflared tunnel on my ubuntu server to expose applications running on the server to the internet. I'm setting up a new server and running cloudflared in its own vm. Get the cloudflared binary Now setup the config directory. For the systemd service to work, the config file needs to be in /etc/cloudflared. I like to give my user rights to edit the config file without being sudo, we will do that here by creating a group , add ourselves to the group, give ownership of to the group, gi
-
price an stl print on slant3d
I've been playing with 3d printing some items through the slant3d api. I've been pricing out different prints by running a slice request through their api. make a project I've been using uv for project management. It's been working well for quick projects like this while making it reproducible, I'm still all in on hatch for libraries. Get an api key You will need an api key from the slant api, which currently requires a google account and a credit card to create. slicing an stl with teh slant a
-
k3s config after first install
-
Trying-n8n
Today I gave n8n a try using podman, their docs gave me docker commands, but it ran fine on my machine using podman.
-
Print in place nuts with cura
-
Obsidian-new-file
Wikilinks are a core concept within obsidian to link to documents by [[slug]] wrapped in double square brackets. These are commonly used within wiki site generators. Obsidian gives you a keybinding to go to that file, but if it does not exist it will create the file for you in the root of the project. It's a nice way to quickly make new documents.
-
Slug
A slug is the part of the url that comes after the domain. Commonly matches the file name of a markdown file many blogging systems. These are typically human readable, unique identifiers for pages within the site.
-
Vim-gq
Vim has a handy feature to format text with . You can use it in visual mode, give it a motion, or if you give it it will format the current line. I use this quite often while writing in markdown, I do not use softwraps in vim, so quickly formats my current line into a paragraph. Once I have done this for a single line one time I typically switch to the motion for around paragraph to format the whole paragraph and not just the current line. before formatting vim-gq-20240805122634078.we
-
Obsidian-go-to-definition
It was not obvious to me, but if you have a wikilink such as [[trying-obsidian]], you can jump to the file in obsidian, just like you can with lsp go to definition, the keybinding is alt + enter.
-
Obsidian Using Templater Like Copier
I've long used copier to create all of my posts for my blog, and it works really well for my workflow. I think of a title, call a template, and give it a title. out of the box obsidian did not seem to work this way. It seems like it wants me to right click a file tree and make a new file using the tree, this is not my jam. Here is what I came up with to replace my til template. is a return value, and it gets placed directly into the place it is in the file creates a tab-index point so I can
-
Obsidian Image Converter
I'm giving obsidian a go as an editor for my blog and one of the main things I want to fix in my workflow is the ability to quickly drop in images. on first look through the community plugins I found Image Converter. I set it up to convert to webp and drop them in a git submodule. I may make it something other than a git repo in the future, but I've learned that adding images to my blog repo quickly makes it heavy and hard to clone on other machines. obsidian-image-converter-20240731211310793
-
convert mp4 for twitter with ffmpeg
I've had a couple of uploads to twitter fail recently and has been a pain. I tried some online converters for convenience, but none of them worked. I reached out to chatgpt and found succeess with this ffmpeg command.
-
k8s kustomize diff
I've started leaning in on kubernetes kustomize to customize my manifests per deployment per environment. Today I learned that it comes with a diff command. You can enable color diffs by using an external diff provider like colordiff. You might need to install colordiff if you don't already have it. Now I can try out kustomize changes and see the change with kustomize diff.
-
arch remove orphaned packages
-
animal well keyboard
Animal well does not let you remap keys, and really doesn't even inform you that it is keyboard compatible. I had to play around and discover the keymap, which can be a bit tricky on a 40% board. This is what I found. wasd - move space - jump / a enter - interact / b x - throw c - inventory 1 - left item / rb 2 - open item menu / triangle 3 - right item / lb
-
diskcache as debounce
I've been using fastapi more and more lately and one feature I just started using is background tasks [[ thoughts-333 ]]. !!! seealso basic diskcache example [[ python-diskcache ]] One Background Task per db entry I am using it for longer running tasks and I don't want to give users the ability to spam these long running tasks with many duplicates running at the same time. And each fastapi worker will be running in a different process so I cannot keep track of work in memory, I have to do it in
-
Install sealed-secreats via manifest
Yesterday I realized that I have overlooked the default installation method of the sealed secrets controller for [[ kubernetes-kubeseal ]] this whole time an jumped straight to the helm section. I spun up a quick [[ kind-cluster ]] and had it up quickly. I can't say this is any better or worse than helm as I have never needed to customize the install. According to the docs you can customize it with [[ kustomize ]] or helm.
-
playerctl fixes arch media keys
I've long had issues with my qmk keyboard media keys on my arch install, I always thought it was on the keyboard end. Today I learned that playerctl fixes this. Once it is installed all of my media keys started working right away. I played around with it a bit more and came up with a way to display the current playing title in my notifictations.
-
tailwind post template
Today I am playing around with tailwind, flexing the css muscle and learning how to build new and different layouts with it. I created a new post template that mimics a terminal look in css where I could inject the post title, description, and other frontmatter elements. I think this is a pretty cool layout, I could make a carbon.now.sh {.hoverlink} clone or more realistically I could make it into a template for blog pages and this could become og images. {.mx-auto .block .w-fit .mb-0} Check out
-
tailscale ssh
Tailscale allows you to ssh into all of your tailscale machines, it busts through firewalls and accross networks without complex setup. If you have used tailscale before this is an obvious no brainer. What is not obvious is that you can configure tailscale to allow ssh connections from devices within your tailnet without even a ssh daemon process running right through the tailscale daemon. I picked this up from the tailscale youtube channel. Tailscale {.youtube-embed}
-
Latest Page in Markata
I just implemented a latest blog post link in Markata by asking for the first post slug from the blog feed. The implementation uses the jinja_md plugin to render jinja against the markdown and a tag to redirect. Setting up the feed Feeds are setup in configuration. They provide a handy way to create an html feed, rss feed, and quickly reference a filtered set of posts like this. For more information on markata check out the full [[ markata ]] post.
-
just picker
has been by go to tool for saving commands in a way that I can replay them and have team members replay them without relying on the shell history of any given machine. This is my go to default step, it lets you pick a just command to run with a fuzzy picker.
-
showmount-e
TIL how to display the list of nfs mounts on your network. You can even look for mounts of other machines on your network.
-
control minio token access
To allow access only to the , you can pass add the Resource field to the User Policy when you create a new token.
-
How to List Sqlite tables
You can inspect sqlite tables with the sqlite shell. note that you get into the shell with I also learned that , and are helper functions that query the table on the database. Here is an output from my redka database. The sqlite_master table contains all the sqlite objects type, name, tbl_name, rootpage, and sql to create them.
-
Redka Runs on SQLite
With the liscense changes to redis there are several new forks out there. One that I am particularly interested in is redka . We now have redis running on port 6379 that we can connect to with a redis client. And we have a sqlite database that we can inspect. We can look at the values in the vstring table.
-
Am I vulnerable to the xz backdoor?
The main system that I am concerned about is my arch BTW machine. I found a great article from the official archlinux site covering it. For my machine I am concerned with this line. The xz packages prior to version 5.6.1-2 (specifically 5.6.0-1 and 5.6.1-1) contain this backdoor. I checked my xz package with paru, and I am good.
-
arch dependencies
paru has some nice features that I rarely use, and hav to look up when I need them. Here are two commands to help with dependency management. You can check all the packages depended on by nodejs by running the following. This is everything from all of the repos you have configured, not what you have installed.
-
copier trust
I recently had to update my copier-gallery command to trust my own templates because some of them have shell scripts that run afterwards. Be warned that this could be a dangerous feature to run on random templates you get off the internet, but these are all mine, so if I wreck it its my own fault. All the the copier copy api can be found with help.
-
ipython f2
Today I accidentally ran f2 in ipython to discover that it opens your $EDITOR! I use this feature quite often in zsh, it is bound to for me, and since I have my environment variable set to it opens nvim when I hit . Today I discovered that Ipython has this bound to . If you know how to set it to let me know I've tried, a lot. better yet add to your .zshrc
-
python inline snapshot
is a new tool that I am trying out for python testing. It takes snapshots of your outputs and places them inline with the test. Here is the most basic starter. Now when I run my tests will fail because my assert has no value, but if I run it will fill out my snapshot values and the file will then look like this. It also works with pydantic models.
-
sqlmodel indexes
I've really been enjoying using sqlmodel for my projects that need a database. One thing that I definitely lacked on for too long was indexing my database. I hit a point with one database where it was taking 7s for pretty simple paginated queries to return 10 records. For every field that you will be querying on, you can create an index, by setting it equal to example courtesy of the docs !!! Note primary keys are indexed by default. The docs cover this pretty well, and in quite depth - Optim
-
sqlite vacuum
Today I learned how to VACUUM a sqlite database and cut its size in about half. It's a database that I have had running for quite awhile and has some decent traffic on it. Why is it important to do a VACUUM? In short its becuase the file system gets fragmented with as data is updated. On delete the files are removed from the database and marked as available for reuse in the filesystem, but the space is not reclaimed. To VACUUM a database, run the following sql command. You can do it right form
-
Tailwind Animations
I learned that tailwind animations are pretty easy to add only needing a few classes. For some reason though my brain broke, thinking that I could dynamically change the number and you can't cause there are only so many pre compiled classes without using an arbitrary value with brackets. Here are the classes that I used to transition my colors very slowly. And the entire square element.
-
How to kill ollama server
I recently updated ollama , and it now installs a systemd service that I was not expecting. Seems like a great option, but I hadn't expeted this and I was able to kill it previously. It was using up gpu, and I do other things on my machine with a gpu. I tried pkill, kill, and everything, it was still coming back. No matter what it comes back You can confirm this with the following command. Next time you want to start you can do it as before with .
-
Composing Typer clis
Typer makes it easy to compose your cli applications, like you might with a web router if you are more familiar with that. This allows you to build smaller applications that compose into a larger application. You will see similar patterns in the wild, namely the cli which always has the pattern. Lets setup the cli app itself first. You can put it in . Creating an app that will become a command is the same as creating a regular app in Typer. We need to create a callback that will become o
-
tailwind arbitrary values
I learned not to fear the arbitrary size feature of tailwind. While building out reader.waylonwalker.com I kept getting content flowing off the screen, and struggling to keep it on the screen. I really felt that I should be able to do this with vanilla tailwind, but after some encouragement from Twitter I decided to lean on arbitrary values and it worked. Don't fear the arbitrary values. Learn more about using-arbitrary-values from their docs docs
-
fix npm global install needs sudo
Each time I go to set up npm I am frustrated by the errors saying that I don't have permission to , and it's frustrating. And I forget what I need to do to tell npm to install packages in a directory I own, and my shell to look there so that I can use the executables. For the fix to remain persistent you need to put these two lines in your shell profile like or .
-
darkmode scrollbars
If you are designing a website in dark mode the scrollbars can be finicky to match the theme. Here is a pretty sane default that looks nice without being obnoxiously contrast to the rest of the site. Want a rounded scrollbar thumb? add these styles. This makes a very nice looking default darkmode scrollbar.
-
Udating Cloudflare Pages using the Wrangler cli
Before deploying to cloudflare pages with wrangler you need a cloudflare api token. You can get one at dash.cloudflare.com/profile/api-tokens . cloudflare-pages-api-token Install Wrangler Next install wrangler using npm. Create a Project Before you deploy to cloudflare pages you need to create a project. You might already have one, or you might want to create one in the webui, but you have the option to create it at the command line with wrangler. Deploy Now you can deploy your static applicat
-
scheduling cron jobs in kubernetes
For my reader app I am using cronjobs to schedule my a new build and upload to cloudflare pages every hour. In this example I have built a docker image and pushed it to dockerhub. It uses a secret to access cloudflare, and the entrypoint itself does the build and upload.
-
jinja macros
I am working on a page for htmx-patterns and I ran into a situation with lots of duplication. Especially when i am using tailwind I run into situations where the duplication can get tedious to maintiain. The solution I found is macros. Now I can use the same code for all of my links, and call the macro to use it.
-
jinja loop variable and htmx
jinja has a loop variable that is very handy to use with htmx. Whether you want to implement a click to load more or an infinite scroll this loop variable is very handy. Now for every chunk of contacts that we load we will trigger the infinite scroll by loading more once the last one has intersected the screen.
-
fastapi jinja url_for with query params
Out of the box Starlette does not support url_for with query params. When trying to use url_for with query params it throws the following error. In my searching for this I found starlette issue #560 quite helpful, but not complete, as it did not work for me. !!! Note "https" If you want url_for to work in production you need some way to convert http to https. Here is how I make it work, for local development I then for each environment that I am running on a server I include it in the list
-
setting up a kind cluster with argocd installed
Kind (Kubernetes in Docker) is a tool that makes it easy to create and tear down local clusters quickly. I like to use it to test out new workflows. Argocd is a continuous delivery tool that makes it easy to setup gitops workflows in kubernetes. Here is how you can setup a new kind cluster and install argocd into it using helm, the kubernetes package manager. If you want to add repos and apps to your cluster you can use the argo cli to do that, but first you will need forward the argocd port an
-
kubernetes kubeseal
In my homelab kubernetes cluster I am using kubeseal to encrypt secrets. I have been using it successfully for a few months now wtih great success. It allows me to commit all of my secrets manifests to git with out risk of leaking secrets. You see kubeseal encrypts your secrets with a private key only stored in your cluster, so only the cluster itself can decrypt them using the kubeseal controller. cover KubeSeal https://sealed-secrets.netlify.app/ {.hoverlink} installation Installation happens
-
nvim stupid gf bind
So after months of fighting with gf not going to template files, I finally decided to put in some effort to make it work. This was the dumbest keybind in my config, that I copied from someone else without understanding it. What I am trying to do I have jinja templates in a directory called . I want to bind gf to open a template file, but it is trying to open a new file What did not work I tried all sorts of changes to my path, but it still didn't work. What I found after digging into my keyma
-
cli auth
Authentication from cli tools can be a bit of a bear, and I have to look it up every time. This is my reference guide for future me to remember how to easily do it. I set up a fastapi server running on port 8000, it uses a basic auth with as the username and as the password. The server follows along with what comes out of the docs. I have it setup to take basic auth, form username and password, or a bearer token for authentication. curl The og of command line url tools. wget My go to if I wan
-
Hiding Form input During htmx Request
I am working on fokais.com's signup page, and I want to hide the form input during an htmx request. I was seeing some issues where I was able to prevent spamming the submit button, but was still able to get one extra hit on it. It also felt like nothing was happening while sending the email to the user for verification. Now I get the form to disappear and a spinner to show during the request. HTML Let's start off with the form. It uses htmx to submit a post request to the route. Note that there
-
Stripe Cancellations in FastAPI and SQLModel
Today I am working on fokais.com, trying to get to a point where I can launch by workig through stripe integrations. This is my first time using stripe, so there has been quite a bit to learn, and I am probably building in more than I need to before launching, but I am learning, and not in a rush to launch. I am building the fokais backent in python primarilyt with fastapi and sqlmodel on sqlite. My billing integration is going to be all Stripe. Stripe Subscription Cancellations Docs Here is a l
-
Still Loving Tailwind
I've been using tailwind for a few months now and I can still say I'm loving it. I've been using it to create some rapid prototypes that may or may not ever become something, a document that is likely to go to print (a resume), and some quick dashboards. I started using Tailwind a few month back A few months back in september of 2023 I made a case for tailwindcss . And have been using it on quite a few projects since. values are well thought out it's really easy to use classes that make sense t
-
jpillora-installer
jpillora/installer is the install script generator I have been looking for. It downloads binaries for your machine from GitHub releases and unzips them for you. It grabs the latest release, so you can easily update them. I have tried scripting these installs in the past and struggled to consistently get the latest version for every package and unpack it correctly. Also these pre-compiled binaries install rediculously fast compared to building them from source. Check out some example links. openi
-
how to host static content with fastapi
I wanted to host some static files through fastapi. Typical use cases for this might be some static web content like html/css/js. It could also be images or some data that doesn't need dynamically rendered. From the Docs The docs cover how to host static files, and give this solution that is built into fastapi. https://fastapi.tiangolo.com/tutorial/static-files/ {.hoverlink} Authenticated Static Files Thanks to #858 . OscartGiles posted this solution to add authentication to static files. I tr
-
Set up minio bucket entrypoint
I recently se tup minio object storage in my homelab for litestream sqlite backups. The litestream quickstart made it easy to get everything up and running on localhost, but I hit a wall when dns was involved to pull it from a different machine. Here is what I got to work First I had to configure the Key ID and Secret Access Key generated in the minio ui. Then set the the s3 signature_version to s3v4. Now when I have minio running on https://my-minio-endpoint.com I can use the aws cli to acces
-
Setup Tailwind for Jinja
I've recently given tailwindcss a second chance and am really liking it. Here is how I set it up for my python based projects. https://waylonwalker.com/a-case-for-tailwindcss {.hoverlink} Installation is used to install the cli that you will need to configure and compile tailwindcss. Setup You will need to create a tailwind.config.js file, to get this you can use the cli. Using tailwind with jinja templates To set up tailwind to work with jinja templates you will need to point the tailwind conf
-
Python scandir ignores hidden directories
The next version of markata will be around a full second faster at building it's docs, that's a 30% bump in performance at the current state. This performance will come when virtual environments are stored in the same directory as the source code. "One lone jedi stands in Glowing chains of interconnected network of technological cubes, in the middle of a futuristic cyberpunk dubai city, in the art style of dan mumford and marc simonetti, atmospheric lighting, intricate, volumetric lighting, beau
-
Getting Started with Pydantic
Pydantic is a Python library for serializing data into models that can be validated with a deep set of built in valitators or your own custom validators, and deserialize back to JSON or dictionary. Installation To install pydantic you will first need python and pip. Once you have pip installed you can install pydantic with pip. Always install in a virtual environment Creating a Pydantic model To get started with pydantic you will first need to create a Pydantic model. This is a python class that
-
setting up paru | installing from the AUR for the ...
paru is an aur helper that allows you to use a package manager to install packages from the aur. What's the Aur The Aur is a set of community managed packages that can be installed on arch based distros. Why a helper? paru just makes it easy, no clone and run makepkg. You can do everything paru can do using the built in pacman installer. Manual Install from the Aur You will need to manually instal pacman from the aur in order to get started. Installing packages with paru Once setup you are ready
-
Releasing a New Version of Your Python Package Jus...
Quickly and easily create new versions of your Python package with the command. Get the version number, changelog, and Releasing a new version of your Python package can be a daunting task. You need to make sure that all the necessary files are included, and that the version number is correct. But now, with the help of the command, you can make the process much smoother. The command allows you to quickly and easily create a new version of your Python package. All you need to do is provide t
-
Arch Linux Randomly Rejecting Passwords
Fix Arch Linux randomly rejecting passwords with one command. Try 'faillock --user $USER' to reset login counter and regain access. Quick solution for a smooth computing" an intertwined mess of wires If you're an Arch Linux user, you may have experienced a frustrating issue where your password is randomly not being accepted by the system. This can be a major inconvenience and can cause a lot of frustration, especially if it happens frequently. The good news is that there is a simple fix for this
-
dash e your github docker actions
Give github actions the -e flag in the shebang so they fail on any one command failure. Otherwise each line will set the exit status, but only the last one will be passed to ci. What is -e The -e flag to the bash command allows your script to exit immediately if any command within the script returns a non-zero exit status. This can be useful for ensuring that your script exits with an error if any of the commands it runs fail, which can help you identify and debug issues in your script. For ex
-
ssh copy id
I recently setup some vm's on my main machine and got sick of signing in with passwords.
-
ssh key permissions
I just shared some ssh keys with myself and ran into this error telling me that I did not set the correct permissions on my key. I changed them with the following commands.
-
formatme
-
nvim navic
With the latest release of version of nvim 0.8.0 we get access to a new winbar feature. One thing I have long wanted somewhere in my nvim is navigation for pairing partners or anyone watching can keep track of where I am. As the driver it's easy to keep track of the file/function you are in. But when you make big jumps in a few keystrokes it can be quite disorienting to anyone watching, and having this feedback to look at is very helpful. "cybernetic soldier working on a rusting tape machine
-
pipx textual devtools
I really like having global cli command installed with pipx. Since textual (the css release) is out I want to be able to pop into textual devtools easily from anywhere. "rusting tape machine robot, cinematic lighting, detailed, cell shaded, 4 k, warm colours, concept art, by wlop, ilya kuvshinov, artgerm, krenz cushart, greg rutkowski, pixiv. cinematic dramatic atmosphere, sharp focus, volumetric lighting, cinematic lighting, studio quality" -s50 -W832 -H416 -C12.0 -Ak_lms -S2404332231 Pipx In
-
textual app devtools
I am working through the textual tutorial, and I want to put it in a proper cli that I can pip install and run the command without . This is a fine pattern, but I also want this to work when I don't have a file to run. "An astronaut working in a lab, hacking on a computer terminal, htop is running, shallow depth of field beakers, test tubes, volumetric lighting, pink lighting, by victo ngai, killian eng vibrant colours, dynamic lighting, digital art" -s50 -W768 -H448 -C7.5 -Ak_lms -S3617210203
-
caching python virtual environments in GitHub Acti...
-
Markata GitHub Pages
11ty https://www.rockyourcode.com/how-to-deploy-eleventy-to-github-pages-with-github-actions/ hugo puts it in the base url https://gohugo.io/getting-started/configuration/#baseurl mkdocs uses a special cli build command https://squidfunk.github.io/mkdocs-material/publishing-your-site/#github-pages
-
obs virtual camera on boot
For far too long I have had to fidget with v4l2oloopback after reboot. I've had this happen on ubuntu 18.04, 22.04, and arch. After a reboot the start virtual camera button won't work, It appears and is clickable, but never turns on. Until I run this command. "cell shaded, long, full body, shot of a cybernetic blue soldier with glowing pink eyes looking into a selfie camera with ring light, llustration, post grunge, 4 k, warm colors, cinematic dramatic atmosphere, sharp focus, pink glowing vol
-
running aws cli commands with localstack
Upon first running an cli command using localstack you might end up with the following error. Easy way The easy easiest way is to leverage a package called . Leveraging the awscli If you want to use the cli pro
-
localstack status permission
I ran into an issue where I was unable to ask localstack for its status. I would run the command and it would tell me that it didn't have permission to read files from my own home directory. Let's fix it The issue I would run this to ask for the status. And get this error What happened It dawned on me that the first time I ran localstack was straight docker, not the python cli. When docker runs it typically runs as root unless the Dockerfile sets up a user and group for it. "cell shaded, long,
-
Markata Supports Jinja Plugins 0.5.0.dev2
Markata now allows you to create jinja extensions that will be loaded right in with nothing more than a . From the Changelog The entry for 0.5.0.dev2 from markata's changelog Created entrypoint hook allowing for users to extend marka with jinja exensions #60 0.5.0.dev2 "cybernetic soldier working on a rusting tape machine robot, cinematic lighting, detailed, cell shaded, 4 k, warm colours, concept art, by wlop, ilya kuvshinov, artgerm, krenz cushart, greg rutkowski, pixiv. cinematic dramatic a
-
Using Django Rest Framework inside react
-
Getting Started with Django REST framework
In my adventure to learn django, I want to be able to setup REST api's to feed into dynamic front end sites. Potentially sites running react under the hood. cell shaded full body shot of a cybernetic blue soldier with glowing eyes working ina lab, llustration, post grunge, pink glowing volumetric lighting, engulfed in smoke and fog, concept art by josan gonzales and wlop, by james jean, Victo ngai, David Rubín, Mike Mignola, Laurie Greasley, highly detailed, sharp focus,alien,Trending on Artstat
-
Markata now uses hatch
Markata now uses hatch as its build backend, and version bumping tool. , and are completely gone. "An astronaut working in a lab, there is a series of eggs ready to hatch baby snakes on the table, experiments running, beakers, test tubes, cyberpunk trending on artstation, neon lighting, volumetric lighting, pink lighting" -s50 -W800 -H450 -C7.5 -Ak_lms -S4048189038 {.more-cinematic} 0.5.0 is big Markata 0.5.0 is now out, and it's huge. Even though it's the backend of this blog I don't actuall
-
django polls app
creating a new app called polls
-
django create superuser
My next step into django made me realize that I do not have access to the admin panel, turns out that I need to create a cuper user first. "cybernetic soldier working on a rusting tape machine robot, cinematic lighting, detailed, cell shaded, 4 k, warm colours, concept art, by wlop, ilya kuvshinov, artgerm, krenz cushart, greg rutkowski, pixiv. cinematic dramatic atmosphere, sharp focus, volumetric lighting, cinematic lighting, studio quality" -s50 -W832 -H416 -C12.0 -Ak_lms -S3309980874 Run Mig
-
django disallowed host
I am continuing my journey into django, but today I am not at my workstation. I am ssh'd in remotely from a chromebook. I am fully outside of my network, so I can't access it by localhost, or it's ip. I do have cloudflared tunnel installed and dns setup to a . Settings I found this in and yolo, it worked first try. I am in from my remote location, and even have auth taken care of thanks to cloudflare. I am really hoping to learn how to setup my own auth with django as this is one of the t
-
Trying out django
I have no experience in django, and in my exploration to become a better python developer I am dipping my toe into one of the most polished and widely used web frameworks Django to so that I can better understand it and become a better python developer. If you found this at all helpful make sure you check out the django tutorial "An atronaut working in a lab, there is a long snake working along side, shallow depth of field beakers, test tubes, volumetric lighting, pink lighting, by victo ngai,
-
how to escape variables in jinja templates
While updating my site to use Markata's new configurable head I ran into some escaping issues. Things like single quotes would cause jinja to fail as it was closing quotes that it shouldnt have. Nuclear core being help up by glowing neon wires, cyberpunk synthwave, intricate abstract. delicate artwork. by tooth wu, wlop, beeple, dan mumford. pink volumetric lighting, octane render, trending on artstation, greg rutkowski very coherent symmetrical artwork. cinematic, hyper realism, high detail, o
-
I've made my ipython config too complicated, let's...
When I am developing python code I often have a repl open alongside of it running snippets ofcode as I go. Ipython is my repl of choice, and I hace tricked it out the best I can and I really like it. The problem I recently discovered is that I have way overcomplicated it. What Have I done?? So in the past the way I have setup a few extensions for myself is to add something like this to my directory. It sets up some things like rich highlighting or in this example automatic imports. I even
-
markata extend in configuration
Astronauts stunting some stylish color explosion {.more-cinematic} A long needed feature of markata has been the ability to really configure out templates with configuration rather. It's been long that you needed that if you really want to change the style, meta tags, or anything in the head you needed to write a plugin or eject out of the template and use your own. Adding some Head Now you can add some extra style to your site with the existing built-in template. You can have more than one Hea
-
Create a new Python Project with the Hatch Cli
I'm really getting into using hatch as my go to build system, and I am really liking it so far. I am slowly finding new things that just work really well. is one of those things that I didn't realize I needed until I had it. Hatch new cover image creating new versions created by myself with stable diffusion hatch-new-cli Note! I am running all of these commands with pipx. I like to use pipx for all of my system level cli applications. To emphasis this point in the article I am going to use
-
Versioning Python Projects with Hatch
Hatch has an amazing versioning cli for python packages that just works. It takes very little config to get going and you can start bumping versions without worry. Hatch version cover image {.more-cinematic} creating new versions created by myself with stable diffusion project layout For trying out the cli let's make a simple project with the terrible name . pyproject.toml The main hero of this post is the . This is what defines all of our PEP 517 style project setup. statically versioni
-
GitHub Actions Delete all Workflow Runs
Today I ran a bunch of actions, but I wanted to clean up all the runs that I used to get it setup so that I had a good clean history to refer back to later. I found this post
-
From Markdown to Blog with Markata | lightning tal...
Markata is a great python framework that allows you to go from markdown to a full website very quickly. You can get up and running with nothing more than Markdown. It is also built on a full plugin architecture, so if there is extra functionality that you want to add, you can create a plugin to make it behave like you want. Full transparancy... I built markata. The talk The talk is live on YouTube. Make sure you check out the other videos from the conference. There were quite a few quality t
-
I spoke at Python Web Conf 2022
I spoke at python webconf in March 2022 about how I deploy this blog on a continuous basis. Building this blog has brought me a lot of benefits. I have a set of custom curated notes to help describe a problem and how to solve it to me. At theis point it's not uncommon to google an Issue I am having and finding my own blog with exactly the solution I need at the top. I also bump into people from time to time that recognize me from the blog, its a nice conversation starter, and street cred. The
-
I turned on 2FA for all of my pypi packages
I got all the pypi packages that I own behind 2 factor authentication. 💪 Recently this really made it's rounds in the python news since pypi was requiring critical package maintainers to have 2FA on and even offering them hardware tokens to help them turn this on. I feel like this caused a bit of confusion as turning on 2FA does not mean that you need to do anything different to deploy a package, and it DOES NOT require a hardware token. You can continue using your favorite 2FA app. You might
-
use vim to remove duplicates
I just love how some features of vim are so discoverable and memorable once you really start to grasp it. Sorting and uniqing your files or ranges is one of those examples for me. I recently used this to dedupe my autogenerated links section for rich-syntax-range-style . More often I am using it to sort and uniqify objects like arrays and lists. Here is what the markdown looks like. Then typing yields a uniqly sorted list of links.
-
Highlighting text ranges with Rich | python
Today I've been playing with py-tree-sitter a bit and I wanted to highlight match ranges, but was unable to figure out how to do it with rich , so I reached out to @textualizeio for help. https://twitter.com/_WaylonWalker/status/1562469770766589952 While waiting for that reply let's show how we got this far. imports Lets import all the classes that we need from rich and setup a console to print to. some code Now we need some code to highlight. I am going to rip my from another post . prin
-
Highlighting text ranges with Rich | python
{% for year in markata.map("date.year", filter='published')|unique %} {{ year }} {% for post in markata.map('post', filter="published and date.year == "+year|string, sort='date') %} [{{ post.title }} - {{ post.date.month }}/{{ post.date.day }}](/{{ post.slug }}) {% endfor %} {% endfor %}
-
vimgrep open buffers
How to vimgrep over hidden files. I needed to delete all build pipeline steps that were named . I currently have about 60 projects running from the same template all running very similar builds. In the past I've scripted out migrations for large changes like this, they involved writing a python script that would load the yaml file into a dictionary, find the corresponding steps make the change and write it back out. Today's job was much simplar, just delete the step, were all steps are surrou
-
markata 0.3.0 is 15-20% faster
image from Dall-e {.more-cinematic} a sprinter edging out his opponent by Dall-e It's about time to release Markata 0.3.0. I've had 8 pre-releases since the last release, but more importantly it has about 3 months of updates. Many of which are just cleaning up bad practices that were showing up as hot spots on my reports Markata started off partly as a python developer frustrated with using nodejs for everything, and a desire to learn how to make frameworks in pluggy. Little did I know how f
-
How to Disable Kedro Viz | or any kedro hook
-
Gpu Stats in my linux statusbar
polybar gpu stats
-
get the version of any python package | python api
A common meta thing that I need in python is to find the version of a package. Most of the time I reach for , but that does not always work. but not all projects have a In searching the internet for an answer nearly every one of them pointed me to . This works for most projects, but is simply a convention, its not required. Not all projects implement a , but most do. I've never seen it lie to me, but there is nothing stopping someone from shipping mismatched versions. If you maintain a pro
-
arch Fonts
https://gist.github.com/YoEight/d19112db56cd8f93835bf2d009d617f7
-
Manage your displays with xrandr manager
a stable diffusion done with a111 web ui xrandr is a great cli to manage your windows in a linux distro using x11, which is most of them. The issue is that I can never remember all the flags to the command, and if you are using it with something like a laptop using a dock the names of all the displays tend to change every time you redock. This makes it really hard to make scripts that work right every time. Homepage Check out the deresmos/xrandr-manager for more details on it. installation xran
-
Get better at jq interactively | ijq
has some syntax that will sneak up on you with complexity. It looks so good, and so understandable, but everytime I go to use it myself, I don't get it. is an interactive alternative to that gives you and nice repl that you can iterate on queries quickly. Here are some other articles, I decided to link at the time of writing this article. [[jut]] [[kedro-node]] [[kedro-pickle]]
-
Two new shell aliases for git
Astronaut doing a mic drop with explosion Recently I added two new bash/zsh aliases to make my git experience just a tad better. trackme Most of our work repos were recently migrated to new remote urls, we scriped out the update to all of the repos, but I was left with a tracking error for all of my open branches. To easily resolve this I just made an alias so that I can just run anytime I see this error. getting the branch The following command will always return the currently checked out br
-
IPython q to exit
So many terminal applications bind to exit, even the python debugger, its muscle memory for me. But to exit ipython I have to type out . This is fine, but since q is muscle memory for me I get this error a few times per day. After digging way too deep into how IPython implements its I realized there was a very simple solution here. automatically imports all the scripts you put in your profile directory, all I needed was to create with the following. It was that simple. This is not a gam
-
Copier Slugify | python templating | using cookiec...
It's no secret that I love automation, and lately my templating framework of choice has been copier. One hiccup I recently ran into was having spaces in my templated directory names. This makes it harder to run commands against as you need to escape them, and if they end up in a url you end up with ugly all over. Cookiecutter has the solution Yes the solution comes from a competing templating framework. I install copier with pipx, so I need to inject cookiecutter in to my copier environment
-
gh repo create
I love getting faster in my workflow, something I have recently added in is creating GitHub repos with the cli. I often create little examples of projects, but they just end up on my machine and not anywhere that someone else can see, mostly because it takes more effort to go create a repo. TIL you can create a repo right from the command line and push to it immediately. gh-repo-create want to see what this repo I created is about? Check out what I created here.
-
Textual has devtools
Textual has devtools in the upcoming css branch, and its pretty awesome! It's still early Textual is still very early and not really ready for prime time, but it's quite amazing how easy some things such as creating keybindings is. The docs are coming, but missing right now so if you want to use textual be ready for reading source code and examples. On to the devtools As @willmcgugan shows in this tweet it's pretty easy to setup, it requires having two terminals open, or using tmux, and curren
-
Python atexit
totally guessed at this post's date I'm still trying to understand this one, but this is how you force a python object to stop atexit.
-
The one pip config you need to have
Whenever you are installing python packages, you should always use a virtual environment. pip makes this easy to follow by adding some configuration to pip. require-virtualenv Pip is the pacakage tool for python. It installs third-party packages and is configurable. One of the configuration settings that I highly reccommend everyone to add is . This will stop pip from installing any packages if you have not activated a virtualenv. why python packages often require many different dependencie
-
pyenv no module named '_sqlite3'
I've been trying to adopt pyenv for a few months, but have been completely blocked by this issue on one of the main machines I use. Whenever I start up ipython I get the following error. I talked about why and how to use pyenv along with my first impressions in this post pyenv/issues/678 According to #678 I need to install on ubuntu to resolve this issue. install libsqlite3-dev can be installed using apt But wait.... When I make a fresh env and install ipython I still get the same error an
-
git merge ours
Sometimes you have a pretty old branch you are trying to merge into and you are absolutely sure what you have is what you want, and therefore you don't want to deal with any sort of merge conflicts, you would rather just tell git to use my version and move on. update main The first step is to make sure your local copy of the branch you are moving into is up to date. update your feature branch It's also worth updating your feature branch before doing the merge. Maybe you have teammates that have
-
vim plugged snapshot
A few of my friends and I all just borked our neovim configs during a plug update, and because none of us were using it was painful to recover from. https://twitter.com/pypeaday/status/1524882893914398732 Lucky for me I did it on a home machine that I only occasionally edit from, so I could still take the snapshot from a working machine before taking the plunge into fixing everying. Why snapshot Snapshotting ensures that you install the same git sha on every single plugin. This way when you ha
-
convert your qutebrowser config to config.py
When you first start qutebrowser It will create some config files in your home directory for you, but they will be empty. Config As far as I know qutebrowser will create this default config out of the box for you, if it doesn't, then somehow it just appeared for me 😁. Why convert You might want to confvert if you are more comfortable with the python config, or if like me you just want config in one place and you are stealing configuration options from others who have thiers in config.py. Convert
-
qutebrowser clean up all status bars
I really like the super clean look of no status menus, no url bar, no bookmarks bar, nothing. Don't get me wrong these things are useful, but honestly they take up screen real estate and I RARELY look at them. What I really want is a toggle hotkey. I found this one from one of DT's youtube video's. I can now tap and both the status bar at the botton and the address bar at the top disappear.
-
Bash function to edit scripts faster
I am often editing my own scripts as I develop them. I want to make a better workflow for working with scripts like this. Currently Currently I am combining with a subshell to etit these files like this. for now lets use my todo command as an example First pass On first pass I made a bash function to do exactly what I have been doing. The will pass the first input to the which subshell. Now we can edit our todo script like this. Note, I use bash functions instead of aliases for things tha
-
List all git commits with GitPython
I am getting ready to do some timeseries analysis on a git repo with python, my first step is to figure out a way to list all of the git commits so that I can analyze each one however I want. The GitPython library made this almost trivial once I realized how. This returns a generator, if you are iterating over them this is likely what you want. The generator will return objects with lots of information about each commit such as , , , , and .
-
GPG signing commits over ssh
I was editing some blog posts over ssh, when I ran into this error. gpg was failing to sign my commits. I realized that this was because I could not answer to the desktop keyring over ssh, but had no idea how to fix it. Error This is the error message I was seeing. The fix The fix ended up being pretty simple, but quite a ways down this stack overflow post . This environment variable tells gpg that we are not logged into a desktop and it does not try to use the desktop keyring, and asks to un
-
Review Pull Requests with git worktrees
Sometimes you get a PR on a project, but cannot review it without wrecking your current working setup. This might be because it needs to be compiled, or a new set of requirements. Git worktrees is a great way to chekout the remote branch in a completely separate directory to avoid changing any files in your current project. This will create a new directory that you can review the branch from the remote . If you have setup different remotes locally you can check for the name of it with
-
Using Git from Python
is a python api for your git repos, it can be quite handy when you need to work with git from python. Use Case I recently made myself a handy tool for making screenshots in python and it need to do a git commit and push from within the script. For this I reached for . [[ screenshot-to-blog ]] Installation is a python library hosted on pypi that we will want to install into our virtual environments using pip. Create a Repo Object Import Repo from the git library and create an instance of the
-
pipx on windows
Python, click install Edit the System Environment Variables Environment Variables button Add the following path to your users Path Variable
-
Python sys.excepthook
Sometimes you just want python to do something else when you hit an exception, maybe that's fire a text, slack message, email, or system notification like I wanted. I am working on a quick and dirty python script designed to take screenshots and land them on my website in a single hotkey. With it being designed to run with a hotkey, if it were to error I would not see it. I could have gone down a logging route, but honestly this is meant to be quick, dirty, and work on my system for me. I just
-
A TTY Can Save Your Bacon
I recently was unable to boot into my home Linux Desktop, it got stuck at diskcheck . I found that I was able to get in to a tty through a hotkey. https://twitter.com/_WaylonWalker/status/1512281106120384519 What's a TTY? There's probably more to it, but to me its a full screen terminal with zero gui, not even your gui fonts. It does log into your default shell so if you have a comfy command line setup it will be here for you even though it looks much different without fonts and full colorspa
-
pygame events are queued | Don't make this mistake
pygame events are stored in a queue, by default the most suggested way shown in all tutorials " " the queue, which removes all the messages. start up pygame You don't necessarily need a full boilerplate to start looking at events, you just just need to and to capture any keystrokes you need a window to capture them on, so you will need a display running. get some events Let's use pygames normal method to get events. printing the events reveal this Lets get some more events. Let's say that we
-
Display Sprites in Pygame | Load and Blit
One of the most essential concepts of pygame to start making a game you will need to understand is loading images and blitting them to the screen. blit stands for block image transfer, to me it feels a lot like layering up layers/images in photoshop or Gimp. Loading an image I started by making a spotlight in Gimp, by opening a 64x64 pixel image and painting the center with a very soft brush. the spotlight I created in gimp This is what it looks like Now we can load this into pygame. Convertin
-
Mixing Colors at the Command Line
From the same Author that brought us command line essentials like and written in rust comes pastel an incredible command-line tool to generate, analyze, convert and manipulate colors. Install You can install from one of the releases , follow the instructions for your system from the repo. I chose to go the nix route. I have enjoyed the simplicity of the nix package manager being cross platform and have very up to date packages in it. Mixing colors Something I often do to blend colors to
-
Dunk is my new diff pager
Dunk is a beautiful git diff tool built on top of rich . Browsing through twitter the other day I discovered it through this tweet by _darrenburns . https://twitter.com/_darrenburns/status/1510350016623394817 {.hoverlink} Dunk is beta Before I dive in deep, I do want to mention that Dunk is super new and beta at this point. I am making it my default pager, because I know what I am doing and can quickly shift back if I need to, no sweat. If you are a little less comfortable with the command
-
Pygame Boilerplate Apr 2022
I'm poking a bit into gamedev. Partly to better understand, partly because it's stretching different parts of my brain/skillset than writing data pipelines does, but mostly for the experience of designing them with my 9yo Wyatt. pygame boilerplates I've seen several pygame boilerplate templates, but they all seem to rely heavily on globl variables. That's just not how I generally develop anything. I want a package that I can pip install, run, import, test, all the good stuff. My current start
-
Unzip minecraft mods to their directory from the c...
This morning I was trying to install a modpack on my minecraft server after getting a zip file, and its quite painful when I unzip everything in the current directory rather than the directory it belongs in. I had the files on a Windows Machine So I've been struggling to get mods installed on linux lately and the easiest way to download the entire pack rather than each mod one by one seems to be to use the overwolf application on windows. Once I have the modpack I can start myself a small mod-s
-
Did my site build just go down?
My personal Site build went down last week, and I was unable to publish a new article. This is the process I went through to get it back up and running quickly. Is it a fluke? Classic IT fix, rerun it and see if you get the same error. Everyone is busy and when you have your build go down you are probably busy doing something else. My first step is often to simply click rerun right from GitHub actions. Sometimes this will fix it, and sometimes it doesn't. It's an easy fix to run in the meant
-
Don't inherit from python BaseException, Here's wh...
I ran into a PR this week where the author was inheriting what BaseException rather than exception. I made this example to illustrate the unintended side effects that it can have. Try running these examples in a file for yourself and try to kill them with control-c. You cannot Keybard interrupt Since things such as are created as an exception that inherits from , if you except you can no longer . except from Exception or higher If you except from exception or something than inherits from
-
How I make cache-keys from python objects
When I need a consistent key for a pythohn object I often reach for It works for me and the use cases I have. diskcache Yesterday we talked about setting up a persistant cache with python diskcache. In order to make this really work we need a good way to make consistent cache keys from some sort of python object. [[ python-diskcache ]] hash does not work My first thought was to just hash the files, this will give me a unique key for each. This will work, and give you a consistant key for one
-
How I setup a sqlite cache in python
When I need to cache some data between runs or share a cache accross multiple processes my go to library in python is . It's built on sqlite with just enough cacheing niceties that make it very worth it. install diskcache Install diskcache into your virtual environement of choice using pip from your command line. setup the cache There are a couple of different types of cache, , , and , you can read more about those in the docs Adding to the cache Adding to the cache only needs a key and val
-
Cache a python function with lru_cache
The easiest way to speed up any code is to run less code. A common technique to reduce the amount of repative work is to implement a cache such that the next time you need the same work done, you don't need to recompute anything you can simply retrieve it from a cache. lru_cache The easiest and most common to setup in python is a builtin functools.lru_cache. when to use lru_cache Any time you have a function where you expect the same results each time a function is called with the same inputs,
-
Set User Agent on pandas read_csv
I keep a small cars.csv on my website for quickly trying out different pandas operations. It's very handy to keep around to help what a method you are unfamiliar with does, or give a teammate an example they can replicate. Hosts switched I recently switched hosting from netlify over to cloudflare. Well cloudflare does some work to block certain requests that it does not think is a real user. One of these checks is to ensure there is a real user agent on the request. Not my go to dataset 😭 Th
-
Get Webpage with python requests
Python's requests library is one of the gold standard apis, designed by Kenneth Reitz. It was designed with the user perspective in mind first and implementation second. I have heard this called readme driven development, where the interface the user will use is laid out first, then implemented. This makes the library much mor intuitive than if it were designed around how it was easiest to implement. Install Requests Requests is on pypi and can be installed into your virtual environtment with p
-
Ease into htmx with htmx-get
I recently attended python web conf 2022 and after seeing some incredible presentations on it I am excited to give htmx a try. The base page Start with some html boilerplate, pop in a script tag to add the htmx.org script, and a button that says click me. I added just a tish of style so that it does not sear your delicate developer your eyes. Save this as and fire up a webserver and you will be presented with this big beefcake of a button. big beefcake of a button If you don't have a develo
-
Style Lookatme Slides a bit more Personal
I recently gave a talk at python web conf 2022, and one of the things I did when I should have been working on my presentation was workig on how my presentation looked... classic procrastination technique. Slide One Lets use this section to show what it looks like as I change my styles. ☝ This is how my website is built write markdown build site publish default This is what the above slide looks like in lookatme. default styles Set focus to the most important element The way I write my sli
-
How I load Markdown in Python
I use a package eyeseast/python-frontmatter {.hoverlink} to load files with frontmatter in them. Its a handy package that allows you to load files with structured frontmatter (yaml, json, or toml). Install It's on pypi, so you can install it into your virtual environment with pip. 🙋 What's Frontmatter Frontmatter is a handy way to add metadata to your plain text files. It's quite common to have yaml frontmatter in markdown. All of my blog posts have yaml frontmatter to give the post metadata
-
Python's Dict Union Operator | Pep 584
Today I was watching the python web conf 2022 and saw @davidbujic use the new Dict Union Operator Live on stage during his Functional Programming talk. This operator was first introduced into python 3.9 with pep584 . Merge Dicts I've long updated dicts through the use of unpacking. Note that the last item always wins. It makes it pretty easy to make user overrides to default configurations. With pep584 landing in python 3.9 we can now leverage the operator to achieve the same result. [[
-
How I Present Markdown Slides from the Terminal
I love the freedom of writing in markdown. It allows me to write content from the comfort of my editor with very little focus on page style. It turns out that markdown is also a fantastic tool for creating slides. Present from the terminal I will most often just present right from the terminal using lookatme . Presenting from the terminal lets me see the results quick right from where I am editing. It also allows me to pop into other terminal applications quickly. reveal.js I sometimes also u
-
How I read Files in Python
When I need to read contents from a plain text file in python I find the easiest way is to just use .
-
Automatically Generate a list of Markdown Links in...
Let's make a vim command to automatically collect all the links in these posts at the end of each article. Regex confuses the heck out of me... I don't have my regex liscense, but regex can be so darn powerful especially in an editor. Step one Before you run someone's regex from the internet that you don't fully understand, check your and make sure you are all clear with git before you wreck something Inspiration Something that I have always appreciated form Nick Janetakis is his links secti
-
Create a Swapfile on Your Linux Machine
If you ever end up on a linux machine that just does not have enough ram to suffice what you are doing and you just need to get the job done you can give it some more swap. You can look up reccomendations for how much swap you should have this is more about just trying to get your job done when you are almost there, but running out of memory on the hardware you have. make the /swap file You can put this where you wish, for this example I am going to pop it into make sure that your swap is on Yo
-
How I glob for Files in Python
A very common task for any script is to look for files on the system. My go to method when globbing for files in python is to use pathlib. Setup I setup a directory to make some examples about globbing. Here is what the directory looks like. 1 directory, 8 files Pathlib Pathlib is a standard library module available in all LTS versions of python at this point. Creating a Path instance. Globbing Examples The path object has a glob method that allows you to glob for files with a unix style glob
-
Set Your Git Pager Config
Setting up your git pager to your liking can help you navigate diffs and logs much more efficiently. You can set it to whatever pager you like so that your keys feel nice and smooth and your fingers know exactly what to do. You might even gain a few extra features. Setting the pager You can set the pager right from your command line with the following command. You can also set your pager by editing your global file which by default is set to . Color In my experience you need to turn colors
-
Configure Git to Autocorrect Your Fat Fingers
If you have ever mistyped a git command very close to an existing one you have likely seen this message. Automatically run the right one What you might not have known is that you can configure git to just run this command for you. Fat Fingers Gone Now when you typo a git command it will autmatically run after the configured number of tenths of a second. My config I'm rocking 10 for now just to see how I feel about it, but honestly I cannot think of a time that I have seen the original warning th
-
pytest-mock Basics
Last Thursday I learned about at a local python meetup. The presenter showed how he uses for his work, and it was kinda eye opening. I knew what mocking was, but I had not seen it in this context. Discovery Watching him use I realized that mocking was not as hard as I had made it out to be. You can install , use the mocker fixture, and patch objects methods with what you want them to be. install pytest-mock is out on pypi and can be installed with pip. What I actually did Sometimes I f
-
Install yq | A light weight yaml parser cli
is a command line utility for parsing and querying yaml, like does for json. This is for me I love that all of these modern tools built in go and rust, just give you a zipped up executable right from GitHub releases, but it's not necessarily straight forward how to install them. does one of the best jobs I have seen, giving you instructions on how to get a specific version and install it. I use a bunch of these tools, and for what its worth I trust the devs behind them to make sure they don
-
Python Walrus Inside List Comprehension
Python 3.8 came out two and a half years ago and I have yet to really lean in on the walrus operator. Partly because it always seemed like something kinda silly (my use cases) to require a python version bump for, and partly because I really didn't understand it the best. Primarily I have wanted to use it in comprehensions, but I did not really understand how. Now that Python 3.6 is end of life, and most folks are using at least it seems time to learn and use it. What's a Walrus := The assig
-
Make Kedro Runs Beautiful
Kedro rich is a very new and unstable (it's good, just not ready) plugin for kedro to make the command line prettier. Install kedro rich There is no pypi package yet, but it's on github. You can pip install it with the git url. Kedro run You can run your pipeline just as you normally would, except you get progress bars and pretty prints. kedro rich pretty run Kedro catalog Listing out catalog entries from the command line now print out a nice pretty table. kedro rich catalog list table output G
-
Git Worktrees are not so Scary
So worktrees, I always thought they were a big scary things. Turns out they are much simpler than I thought. Myth #1 no special setup I thought you had to be all in or worktrees or normal git, but not both. When I see folks go all in on worktrees they start with a bare repo, while its true this is the way you go all in, its not true that this is required. Lets make a worktree Making a worktree is as easy as making a branch. It's actually just a branch that lives in another place in your files
-
Configure Git to Always Push to the Current Branch
Has no upstream branch errors in git can be such a damn productivity killer. You gotta stop your flow and swap over the branch, there is a config so that you don't have to do this. fatal has no upstream branch If you have not yet configured git to always push to the current branch, you will get a error if you don't explicitly set it. Let's show an example You will be presented with the following error. Option 1: follow the instructions To resolve this fatal error your first option is simply
-
Setup SSH from chromebook to home desktop
I write many of these posts from a 10 year old desktop that sits in my office these days. It does a very fine job running all of the things I need it to for my side work, but sometimes I want a mobile setup. I don't really want to spend the $$ on a new laptop just for the few times I want to be somewhere else in the house. What I do have though is a chromebook. I've tried to get the chromebook into my workflow in the past, but have failed. Much because by the time I got all of my tools up an
-
Mermaid Highlight
Mermaid gives us a way to style nodes through the use of css, but rather than using normal css selectors we need to use . This also applies to subgraphs, and we can use the name of the subgraph in place of the nodeid. produces the following graph style one fill:#BADA55
-
Open Files with Nvim Remote
I recently found a really great plugin by mhinz to open files in neovim from a different tmux split, without touching neovim at all. Installation neovim-remote is not a neovim plugin at all, it's a python cli that you can install with pip. Unlike the repo suggests, I use pipx to install . How I use it I have this added to my that is in every one of my projects. This will tie a neovim session to that directory, and all directories under it. In my workflow I open a tmux session for each pr
-
Grouping Mermaid nodes in Subgraphs
Mermaid provides some really great ways to group or fence in parts of your graphs through the use of subgraphs. Here we can model some sort of data ingest with some raw iot device and our warehouse in different groups. connecting subgroups If we want to connect them, we can make a connection between a and A outside of the subgraphs. separation of concerns It's also possible to specify subgraphs separate from where you define your nodes. which allows for some different levels of grouping that wou
-
Dedupe your shell paths
If you have ever ran and see duplicate entries it's likely that you have duplicate entries in your $PATH. You can clean this up with a one liner at the end of your bashrc or zshrc.
-
Simple Plain Text Diagrams in HTML
Since GitHub started supporting mermaid in their markdown I wanted to take another look at how to implement it on my site, I think it has some very nice opportunities in teaching, documenting, and explaining things. The docs kinda just jumped right into their mermaid language and really went through that in a lot of depth, and skipped over how to implement it yourself, turns out its pretty simple. You just write mermaid syntax in a div with a class of mermaid on it! You just write mermaid synt
-
Bash mktemp
There is GNU coreutils command called that is super handy in shell scripts to make temporary landing spots for files so that they never clash with another instance, and will automatically get cleaned up when you restart, or whenever gets wiped. I'm not sure when that is, but I don't expect it to be long. Making temp directories Here are some examples of making temp directories in different places, my favorite is . Use Case Here is a sample script that shows how to capture the tempdir as a
-
Recover a lost git branch with checkout
Once you give a branch the big D ( ) its gone, its lost from your history. It's completely removed from your log. There will be no reference to these commits, or will there? TLDR Checkout is your savior, all you need is the commit hash. Immediate Regret your terminal is still open We have all done this, you give branch the big D only to realize it was the wrong one. Don't worry, not all is lost, this is the easiest to recover from. When you run the delete command you will see something like
-
git find deleted files
It's nearly impossible to completely loose a file if it is commited to git. It's likely harder to fully remove the file than it is to recover it, but how do we go about recovering those precious files that we have lost. Listing all the deleted files in all of git history can be done by combining with . The log gives you lots of options to show different bits of information about the commit that happened at that point. It's even possible to get a completely clean list of files that are in y
-
git diff-filter
Git commands such as , , all take a flag called . This can filter for only certain types of diffs, such as added (A), modified (M), or deleted (D). Man page You can find the full description by searching for in the page. Try it out Open up a git repo and play around with this, here are some example that I played with that seemed useful to me.
-
Textual Popup Hack
As I am toying around with textual, I am wanting some popup user input to take over. Textual is still pretty new and likely to change quite significantly, so I don't want to overdo the work I put into it, So for now on my personal tuis I am going to shell out to tmux. The Problem The main issue is that when you are in a textual app, it kinda owns the input. So if you try to run another python function that calls for it just cant get there. There is a textual-inputs library that covers this,
-
Install obs flatpak
Big announcement recently that obs studio now builds out to a flatpak, hopefully making it easier for all of us to install, especially us near normies that don't regularly compile anything from source. install flatpak I did not have flatpak installed so the first thing I had to do was get the command installed, and add their default repo. Once I had flatpak, I was able to get obs installed with the following command. Once Installed it fired right up for me with the next command they suggested.
-
GitHub Markdown now Supports Mermaid Diagrams
Mermaid diagrams provide a way to display graphs defined as plain text. Some markdown renderers support this as a plugin. GitHub now supports it. example You can define nodes like this in mermaid, and GitHub will now render them as a pretty graph diagram. Its rendered in svg, so its searchable with and everything. Here is what the example looks like on GitHub Links GitHub support announcement mermaid docs
-
Git rebase to the beginning of time
Git has a built in way to rebase all the way back to the beginning of time. There is no need to scroll through the log to find the first hash, or find the total number of commits. Just use .
-
Glances can watch docker processes
Glances is a system monitor with a ton of features, including docker processes. I have started using portainer to look at running docker processes, its a great heavy-weight docker process monitor. glances works as a great lightweight monitor to just give you the essentials, ( Name, Status, CPU%, MEM, /MAX, IOR/s, IOW/s, Rx/s, Tx/s, Command) install You will need to install glances to use the glances webui. We can still use to manage our virtual environment for us so that we do not need to do
-
Revive files from the dead with git
Git reflog can perform some serious magic in reviving your hard work from the dead if you happen to loose it. caveat You must git commit! If you never commit the file, git cannot help you. You might look into your trashcan, filesystem versions, onedrive, box, dropbox. If you have none of this, then you are probably hosed. practice I really like to practice these techniques before I need to use them so that I understand how they work in a low stakes fashion. This helps me understand what I can
-
Glances webui with pipx
Glances has a pretty incredible webui to view system processes and information like htop, or task manager for windows. The nice thing about the webui is that it can be accessed from a remote system. This would be super nice on something like a raspberry pi, or a vm running in the cloud. Its also less intimidating and easier to search if you are not a terminal junky. install You will need to install glances to use the glances webui. We can still use to manage our virtual environment for us so
-
Git reflog is an alias for git log -g
Right inside the git docs , is states that the command runs by default which is an alias for This epiphany deepens my understanding of git, and lets me understand that most flags might also work with . full or short format Here are some git commands for you to try out on your own that are all pretty similar, but vary in how much information they show. add files If I am looking for a missing file, I might want to leverage or , to see where I might have hard reset that file, or deleted i
-
Run glances without install with pipx
Glances is a fully featured system monitoring tool written in python. Out of the box it's quite similar to htop, but has quite a few more features, and can be ran without installing anything other than , which you should already have installed if you do anything with python. Once you run this you will be in a tui application similar to htop. You can kill processes with k, use left and right arrows to change the sorting column, and up and down to select different processes. running pipx run gl
-
Nested requirements.txt in python
python requirements text files can in fact depend on each other due to the fact that you can pass pip install arguments right into your file. The trick is to just prefix the file with a flag, just like you would if you were installing it with try it out Lets create two requirements files in a new directory to play with. Then add the following to each requirements file. Installing Installing requirements_dev.txt will install both ipython and pandas since it includes the base requirements file
-
Modded Minecraft in Docker
In my adventure to put more homelab in docker, I moved our modded minecraft setup to docker. Getting Mods So far I have found all of our mods from curse forge . modpacks make getting multiple mods working together much easier, someone else has already vetted a pack of often times 100+ mods that all play well together. I have yet to get these working in docker, I will, but for not I just have individual mods. download file under the hood docker is using wget to get the mod. The link you click
-
View AWS event bridge rules with visidata
Reading eventbridge rules from the command line can be a total drag, pipe it into visidata to make it a breeze. I just love when I start thinking through how to parse a bunch of json at the command line, maybe building out my own custom cli, then the solution is as simple as piping it into visidata. Which is a fantastic tui application that had a ton of vim-like keybindings and data features.
-
Vim remaps use cmd in place of :
Anyone just starting out their vim customization journey is bound to run into this error. I did not get it I'll admit, in hindsight it's very clear what this is trying to tell me, but for whatever reason I still did not understand it and I just used a : everywhere. From the docs If you run you will see a lot of reasons why you should do it, from performance, to hygene, to ergonomics. You will also see another clear statement about how to use . When to map with a : You still need to map your
-
A better copy-mode bind for Tmux
The default keybinding for copy-mode is one that is just so awkward for me to hit that I end up not using it at all. I was on a call with my buddy Nic this week and saw him just fluidly jump into in an effortless fashion, so I had to ask him for his keybinding and it just made sense. Enter, that's it. So I have addedt his to my along with one for and have found myself using it way more so far. Setting copy-mode to enter To do this I just popped open my and added the following. Now I c
-
Python string of letters is a string of letters, b...
In python, a string is a string until you add special characters. In browsing twitter this morning I came accross this tweet, that showed that you can use accross two strings if they do not contain special characters. https://twitter.com/bascodes/status/1492147596688871424 I popped open ipython to play with this. I could confirm on , short strings that I typed in worked as expected. Using the method on these strings does break down. If You can also see this in the id of the objects as well
-
Bluetooth at the command line on Ubuntu
One thing about moving to a tiling window manager like awesome wm or i3 is that they are so lightweight they are all missing things like bluetooth gui's out of the box, and you generally bring your own. Today I just needed to connet a new set of headphones, so I decided to just give the cli a try. It seems to come with Ubuntu, I don't think I did anything to get it. Running pops you into a repl/shell like bah, python, or ipython. From here you can execute commands. Here is what I had to
-
Read stderr from python subprocess.Popen
I often run shell commands from python with Popen, but not often enough do I set up error handline for these subprocesses. It's not too hard, but it can be a bit awkward if you don't do it enough. Using Popen reading from stderr To get the stderr we must get it from the proc, read it, and decode the bystring. Note that we can only get the stderr object once, so if you want to do more than just read it you will need to store a copy of it. Better Exception Now that we can read the we can make
-
Simple Samba Share Setup
Samba is an implementation of the smb protocol that allows me to setup network shares on my linux machine that I can open on a variety of devices. I think the homelab is starting to intrigue me enought to dive into the path of experimenting with different things that I might want setup in my own home. One key piece of this is network storage. As I looked into nas, I realized that it takes a dedicated machine, or one virtualized at a lower level than I have capability for right now. Humble Begin
-
ag silver searcher look ahead and look behind
A super useful tool when doing PR's or checking your own work during a big refactor is the silver searcher. Its a super fast command line based searching tool. You just run to search for your search term. This will list out every line of every file in any directory under your current working directory that contains a match. Ahead/Behind It's often useful to need some extra context around the change. I recently reviewed a bunch of PR's that moved schema from to the root of the dataset in a
-
Running a Minecraft Server in Docker
I've ran a Minecraft server at home since December 2017 for me and my son to play on. We start a brand new one somewhere between every day and every week. The older he gets the longer the server lasts. In all these years, I've been popping open the command line and running the server manually, and even inside of Digital Ocean occasionally to play a more public server with a friend. My buddy Nic has been sharing me some of his homelab setup, and it's really got me to thinking about what I can r
-
Installing Rust and Cargo on Ubuntu 21.10 using An...
Installing rust in your own ansible playbook will make sure that you can get consistent installs accross all the machines you may use, or replicate your development machine if it ever goes down. Personal philosophy I try to install everything that I will want to use for more than just a trial inside of my ansible playbook. This way I always get the same setup across my work and home machines, and anytime I might setup a throw away vm. reccommended install This is how rust reccomends that you in
-
Using a Python Markdown ast to Find All Paragraphs
In looking for a way to automatically generate descriptions for pages I stumbled into a markdown ast in python. It allows me to go over the markdown page and get only paragraph text. This will ignore headings, blockquotes, and code fences. It's also super fast, previously I was rendering to html and using beautifulsoup to get only the paragraphs. Using the commonmark ast was about 5x faster on my site. Duplicate Paragraphs When I originally wrote this post, I did not realize at the time that
-
Neovim Config for Git
Creating a minimal config specifically for git commits has made running much more pleasant. It starts up Much faster, and has all of the parts of my config that I use while making a git commit. The one thing that I often use is autocomplete, for things coming from elsewhere in the tmux session. For this specifically is super helpful. The other thing that is engrained into my muscle memory is for escape. For that I went agead and added my and with no noticable performance hit. Here is
-
python dict get
For an embarassingly long time, til today, I have been wrapping my dict gets with key errors in python. I'm sure I've read it in code a bunch of times, but just brushed over why you would use get. That is until I read a bunch of PR's from my buddy Nic and notice that he never gets things with brackets and always with . This turns out so much cleaner to create a default case than try except. Example Lets consider this example for prices of supplies. Here we set a variable of prices as a dict
-
Nix Versions By Commit Count
I was listening to shipit37 with Vincent Ambo talking about building fully declaritive systems with nix. Vincent is building out Nixery and strongly believes that standard versioning systems are flawed. If we have good ci setup, and every commit is a good commit the idea of a release is just some arbitrary point in history that the maintainer decided was a good time to release, and has less to do about features and quality. Since many things still want to see a version number, there is one a
-
Find all Headings with BeautifulSoup
BeautifulSoup is a DOM like library for python. It's quite useful to manipulate html. Here is an example to find_all html headings. I stole the regex from stack overflow, but who doesn't. Make an example sample.html Lets make a sample.html file with the following contents. It mainly has some headings, and tags that I want to be able to find. Get the headings with BeautifulSoup Lets import our packages, read in our using pathlib and find all headings using BeautifulSoup. And what we get
-
Lambda Function as a Kedro Node
I keep my nodes short and sweet. They do one thing and do it well. I turn almost every DataFrame transformation into its own node. It makes it must easier to pull catalog entries, than firing up the pipeline, running it, and starting a debugger. For this reason many of my nodes can be built from inline lambdas. Examples Here are two examples, the first one is sometimes referred to as an identity function. This is super common to use in the early phases of a project. It lets you follow sta
-
How to Properly Simulate Stow
-
A Good Use for global .gitignore
I've never found a great use for a global file. Mostly I fear that by adding a lot of the common things like files it will be missing from the project and inevitably be committed to the project by someone else. Personal Tools Within the past year I have added some tools to my personal setup that are not required to run the project, but works really well with my setup. They are and . Since these both support project level configuration, are less common, and not in most templates they
-
Squoosh cli
Today I discovered a sweet new cli for compressing images. squoosh cli is a wasm powered cli that supports a bunch of formats that I would want to convert my website images to. !!! Note from the future > Unfortunately, due to a few people leaving the team, and staffing issues > resulting from the current economic climate (ugh), I'm deprecating the > CLI and libsquoosh parts of Squoosh. The web app will continue to be > supported and improved. I know that sucks, but there simply isn't the > time
-
Add New Dependencies to Your Kedro Project
As you work on your kedro projects you are bound to need to add more dependencies to the project eventually. Kedro uses a fantastic command under the hood to ensure that everyone is on the same version of packages at all times, and able to easily upgrade them. It might be a bit different workflow than what you have seen, let's take a look at it. git status Before you start mucking around with any changes to dependencies make sure that your git status is clean. I'd even reccomend starting a n
-
Practice making pipelines with kedro
I am a huge believer in practicing your craft. Professional athletes spend most of their time honing their skills and making themsleves better. In Engineering many spend nearly 0 time practicing. I am not saying that you need to spend all your free time practicing, but a few minutes trying new things can go a long way in how you understand what you are doing and make a hue impact on your long term productivity. [[ what-is-kedro ]] Start practicing practice building pipelines with #kedro t
-
Tmux and Vim Clipboard for Ubuntu
One of the first things I noticed broken in my terminal based workflow moving from Windows wsl to ubuntu was that my clipboard was all messed up and not working with my terminal apps. Luckily setting tmux and neovim to work with the system clipboard was much easier than it was on windows. First off you need to get if you don't already have it provided by your distro. I found it in the apt repositories. I have used it between Ubuntu 18.04 and 21.10 and they all work flawlessly for me. I have
-
nix rescues modded minecraft night
With the latest version of minecraft it requires a very new, possibly the latest, version of java. Lately we have been getting into modded minecraft and I maintain the server for us. It's been tricky to say the least. One hurdle I recently hit involves having the wrong version of java. I was getting this error trying to get a 1.12.2 forge server running. Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoad
-
Tmux hotkey for copier templates
I have added a hotkey to my copier template setup to quickly access all my templates at any time from tmux. At any point I can hit , thats holding control and hitting , and I will get a popup list of all of my templates directory names. Its an fzf list, which means that I can fuzzy search through it for the template I want, or arrow key to the one I want if I am feeling insane. I even setup it up so that the preview is a list of the files that come with the template in tree view. I've had t
-
Markata Filters as Telescope Pickers in Neovim
I often pop into my blog from neovim with the intent to look at just a single series of posts, , , or just see todays posts. Markata has a great way of mapping over posts and returning their path that is designe exactly for this use case. Markata listing out posts from the command line {.wide} To tie these into a Telescope picker you add the command as the find_command, and comma separate the words of the command, with no spaces. I did also in there so that the newest posts are closest to
-
Copier Tasks | Python templating post run task
Copier allows you to run post render tasks, just like cookiecutter. These are defined as a list of in your . They are simply shell commands to run. The example I have below runs an bash script after the copier template has been rendered. I have put the script in so that I know it's always on my . It will reach back into the and update the default number.
-
Gradual Typing in Python
I've referenced a video from Anthony Sotile in passing conversation several times. Walking through his gradual typing process has really helped me understand typing better, and has helped me make some projects better over time rather than getting slammed with typing errors. https://youtu.be/Rk-Y71P_9KE Step 1 Run Mypy as is, don't get fancy yet. This will not reach into any functions unless they are alreay explicitly typed. It will not enforce you to type them either. Step 2 Next we will add
-
Python Reverse Sluggify
In order to make an auto title plugin for markata I needed to come up with a way to reverse the slug of a post to create a title for one that does not explicitly have a title. !!! Note "slugs" a slug is generally all lowercase and free of spaces, and is a way to make website routes (urls) Here I have a available that gives me the articles path, ex. . An easy way to get rid of the file extension, is to pass it into pathlib.Path and ask for the stem, which returns . Then from There I chose t
-
fuzzy wallpaper with fzf
I really appreciate that in linux anything can be scripted, including setting the wallpaper. So everytime I disconnect a monitor I can just rerun my script and fix my wallpaper without digging deep into the ui and fussing through a bunch of settings. I set my default wallpaper with using the command above. Leaning in on feh, we can use fzf to pick a wallpaper from a directory full of wallpapers with very few keystrokes. I have mine alias'd to so that I can quickly run it from my terminal.
-
Get Python docstring with ast
Getting docstrings from python's ast is far simpler and more reliable than any method of regex or brute force searching. It's also much less intimidating than I originally thought. Parsing First you need to load in some python code as a string, and parse it with . This gives you a tree like object, like an html dom. Getting the Docstring You can then use to get the docstring of the node you are currently looking at. In the case of freshly loading in a file, this will be the module level doc
-
Python Respect the .gitignore
Many tools such as ripgrep respect the file in the directory it's searching in. This helps make it incredibly faster and generally more intuitive for the user as it just searches files that are part of thier project and not things like their virtual environments, node modules, or compiled builds. Editors like vscode often do not include files that are .gitignored in their search either. is a pattern matching library that implements git's wildmatch pattern so that you can ignore files include
-
Rename Python Variables with nvim
I don't use refactoring tools as much as I probably should. mostly because I work with small functions with unique names, but I recently had a case where a variable name was everywhere and I wanted it named better. This was not possible with find and replace, because there were other 's in this region. I first tried the nvim lsp rename, and it failed, Then I pip installed rope, a refactoring tool for python, and it just worked! Once you have rope installed you can call rename on the variabl
-
Python Find Available Port
When running a python process that requires a port it's handy if there is an option for it to just run on the next avaialble port. To do this we can use the socket module to determine if the port is in use or not before starting our process.
-
python functools total ordering
functools.total_ordering makes adding all of six of the rich comparison operators to your custom classes much easier, and more likely that you remember all of them. From the Docs: The class must define one of __lt__(), __le__(), __gt__(), or __ge__ In addition, the class should supply an __eq__() method. one of these lt () le () gt () ge () and required to have this one eq () Total Ordering Docs Here is an example using the Enum I was working on the other day.
-
Implement --pdb in a python cli
Adding a flag to your applications can make them much easier for those using it to debug your application, especially if your applicatoin is a cli application where the user has much fewer options to start this for themselves. To add a pdb flag to your applications you will need to wrap your function call in a try/except, and start a post_mortem debugger. I give credit to this stack overflow post for helping me figure this out. Using --pdb running this example with and without --pdb flag
-
Converting markdown to pdf with pandoc on linux
Converting markdown posts to pdf on ubuntu takes a few packages from the standard repos. I had to go through a few stack overflow posts, and nothing seemed to have all the fonts and packages that I needed to convert markdown, but this is what ended up working for me. Installing all the packages Using pandoc to convert markdown to a pdf results of converting this post to a pdf Here is an image of what converting this article over to a pdf looks like. The raw markdown is here .
-
Python Enum
Python comes with an enum module for creating enums. You can make your own enum by inheriting importing and inheriting from Enum. auto incrementing Enum values can be auto incremented by importing auto, and calling as their value. using the enum Enum's are accessed directy under the class itself, and have primarily two methods underneath each thing you make, and . using the Lifecycle Enum
-
Installing Pipx on Ubuntu
I recently paired up with another dev running windows with Ubuntu running in wsl, and we had a bit of a stuggle to get our project off the ground because they were missing com system dependencies to get going. Straight in the terminal Open up a terminal and get your required system dependencies using the apt package manager and the standard ubuntu repos. Using an Ansible-Playbook I like running things like this through an ansible-playbook as it give me some extra control and repeatability next t
-
2 minutes to stow
Stow is an incredible way to manage your dotfiles. It works by managing symlinks between your dotfiles directory and the rest of the system. You can then make your dotfiles directory a git repo and have it version controlled. In my honest opinion, when I was trying to get started the docs straight into deep detail of things I frankly don't really care about and jumped right over how to use it. When using stow its easiest to keep your dotfiles directory (you may name it what you want) in your
-
Using Copier Answers to rerun templates quickly
The copier answers file is a key component to making your templates re-runnable. Let's look at the example for my setup.py. Inside of my file is this, a message not to muck around with it, and the ansers in yaml form. The first line is just a helper for the blog post. Inside my copier.yml I have setup my _answers_file to point to a special file. This is because this is not a whole projet template, but one just for a single file. Once I change the _answers_file I was incredibly stuck Run it
-
Making a Textual Widget from a Rich Renderable
Once you have made your sick looking cli apps with rich, eventually you are going to want to add some keybindings to them. Currently Textual, also written by @willmcgugan , does this extremely well. Fair Warning it is in super beta mode and expected to change a bunch. So take it easy with hopping on the train so fast. Get the things Install them from the command line. Import make a .py file and import them in it. Make what you have a widget If you return your rich renderable out of class that
-
Remove Vim Tab Characters
I've been stuck many times looking at a vim buffer with little question marks at the beginning of each line and trying to get rid of them. for so long I didn't know what they were so trying to get rid of them was impossible. example of what the tab character renders as in my editor It turns out they are tabs, and you can get rid of the little leading question marks with this substitution command.
-
Tmux Pop size
tmux popups can be sized how you like based on the % width of the terminal on creation by using the flags (h, w, x, y) for height, width, and position. example running these commands
-
Changing copier template strings (_endops)
I was completely stuck for awhile. copier was not replacing my template variables. I found out that adding all these fixed it. Now It will support all of these types of variable wrappers !RTFM: Later I read the docs and realized that copier defaults to using and for its templates unlike other tools like cookiecutter.
-
copier template variables
I've been looking for a templating tool for awhile that works well with single files. My go to templating tool does not work for single files, it needs to put files into a directory underneath of it. template variables By default copier uses double square brackets for its variables. variables in files, directory_names, or file_names will be substituted for their value once you render them. note! by default copier will not inject variables into your unless you use a .tmpl suffix. Before runni
-
Running Kedro on Ubuntu 21.10 Impish Indri
I just installed a brand new Ubuntu 21.10 Impish Indri, and wanted a kedro project to play with so I did what any good kedroid would do, I went to my command line and ran But what I got back was not what I expected! This is weird, why cant I run kedro new with pipx? Lets try pip. Same issue. [[ what-is-kedro ]] Curious what kedro is? Check out this article. What's up wrong python version The issue is that kedro only runs on up to , and on Ubuntu 21.10 when you you get and the standard rep
-
A Minimal Pluggy Example
Pluggy makes it so easy to allow users to modify the behavior of a framework without thier specific feature needing to be implemented in the framework itself. I've really been loving the workflow of frameworks built with pluggy. The first one that many python devs have experience with is pytest. I've never created a pytest plugin, and honestly at the time I looked into how they were made was a long time ago and it went over my head. I use a data pipelining framework called kedro, and have bui
-
List all the files containing a phrase
One of the most useful skills you can acquire to make you faster at almost any job that uses a computer is getting good at finding text in your current working diretory and identifying the files that its in. I often use the silver searcher or ripgrep to find files in large directories quickly. Both have a sane set of defaults that ignore hidden and gitignored files, but getting them to list only the filenames and not the matched was not trivial to me. I've searched throught he help/man pag
-
My first impressions with pyenv
pyenv provides an easy way to install almost any version of python from a large list of distributions. I have simply been using the version of python from the os package manager for awhile, but recently I bumped my home system to Ubuntu 21.10 impish, and it is only 3.9+ while the libraries I needed were only compatable with up to 3.8. I needed to install an older version of python on ubuntu I've been wanting to check out pyenv for awhile now, but without a burning need to do so. installing Based
-
Installing Homebrew on Linux
Installing brew on linux proved quite easy and got pyenv running for me within 4 commands. I had never used homebrew before, honestly I thought it was a mac only thing for years. Today I wanted to try out pyenv, and the reccommended way to install was using homebrew. I am not yet sure if I want either in my normal workflow, so for now I am just going to pop open a new terminal and install homebrew and see how it goes. That was it, now homebrew is working. Starting a new shell and running the c
-
Serve html from your command line
When I first moved to vim from and ide like vscode or sublime text one of my very first issues was trying to preview my website at . There had always just been a button there to do it in all of my other editors, not vim. There are not many buttons for anything in vim. While there is probably a plugin that can run a webserver for me in vim, it's not necessary, we just need the command line we are already in. running a separate process You will need a way to run another process alongside vim,
-
Opening files in vim from output of command
Many command line tools can output a list of files, this is quite powerful. I often want to search for something, then open it from a fuzzy picker. This can be done with fzf in the terminal, but often I am already in vim and I want to open it inside my current session. Telescope how to pass a custom command to telescope Telescope is the fuzzy file finder I use every day inside of neovim. Its pretty fantastic and easy to extent like this. This first example I am only passing in files from the
-
Finding hidden (dotfiles) using Telescope in neovi...
Finding hidden files using Telescope as you fuzzy file finder is not too hard, its a single flag passed in. Then it will use whichever file finder it can find ['fd', 'fdfind', 'rg --files', 'find', or 'where'] in that order. These tools each have their own way of handling hidden files, but telescope takes care of that so all you need to do is pass in . I have this keymap set to help me list out all files including hidden files using the pnumonic go edit hidden. I use ge for quite a few differ
-
Installing system nerd-fonts with ansible
Lately I've been on a journey to really clean up my dotfiles, and I was completely missing fonts. I noticed jumping into a new vm I had a bunch of broken devicons when using Telescope with the devicons plugins. This is one of those things that can be a total pain to get right on some systems, and it's so nice when it's just there for you pretty much out of the box. make sure your user fonts directory exists chech if the font you want exists on your machine download and unzip fonts into the font
-
Installing packages with ansible only if they do n...
Part of my neovim setup requires having the python formatter installed and callable. I install it with so that I don't have to manage a virtual environment and have it available everywhere. So far this works well for me, if there are ever breaking changes I may need to rethink this. re-installing a bunch of things that are already installed can be quite a waste and really add up to my ansible run time, so for most of my ansible tasks that install a command like this I have been following t
-
Adding __rich__ methods to python classes
Adding a method that returns a rich renderable to any python class makes it display this output if printed with rich. This also includes being nested inside a rich Layout. results of printing ShowMe with rich
-
fugitive verbose commit
Fugitive comes with a pretty sick way to commit files and see the diff at the same time with verbose commit. Opening the fugitive menu with brings up your git status, you can stage files with , unstage them with , toggle them with , and toggle their diff with . Once you have staged your files for commit, you can commit with , but today I found that you can commit verbose with . This brings up not only a commit widow with your git status shown, but the diff that you are about to commit