Looking for inspiration? bubbletea [1] by charmbracelet [2].
A powerful little TUI framework 🏗
References:
[1]: https://github.com/charmbracelet/bubbletea
[2]: https://github.com/charmbracelet
Publishing rhythm
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]
- ...
If you’re into interesting projects, don’t miss out on pjs [1], created by bashbunni [2].
A basic CLI for regularly updating your project’s status
References:
[1]: https://github.com/bashbunni/pjs
[2]: https://github.com/bashbunni
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://dropper.waylonwalker.com/file/159cbd51-140a-4595-907f-676fe20f510b.webp
[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-...
The default keybinding for copy-mode <prefix>-[ 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
copy-mode 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 ~/.tmux.conf along with one for alt-enter and have found
myself using it way more so far.
Setting copy-mode to enter # [1]
To do this I just popped open my ~/.tmux.conf and added the following.
Now I can get to copy-mode with <prefix>-Enter which is control-b Enter, or alt-enter.
bind Enter copy-mode
bind -n M-Enter copy-mode
More on copy-mode # [2]
I have a full video on copy-mode you can find here.
tmux copy-mode [3]
References:
[1]: #setting-copy-mode-to-enter
[2]: #more-on-copy-mode
[3]: /tmux-copy-mode/
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 is 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 3.9.7, short
strings that I typed in worked as expected.
waylonwalker ↪main v3.9.7 ipython
❯ a = "asdf"
waylonwalker ↪main v3.9.7 ipython
❯ b = "asdf"
waylonwalker ↪main v3.9.7 ipython
❯ a is b
True
Using the upper() method on these strings does break down.
waylonwalker ↪main v3.9.7 ipython
❯ a.upper() is b.upper()
False
waylonwalker ↪main v3.9.7 ipython
❯ a = "ASDF"
waylonwalker ↪main v3.9.7 ipython
❯ b = "ASDF"
waylonwalker ↪main v3.9.7 ipython
❯ a is b
True
If You can also see this in the id of the objects as well, which is the memmory
address in CPython.
waylonwalker ↪main v3.9.7 ipython
❯ id(a)
140717359289568
waylonwalker ↪main v3.9.7 ipython
❯ id(b)
140717359289568
waylonwalker ↪main v3.9.7 ipython
❯ id(a.upper())
140717359581824
waylonwalker ↪main v3.9.7 ipython
❯ id(b.upper())
140717360337824
Finally just as the post shows if...
Just starred nvim-terminal.lua [1] by norcalli [2]. It’s an exciting project with a lot to offer.
A high performance filetype mode for Neovim which leverages conceal and highlights your buffer with the correct color codes.
References:
[1]: https://github.com/norcalli/nvim-terminal.lua
[2]: https://github.com/norcalli
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 bluetoothctl cli a try. It
seems to come with Ubuntu, I don’t think I did anything to get it.
bluetoothctl
Running bluetoothctl pops you into a repl/shell like bah, python, or ipython.
From here you can execute bluetoothctl commands.
Here is what I had to do to connect my headphones.
# list out the commands available
help
# scan for new devices and stop when you see your device show up
scan on
scan off
# list devices
devices
paired-devices
# pair the device
pair XX:XX:XX:XX:XX:XX
# now your device should show up in the paired list
paired-devices
# connet the device
connect XX:XX:XX:XX:XX:XX
help # [1]
Here is the output of the help menu on my machine, it seems pretty straight
forward to block, and remove devices from here.
note ctrl revers to the bluetooth controller on the machine you are on, and dev
refers to a device id.
Menu main:
Available commands:
-------------------
advertise A...
The work on xsv [1] by BurntSushi [2].
A fast CSV command line toolkit written in Rust.
References:
[1]: https://github.com/BurntSushi/xsv
[2]: https://github.com/BurntSushi
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 # [1]
import subprocess
from subprocess import Popen
# this will run the shell command `cat me` and capture stdout and stderr
proc = Popen(["cat", "me"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# this will wait for the process to finish.
proc.wait()
reading from stderr # [2]
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.
proc.stderr.read().decode()
Better Exception # [3]
Now that we can read the stderr we can make better error tracking for the
user so they can see what to do to resolve the issue rather than blindly
failing.
err_message = proc.stderr.read().decode()
if proc.returncode != 0:
# the process was not successful
if "No such file" in err_message:
raise FileNotFoundError('No such file "me"')
References:
[1]: #using-popen
[2]: #reading-from-stderr
[3]: #better-exception
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 [1] 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 Beginnings # [2]
To get goind I am going to make a directory /srv/samba/public open to anyone
on my network. I am not going to worry too much about it, I just want
something up and running so that I can learn.
Install samba, open the firewall, and edit the smb.conf
sudo apt install samba samba-common-bin
sudo ufw allow samba
sudo nvim /etc/samba/smb.conf
I added this to the end of my smb.conf
[public]
comment = public share, no need to enter username and password
path = /srv/samba/public/
browseable = yes
writable = yes
guest ok = yes
Then I made the /srv/samba/public directory and made it writable by anyone.
sudo mkdir -p /srv/samba/public
sudo setfacl -R -m "u:nobody:rwx" /srv/s...
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 ag "<search term>" 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 # [1]
It’s often useful to need some extra context around the change. I recently
reviewed a bunch of PR’s that moved schema from save_args to the root of the
dataset in all yaml configs. To ensure they all made it to the top level
DataSet configuraion, and not underneath save_args. I can do a search for all
the schemas, and ensure that none of them are under save_args anymore.
ag "schema: " -A 12 -B 12
References:
[1]: #aheadbehind
I’m really excited about kondo [1], an amazing project by tbillington [2]. It’s worth exploring!
Cleans dependencies and build artifacts from your projects.
References:
[1]: https://github.com/tbillington/kondo
[2]: https://github.com/tbillington
Check out snapdrop [1] by SnapDrop [2]. It’s a well-crafted project with great potential.
A Progressive Web App for local file sharing
References:
[1]: https://github.com/SnapDrop/snapdrop
[2]: https://github.com/SnapDrop