Drafts

Draft and unpublished posts

0 posts
If you have ever ran which <command> 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. eval "typeset -U path"
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! <script src='https://unpkg.com/[email protected]/dist/mermaid.min.js'></script> <div class='mermaid'> graph TD; a --> A A --> B B --> C </div> You just write mermaid syntax in a div with a class of mermaid on it! The above gets me this diagram. graph TD; a --> A A --> B B --> C This feels so quick and easy to start getting some graphs up and running, but does lead to layout shift and extra bytes down the pipe. The best solution in my opionion would be to forgo the js and ship svg. That said, this is do dang convenient I will be using it for some things. import mermaid from '/assets/vendor/mermaid/mermaid.esm.min.mjs'; const rootStyle = getComputedStyle(document.documentElement); const css = (name, fallback) => ...
There is GNU coreutils command called mktemp 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 /tmp gets wiped. I’m not sure when that is, but I don’t expect it to be long. Making temp directories # [1] Here are some examples of making temp directories in different places, my favorite is mktemp -dt mytemp-XXXXXX. # makes a temporary directory in /tmp/ with the defaul template tmp.XXXXXXXXXX mktemp # makes a temporary directory in your current directory mktemp --directory mytemp-XXXXXX # shorter version mktemp -d mytemp-XXXXXX # same thing, but makes a file mktemp mytemp-XXXXXX # makes a temporary directory in your /tmp/ directory (or what ever you have configured as your TMPDIR) mktemp --directory --tmpdir mytemp-XXXXXX # shorter version mktemp -dt mytemp-XXXXXX # same thing, but makes a file mktemp --tmpdir mytemp-XXXXXX # shorter version mktemp -t mytemp-XXXXXX Use Case # [2] Here is a sample script that shows how to capture the tempdir as a variable and reuse it. Here is an example of curling my bootstrap file into a temp dir...
Once you give a branch the big D (git branch -D mybranch) 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 # [1] Checkout is your savior, all you need is the commit hash. Immediate Regret # [2] 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 this. ❯ git branch -D new Deleted branch new (was bc02a64). Notice the hash is right there is the hash of your commit. You can use that to get your content back. git checkout -b bc02a64 git branch new # or in one swoop checkout your new branch at the `start-point` you want git checkout -b new bc02a64 Delayed reaction # [3] you have closed your terminal If you have closed your terminal, or have deleted with a gui or something that does not tell you the hash as you run it, don’t fret, all your work is still there (as long as you have commited). You just have to dig it out. The reflog contains a list of all git [4] operations that have occurred on your ...
It’s nearly impossible to completely loose a file if it is commited to git [1]. 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 git log with --diff-filter. 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 your git history but have been deleted. git log –diff-filter # [2] These various commands will show all files that were ever deleted on your current branch. # This one includes the date, commit hash, and Author git log --diff-filter D # this one could be a git alias, but includes empty lines git log --diff-filter D --pretty="format:" --name-only # this one has the empty lines cleaned up git log --diff-filter D --pretty="format:" --name-only | sed '/^$/d' git diff-filter [3] git reflog –diff-filter # [4] The reflog can be super powerful in finding lost files here, as it only cares about git operations, not just the current branch. It will search accross all branch...
git
Git [1] commands such as diff, log, whatchanged all take a flag called --diff-filter. This can filter for only certain types of diffs, such as added (A), modified (M), or deleted (D). Man page # [2] You can find the full description by searching for --diff-filter in the man git diff page. --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected. Also, these upper-case letters can be downcased to exclude. E.g. --diff-filter=ad excludes added and deleted paths. Note that not all diffs can feature all types. For instance, diffs from the index to the working tree can never have Added entries (because the set of paths included in the diff is limited by what is in the index). Sim...
git
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 # [1] 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 input it just cant get there. There is a textual-inputs [2] library that covers this, and it might work really well for some use cases, but many of my use cases have been for things that are pre-built like copier, and I am trying to throw something together quick. textual is still very beta Part of this comes down to the fact that textual is still very beta and likely to change a lot, so all of the work I have done with it is for quick and dirty, or fun side projects. The Solution # [3] So the solution that was easiest for me… shell out to a tmux popup. The application I am working on wants to create new documents using copier templates. copier has a fantastic cli that walks throught he template variables and asks the user to fill them in, so I just shell...
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 # [1] I did not have flatpak installed so the first thing I had to do was get the flatpak command installed, and add their default repo. sudo apt install flatpak flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo Once I had flatpak, I was able to get obs installed with the following command. flatpak install flathub com.obsproject.Studio Once Installed it fired right up for me with the next command they suggested. flatpak run com.obsproject.Studio It Works # [2] Pretty straightforward, following the instructions given it all worked for me, but it was missing a lot of the plugins that the current snap package I am using gives me (namely virtual webcam). So I am not ready to jump onto it until I figure out how to manage my own obs plugins. For now I think the snap is working just well enough. Links # [3] - flatpak setup for ubuntu [4] - obs release notes [5] - obs flatpak [6] References: [1]: #install-flatpak [2]: #it-wo...
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 # [1] 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 control f and everything. graph TD; A-->B; A-->C; B-->D; C-->D-->OUT; E-->F-->G-->OUT [2] Links # [3] - GitHub support announcement [4] - mermaid docs [5] import mermaid from '/assets/vendor/mermaid/mermaid.esm.min.mjs'; const rootStyle = getComputedStyle(document.documentElement); const css = (name, fallback) => (rootStyle.getPropertyValue(name) || fallback).trim(); const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches || document.documentElement.dataset.theme === 'dark'; const accent = css('--color-primary', '#ffcd11'); const flowchart = { nodeSpacing: 60, rankSpacing: 90, padding: 12, }; const themeCSS = ` .label foreignObject > div { padding: 14px 14px 10px; line-height: 1.2; } .nodeLabel { padding: 14px 14px 10px; line-height: 1.2; } * { cursor: pointer; } `; const themeVariables = { background: css('--color-background', '#...
Git [1] 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 --root. git rebase --root References: [1]: /glossary/git/
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 # [1] You will need to install glances to use the glances webui. We can still use pipx to manage our virtual environment [2] for us so that we do not need to do so manually or run the risk of globally installed package dependency hell. pipx install glances pipx inject glances "glances[docker]" You will be presented with this success message. injected package glances into venv glances done! ✨ 🌟 ✨ results # [3] Now running glances will also show information about your running docker containers. [4] Links # [5] - glances docker [6] - pipx [7] - website [8] - docs [9] - github [10] References: [1]: #install [2]: /virtual-environment/ [3]: #results [4]: https://images.waylonwalker.com/glances-docker.png [5]: #links [6]: https://glances.readthedocs.io/en/catest/docker.html [7]: https://pipx.pypa.io/stable/ [8]: https://nicol...
Git [1] reflog can perform some serious magic in reviving your hard work from the dead if you happen to loose it. caveat # [2] 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 # [3] 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 and cannot do, and how to do it in a place that does not matter in any way at all. This is what I did to revive a dropped docker-compose.yml file. The idea is that if I can find the commit hash, I can cherry-pick it. git init touch readme.md git add readme.md git commit -m "add readme" touch docker-compose.yml git add docker-compose.yml git commit -m "add docker-compose" git reset 3cfc --hard git reflog # copy the hash of the commit with my docker-compose commit git cherry-pick fd74df3 reflog # [4] Here was the final reflog that shows all of my git actions. note I did reset twice. ❯ git reflog --name-only 0404b6a (HEAD -> main) HEAD@{0}: cherry-pick: add docker-compo...
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 # [1] You will need to install glances to use the glances webui. We can still use pipx to manage our virtual environment [2] for us so that we do not need to do so manually or run the risk of globally installed package dependency hell. pipx install glances pipx inject glances "glances[web]" You will be presented with this success message. injected package glances into venv glances done! ✨ 🌟 ✨ running the webui # [3] Now that you have glances installed you can run it with the -w flag to run the webui. glances -w This will present you with the following success message. Glances Web User Interface started on http://0.0.0.0:61208/ Open it in your browser # [4] Now that its running you can open your web browser to localhost:61208 and be presented with the glances webui. [5] Links # [6] - pipx [7] - ...
Right inside the git [1] docs [2], is states that the git reflog command runs git reflog show by default which is an alias for git log -g --abbrev-commit --pretty=oneline This epiphany deepens my understanding of git, and lets me understand that most git log flags might also work with git log -g. full or short format # [3] 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. # These show only first line of the commit message subject, the hash, and index git reflog git log -g --abbrev-commit --pretty=oneline # similar to git log, this is a fully featured log with author, date, and full # commit message git log -g add files # [4] If I am looking for a missing file, I might want to leverage --name-only or --stat, to see where I might have hard reset that file, or deleted it. git reflog --stat git log -g --stat --abbrev-commit --pretty=oneline git reflog --name-only git log -g --name-only --abbrev-commit --pretty=oneline example # [5] Here is an example where I lost my docker-compose.yml file in a git reset, and got it back by finding the commit hash with git reflog and cherry picked it back. ❯...
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 pipx, which you should already have installed if you do anything with python. pipx run glances 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. [1] Links # [2] - pipx [3] - website [4] - docs [5] - github [6] References: [1]: https://images.waylonwalker.com/pipx-run-glances.png [2]: #links [3]: https://pipx.pypa.io/stable/ [4]: https://nicolargo.github.io/glances/ [5]: https://glances.readthedocs.io/en/latest/index.html [6]: https://github.com/nicolargo/glances
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 requirements.txt file. The trick is to just prefix the file with a -r flag, just like you would if you were installing it with pip install try it out # [1] Lets create two requirements files in a new directory to play with. mkdir requirements-nest cd requirements-nest touch requirements.txt requirements_dev.txt Then add the following to each requirements file. # requirements.txt kedro[pandas.ParquetDataSet] # requirements_dev.txt -r requirements.txt ipython Installing # [2] Installing requirements_dev.txt will install both ipython and pandas since it includes the base requirements file. # this will install only pandas pip install -r requirements.txt # this will install both ipython and pandas pip install -r requirements_dev.txt Links # [3] This is covered in the pip user guide [4], but it is not obvious that this can be done in a requirements.txt file. References: [1]: #try-it-out [2]: #installing [3]: #links [4]: https://pip.pypa.io/en/stable/user_guide/
In my adventure to put more homelab [1] in docker, I moved our modded minecraft setup to docker. Getting Mods # [2] So far I have found all of our mods from curse forge [3]. 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 # [4] under the hood docker is using wget to get the mod. The link you click on from curseforge will block wget. What I do is pop open the devtools (f12 in chrome), click on the network tab, click the download link on the web page, and watch the real link show up. [5] Docker-compose # [6] I am using docker compose, it makes the command much easier to start, and all the things needed stored in a file. I am not using compose to run multiple things, just for the simple start command. Create a directory for your server and add the following to a docker-compose.yml file. version: "3.8" services: mc: container_name: walkercraft image: itzg/minecraft-server ports: - 25565:25565 environment: EULA: "TRUE" TYPE: "FORGE" VERSION: 1.16.5 M...
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. alias awsevents = aws events list-rules | visidata -f json
Anyone just starting out their vim customization journey is bound to run into this error. E5520: <Cmd> mapping must end with <CR> I did not get it # [1] 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 # [2] If you run :h <cmd> 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 <cmd>. E5520 <Cmd> commands must terminate, that is, they must be followed by <CR> in the {rhs} of the mapping definition. Command-line mode is never entered. When to map with a : # [3] You still need to map your remaps with a : if you do not close it with a <cr>. This might be something like prefilling a command with a search term. nnoremap <leader><leader>f :s/search/ Otherwise use # [4] If you can close the <cmd> with a <cr> the command do so. Your map will automatically be silent, more ergonomic, performant, and all that good stuff. nnoremap <leader><leader>f <cmd>s/search/Search/g<cr> References: [1]: #i-did-not-get-it [2]: #from-the-docs [3]: #when-to-map-with-a-...

Hydroneer

Steam achievements and progress for Hydroneer - 0.0% complete with 0/78 achievements unlocked.

6 min