{"@attributes":{"version":"2.0"},"channel":{"title":"DEV Community: Waylon Walker","description":"The latest articles on DEV Community by Waylon Walker (@waylonwalker).","link":"https:\/\/dev.to\/waylonwalker","image":{"url":"https:\/\/media2.dev.to\/dynamic\/image\/width=90,height=90,fit=cover,gravity=auto,format=auto\/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F271838%2F95e313ca-39fc-4ee6-bf57-ad52b4dcf0d2.png","title":"DEV Community: Waylon Walker","link":"https:\/\/dev.to\/waylonwalker"},"language":"en","item":[{"title":"Who has an website idea to build #hacktoberfest","pubDate":"Thu, 06 Oct 2022 20:21:48 +0000","link":"https:\/\/dev.to\/waylonwalker\/who-has-an-website-idea-to-build-hacktoberfest-1f2k","guid":"https:\/\/dev.to\/waylonwalker\/who-has-an-website-idea-to-build-hacktoberfest-1f2k","description":"<p>If you are someone who likes building things with python for the web, check out a project I have been slowly building up over the past few years.  Open sourced in March this year.<\/p>\n\n<h2>\n  \n  \n  Markata\n<\/h2>\n\n<p><a href=\"https:\/\/markata.dev\">Markata<\/a> is a plugins all the way down static site generator for python.  Meaning that you can build a working site from it out of the box, and you can make it your own through configuration.  You can also really make it completely customized to your needs by writing plugins to do what you need it to do.<\/p>\n\n<h2>\n  \n  \n  Contribute to the project-gallery\n<\/h2>\n\n<p>Once you have something built, and hosted in the wild, submit it to the <a href=\"https:\/\/markata.dev\/project-gallery\/\">project-gallery<\/a>.  There are instructions inside <a href=\"https:\/\/github.com\/WaylonWalker\/markata\/issues\/78\">issue#78<\/a>.<\/p>\n\n<h2>\n  \n  \n  The Blog Starter\n<\/h2>\n\n<p><em>want to see an example check out the <a href=\"https:\/\/blog-starter.markata.dev\/\">starter<\/a><\/em><\/p>\n\n<p>Throughout this month I have been converting some of my sites over to an official blog <a href=\"https:\/\/blog-starter.markata.dev\/\">starter<\/a> that uses all of the best features for a blog out of the box.  It includes a variety of pages that are general instructions about how to configure the various plugins.  These serve as great examples of how to use it, especially while the docs are a bit of a work in progress.<\/p>\n\n<h2>\n  \n  \n  Don't want to host an example?\n<\/h2>\n\n<p>If you don't have anything that you want to host in public I would still appreciate anyone to try to make a project with it and leave feedback.  If you run into any issues submit a small pr to either the project or the starter template.  If you have a larger issue, please raise an issue and discuss it before putting tons of work into it.<\/p>\n\n<h2>\n  \n  \n  Site Ideas\n<\/h2>\n\n<p>Markata is setup to build about anything you can imagine on the web that can be statically compiled and hosted.  Please make something that you want for yourself.  Something that is all yours, and brings you joy.  If you are struggling with ideas here are a few.<\/p>\n\n<ul>\n<li>\n<a href=\"https:\/\/github.com\/WaylonWalker\/markata-gh\">gh projet portfolio<\/a> - This is a starter repo.<\/li>\n<li><a href=\"https:\/\/github.com\/WaylonWalker\/markata-blog-starter\">markata-starter-blog<\/a><\/li>\n<li>wiki<\/li>\n<li>docs<\/li>\n<li>Journal<\/li>\n<li>Tils<\/li>\n<li>Linktree<\/li>\n<li><a href=\"https:\/\/github.com\/WaylonWalker\/markata-todo\">Todo<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/WaylonWalker\/markata-slides\">Slides<\/a><\/li>\n<li>Image Gallery - ex: <a href=\"https:\/\/stable-diffusion.waylonwalker.com\/\">my stable diffusions<\/a>\n<\/li>\n<li>Re-host your tweets \/ social posts<\/li>\n<\/ul>\n\n<h2>\n  \n  \n  What do you think?\n<\/h2>\n\n<p>I'd love to hear your thoughts down below.  Check out the <a href=\"https:\/\/blog-starter.markata.dev\/\">starter<\/a> and tell me what you think.<\/p>\n\n","category":["hacktoberfest","python"]},{"title":"Two new shell aliases for git","pubDate":"Wed, 14 Sep 2022 14:28:42 +0000","link":"https:\/\/dev.to\/waylonwalker\/two-new-shell-aliases-for-git-3bfo","guid":"https:\/\/dev.to\/waylonwalker\/two-new-shell-aliases-for-git-3bfo","description":"<p>Recently I added two new bash\/zsh aliases to make my git experience just a tad better.<\/p>\n\n<h2>\n  \n  \n  trackme\n<\/h2>\n\n<p>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 <code>trackme<\/code> anytime I see this error.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>There is no tracking information for the current branch.\n    Please specify which branch you want to merge with.\n    See git-pull(1) for details\n\n    git pull &lt;remote&gt; &lt;branch&gt;\n\nIf you wish to set tracking information for this branch you can do so with:\n\n    git branch --set-upstream develop origin\/&lt;branch&gt;\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h3>\n  \n  \n  getting the branch\n<\/h3>\n\n<p>The following command will always return the currently checked out branch name.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>git symbolic-ref <span class=\"nt\">--short<\/span> HEAD\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Injecting this into the suggested <code>git<\/code> command as a subshell gives us this alias that when ran with <code>trackme<\/code> will automatically fix tracking for my branch.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code><span class=\"nb\">alias <\/span><span class=\"nv\">trackme<\/span><span class=\"o\">=<\/span><span class=\"s1\">'git branch --set-upstream-to=origin\/$(git symbolic-ref --short HEAD)'<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  rebasemain\n<\/h2>\n\n<p>I sometimes get a bit lazy at checking main for changes before submitting any prs, so again I made a quick shell alias that will rebase main into my branch before I open a pr.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code><span class=\"nb\">alias <\/span><span class=\"nv\">rebasemain<\/span><span class=\"o\">=<\/span><span class=\"s1\">'git pull origin main --rebase'<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  The Aliases\n<\/h2>\n\n<p>Here are both of the alias's, feel free to steal and modify them into your dotfiles.  If you are uniniatiated a common starting place to put these is either in your <code>~\/.bashrch<\/code> or <code>~\/.zshrc<\/code> depending on your shell of choice.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code><span class=\"nb\">alias <\/span><span class=\"nv\">trackme<\/span><span class=\"o\">=<\/span><span class=\"s1\">'git branch --set-upstream-to=origin\/$(git symbolic-ref --short HEAD)'<\/span>\n<span class=\"nb\">alias <\/span><span class=\"nv\">rebasemain<\/span><span class=\"o\">=<\/span><span class=\"s1\">'git pull origin main --rebase'<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n","category":"git"},{"title":"IPython q to exit","pubDate":"Thu, 14 Jul 2022 20:17:11 +0000","link":"https:\/\/dev.to\/waylonwalker\/ipython-q-to-exit-4k51","guid":"https:\/\/dev.to\/waylonwalker\/ipython-q-to-exit-4k51","description":"<p>So many terminal applications bind <code>q<\/code> to exit, even the python debugger, its muscle memory for me.  But to exit ipython I have to type out <code>exit&lt;ENTER&gt;<\/code>. This is fine, but since q is muscle memory for me I get this error a few times per day.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Traceback (most recent call last) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 &lt;ipython-input-1-2b66fd261ee5&gt;:1 in &lt;module&gt;                                                     \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\nNameError: name 'q' is not defined\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>After digging way too deep into how IPython implements its <code>ExitAutoCall<\/code> I realized there was a very simple solution here.  <code>IPython<\/code> automatically imports all the scripts you put in your profile directory, all I needed was to create <code>~\/.ipython\/profile_default\/startup\/q.py<\/code> with the following.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>q = exit\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>It was that simple.  This is not a game changer by any means, but I will now see one less error in my workflow.  I just press <code>q&lt;Enter&gt;<\/code> and I am out, without error.<\/p>\n\n","category":"python"},{"title":"Copier Slugify | python templating | using cookiecutter","pubDate":"Wed, 29 Jun 2022 14:13:24 +0000","link":"https:\/\/dev.to\/waylonwalker\/copier-slugify-python-templating-using-cookiecutter-n9h","guid":"https:\/\/dev.to\/waylonwalker\/copier-slugify-python-templating-using-cookiecutter-n9h","description":"<p>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 <code>%20<\/code> all over.<\/p>\n\n<h2>\n  \n  \n  Cookiecutter has the solution\n<\/h2>\n\n<blockquote>\n<p>Yes the solution comes from a competing templating framework.<\/p>\n<\/blockquote>\n\n<p>I install copier with pipx, so I need to inject cookiecutter in to my copier environment to use the slugify filter.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>pipx inject copier cookiecutter\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>If you are using a normal virtual environment you can just pip install it.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>pip <span class=\"nb\">install <\/span>copier cookiecutter\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  add the extension to your template\n<\/h2>\n\n<p><em>copier.yml<\/em><\/p>\n\n<p>Now to enable the extension you need to declare it in your <code>copier.yml<\/code> file in your template.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight yaml\"><code><span class=\"na\">_jinja_extensions<\/span><span class=\"pi\">:<\/span>\n    <span class=\"pi\">-<\/span> <span class=\"s\">cookiecutter.extensions.SlugifyExtension<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  Use it | slugify\n<\/h2>\n\n<p><em>use-it<\/em><\/p>\n\n<p>Now to use it, anywhere that you want to slugify a variable, you just pipe it into slugify.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>\u276f tree <span class=\"nb\">.<\/span>\n<span class=\"nb\">.<\/span>\n\u251c\u2500\u2500 copier.yml\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 <span class=\"o\">{{<\/span> site_name|slugify <span class=\"o\">}}<\/span>\n    \u2514\u2500\u2500 markata.toml.jinja\n\n1 directory, 3 files\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Here is a slimmed down version of what the <code>copier.yml<\/code> looks like.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight yaml\"><code><span class=\"na\">site_name<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">type<\/span><span class=\"pi\">:<\/span> <span class=\"s\">str<\/span>\n  <span class=\"na\">help<\/span><span class=\"pi\">:<\/span> <span class=\"s\">What is the name of your site, this shows in seo description and the site title.<\/span>\n  <span class=\"na\">default<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Din Djarin<\/span>\n\n<span class=\"na\">_jinja_extensions<\/span><span class=\"pi\">:<\/span>\n    <span class=\"pi\">-<\/span> <span class=\"s\">cookiecutter.extensions.SlugifyExtension<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  Results\n<\/h2>\n\n<p>Running the template looks a bit like this.<\/p>\n\n<p><a href=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--wbGdywYf--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/screenshots.waylonwalker.com\/copier-cookiecutter-slugify.webp\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--wbGdywYf--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/screenshots.waylonwalker.com\/copier-cookiecutter-slugify.webp\" alt=\"running python copier with the cookiecutter slugify extension\" width=\"800\" height=\"313\"><\/a><\/p>\n\n\n\n\n<h2>\n  \n  \n  straight from their docs\n<\/h2>\n\n<p>The next section is straight from the <a href=\"https:\/\/cookiecutter.readthedocs.io\/en\/latest\/advanced\/template_extensions.html#slugify-extension\">cookiecutter docs<\/a><\/p>\n\n<h3>\n  \n  \n  Slugify extension\n<\/h3>\n\n<p>The <code>cookiecutter.extensions.SlugifyExtension<\/code> extension provides a <code>slugify<\/code> filter in templates that converts string into its dashed (\"slugified\") version:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight jinja\"><code><span class=\"cp\">{%<\/span> <span class=\"s2\">\"It's a random version\"<\/span> <span class=\"o\">| <\/span><span class=\"nf\">slugify<\/span> <span class=\"cp\">%}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Would output:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>it-s-a-random-version\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>It is different from a mere replace of spaces since it also treats some special characters differently such as <code>'<\/code> in the example above. The function accepts all arguments that can be passed to the <code>slugify<\/code> function of<br>\n<code>python-slugify<\/code><em>. For example to change the output from<br>\n<code>it-s-a-random-version<\/code> to <code>it_s_a_random_version<\/code>, the <code>separator<\/code> parameter<br>\nwould be passed: `slugify(separator='<\/em>')`.<\/p>\n\n","category":"python"},{"title":"gh repo create","pubDate":"Fri, 24 Jun 2022 12:25:59 +0000","link":"https:\/\/dev.to\/waylonwalker\/gh-repo-create-58pd","guid":"https:\/\/dev.to\/waylonwalker\/gh-repo-create-58pd","description":"<p>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.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>gh repo create waylonwalker-cli\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p><a href=\"https:\/\/media.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fscreenshots.waylonwalker.com%2Fgh-repo-create.webp\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fscreenshots.waylonwalker.com%2Fgh-repo-create.webp\" alt=\"gh-repo-create\"><\/a><\/p>\n\n<h2>\n  \n  \n  want to see what this repo I created is about?\n<\/h2>\n\n<p>Check out what I created here.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>pipx run waylonwalker\n<\/code><\/pre>\n\n<\/div>\n\n\n\n","category":"git"},{"title":"Textual has devtools","pubDate":"Fri, 17 Jun 2022 21:51:08 +0000","link":"https:\/\/dev.to\/waylonwalker\/textual-has-devtools-j37","guid":"https:\/\/dev.to\/waylonwalker\/textual-has-devtools-j37","description":"<p>Textual has devtools in the upcoming css branch, and its pretty awesome!<\/p>\n\n<h2>\n  \n  \n  It's still early\n<\/h2>\n\n<p>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.<\/p>\n\n<h2>\n  \n  \n  On to the devtools\n<\/h2>\n\n<p>As <a href=\"https:\/\/twitter.com\/willmcgugan\">@willmcgugan<\/a> shows in this tweet it's pretty easy to setup, it requires having two terminals open, or using tmux, and currently you have to use the css branch.<\/p>\n\n<p><iframe class=\"tweet-embed\" id=\"tweet-1531294412696956930-701\" src=\"https:\/\/platform.twitter.com\/embed\/Tweet.html?id=1531294412696956930\">\n<\/iframe>\n\n  \/\/ Detect dark theme\n  var iframe = document.getElementById('tweet-1531294412696956930-701');\n  if (document.body.className.includes('dark-theme')) {\n    iframe.src = \"https:\/\/platform.twitter.com\/embed\/Tweet.html?id=1531294412696956930&amp;theme=dark\"\n  }\n\n\n\n<\/p>\n\n<h2>\n  \n  \n  Why does textual need its own devtools\n<\/h2>\n\n<p>Textual is a tui application framework. Unlike when you are building cli applications, when the tui takes over the terminal in full screen there is no where to print statement debug, and breakpoints don't work.<\/p>\n\n<h2>\n  \n  \n  getting the css branch\n<\/h2>\n\n<p>In the future it will likely be in main and not need this, but for now you need to get the css branch to get devtools.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>git clone https:\/\/github.com\/Textualize\/textual git fetch <span class=\"nt\">--alll<\/span> git checkout css\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  install in a virtual environment\n<\/h2>\n\n<p>Now you can create a virtual environment, feel free to use whatever virtual environment tool you want, venv is built in to most python distributions though, and should just be there.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>python3 <span class=\"nt\">-m<\/span> venv .venv <span class=\"nt\">--prompt<\/span> textual <span class=\"nb\">source<\/span> .venv\/bin\/activate pip <span class=\"nb\">install<\/span> <span class=\"nb\">.<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  Now that we have textual installed\n<\/h2>\n\n<p>Once textual is installed you can open up the devtools by running textual console.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>textual console\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p><a href=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--TnBfpMWR--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/screenshots.waylonwalker.com\/textual-console.webp\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--TnBfpMWR--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/screenshots.waylonwalker.com\/textual-console.webp\" alt=\"textual-console\" width=\"800\" height=\"195\"><\/a><\/p>\n\n","category":"python"},{"title":"The one pip config you need to have","pubDate":"Wed, 01 Jun 2022 19:55:07 +0000","link":"https:\/\/dev.to\/waylonwalker\/pip-require-virtualenv-43db","guid":"https:\/\/dev.to\/waylonwalker\/pip-require-virtualenv-43db","description":"<p>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.<\/p>\n\n<h2>\n  \n  \n  require-virtualenv\n<\/h2>\n\n<p>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 <code>require-virtualenv<\/code>.  This will stop pip from installing any packages if you have not activated a virtualenv.<\/p>\n\n<h2>\n  \n  \n  why\n<\/h2>\n\n<p>python packages often require many different dependencies, sometimes packages are up to date and sometimes they require different versions of dependencies. If you install everything in one environment its easy to end up with version conflict issues that are really hard to resolve, especially since your system environment cannot easily be restarted.<\/p>\n\n<h2>\n  \n  \n  PIPX my one exception\n<\/h2>\n\n<p>My one exception that I put in my system level packages is <code>pipx<\/code>.  <code>pipx<\/code> is very handy as it manages virtual environments for you and is intended for command line utilities that would end up in your system env or require you to manually manage virtual environments without it.<\/p>\n\n<h2>\n  \n  \n  pip config\n<\/h2>\n\n<p>Your pip config might be found in either <code>~\/.pip\/pip.conf<\/code> or<br>\n<code>~\/.config\/pip\/pip.conf<\/code>.  You can either use the <code>pip config set<\/code> command or<br>\nedit one of these files manually.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>pip config <span class=\"nb\">set <\/span>global.require-virtualenv True\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Now you sould see this in your <code>~\/.config\/pip\/pip.conf<\/code><br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight toml\"><code><span class=\"nn\">[global]<\/span> <span class=\"py\">require-virtualenv<\/span> <span class=\"p\">=<\/span> <span class=\"err\">True<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  pip config debug\n<\/h2>\n\n<p>If you want to know where pip is looking for configuration on your system, and what files are setting a certain config you can use <code>pip config debug<\/code> to find it.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>\u276f pip config debug\n\nenv_var: <span class=\"nb\">env<\/span>: global:\n  \/etc\/xdg\/xdg-awesome\/pip\/pip.conf, exists: False\n  \/etc\/xdg\/pip\/pip.conf, exists: False\n  \/etc\/pip.conf, exists: False\nsite:\n  \/home\/waylon\/git\/waylonwalker.com\/.venv\/pip.conf, exists: False\nuser:\n  \/home\/waylon\/.pip\/pip.conf, exists: False\n  \/home\/waylon\/.config\/pip\/pip.conf, exists: True\n    global.require-virtualenv: True\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  saved my bacon\n<\/h2>\n\n<p>This setting recently saved me when I modified my <code>.envrc<\/code> file my virtual environment deactivated, so when I went to pip install something it gave me an error that it was not active.  Situations like this are an easy way to pollute your system with packages that it does not need installed.<\/p>\n\n<p><a href=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--GW3DM0Nv--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/screenshots.waylonwalker.com\/pip-require-virtualenv-direnv-error.webp\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--GW3DM0Nv--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800\/https:\/\/screenshots.waylonwalker.com\/pip-require-virtualenv-direnv-error.webp\" alt=\"pip-require-virtualenv-direnv-error\" width=\"800\" height=\"129\"><\/a><\/p>\n\n<h2>\n  \n  \n  TLDR\n<\/h2>\n\n<p>Run this at your command line to avoid polluting your system environment by mistake before running any pip command.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>pip config <span class=\"nb\">set <\/span>global.require-virtualenv True\n<\/code><\/pre>\n\n<\/div>\n\n\n\n","category":"python"},{"title":"pyenv no module named '_sqlite3'","pubDate":"Tue, 31 May 2022 19:58:53 +0000","link":"https:\/\/dev.to\/waylonwalker\/pyenv-no-module-named-sqlite3-3ea2","guid":"https:\/\/dev.to\/waylonwalker\/pyenv-no-module-named-sqlite3-3ea2","description":"<p>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.<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\n\nImportError: No module named '_sqlite3\n\n\n<\/code><\/pre>\n\n<\/div>\n\n<p>I talked about why and how to use pyenv along with my first impressions in <a href=\"https:\/\/dev.to\/til\/pyenv-first-impressions\">this post<\/a><\/p>\n\n<h2>\n  \n  \n  pyenv\/issues\/678\n<\/h2>\n\n<p>According to <a href=\"https:\/\/github.com\/pyenv\/pyenv\/issues\/678\" rel=\"noopener noreferrer\">#678<\/a> I need to install <code>libsqlite3-dev<\/code> on ubuntu to resolve this issue.<\/p>\n\n<h2>\n  \n  \n  install libsqlite3-dev\n<\/h2>\n\n<p><code>libsqlite3-dev<\/code> can be installed using apt<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>\n\n<span class=\"nb\">sudo <\/span>apt <span class=\"nb\">install <\/span>libsqlite3-dev\n\n\n<\/code><\/pre>\n\n<\/div>\n<h2>\n  \n  \n  But wait....\n<\/h2>\n\n<p>When I make a fresh env and install ipython I still get the same error and I am still not able to use ipython with pyenv.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight python\"><code>\n\n<span class=\"nb\">ImportError<\/span><span class=\"p\">:<\/span> <span class=\"n\">No<\/span> <span class=\"n\">module<\/span> <span class=\"n\">named<\/span> <span class=\"sh\">'<\/span><span class=\"s\">_sqlite3\n\n\n<\/span><\/code><\/pre>\n\n<\/div>\n<h2>\n  \n  \n  re-install python\n<\/h2>\n\n<p>After having this issue for awhile an coming back to <a href=\"https:\/\/github.com\/pyenv\/pyenv\/issues\/678\" rel=\"noopener noreferrer\">#678<\/a> several times I realized that<br>\n<code>libsqlite3-dev<\/code> needs to be installed while during install.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>\n\npyenv <span class=\"nb\">install <\/span>3.8.13\n\n\n<\/code><\/pre>\n\n<\/div>\n\n<p>I think I had tried this several times, but was missing the <code>-y<\/code> option each time.  You gotta read errors like this, I am really good at glossing over them.<\/p>\n\n<p><a href=\"https:\/\/media.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fscreenshots.waylonwalker.com%2Fpyenv-install-exists.webp\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fscreenshots.waylonwalker.com%2Fpyenv-install-exists.webp\" alt=\"pyenv-install-exists\"><\/a><\/p>\n\n<h2>\n  \n  \n  Let's never have this issue again.\n<\/h2>\n\n<p>When you spend months living with little errors like this and finally fix it, its good to make sure that it never happens again.  Whenever I start a new ubuntu machine I run an ansible playbook that does all the setup for me.  I added <code>libsqlite3-dev<\/code> to my core install in <a href=\"https:\/\/github.com\/WaylonWalker\/devtainer\/commit\/64c85ca1b38eefe95dfc8723c1e83e8e334cf4dc\" rel=\"noopener noreferrer\">64c85ca<\/a> now it will be on all of my machines and not break again.<\/p>\n\n","category":"python"},{"title":"git merge ours","pubDate":"Wed, 25 May 2022 14:19:11 +0000","link":"https:\/\/dev.to\/waylonwalker\/git-merge-ours-k82","guid":"https:\/\/dev.to\/waylonwalker\/git-merge-ours-k82","description":"<p>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.<\/p>\n\n<h2>\n  \n  \n  update main\n<\/h2>\n\n<p>The first step is to make sure your local copy of the branch you are moving into is up to date.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>git checkout main git pull\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  update your feature branch\n<\/h2>\n\n<p>It's also worth updating your feature branch before doing the merge. Maybe you have teammates that have updated the repo, or you popped in a quick change from the web ui. It's simple and worth checking.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>git checkout my-feature git pull\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  start the merge\n<\/h2>\n\n<p>Merge the changes from main into <code>my-feature<\/code> branch.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>git merge main\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Now is where the merge conflict may have started. If you are completely sure that your copy is correct you can <code>--ours<\/code>, if you are completely sure that<br>\n<code>main<\/code> is correct, you can <code>--theirs<\/code>.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>git checkout --ours .\ngit merge --continue\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>This will pop open your configured <code>git.core.editor<\/code> or <code>$EDTIOR<\/code>. If you have not configured your editor, it will default to vim.  Close vim with <code>&lt;escape&gt;:x<\/code>, accepting the merge message.<\/p>\n\n<p>Now push your changes that do not clash with main and finish your pr.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>git push\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>If you liked this one checkout <a href=\"https:\/\/waylonwalker.com\/\/til\/git-find-deleted-files\">git-find-deleted-files<\/a> to find all the files you have deleted, but still exist somewhere in git.<\/p>\n\n<h2>\n  \n  \n  Discuss\n<\/h2>\n\n<p>Do you use --our\/--theirs?  With merge or maybe even rebase?<\/p>\n\n","category":"git"},{"title":"What's your favorite piece of software that you built for yourself?","pubDate":"Sun, 22 May 2022 00:34:57 +0000","link":"https:\/\/dev.to\/waylonwalker\/whats-your-favorite-piece-of-software-that-you-built-for-yourself-2la0","guid":"https:\/\/dev.to\/waylonwalker\/whats-your-favorite-piece-of-software-that-you-built-for-yourself-2la0","description":{},"category":"discuss"},{"title":"Bash function to edit scripts faster","pubDate":"Wed, 11 May 2022 02:25:02 +0000","link":"https:\/\/dev.to\/waylonwalker\/bash-function-to-edit-scripts-faster-1kl5","guid":"https:\/\/dev.to\/waylonwalker\/bash-function-to-edit-scripts-faster-1kl5","description":"<p>I am often editing my own scripts as I develop them. I want to make a better workflow for working with scripts like this.<\/p>\n\n<h2>\n  \n  \n  Currently\n<\/h2>\n\n<p>Currently I am combining <code>nvim<\/code> with a <code>which<\/code> subshell to etit these files like this.<\/p>\n\n<blockquote>\n<p>for now lets use my todo command as an example<br>\n<\/p>\n<\/blockquote>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>nvim <span class=\"sb\">`<\/span>which todo<span class=\"sb\">`<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  First pass\n<\/h2>\n\n<p>On first pass I made a bash function to do exactly what I have been doing.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>ewhich <span class=\"o\">()<\/span> <span class=\"o\">{<\/span><span class=\"nv\">$EDITOR<\/span> <span class=\"sb\">`<\/span>which <span class=\"s2\">\"<\/span><span class=\"nv\">$1<\/span><span class=\"s2\">\"<\/span><span class=\"sb\">`<\/span><span class=\"o\">}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>The <code>$1<\/code> will pass the first input to the which subshell.  Now we can edit our todo script like this.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>ewich todo\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<blockquote>\n<p>Note, I use bash functions instead of aliases for things that require input.<\/p>\n<\/blockquote>\n\n<h2>\n  \n  \n  Final State\n<\/h2>\n\n<p>This works fine for commands that are files, but not aliases or shell functions.  Next I jumped to looking at the output of <code>command -V $1<\/code>.<\/p>\n\n<ul>\n<li>if the command is not found, search for a file<\/li>\n<li>if its a builtin, exit<\/li>\n<li>if its an alias, open my <code>~\/.alias file to that line<\/code>\n<\/li>\n<li>if its a function, open my <code>~\/.alias file to that line<\/code>\n<\/li>\n<\/ul>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>ewhich <span class=\"o\">()<\/span> <span class=\"o\">{<\/span> <span class=\"k\">case<\/span> <span class=\"sb\">`<\/span><span class=\"nb\">command<\/span> <span class=\"nt\">-V<\/span> <span class=\"nv\">$1<\/span><span class=\"sb\">`<\/span> <span class=\"k\">in<\/span>\n    <span class=\"s2\">\"<\/span><span class=\"nv\">$1<\/span><span class=\"s2\"> not found\"<\/span><span class=\"p\">)<\/span>\n        <span class=\"nv\">FILE<\/span><span class=\"o\">=<\/span><span class=\"sb\">`<\/span>fzf <span class=\"nt\">--prompt<\/span> <span class=\"s2\">\"<\/span><span class=\"nv\">$1<\/span><span class=\"s2\"> not found searching ...\"<\/span> <span class=\"nt\">--query<\/span> <span class=\"nv\">$1<\/span><span class=\"sb\">`<\/span>\n        <span class=\"o\">[<\/span> <span class=\"nt\">-z<\/span> <span class=\"s2\">\"<\/span><span class=\"nv\">$FILE<\/span><span class=\"s2\">\"<\/span> <span class=\"o\">]<\/span> <span class=\"o\">&amp;&amp;<\/span> <span class=\"nb\">echo<\/span> <span class=\"s2\">\"closing\"<\/span> <span class=\"o\">||<\/span> <span class=\"nv\">$EDITOR<\/span> <span class=\"nv\">$FILE<\/span><span class=\"p\">;;<\/span>\n    <span class=\"k\">*<\/span><span class=\"s2\">\"is a shell builtin\"<\/span><span class=\"k\">*<\/span><span class=\"p\">)<\/span>\n        <span class=\"nb\">echo<\/span> <span class=\"s2\">\"<\/span><span class=\"nv\">$1<\/span><span class=\"s2\"> is a builtin\"<\/span><span class=\"p\">;;<\/span>\n    <span class=\"k\">*<\/span><span class=\"s2\">\"is an alias\"<\/span><span class=\"k\">*<\/span><span class=\"p\">)<\/span>\n        <span class=\"nv\">$EDITOR<\/span> ~\/.alias +\/alias<span class=\"se\">\\ <\/span><span class=\"nv\">$1<\/span><span class=\"p\">;;<\/span>\n    <span class=\"k\">*<\/span><span class=\"s2\">\"is a shell function\"<\/span><span class=\"k\">*<\/span><span class=\"p\">)<\/span>\n        <span class=\"nv\">$EDITOR<\/span> ~\/.alias +\/^<span class=\"nv\">$1<\/span><span class=\"p\">;;<\/span>\n    <span class=\"k\">*<\/span><span class=\"p\">)<\/span>\n        <span class=\"nv\">$EDITOR<\/span> <span class=\"sb\">`<\/span>which <span class=\"s2\">\"<\/span><span class=\"nv\">$1<\/span><span class=\"s2\">\"<\/span><span class=\"sb\">`<\/span><span class=\"p\">;;<\/span>\n<span class=\"k\">esac<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  a bit more ergo, and less readable\n<\/h2>\n\n<p>To make it easier to type, at the sacrifice of readability for anyone watching I added a single character <code>e<\/code> alias to ewhich.  So when I want to edit anything I just use <code>e<\/code>.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code><span class=\"nb\">alias <\/span><span class=\"nv\">e<\/span><span class=\"o\">=<\/span>ewhich\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<h2>\n  \n  \n  Results\n<\/h2>\n\n<p>Here is a quick screencast of how it works.<\/p>\n\n\n     \n     Sorry, your browser doesn't support embedded videos.\n\n\n","category":"bash"},{"title":"List all git commits with GitPython","pubDate":"Mon, 09 May 2022 21:08:10 +0000","link":"https:\/\/dev.to\/waylonwalker\/list-all-git-commits-with-gitpython-4ek2","guid":"https:\/\/dev.to\/waylonwalker\/list-all-git-commits-with-gitpython-4ek2","description":"<p>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.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight python\"><code><span class=\"kn\">from<\/span> <span class=\"n\">git<\/span> <span class=\"kn\">import<\/span> <span class=\"n\">Repo<\/span>\n\n<span class=\"n\">repo<\/span> <span class=\"o\">=<\/span> <span class=\"nc\">Repo<\/span><span class=\"p\">(<\/span><span class=\"sh\">'<\/span><span class=\"s\">.<\/span><span class=\"sh\">'<\/span><span class=\"p\">)<\/span> <span class=\"n\">commits<\/span> <span class=\"o\">=<\/span> <span class=\"n\">repo<\/span><span class=\"p\">.<\/span><span class=\"nf\">iter_commits<\/span><span class=\"p\">()<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>This returns a generator, if you are iterating over them this is likely what you want.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight python\"><code><span class=\"n\">commits<\/span>\n<span class=\"c1\"># &lt;generator object Commit._iter_from_process_or_stream at 0x7f3307584510&gt;\n<\/span><\/code><\/pre>\n\n<\/div>\n\n\n\n<p>The generator will return <code>git.Commit<\/code> objects with lots of information about each commit such as <code>hexsha<\/code>, <code>author<\/code>, <code>commited_datetime<\/code>, <code>gpgsig<\/code>, and<br>\n<code>message<\/code>.<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight python\"><code><span class=\"nf\">next<\/span><span class=\"p\">(<\/span><span class=\"n\">commits<\/span><span class=\"p\">)<\/span>\n<span class=\"c1\"># &lt;git.Commit \"d125317892d0fab10a36638a2d23356ba25c5621\"&gt;\n<\/span><\/code><\/pre>\n\n<\/div>\n\n\n\n","category":["python","git"]}]}}