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.
# normal popup
tmux popup figlet "Hello"
# fullscreen popup
tmux popup -h 100% -w 100% figlet "Hello"
# 75% centered popup
tmux popup -h 100% -w 75% figlet "Hello"
# 75% popup on left side
tmux popup -h 100% -w 75% -x 0% figlet "Hello"
Sorry, your browser doesn't support embedded videos.
example running these commands
Drafts
Draft and unpublished posts
0 posts
Copier Templates
%%include til/copier_endops
%%include til/copier-template-variables
%%include til/copier-answers
I was completely stuck for awhile. copier was not replacing my template
variables. I found out that adding all these _endops fixed it. Now
It will support all of these types of variable wrappers
# copier.yml
_templates_suffix: .jinja
_envops:
block_end_string: "%}"
block_start_string: "{%"
comment_end_string: "#}"
comment_start_string: "{#"
keep_trailing_newline: true
variable_end_string: "}}"
variable_start_string: "{{"
!RTFM: Later I read the docs and realized that copier defaults to using [[
and ]] for its templates unlike other tools like cookiecutter.
I’ve been looking for a templating tool for awhile that works well with
single files. My go to templating tool cookiecutter does not work for
single files, it needs to put files into a directory underneath of it.
template variables # [1]
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.
# hello-py/hello.py.tmpl
print('hello-[[name]]')
note! by default copier will not inject variables into your
template-strings unless you use a .tmpl suffix.
Before running copier we need to tell copier what variables to ask for,
we do this with a copier.yml file.
# copier.yml
name:
default: my_name
type: str
help: What is your name
installing copier # [2]
I prefer to install cli tools that I need globally with pipx, this
always gives me access to the tool without worrying about dependency
conflicts, bloating my system site-packages, or managing a separate
virtual environment [3] for it myself.
pipx install copier
running copier # [4]
When running copier copy we pass in the directory of the template, and
the directory that we want to render the template into.
cop...
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
pipx run kedro new --starter spaceflights
But what I got back was not what I expected!
Fatal error from pip prevented installation. Full pip output in file:
/home/walkers/.local/pipx/logs/cmd_2022-01-01_20.42.16_pip_errors.log
Some possibly relevant errors from pip install:
ERROR: Could not find a version that satisfies the requirement kedro (from versions: none)
ERROR: No matching distribution found for kedro
Error installing kedro.
This is weird, why cant I run kedro new with pipx? Lets try pip.
pip install kedro
Same issue.
ERROR: Could not find a version that satisfies the requirement kedro (from versions: none)
ERROR: No matching distribution found for kedro
What is Kedro [1]
Curious what kedro is? Check out this article.
What’s up # [2]
wrong python version
The issue is that kedro only runs on up to python 3.8, and on Ubuntu
21.10 when you apt install python3 you get python 3.9 and the
standard repos don’t have an old enough version to run kedro.
How to fix this? # [3]
Theres a couple of wa...
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 build many plugins for it.
Making a plugin # [1]
super easy to do
As long as the framework document the hooks that are available and what it
passes to them it’s so easy to make a plugin. Its just importing the
hook_impl, making a class with a function that represents one of the hooks,
and decorating it.
from framework import hook_impl
class LowerHook:
@hook_impl
def start(pluggy_example):
pluggy_example.message = pluggy_example.message.lower()
installing pluggy # [2]
Installing pluggy is just like most python applications, install python, make
your virtual environment [3], and pip install it.
pip install pluggy
Making a plugin driven framework # [4]
much less easy
At the time I sta...
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 ag or ripgrep rg 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 pages many times looking for these
flags and they always seem to evade me.
ag # [1]
Passing the flag -l to ag will get it to list only the filepath, and
not the match. Here I gave it a --md as well to only return markdown
filetypes. ag supports a number of filetypes in a very similar way.
ag nvim --md -l
rg # [2]
Giving rg the --files-with-matches flag will yield you a similar set
of results, giving only the filepaths themselves and not the match
statement. Also passing in the -g "*.md" will similarly yield only
results from markdown files.
rg --files-with-matches you -g "*.md"
References:
[1]: #ag
[2]: #rg
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 # [1]
Based on the Readme it looked like I needed to install using homebrew,so this
is what I did, but I later realized that there is a pyenv-installer repo that
may have saved me this need.
Installing Homebrew on Linux [2]
List out install candidates # [3]
You can list all of the available versions to install with
pyenv install --list. It does reccomend updating pyenv if you suspect
that it is missing one. At the time of writing this comes out to 532
different versions!
pyenv install --list
Let’s install the latest 3.8 patch # [4]
Installing a version is as easy as pyenv install 3.8.12. This will
install it, but not make it active anywhere.
pyenv install 3.8.12
let’s use python 3.8...
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.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/walkers/.zprofile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
That was it, now homebrew is working. Starting a new shell and running
the command to install pyenv worked.
brew install pyenv
Links # [1]
- homebrew [2]
References:
[1]: #links
[2]: https://brew.sh/
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 localhost:8000. 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 # [1]
You will need a way to run another process alongside vim, here are a couple
ideas to get you going that are not the focus here.style
- use background jobs
- c-z to send a job to the background
- fg to bring it back
- use a second terminal
- use a second tab
- use tmux and run it in a separate split/window
- use an embeded nvim terminal
running a development webserver from the command line # [2]
Python already exists on most linux systems by default, and most are now on
python3. If you are on windows typing python will take you directly to the
windows store to install it, or you can also use wsl.
# python3
python -m http.server
# running on port 5000
python -m http.server --directory markout 5000
# for the low chance ...
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 # [1]
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 current working directory by using ls.
:Telescope find_files find_command=ls
This brings up a normal Telescope picker with results from the ls command.
More arguments # [2]
how to pass a muli-argument command to telescope
Adding more arguments can be done by comma separating them as shown in the
example below. This command will run the silver-searcher, search for all
occurences of nvim inside of a markdown file, and return only the filepaths so
Telescope can pick from them.
:Telescope find_files find_command=ag,nvim,--md,-l
References:
[1]: #telescope
[2]: #more-arguments
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
hidden=true.
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
different things to take me directly to a specific file or picker.
nnoremap geh <cmd>Telescope find_files hidden=true<cr>
see the
implementation [1]
telescope finds your files.
References:
[1]: https://github.com/nvim-telescope/telescope.nvim/blob/82e3cc322ad87b262aef092cb7475e769740e83a/lua/telescope/builtin/files.lua#L167-L184
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 fonts directory
- repeat 2-3 for all the fonts you use on your system
- name: ensure fonts directory
file:
path: "{{ lookup('env', 'HOME') }}/.fonts"
state: directory
- name: Hack exists
shell: "ls {{ lookup('env', 'HOME') }}/.fonts/Hack*Nerd*Font*Complete*"
register: hack_exists
ignore_errors: yes
- name: Download Hack
when: hack_exists is failed
ansible.builtin.unarchive:
src: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Hack.zip
dest: "{{ lookup('env', 'HOME') }}/.fonts/"
remote_src: yes
https://www.youtube.com/watch?v=2MEmsinxRK4
I made a YT based on this post
Links # [1]
- ansible docs for builtin.unarchive [2]
Setup a yaml schema | yamlls...
Part of my neovim setup requires having the black python formatter
installed and callable. I install it with pipx so that I don’t have
to manage a virtual environment [1] 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
this pattern.
- check if the command is installed with command -v <command>
- register that step
- ignore if that step fails
- add a when: <xxx>_exists is failed condition to the step that
installs that command.
- name: check is black installed
shell: command -v black
register: black_exists
ignore_errors: yes
- name: install black
when: black_exists is failed
shell: pipx install black
https://www.youtube.com/watch?v=MCFg6-W5SBI
I made a video based on this post, check it out if its your thing
References:
[1]: /virtual-environment/
Adding a __render__ 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.
import rich
from rich.panel import Panel
class ShowMe:
def __rich__(self):
return Panel("hello", border_style="gold1")
if __name__ == "__main__":
rich.print(ShowMe())
[1]
References:
[1]: https://images.waylonwalker.com/dunder_rich_showme.png
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 :G brings up
your git [1] status, you can stage files with s, unstage them with u, toggle
them with -, and toggle their diff with >. Once you have staged your files
for commit, you can commit with cc, but today I found that you can commit
verbose with cvc. This brings up not only a commit widow with your git
status shown, but the diff that you are about to commit.
[2]
example of a verbose commit in fugitive
References:
[1]: /glossary/git/
[2]: https://images.waylonwalker.com/fugitive-verbose-commit.png
Kedro Course
-
find all nodes with raw in the name
-
use parameters
-
make and use a logger
-
use find-kedro in spaceflights
-
slide in a new node
-
vizualize your pipeline
-
find slow nodes
-
move the configuration directory
-
build kedro into docker and run it
-
pyinstrument
-
pdb
-
make a new cli command
-
make a hook
-
load catalog entries
-
slice a pipeline
- by tag
- by name
- from inputs
- to outputs
Uses
This is a listing of all the things that I use on a daily basis to build data
pipelines, lead my team, and build this website.
older editions # [1]
[[ uses-2021 ]]
Installation # [2]
Everything installed on my machines is done through ansible-playbooks. It’s
been a long transformation to get here, but its so satisfying to boot a brand
new system, run a single command a have every single thing cofigured exactly to
my liking.
# GET is available by default on Ubuntu
GET waylonwalker.com/bootstrap | bash
# For debian based systems without GET by default
sudo apt install curl
curl -F https://waylonwalker.com/bootstrap | bash
OS # [3]
I run Ubuntu, it works well for me without too much fuss. For me the
distribution does not really matter too much, I’m more interested in what’s
inside.
Window Manager # [4]
I use awesome wm. Awesome is a tiling window manager that alows me to navigate
through 9 workspaces (technically called tags in awesomewm). I can script out
certain applications...
Update Alternatives in Linux
update-alternatives --query python
update-alternatives: error: no alternatives for python
sudo update-alternatives --install /usr/local/bin/python python `which python3.8` 2
# update-alternatives: using /usr/bin/python3.8 to provide /usr/local/bin/python (python) in auto mode
sudo update-alternatives --install /usr/local/bin/python python `which python2.7` 5
# update-alternatives: using /usr/bin/python2.7 to provide /usr/local/bin/python (python) in auto mode
update-alternatives --query python
# Name: python
# Link: /usr/local/bin/python
# Status: auto
# Best: /usr/bin/python2.7
# Value: /usr/bin/python2.7
#
# Alternative: /usr/bin/python2.7
# Priority: 5
#
# Alternative: /usr/bin/python3.8
# Priority: 2
sudo update-alternatives --install /usr/local/bin/python python `which python3.8` 20
# update-alternatives: using /usr/bin/python3.8 to provide /usr/local/bin/python (python) in auto mode
Using Nix to manage my Python Interpreter
I recently started playing with nix.
goals # [1]
- automatically select correct python version per project
- activating one doesn’t bleed into the other
Installing nix # [2]
curl -L https://nixos.org/nix/install | sh
controlling nix-env # [3]
nix-env -iA nixpkgs.python310
nix-env -iA nixpkgs.python39
nix-env -iA nixpkgs.python38
nix-env -iA nixpkgs.python37
searching for packages # [4]
https://search.nixos.org/
nix-env -qaP .\*python.\*
nix search nixpkgs python
shell # [5]
nix-shell -p python39
References:
[1]: #goals
[2]: #installing-nix
[3]: #controlling-nix-env
[4]: #searching-for-packages
[5]: #shell