<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Waylon Walker]]></title><description><![CDATA[Waylon Walker]]></description><link>https://h.waylonwalker.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1597411536997/QLoOvGRa5.png</url><title>Waylon Walker</title><link>https://h.waylonwalker.com</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 09:54:07 GMT</lastBuildDate><atom:link href="https://h.waylonwalker.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Nvim Remaps Like a Boss]]></title><description><![CDATA[I've slowly adding more and more lua functions into my neovim configuration, and recently I noticed a pattern for a class of functions that reach out to…]]></description><link>https://h.waylonwalker.com/nvim-remaps-like-a-boss</link><guid isPermaLink="true">https://h.waylonwalker.com/nvim-remaps-like-a-boss</guid><category><![CDATA[vim]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Tue, 05 Oct 2021 13:38:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1633441074794/i2aDdjdte.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I've slowly adding more and more lua functions into my neovim configuration,
and recently I noticed a pattern for a class of functions that reach out to run
shell commands that can be abstracted away.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/8m5ipBuopPU">https://youtu.be/8m5ipBuopPU</a></div>
<h2 id="telegraphnvim">Telegraph.nvim</h2>
<p>Check out the project <a target="_blank" href="https://github.com/WaylonWalker/Telegraph.nvim">readme</a>
for the most up to date details on the plugin itself.</p>
<h2 id="motivation">Motivation</h2>
<p>I want a simple way to make remaps into shell commands that can open new tmux
windows, popups, or just run a command with context from the editor.</p>
<p>For example I want to make remaps to do things like open the current file in lookatme.</p>
<pre><code class="lang-vim"># vim :terminal
nnoremap &lt;leader&gt;s &lt;cmd&gt;Telegraph pipx run lookatme {filepath} --live-reload --style gruvbox-dark&lt;cmd&gt;

# tmux session
nnoremap &lt;leader&gt;&lt;leader&gt;s &lt;cmd&gt;lua require'telegraph'.telegraph({cmd='pipx run lookatme {filepath} --live-reload --style gruvbox-dark', how='tmux'})&lt;CR&gt;

# tmux popup
nnoremap &lt;leader&gt;&lt;leader&gt;S &lt;cmd&gt;lua require'telegraph'.telegraph({cmd='pipx run lookatme {filepath} --live-reload --style gruvbox-dark', how='tmux_popup'})&lt;CR&gt;
</code></pre>
<p>The main goal here is that remaps become one liners that can just be put
directly in my <code>init.vim</code> without creating a whole new lua module for each
shell command I want to bind.</p>
<h2 id="how">how</h2>
<p><code>telegraph</code> takes in a <code>how</code> argument to determine where to tun the command.j</p>
<ul>
<li><code>term</code>(default) runs command in the built in terminal</li>
<li><code>tmux</code> runs command in a new tmux session and joins it.</li>
<li><code>tmux_popup</code> runs command in a tmux popup window.</li>
<li><code>tmux_popup_session</code> runs command in a tmux session and displays it in a popup</li>
<li><code>subprocess</code> runs command in a subprocess</li>
</ul>
<h2 id="format-strings">Format strings</h2>
<p>The current set of format strings that can be used with telegraph.  Placing
these in braces <code>{}</code> within your command will get rendered into something with
context from the editor.</p>
<ul>
<li><code>cword</code> - the current word under the cursor</li>
<li><code>cWORD</code> - the current BIG Word under the cursor</li>
<li><code>cline</code> - the current line under the cursor</li>
<li><code>filepath</code> - the filepath of the current file</li>
<li><code>filename</code> - the filename of the current file</li>
<li><code>parent</code> - the parent directory of the current file</li>
<li><code>current_session_name</code> - name of the current tmux session</li>
<li><code>cwd</code> - the current working directory</li>
</ul>
<h2 id="give-it-a">Give it a ⭐</h2>
<p>Check out the <a target="_blank" href="https://github.com/WaylonWalker/Telegraph.nvim">repo</a> and give
it a star if its something that interests you.</p>
]]></content:encoded></item><item><title><![CDATA[waylonwalker.com/kedro-silence]]></title><description><![CDATA[Kedro can have a chatty logger. While this is super nice in production so see everything that happened during a pipeline run. This can be troublesome while]]></description><link>https://h.waylonwalker.com/waylonwalkercomkedro-silence</link><guid isPermaLink="true">https://h.waylonwalker.com/waylonwalkercomkedro-silence</guid><category><![CDATA[Python]]></category><category><![CDATA[Data Science]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Fri, 21 May 2021 14:12:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1621606289789/nQCRPv84z.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Kedro can have a chatty logger.  While this is super nice in production so see everything that happened during a pipeline run. This can be troublesome while trying to implement a cli extension with clean output.</p>
<h2 id="silence-a-python-log">Silence a Python log</h2>
<p>First, how does one silence a python log?  Python loggers can be retrieved by the <code>logging</code> module's <code>getLogger</code> function. Then their log level can be changed.  Much of kedro's chattiness comes from INFO level logs.  I don't want to hear about anything for my current use case unless it's essential, i.e., a failure.  In this case, I set the log levels to ERROR as most errors should stop execution anyways.</p>
<h3 id="python-logging-levels">python logging levels</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Level</td><td>Numeric value</td></tr>
</thead>
<tbody>
<tr>
<td>CRITICAL</td><td>50</td></tr>
<tr>
<td>ERROR</td><td>40</td></tr>
<tr>
<td>WARNING</td><td>30</td></tr>
<tr>
<td>INFO</td><td>20</td></tr>
<tr>
<td>DEBUG</td><td>10</td></tr>
<tr>
<td>NOTSET</td><td>0</td></tr>
</tbody>
</table>
</div><h2 id="get-or-create-a-logger">Get or Create a logger</h2>
<p>Getting a python logger is straightforward if we know the name of the logger.  The following block will grab the logger object for the logger currently registered under the name passed in.</p>
<pre><code class="lang-python">logger = logging.getLogger(<span class="hljs-string">'kedro'</span>)
</code></pre>
<blockquote>
<p>🔥 If a logger doesn't exist under the passed in name, it will create one for you.</p>
</blockquote>
<h2 id="set-level">Set Level</h2>
<p>Once we get the logger, we need to silence it by setting the log level.  Typically it's not appropriate to completely turn off loggers as you would still want information in the case of a complete failure.  If you are building a cli such as one that prints out the pipelines to the console, you may not want to see logs that happen during regular operation as this would make it more challenging to integrate with other shell applications.</p>
<pre><code class="lang-python">logger.setLevel(logging.ERROR)
</code></pre>
<blockquote>
<p>⚠ Be sure to leave some logging left. After the point of error, you are not going to get a clean output anyways.  So let the user see what happened.</p>
</blockquote>
<p>It is possible to set the log level before kedro even registers the logger, if there is no logger currently setup under getLogger, it will create one.</p>
<h2 id="silent-all-kedro-loggers">Silent all kedro loggers</h2>
<p>As of <code>kedro==0.17.3</code> this function covers every logger issued by kedro.  I generated this list of <code>known_kedro_loggers</code> by looking through their codebase and filling in a few others I found by running it.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">silent_loggers</span>() -&gt; <span class="hljs-keyword">None</span>:</span>
    <span class="hljs-string">"""All logs need to be silent in order for a clean kedro diff output."""</span>
    known_kedro_loggers = [
        <span class="hljs-string">"ProfileTimeTransformer"</span>,
        <span class="hljs-string">"hooks_handler"</span>,
        <span class="hljs-string">"kedro.__init__"</span>,
        <span class="hljs-string">"kedro"</span>,
        <span class="hljs-string">"kedro.config"</span>,
        <span class="hljs-string">"kedro.config.config"</span>,
        <span class="hljs-string">"kedro.extras.decorators.memory_profiler"</span>,
        <span class="hljs-string">"kedro.framework.cli"</span>,
        <span class="hljs-string">"kedro.framework.session.session"</span>,
        <span class="hljs-string">"kedro.framework.session.store"</span>,
        <span class="hljs-string">"kedro.framework.session"</span>,
        <span class="hljs-string">"kedro.io.cached_dataset"</span>,
        <span class="hljs-string">"kedro.io.data_catalog"</span>,
        <span class="hljs-string">"kedro.io"</span>,
        <span class="hljs-string">"kedro.journal"</span>,
        <span class="hljs-string">"kedro.pipeline"</span>,
        <span class="hljs-string">"kedro.pipeline.decorators"</span>,
        <span class="hljs-string">"kedro.pipeline.node"</span>,
        <span class="hljs-string">"kedro.pipeline.pipeline"</span>,
        <span class="hljs-string">"kedro.runner"</span>,
        <span class="hljs-string">"kedro.runner.runner"</span>,
        <span class="hljs-string">"kedro.versioning.journal"</span>,
        <span class="hljs-string">"py4"</span>,
    ]
    <span class="hljs-keyword">for</span> logger <span class="hljs-keyword">in</span> [
        *known_kedro_loggers,
        *list(logging.root.manager.loggerDict.keys()),  <span class="hljs-comment"># type: ignore</span>
    ]:
        logging.getLogger(logger).setLevel(logging.ERROR)
</code></pre>
<p>This function comes right from a plugin I am currently working on <a target="_blank" href="https://github.com/WaylonWalker/kedro-diff">kedro-diff</a>.  Check it out, give it a star, and watch it for release.</p>
<p>https://waylonwalker.com/what-is-kedro/</p>
<blockquote>
<p>Not familiar with kedro, check out this article to see what it's all about.</p>
</blockquote>
<h2 id="master-the-log">Master the log</h2>
<p>Python logs can seem super confusing at first, understanding how to get a logger and set its level are the first steps to mastering it.</p>
<hr />
<h2 id="check-out-these-related-posts">Check Out These Related Posts</h2>
<p>https://waylonwalker.com/if_name_main/</p>
<p>https://waylonwalker.com/install-micromamba/</p>
<p>https://waylonwalker.com/kedro172_replit/</p>
]]></content:encoded></item><item><title><![CDATA[How I navigate tmux in 2021]]></title><description><![CDATA[In 2021 I changed the way I navigate between tmux sessions. Now I can create, kill, switch with ease, and generally keep work separated into logical groups]]></description><link>https://h.waylonwalker.com/tmux-nav-2021</link><guid isPermaLink="true">https://h.waylonwalker.com/tmux-nav-2021</guid><category><![CDATA[cli]]></category><category><![CDATA[Linux]]></category><category><![CDATA[Bash]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Wed, 12 May 2021 14:04:50 GMT</pubDate><content:encoded><![CDATA[<p>In 2021 I changed the way I navigate between tmux sessions big time.  Now I can create, kill, switch with ease, and generally keep work separated into logical groups.</p>
<blockquote>
<p>🔗 Check out the post on https://waylonwalker.com/tmux-nav-2021/ to speed up or slow down the recordings.</p>
</blockquote>
<h2 id="chris-toomeyshttpstwittercomchristoomey-tmux-course"><a target="_blank" href="https://twitter.com/christoomey">Chris Toomey's</a> Tmux Course</h2>
<p>I took Chris's <a target="_blank" href="https://thoughtbot.com/upcase/tmux">tmux course</a> in December 2020 and it was fantastic.  Even as a seasoned tmux user, I learned quite a bit.  Before the course, I was proficient in navigating within each of my tmux sessions but rarely started more than one session.  A few months later, I have adopted a lot of what I learned from Chris and made it my own.</p>
<p>I am now keeping projects to their own session and can move between them fluidly with just a few keystrokes.  For high-traffic projects, I have them bound to a single keystroke for instant switching.  This change has been a game-changer from the mess of windows I used to have and the nightmare it was to find work I was doing and end up duplicating project work in two separate windows.</p>
<blockquote>
<p>📝 <strong>NOTE:</strong> Some of my config comes straight from the course, and some of it has been extended to my liking.</p>
</blockquote>
<p>Let's take a quick look at how I am navigating through tmux on a day-to-day basis.</p>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021.gif" alt="overview of how I switch and manage tmux sessions" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.



<blockquote>
<p>👆 Overview of how I navigate tmux</p>
</blockquote>
<h2 id="tmux-ls">tmux ls</h2>
<p>Throughout this article, I have several recordings showing how I use manage sessions with my keybindings.  I will often run a <code>tmux ls</code> command to highlight running sessions at various points to help guide the viewer.</p>
<h2 id="ta">ta</h2>
<p><em>my attach/session switch script</em></p>
<p>At the heart of my tmux navigation is a highly customized version of Chris's tat script that I renamed <code>ta</code>.  Many folks add this to their bashrc <code>alias ta=tmux attach</code>.  Simply calling ta will do the same thing as shown below.  If you're in a tmux session, it does nothing, and if you're not in one, it will attach you to the first one.</p>
<blockquote>
<p>get the full <a target="_blank" href="https://github.com/WaylonWalker/devtainer/blob/main/bin/ta">script</a> from GitHub.</p>
</blockquote>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-ta.gif" alt="overview of how I switch and manage tmux sessions" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.



<blockquote>
<p>👆 attaching to a session by default</p>
</blockquote>
<p>In my <code>~/.bashrc</code> or <code>~/.zshrc</code> I add the <code>ta</code> command to keep myself in a tmux session at all times.  Whenever I open my terminal, I am automatically dropped into a tmux session, but if I am opening a split while in tmux it's smart enough to know not to nest tmux sessions.</p>
<pre><code class="lang-bash">ta
</code></pre>
<p>Another article can dive into my <code>ta</code> command. This one is more about the methodology, workflow, and keybindings to get me there.  It's available in my <a target="_blank" href="https://github.com/WaylonWalker/devtainer/blob/main/bin/ta">devtainer repo</a>.</p>
<h3 id="but-theres-more">but there's more</h3>
<p><em>gettin fuzzy</em></p>
<p>Give it a directory, and a <code>fzy</code> dropdown will let you choose a subdirectory to start your session in, and name the session after that directory.</p>
<pre><code class="lang-bash">ta ~/git
</code></pre>
<blockquote>
<p>🔥 Bonus, use direnv to automatically set settings, echo your git status, activate your environment or whatever else you need.</p>
</blockquote>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-ta-directory.gif" alt="overview of how I switch and manage tmux sessions" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.



<blockquote>
<p>👆 give it a directory, it will ask for input to which project and start a new named session in that directory.</p>
</blockquote>
<p>Note that starting from outside currently does not start in a split layout like it does when starting from within tmux.  I am still playing with this, but generally, I want my terminal session to be plain when I first start my terminal. I usually am starting work after the first default session.</p>
<blockquote>
<p>🤔 I still use both fzy and fzf. It probably doesn't make sense to use both, but I am currently giving fzy a try.</p>
</blockquote>
<h2 id="prefixw">prefix+w</h2>
<p><em>tmux choose-tree</em></p>
<p>By default, tmux comes with a <code>tmux choose-tree</code> command bound to <code>prefix+w</code>, which opens in full screen.  The upper section of the screen will show every window opened.  While selected, you can show the splits in each window by hitting l, or fold it with h. You can search for a session name by hitting /.</p>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-prefix+w.gif" alt="jump to existing sessions with prefix+w" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<pre><code class="lang-bash"><span class="hljs-comment"># ~/.tmux.conf</span>

<span class="hljs-comment"># expanded to show all splits</span>
<span class="hljs-built_in">bind</span> s choose-tree
<span class="hljs-comment"># simpler window to show only sessions</span>
<span class="hljs-built_in">bind</span> S choose-session
</code></pre>
<h3 id="keybindings-in-choose-treechoose-session">Keybindings in choose-tree/choose-session</h3>
<p>The default keybindings of the tmux <code>choose-tree</code> and <code>choose-session</code> that I use are listed below.  J/K are very intuitive, but I just learned about h,l,/.  When I do use one of these, the / (search) can be super helpful to find sessions/windows faster.</p>
<table>
<thead>
<tr>
<td>action</td><td>key</td></tr>
</thead>
<tbody>
<tr>
<td>fold</td><td>h</td></tr>
<tr>
<td>unfold</td><td>l</td></tr>
<tr>
<td>up</td><td>k</td></tr>
<tr>
<td>down</td><td>j</td></tr>
<tr>
<td>search</td><td>/</td></tr>
</tbody>
</table>
<h2 id="prefixc-w-prefixc-g">prefix+c-w prefix+c-g</h2>
<p><em>open a project</em></p>
<p>I have set up to make it easy to open my non-work projects <em>(in my ~/git directory)</em> and my work projects <em>(in my ~/work directory)</em>.  I bound <code>prefix+c-g</code> and <code>prefix+c-w</code> to open a new session in their respective directories.  I like mapping common prefix commands with control to keep my pinky mashed on that control key.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># ~/.tmux.conf</span>

<span class="hljs-built_in">bind</span> C-w new-window -n <span class="hljs-string">"work-session-picker"</span> <span class="hljs-string">"ta ~/work"</span>
<span class="hljs-built_in">bind</span> C-g new-window -n <span class="hljs-string">"git-session-picker"</span> <span class="hljs-string">"ta ~/git"</span>
</code></pre>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-prefix+c-g.gif" alt="create a new session from my ~/git directory" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<h2 id="prefixc-j">prefix+c-j</h2>
<p><em>jump to session</em></p>
<p>Now that I have <code>ta</code> rocking with a good create or attach setup, I am rarely toggling through a list of running sessions, but I am doing it with <code>prefix+c-j</code> when I do it. Keeping my finger on control and pressing <code>&lt;space&gt;+j</code>.  This keybinding uses fzf to fuzzy match to an existing session and attach.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">bind</span> C-j new-window -n <span class="hljs-string">"session-switcher"</span> <span class="hljs-string">"tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^<span class="hljs-subst">$(tmux display-message -p '#S')</span>\$\" | fzf --reverse | xargs tmux switch-client -t"</span>
</code></pre>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-prefix+c-j.gif" alt="jump to existing sessions with prefix+c-j" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<h2 id="m-n-m-p">M-N M-P</h2>
<p><em>next/prev</em></p>
<p>Next and Previous sessions.  This is super handy when working with under 3 sessions to be able to cycle through sessions holding <code>shift+alt</code> and pressing <code>n</code> or <code>p</code>.</p>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-m-N-M-P.gif" alt="jump to next or previous sessions with m-N or m-P" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<h2 id="tkill">tkill</h2>
<p><em>time to clean up</em></p>
<p>It's easy to get a long crufty list of sessions running throughout the day.  Typically this is not too bad on system resources compared to running vscode in every working project, but it does make it more challenging to manage and wade through the sessions list.  I use a handy shell alias that's been in my zshrc for quite some time.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">alias</span> tkill=<span class="hljs-string">"for s in \$(tmux list-sessions | awk '{print \$1}' | rg ':' -r '' | fzy); do tmux kill-session -t \$s; done;"</span>
</code></pre>
<p>I don't have this one set up with a nice hotkey, but it works for my fingers.  I often pop open a lower split(<code>M-s</code>), run <code>tkill</code>, and close (<code>M-x</code>).</p>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-tkill.gif" alt="create a new session git-diff switch back to original session with prefix+c-g then use tkill to kill the git-diff session" /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<h2 id="last-session">Last Session</h2>
<p><em>back</em></p>
<p>While <code>M-n</code> and <code>M-p</code> work well with a small, focused number of sessions, I often end up with too many sessions open, and it's not efficient to remember a double <code>M-N</code> followed by a triple <code>M-P</code> to get back and forth.  Most often, I want to get between two sessions quickly, no matter what the order is.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">bind</span> -n M-B switch-client -l
<span class="hljs-built_in">bind</span> -n M-b switch-client -l
</code></pre>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-m-b.gif" alt /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<blockquote>
<p>Once I get two sessions back to back, I can switch between them with insane speed and precision.</p>
</blockquote>
<h2 id="more-precision">More Precision</h2>
<p><em>one keystroke</em></p>
<p>The final layer of precision is for my most current project. I need to get to these with a single keystroke.  These are bound to a set of keybindings that were readily available, just above the home row.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">bind</span> C-t new-session -A -s todo <span class="hljs-string">"cd ~/work/todo &amp;&amp; nvim -O backlog.md doing.md done.md"</span>
<span class="hljs-built_in">bind</span> -n M-i new-session -A -s ww3 <span class="hljs-string">"cd ~/git/ww3/ &amp;&amp; nvim"</span>
<span class="hljs-built_in">bind</span> -n M-o new-session -A -s images_waylonwalker_com <span class="hljs-string">"cd ~/git/images.waylonwalker.com/ &amp;&amp; nvim"</span>
</code></pre>
<p><img src="https://images.waylonwalker.com/tmux-navigation-2021-m-i-m-o.gif" alt /></p>

    
    
    Sorry, your browser doesn't support embedded videos.


<blockquote>
<p>These few directories are always at my fingertips, encouraging me to keep better notes</p>
</blockquote>
<p>And yes, I did steal this last one from <a target="_blank" href="https://twitter.com/ThePrimeagen">Harpoon-man</a> By The Way.</p>
<h2 id="hub-and-spoke">Hub and Spoke</h2>
<p><em>M-i M-b</em></p>
<p>I have really been digging this hub and spoke workflow where I am rocking away on a project hit <code>M-I</code>, take some notes then hit <code>M-b</code> to get back to where I was.</p>
<p><img src="https://images.waylonwalker.com/tmux-nav-hub-spoke.png" alt="hub and spoke" /></p>
<blockquote>
<p>Model of my current workflow</p>
</blockquote>
<h3 id="example-workflow">Example workflow</h3>
<ol>
<li>open tmux session with ta</li>
<li><code>prefix+c-g</code> start work in a project using a fuzzy matcher</li>
<li><code>M-t</code> over to my todo list</li>
<li><code>M-b</code> back to my project</li>
<li><code>M-i</code> to my blog to look up notes/make notes</li>
<li><code>M-b</code> back to my project</li>
<li><code>prefix+c-g</code> start work in another project using a fuzzy matcher</li>
<li><code>M-t</code> over to my todo list</li>
<li><code>M-b</code> back to my project</li>
<li><code>prefix+c-j</code> fuzzy back to the first project</li>
<li><code>M-b</code> back to the second project</li>
</ol>
<hr />
<p>Please let me know your thoughts.  <a target="_blank" href="https://twitter.com/_WaylonWalker">@waylonwalker</a>, this one took me a bit longer to put together with all of the animated gif's, but I think it helps visually show how I navigate tmux every day.</p>
<h3 id="please-give-it-a-share-if-you-liked-it">Please give it a share if you liked it</h3>
<p>If you liked it, give it a share and tag me on <a target="_blank" href="https://twitter.com/_WaylonWalker">twitter</a>.  I don't often ask but this article took a bit more to put together than my normal post.</p>
<hr />
<h2 id="check-out-these-related-posts">Check Out These Related Posts</h2>
<p>https://waylonwalker.com/symlink-gallery/</p>
<p>https://waylonwalker.com/neovim-live-substitution/</p>
<p>https://waylonwalker.com/find-replace/</p>
]]></content:encoded></item><item><title><![CDATA[Stand With Your Team]]></title><description><![CDATA[People who are quick to toss team members under a bus are not well trusted or highly thought of and it will lead to some toxic team dynamics. While…]]></description><link>https://h.waylonwalker.com/stand-with-your-team</link><guid isPermaLink="true">https://h.waylonwalker.com/stand-with-your-team</guid><category><![CDATA[skills]]></category><category><![CDATA[watercooler]]></category><category><![CDATA[General Advice]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Fri, 22 Jan 2021 15:13:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611328370911/ljI95k794.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>People who are quick to toss team members under a bus are not well trusted or highly thought of and it will lead to some toxic team dynamics.</p>
<h2 id="building-steam">Building Steam</h2>
<p>While collaborating on any project there are going to be decisions made that aren't necessarily your favorite, during a summer internship my mentor made some decisions that I was not on board with, but I accepted his wisdom and moved forward with little push back.</p>
<h2 id="full-spead-ahead">Full Spead Ahead</h2>
<p>During a review, leadership showed interest in the option that I wanted to go towards.  I was quick to jump up and say I  told you so right then and there and pitch reasons why my idea was so much better.</p>
<h2 id="the-aftermath">The Aftermath</h2>
<p>I walked out so <strong>proud</strong> that leadership recognized my idea, but I will never forget the look on my teammate's face and what he told me after the meeting.</p>
<blockquote>
<p>"Wow quick to throw me under the bus in front of everyone 😢".   I</p>
</blockquote>
<p>~ my teammate</p>
<h2 id="realizing-what-happened">Realizing what Happened</h2>
<p>It was at this moment that I threw my mentor, a good <strong>friend</strong> in front of a bus that was at full speed.  I will never forget this moment and the importance of being a good trustworthy team player.</p>
<h2 id="speak-your-mind-be-heard-shut-up">Speak your Mind, be heard, shut up</h2>
<p>This day I learned that there is a time to speak your mind.  While that bus is sitting idle it would have hurt no one.</p>
<p>There were times to hear out ideas, and there were times that we need to accept the decisions the team made.  The team that you were a part of and had a chance to steer.</p>
<p>There are times where it's appropriate to sit down and shut up.</p>
<h1 id="your-story">Your Story 👇</h1>
<p>Do you have a story of how not standing with your team caused you pain later on.  I would love to hear and learn from your experience.</p>
]]></content:encoded></item><item><title><![CDATA[Blogging For Me]]></title><description><![CDATA[I create this blog with one person in mind, me. This is not completely selfish, as there are likely many others out there that think similarly to me…]]></description><link>https://h.waylonwalker.com/blogging-for-me</link><guid isPermaLink="true">https://h.waylonwalker.com/blogging-for-me</guid><category><![CDATA[blog]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Fri, 22 Jan 2021 01:19:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611278349238/1yiLjgb6V.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I create this blog with one person in mind, me.</p>
<h2 id="there-are-others-like-me">There are others like me</h2>
<p>This is not completely selfish, as there are likely many others out there that think similarly to me.  Everyone comes from different backgrounds and varying levels of experience.  In no way do you need to be an expert to create content others will benefit from.</p>
<h2 id="accurate">Accurate</h2>
<p>I am as accurate as possible.  I don't know everything, and If I waited for that to happen I would never post, or write at such a high level no one else
(including me) would ever want to read.</p>
<p>Generally, I know that I am directionally accurate for most of the article.  In fact, there is often a part of the article that I don't feel the best about.  It may have been some code that could have been better.  I try to point these things out.  Often when I am honest and point out where I know there is an improvement to be had I get the most welcoming comments, "that was just fine
how you did that", or "I tried that myself and saw a better abstraction.</p>
<h2 id="create-the-articles-i-want-to-read">Create the articles I want to read</h2>
<p>Generally, the articles I want to read are directly relatable to things I am currently working on and vary over time.  Over the last year its been leaning a bit more towards automation with <a target="_blank" href="https://waylonwalker.com/archive/linux">bash</a>, <a target="_blank" href="https://waylonwalker.com/archive/python">python</a>, <a target="_blank" href="https://waylonwalker.com/archive/kedro">kedro</a> tools.</p>
<h2 id="on-brand">On Brand</h2>
<p>I try to stay on the brand of who I am.  I remember writing my first articles.  I was trying to be witty, and include funny memes.  That's not me.  I am not a comedian, and generally, memes go right over my head.  I can remember back in High School, I was the one that didn't understand a lot of pop culture and was kinda treated as if I was always living under a rock.  I knew it was true and I owned it, so no one ever got to mean about it.</p>
<h1 id="honest-never-fake">Honest, never fake</h1>
<p>I will not try to pretend that I know everything.  You may read my blog on occasion and think I know a lot, also possible that you think "wow what an idiot".  I welcome you to share your thoughts and techniques in a positive way. I often cringe at some of my old posts and think about how differently I would approach something not that long after posting.  I honest, never fake know what I need to know, and don't pretend to know anything outside of my wheelhouse.</p>
]]></content:encoded></item><item><title><![CDATA[Minimal Kedro Pipeline]]></title><description><![CDATA[How small can a minimum kedro pipeline ready to package be? I made one within 4 files that you can pip install. It's only a total of 35 lines of python, 8…]]></description><link>https://h.waylonwalker.com/minimal-kedro-pipeline</link><guid isPermaLink="true">https://h.waylonwalker.com/minimal-kedro-pipeline</guid><category><![CDATA[Python]]></category><category><![CDATA[Data Science]]></category><category><![CDATA[data]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Wed, 20 Jan 2021 16:45:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611160719446/9cPQzaugm.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>How small can a minimum kedro pipeline ready to package be?  I made one within 4 files that you can pip install.  It's only a total of 35 lines of python, 8 in <code>setup.py</code> and 27 in <code>mini_kedro_pipeline.py</code>.</p>
<h1 id="minimal-kedro-pipeline">Minimal Kedro Pipeline</h1>
<p>I have everything for this post hosted in this <a target="_blank" href="https://github.com/WaylonWalker/mini-kedro-pipeline">gihub repo</a>, you can fork it, clone it, or just follow along.</p>
<h2 id="installation">Installation</h2>
<pre><code class="lang-bash">pip install git+https://github.com/WaylonWalker/mini-kedro-pipeline
</code></pre>
<h2 id="caveats">Caveats</h2>
<p>This repo represents the minimal amount of structure to build a kedro pipeline that can be shared across projects.  Its installable, and drops right into your <code>hooks.py</code> or <code>run.py</code> modules.  It is not a runnable pipeline.  At this point
I think the config loader requires to have a logging config file.</p>
<p>This is a sharable pipeline that can be used across many different projects.</p>
<h2 id="usage">Usage</h2>
<pre><code class="lang-python"><span class="hljs-comment"># hooks.py</span>

<span class="hljs-keyword">import</span> mini_kedro_project <span class="hljs-keyword">as</span> mkp

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ProjectHooks</span>:</span>
<span class="hljs-meta">    @hook_impl</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">register_pipelines</span>(<span class="hljs-params">self</span>) -&gt; Dict[str, Pipeline]:</span>
        <span class="hljs-string">"""Register the project's pipeline.

        Returns:
            A mapping from a pipeline name to a ``Pipeline`` object.

        """</span>

        <span class="hljs-keyword">return</span> {<span class="hljs-string">"__default__"</span>: Pipeline([]), <span class="hljs-string">"mkp"</span>: mkp.pipeline}
</code></pre>
<h2 id="implemantation">Implemantation</h2>
<p>This builds on another post that I made about creating the minimal python package.  I am not sure if it should be called a package, it's a module, but what do you call it after you build it and host it on pypi?</p>
<hr />
<table><td>
<a class="onelinelink" href="https://waylonwalker.com/minimal-python-package/">
<img src="https://waylonwalker.com/static/de47aa7ab3bcdcd5f0dade8cdccdddc2/630fb/minimal-python-package-xmas2020.png" alt="article cover for Minimal Python Package" />
<div class="right">
    <h2>Minimal Python Package</h2>
    <p>
    What does it take to create an installable python package that can be hosted on pypi? What is the minimal python package
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
</a>
</td></table>

<hr />
<h2 id="directory-structure">Directory structure</h2>
<pre><code class="lang-bash">.
├── .gitignore
├── README.md
├── setup.py
└── my_pipeline.py
</code></pre>
<h2 id="setuppy">setup.py</h2>
<p>This is a very minimal <code>setup.py</code>.  This is enough to get you started with a package that you can share across your team.  In practice, there is a bit more that you might want to include as your project grows.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> setuptools <span class="hljs-keyword">import</span> setup

setup(
    name=<span class="hljs-string">"MiniKedroPipeline"</span>,
    version=<span class="hljs-string">"0.1.0"</span>,
    py_modules=[<span class="hljs-string">"mini_kedro_pipeline"</span>],
    install_requires=[<span class="hljs-string">"kedro"</span>],
)
</code></pre>
<h2 id="minikedropipelinepy">mini_kedro_pipeline.py</h2>
<p>The mini kedro pipeline looks like any set of nodes in your project.  Many projects will separate nodes and functions, I prefer to keep them close together.  The default recommendation is also to have a <code>create_pipelines</code> function that returns the pipeline.</p>
<p>This pattern creates a singleton, if you were to reference the same pipeline in multiple places within the same running interpreter and modify the one you would run into issues.  I don't foresee myself running into this issue, but maybe as more features become available I will change my mind.</p>
<pre><code class="lang-python"><span class="hljs-string">"""
An example of a minimal kedro pipeline project
"""</span>
<span class="hljs-keyword">from</span> kedro.pipeline <span class="hljs-keyword">import</span> Pipeline, node

__version__ = <span class="hljs-string">"0.1.0"</span>
__author__ = <span class="hljs-string">"Waylon S. Walker"</span>

nodes = []


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_data</span>():</span>
    <span class="hljs-string">"creates a dictionary of sample data"</span>
    <span class="hljs-keyword">return</span> {<span class="hljs-string">"beans"</span>: range(<span class="hljs-number">10</span>)}


nodes.append(node(create_data, <span class="hljs-literal">None</span>, <span class="hljs-string">"raw_data"</span>, name=<span class="hljs-string">"create_raw_data"</span>))


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">mult_data</span>(<span class="hljs-params">data</span>):</span>
    <span class="hljs-string">"multiplies each record of each item by 100"</span>
    <span class="hljs-keyword">return</span> {item: [i * <span class="hljs-number">100</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> data[item]] <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> data}


nodes.append(node(mult_data, <span class="hljs-string">"raw_data"</span>, <span class="hljs-string">"mult_data"</span>, name=<span class="hljs-string">"create_mult_data"</span>))

pipeline = Pipeline(nodes)
</code></pre>
<h2 id="share-your-pipelines">Share your pipelines</h2>
<p>Go forth and share your pipelines across projects.  Let me know, do you share pipelines or catalogs across projects?</p>
]]></content:encoded></item><item><title><![CDATA[🎯 My Content Strategy For 2021]]></title><description><![CDATA[I am making another push in 2021 to get my content out in the world and meeting users where they are. See how I plan to execute. My content is written in…]]></description><link>https://h.waylonwalker.com/content-strategy-for-2021</link><guid isPermaLink="true">https://h.waylonwalker.com/content-strategy-for-2021</guid><category><![CDATA[blog]]></category><category><![CDATA[branding]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Tue, 19 Jan 2021 15:05:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611068638537/Ud7xYovUk.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I am making another push in 2021 to get my content out in the world and meeting users where they are.  See how I plan to execute.</p>
<h2 id="platforms">Platforms</h2>
<ul>
<li>waylonwalker.com</li>
<li>Twitter</li>
<li>DEV</li>
<li>hashnode</li>
<li>Medium</li>
<li>LinkedIn</li>
<li>Anchor</li>
</ul>
<h2 id="markdown">Markdown</h2>
<p>My content is written in markdown, all markdown.  I find that markdown does a really great job at getting out of the way and letting ideas flow onto the page.  I am never fussing with fonts and formatting while physically writing posts.   Not that I don't spend way more time than I need to tweak these things on my own personal site where everything gets posted.</p>
<h2 id="articles">Articles</h2>
<p>Much of what I create is inside of short articles that get posted to my personal site <a target="_blank" href="https://waylonwalker.com">waylonwalker.com</a>.  These will get cross-posted to <a target="_blank" href="https://dev.to/waylonwalker">DEV</a>,
<a target="_blank" href="https://h.waylonwalker.com/">hashnode</a>, <a target="_blank" href="https://waylonwalker.medium.com/">Medium</a>.</p>
<p>I have made cross-posting a bit easier for myself by posting the markdown for each article next to the post on my personal site.  Add .md to any post and there is the source.</p>
<p>Should I be giving my articles to Medium??  Personally, I am not a fan of the bait and switch that they did with adding a paywall years after launch.  From what I can tell authors are not getting paid much from it, users are discouraged when they are blocked, and they really only promote articles that are behind the paywall.</p>
<p>In the end, I am a fan of meeting users where they are, if they like Medium I don't want them to miss my content.</p>
<h2 id="more-catalytic">More Catalytic</h2>
<p><em>soft skills</em></p>
<p>My articles are very code-heavy, I do want to transition over to some more evergreen type of posts that are long-lasting.  I want to create some more content around how to be a good developer, data scientist, engineer, whatever you call yourself.</p>
<p>Personally, this is some of the content I enjoy consuming, but for some reason is not something I tend to create.</p>
<h2 id="slides">Slides</h2>
<p>I am really enjoying the slide output of my articles on
<a target="_blank" href="https://www.linkedin.com/in/waylonwalker/detail/recent-activity/shares/">LinkedIn</a>. It makes for something that is unique and easy to digest.  I have a pandoc script that takes in the markdown from my posts and kicks out a set of slides, so it's quick and easy to do.  Not every post works well this way by many have so
far.</p>
<p><img src="https://waylonwalker.com/linkedin-activity-slides.gif" alt="my linked in slide
activity" /></p>
<h2 id="threads">Threads</h2>
<p>With less success (shares, views, likes) I have been converting articles over to Twitter threads as they are released, again not every article works well this way, but many do.</p>
<p>{% tweet 1349716127887347717 %}</p>
<h2 id="simplicity">Simplicity</h2>
<p><em>just write markdown</em></p>
<p>In the end, everything needs to be simple and build off of the original markdown post.  Automation should be in a place where it makes sense.  I am no longer manually creating cover art or article descriptions, those are scripted out of the article itself.</p>
<p>I have come cli tooling in place to simplify my process. Expect more of that to come.</p>
<h2 id="audio">Audio</h2>
<p>I have set up a podcast where I read out my posts, but the time that I have available to read them is very constraining to the process.  It may be something that I figure out how to work out or something that I drop.  It's something that I think would be really nice, but still trying to figure out how to do it.</p>
<table><td>
<a class="onelinelink" href="https://waylonwalker.com/audio-for-blog/">
<img src="https://waylonwalker.com/static/a8606be154d71412741094d011b75098/630fb/audio-for-blog-xmas2020.png" alt="article cover for Adding Audio to my blog posts" />
<div class="right">
<h2>Adding Audio to my blog posts</h2>
<p>
This is episode 1 of the Waylon Walker Audio experience, posts from waylonwalker.com in audio form. So I have had this
</p>
<p>
<span class="read-more">read more</span>  waylonwalker.com
</p>
</div>
</a>
</td></table>

<p>I personally really like this as I often find a cool blog article that I want to read, but it's time to cook dinner or drive somewhere.  Articles with audio make it super convenient to consume while doing a task requiring eye contact.</p>
<h2 id="tldr">TLDR</h2>
<p>Meet Users Where They are.</p>
]]></content:encoded></item><item><title><![CDATA[Quickly Edit Posts]]></title><description><![CDATA[Recently I automated starting new posts with a python script. Today I want to work on the next part that is editing those posts quickly. Recently I…]]></description><link>https://h.waylonwalker.com/quickly-edit-posts</link><guid isPermaLink="true">https://h.waylonwalker.com/quickly-edit-posts</guid><category><![CDATA[Bash]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Mon, 18 Jan 2021 16:46:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610988377171/2O1Kf-6X3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Recently I automated starting new posts with a python script.  Today I want to work on the next part that is editing those posts quickly.</p>
<table><td>
<a class="onelinelink" href="https://waylonwalker.com/automating-my-post-starter/">
<img src="https://waylonwalker.com/static/fd0bd45e6a1500a02b7f796ae7294550/630fb/quickly-edit-posts-xmas2020.png" alt="article cover Quickly Edit Posts" />
<div class="right">
    <h2>Quickly Edit Posts</h2>
    <p>
Recently I automated starting new posts with a python script. Today I want to work on the next part that is editing tho
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
</a>
</td></table>

<blockquote>
<p>Check out this post about setting up my posts with python 🐍</p>
</blockquote>
<h2 id="enter-bash">Enter Bash</h2>
<p>For the process of editing a post I just need to open the file in vim quickly. I dont need much in the way of parsing and setting up the frontmatter.  I think this is a simple job for a <strong>bash</strong> script and fzf.</p>
<ol>
<li>change to the root of my blog</li>
<li>fuzzy find the post</li>
<li>open it with vim</li>
<li>change back to the directory I was in</li>
</ol>
<h2 id="bash-function">bash function</h2>
<p>For this, I am going to go with a bash function.  This is partly due to being able to track where I was and get back.  Also, the line with nvim will run fzf every time you source your <code>~/.alias</code> file which is not what we want.</p>
<p>Let's set up the <strong>boilerplate</strong>.  It's going to create a function called ep <code>"edit post"</code>, track our current directory, create a sub-function <code>_ep</code>.  Then call that function and cd back to where we were no matter if <code>_ep</code> fails or
succeeds.</p>
<p><em>boilerplate</em></p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">ep</span></span> () {
    _dir=$(<span class="hljs-built_in">pwd</span>)
    <span class="hljs-function"><span class="hljs-title">_ep</span></span> () {
        <span class="hljs-comment"># open file here</span>
    }
    _ep &amp;&amp; <span class="hljs-built_in">cd</span> <span class="hljs-variable">$_dir</span> || <span class="hljs-built_in">cd</span> <span class="hljs-variable">$_dir</span>
}
</code></pre>
<table><td>
<a class="onelinelink" href="https://waylonwalker.com/reusable-bash/">
<img src="https://waylonwalker.com/static/96bd1b466e9e00834d0d7eda8af04b97/630fb/reusable-bash-xmas2020.png" alt="article cover for Creating Reusable Bash Scripts" />
<div class="right">
    <h2>Creating Reusable Bash Scripts</h2>
    <p>
    Bash is a language that is quite useful for automation no matter what language you write in. Bash can do so many powerful system-level tasks. Even if you are on windows these days you are likely to come across bash inside a cloud VM, Continuous Integration, or even inside of docker.
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
</a>
</td></table>

<blockquote>
<p>check out this post for more information about writing reusable bash scripts.</p>
</blockquote>
<h2 id="fzf">FZF</h2>
<p>Let's focus in on that <code>_ep</code> function here that is going to do the bulk of the work to edit the post.</p>
<p><em>cd to where I want to edit from</em></p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> ~/git/waylonwalkerv2/
</code></pre>
<p>Next I need to find all markdown pages within my posts directory.  There is probably a better way to filter with the <code>find</code> command directly, but I am not worried about perf here and I knew how to do it without google.</p>
<p><em>find all markdown</em></p>
<pre><code class="lang-bash">find ~/git/waylonwalkerv2/src/pages/ | grep .md$
</code></pre>
<p>Now that we can list all potential posts, sending the selected post back to neovim is as easy as piping those files into fzf inside of a command substitution that is called with neovim.</p>
<p><em>putting together the edit command</em></p>
<pre><code class="lang-bash"><span class="hljs-variable">$EDITOR</span> $(find ~/git/waylonwalkerv2/src/pages/ | grep .md$ | fzf)
</code></pre>
<h2 id="final-script">Final Script</h2>
<p><em>final ep function</em></p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">ep</span></span> () {
    _dir=$(<span class="hljs-built_in">pwd</span>)
    <span class="hljs-function"><span class="hljs-title">_ep</span></span> () {
        <span class="hljs-built_in">cd</span> ~/git/waylonwalkerv2/
        <span class="hljs-variable">$EDITOR</span> $(find ~/git/waylonwalkerv2/src/pages/ | grep .md$ | fzf)
    }
    _ep &amp;&amp; <span class="hljs-built_in">cd</span> <span class="hljs-variable">$_dir</span> || <span class="hljs-built_in">cd</span> <span class="hljs-variable">$_dir</span>
}
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Gitui is a blazing fast terminal git interface]]></title><description><![CDATA[Gitui is a terminal-based git user interface (TUI) that will change the way that you work with git. I have been a long-time user of the git cli, and it's…]]></description><link>https://h.waylonwalker.com/gitui</link><guid isPermaLink="true">https://h.waylonwalker.com/gitui</guid><category><![CDATA[Git]]></category><category><![CDATA[terminal]]></category><category><![CDATA[Linux]]></category><category><![CDATA[Bash]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Sun, 17 Jan 2021 16:45:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610901882127/krhVeWAvu.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Gitui is a terminal-based git user interface (TUI) that will change the way that you work with git. I have been a long-time user of the git cli, and it's been hard to beat, mostly because there is nothing that keeps my fingers on the keyboard quite like it, except <code>gitui</code> which comes with some great ways to very
quickly walk through a git project.</p>
<h2 id="installation">installation</h2>
<p>Go to their [releases]https://github.com/extrawurst/gitui/releases) page,
download the latest build, and pop it on your PATH.  I have the following stuffed away in some install scripts to get the latest version.</p>
<p><em>install latest release</em></p>
<pre><code class="lang-bash">GITUI_VERSION=$(curl --silent https://github.com/extrawurst/gitui/releases/latest | tr -d <span class="hljs-string">'"'</span> | sed <span class="hljs-string">'s/^.*tag\///g'</span> | sed <span class="hljs-string">'s/&gt;.*$//g'</span> | sed <span class="hljs-string">'s/^v//'</span>)
wget https://github.com/extrawurst/gitui/releases/download/v<span class="hljs-variable">${GITUI_VERSION}</span>/gitui-linux-musl.tar.gz -O- -q | sudo tar -zxf - -C /usr/bin/
</code></pre>
<h2 id="run-gitui">run <code>gitui</code></h2>
<p>It opens blazing fast.</p>
<pre><code class="lang-bash">gitui
</code></pre>
<h2 id="quick-commits">Quick Commits</h2>
<p>Sometimes I edit a number of files and want to commit them one at a time, this is painful in the git cli and my main use case for <code>gitui</code>.  <code>gitui</code> shows unstaged changes at the top, staged changes on the bottom, and a diff on the right.</p>
<p><img src="https://waylonwalker.com/gitui-status.png" alt="gitui status" /></p>
<h2 id="navigate-with-hjkl">Navigate with hjkl</h2>
<p>By default, <code>gitui</code> uses arrow keys, but simply copying <a target="_blank" href="https://github.com/extrawurst/gitui/blob/master/assets/vim_style_key_config.ron">vim_style_key_config.ron</a> to your config directory will get you vim-like keybindings.</p>
<h2 id="workflow">workflow</h2>
<p>Generally, I pop open <code>gitui</code>, use j/k to get to the file I want to commit, glance at the diff to the right, press enter to stage the file, sc to switch focus to the saged files and commit, write my commit message hit enter and done.</p>
<ul>
<li>w/s:   to toggle focus between working and staged changes</li>
<li>j/k:   to scroll each section</li>
<li>h/l:   switch between left and right side</li>
<li>enter: toggle file from working or staging</li>
<li>c:     start a commit message</li>
<li>p:     push</li>
<li>: quit</li>
</ul>
<h2 id="other-panes">Other Panes</h2>
<p>I am in the <code>Status [1]</code> pane 90% of the time, but it also has three other panes for <code>Log [2]</code>, <code>Stashing [3]</code>, and <code>Stashes [4]</code>.  I do not really use the stashes panes, but the <code>Log [2]</code> pane is quite useful to quickly go through the last set of commits and see the diff for each of them.</p>
<h2 id="what-ui-do-you-use-for-git">What UI do you use for git</h2>
<p>Let me know what ui you use for git, do you stick to the cli, use a gui, or use a similar <code>TUI</code> interface?</p>
]]></content:encoded></item><item><title><![CDATA[Keep Location List Closed]]></title><description><![CDATA[canonical_url: cover: /static/keep-location-list-closed-xmas2020.png cover_image: https:waylonwalker.com/keep-location-list-closed.png tags: ["vim"] title…]]></description><link>https://h.waylonwalker.com/keep-location-list-closed</link><guid isPermaLink="true">https://h.waylonwalker.com/keep-location-list-closed</guid><category><![CDATA[vim]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Sat, 16 Jan 2021 17:25:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610817850682/ML6nkPbx1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p>canonical_url: https://waylonwalker.com/keep-location-list-closed
cover: /static/keep-location-list-closed-xmas2020.png
cover_image: https:waylonwalker.com/keep-location-list-closed.png
tags: ["vim"] 
title: Keep Location List Closed
published: true</p>
<h2 id="status-draft">status: draft</h2>
<p>Vim's (neovim in my case) location list can provide some very useful information while developing.  Mine gives me information about linting and type checking errors with fairly little config.  Generally, it sits nicely at the bottom of the screen and barely affects me.  Other times, especially while zoomed way in during a presentation, it just gets in the way.</p>
<p><img src="https://waylonwalker.com/location-list-eats-screen.png" alt="location list eats the screen" /></p>
<blockquote>
<p>Location List eating up the screen while I am zoomed in and trying to live code</p>
</blockquote>
<h2 id="toggling-the-location-list">Toggling the location list</h2>
<p>Through some google search I found the culprit was syntastic.  It has an <code>auto_loc_list</code> feature.  We can turn it off by setting
<code>syntastic_auto_loc_list=0</code>.</p>
<pre><code class="lang-vim">let syntastic_auto_loc_list=0
</code></pre>
<h2 id="keybindings">Keybindings</h2>
<p>I want to keep the location list open automatically most of the time, but when I don't want it to keep opening it's generally detrimental.  Trying to live code while the location list keeps taking up the whole screen is not cool.</p>
<p>First, create a function that will toggle both the location list and syntactic together.</p>
<pre><code class="lang-vim">let s:syntastic_auto_loc_list = 0
function! s:ToggleLocationList()
    if s:syntastic_auto_loc_list == 1
        let s:syntastic_auto_loc_list = 0
        let syntastic_auto_loc_list = 0
        :lclose
    else
        let s:syntastic_auto_loc_list = 1
        let syntastic_auto_loc_list = 1
        :lopen
    endif
endfunction
</code></pre>
<p>This binding will allow me to use <code>gtl</code> from normal mode to toggle the location list.</p>
<pre><code class="lang-vim">:command! ToggleLocationList :call s:ToggleLocationList()
nnoremap gtl :ToggleLocationList&lt;CR&gt;
</code></pre>
<p>I am starting a set of <strong>toggle</strong> keymaps under the <code>gt</code> keybinding, this one is the second one after a keybinding made to toggle paste mode.</p>
]]></content:encoded></item><item><title><![CDATA[📄 Kedro - My Data Is Not A Table]]></title><description><![CDATA[In python data science/engineering most of our data is in the form of some sort of table, typically a DataFrame from a library like pandas, spark, or dask.]]></description><link>https://h.waylonwalker.com/kedro-pickle</link><guid isPermaLink="true">https://h.waylonwalker.com/kedro-pickle</guid><category><![CDATA[Python]]></category><category><![CDATA[Data Science]]></category><category><![CDATA[data]]></category><category><![CDATA[data structures]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Fri, 15 Jan 2021 16:29:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610728120399/1w__rrA0Q.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In python data science/engineering most of our data is in the form of some sort of table, typically a DataFrame from a library like pandas, spark, or dask.</p>
<h2 id="dataframes-are-the-heart-of-most-pipelines">DataFrames are the heart of most pipelines</h2>
<p>These containers for data contain many convenient methods to manipulate table-like data structures.  Sometimes we leverage other data types, namely vanilla
types like lists and dicts, or even numpy data types.</p>
<p>{% post waylonwalker/what-is-kedro-lob %}</p>
<blockquote>
<p>unfamiliar with kedro, check out this post</p>
</blockquote>
<h2 id="sometimes-datasets-are-not-tables">Sometimes datasets are not tables</h2>
<p>There are times when our data doesn't fit nicely into a DataFrame. Lucky for us Kedro has pickle support out of the box.  Pickle is a way to store any python
object to disk.  Beware that pickle files coming from an unknown source can run malicious code and are considered unsafe.  For the most part though when you
read and write your own pickle files they are a good tool to consider.</p>
<blockquote>
<p>See more about <a target="_blank" href="https://docs.python.org/3/library/pickle.html">pickle</a> from python.org.</p>
</blockquote>
<h2 id="cataloging-pickle">Cataloging Pickle</h2>
<p>I may have a dictionary that describes some cars.</p>
<pre><code class="lang-python">{
  <span class="hljs-string">'truck-012-abc'</span>: {
    <span class="hljs-string">'type'</span>: <span class="hljs-string">'truck'</span>
    <span class="hljs-string">'sales'</span>: [<span class="hljs-number">12</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">8</span>]
    <span class="hljs-string">'weight'</span>: <span class="hljs-number">9024</span>,
    <span class="hljs-string">'accesories'</span>: [<span class="hljs-string">'leather'</span>, <span class="hljs-string">'audio-1'</span>]
}
</code></pre>
<p>In the catalog, we will simply set the type as <code>pickle.PickleDataSet</code> and give it a <code>filepath</code>.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">cars:</span>
  <span class="hljs-attr">filepath:</span> <span class="hljs-string">data/cars.pkl</span>
  <span class="hljs-attr">type:</span> <span class="hljs-string">pickle.PickleDataSet</span>
</code></pre>
<blockquote>
<p>This <code>filepath</code> does not have to be on the local filesystem it can be on the cloud thanks to how kedro utilizes <code>fsspec</code> for each of its datasets.</p>
</blockquote>
<h2 id="loading-the-dataset">Loading the dataset</h2>
<p>The benefit of cataloging this dataset compared to leaving it as a <code>MemoryDataSet</code> is that you can easily load this data back into memory for further development or debugging without running any of the pipelines.</p>
<pre><code class="lang-python">catalog.load(<span class="hljs-string">'cars'</span>)
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Minimal Python Package]]></title><description><![CDATA[cover: /static/minimal-python-package-xmas2020.png cover_image: published: true status: published tags:]]></description><link>https://h.waylonwalker.com/minimal-python-package</link><guid isPermaLink="true">https://h.waylonwalker.com/minimal-python-package</guid><category><![CDATA[Python]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Thu, 14 Jan 2021 13:40:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610631609550/WpkoLypkJ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p>cover: /static/minimal-python-package-xmas2020.png
cover_image: https://waylonwalker.com//static/minimal-python-package.png
published: true
status: published
tags:</p>
<ul>
<li>python
templateKey: blog-post
title: Minimal Python Package</li>
</ul>
<hr />
<p>What does it take to create an installable python package that can be hosted on pypi?</p>
<h2 id="what-is-the-minimal-python-package">What is the minimal python package</h2>
<ul>
<li>setup.py</li>
<li>my_module.py</li>
</ul>
<p>This post is somewhat inspired by the bottle framework, which is famously created as a single python module.  Yes, a whole web framework is written in one file.</p>
<h2 id="directory-structure">Directory structure</h2>
<pre><code class="lang-bash">
.
├── setup.py
└── my_pipeline.py
</code></pre>
<h2 id="setuppy">setup.py</h2>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> setuptools <span class="hljs-keyword">import</span> setup

setup(
    name=<span class="hljs-string">""</span>,
    version=<span class="hljs-string">"0.1.0"</span>,
    py_modules=[<span class="hljs-string">"my_pipeline"</span>, ],
    install_requires=[<span class="hljs-string">"kedro"</span>],
)
</code></pre>
<h2 id="name">name</h2>
<p>The name of the package can contain any letters, numbers, "_", or "-".  Even if it's for internal/personal consumption only I usually check for discrepancy with pypi so that you don't run into conflicts. </p>
<blockquote>
<p>Note that pypi treats "-" and "_" as the same thing, beware of name clashes</p>
</blockquote>
<h2 id="version">version</h2>
<p>This is the version number of your package.  Most packages follow
<a target="_blank" href="semver.org">semver</a>.  At a high level its three numbers separated by a <code>.</code> that follow the format <code>major.minor.patch</code>.  It's a common courtesy to only break APIs on major changes, new releases on minor, and fixes on patch.  This can become much more blurry in practice so checkout <a target="_blank" href="https://semver.org/">semver.org</a>.</p>
<h2 id="pymodules">py_modules</h2>
<p>Typically most packages use the <code>packages</code> argument combined with
<code>find_packages</code>, but for this minimal package, we are only creating one <code>.py</code> file.</p>
<h2 id="using-packages-instead">Using packages instead</h2>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> setuptools <span class="hljs-keyword">import</span> setup, find_packages

setup(
    name=<span class="hljs-string">""</span>,
    version=<span class="hljs-string">"0.1.0"</span>,
    packages=find_packages(),
    install_requires=[<span class="hljs-string">"kedro"</span>],
)
</code></pre>
<h2 id="installrequires">install_requires</h2>
<p>These are your external dependencies that come from pypi.  They go in this list but are often pulled in from a file called <code>requirements.txt</code>.  Other developers may look for this file and want to do a <code>pip install -r
requirements.txt</code>.</p>
<h2 id="clean">Clean?</h2>
<p>One thing to be careful of here is that everything sits at the top level API, when you users import your module and hit tab they are going to see a lot of stuff unless you hide all of your internal functions behind an <code>_</code>.</p>
<h2 id="minimal">Minimal</h2>
<p>Can you create a python package with less than two files and less than 8 lines? Should you?  I really like a minimal point to get started from for quick and simple prototypes.  You can always pull a more complicated <code>cookiecutter</code> template later if the project is successful.</p>
]]></content:encoded></item><item><title><![CDATA[Expand One Line Links 🔗]]></title><description><![CDATA[I wanted a super simple way to cross-link blog posts that require as little effort as possible, yet still looks good in vanilla markdown in GitHub. I have…]]></description><link>https://h.waylonwalker.com/expand-one-line-links</link><guid isPermaLink="true">https://h.waylonwalker.com/expand-one-line-links</guid><category><![CDATA[Python]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Blogging]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Thu, 14 Jan 2021 01:26:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610587559856/gilrETf0N.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I wanted a super simple way to cross-link blog posts that require as little effort as possible, yet still looks good in vanilla markdown in GitHub.  I have been using a snippet that puts HTML into the markdown.  While this works, it's more manual/difficult for me does not look the best, and does not read well as</p>
<h2 id="goals-for-new-card">Goals for new card</h2>
<p>The new card should be fully automated to expand with title, description, and
cover image.  Bonus if I am able to attach a comment behind it.</p>
<ul>
<li>fully automated</li>
<li>card expansion</li>
<li>Title</li>
<li>description</li>
<li>cover image</li>
</ul>
<h2 id="old-card">Old Card</h2>
<p>If you can call it a card 🤣.  This card was just an image wrapped in an anchor tag and a paragraph tag.  I found this was the most consistent way to get an image narrower and centered in both GitHub and dev.to.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">style</span>=<span class="hljs-string">'text-align: center'</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'https://waylonwalker.com/notes/eight-years-cat'</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">img</span>
    <span class="hljs-attr">style</span>=<span class="hljs-string">'width:500px; max-width:80%; margin: auto;'</span>
    <span class="hljs-attr">src</span>=<span class="hljs-string">"https://waylonwalker.com/eight-years-cat.png"</span>
    <span class="hljs-attr">alt</span>=<span class="hljs-string">"My first eight years as a working professional article"</span>
    /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>
  <a href="https://waylonwalker.com/notes/eight-years-cat">
    <img src="https://waylonwalker.com/eight-years-cat.png" alt="My first eight years as a working professional article" />
  </a>
</p>

<p>The key here is that I have to put the HTML into the markdown.  It looks a bit dirty while editing and quite frankly it's a pain to deal with.</p>
<hr />
<h2 id="new-card">New Card</h2>
<pre><code class="lang-markdown">
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"onelinelink"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://waylonwalker.com/eight-years-cat/"</span>&gt;</span></span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"float: right;"</span> <span class="hljs-attr">align</span>=<span class="hljs-string">'right'</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://waylonwalker.com/static/29cdf6fcfb17d7fd766fc438144fb3e4/630fb/eight-years-cat-xmas2020.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"article cover for My first eight years as a working professional."</span>&gt;</span></span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"right"</span>&gt;</span></span>
<span class="hljs-code">    &lt;h2&gt;My first eight years as a working professional.&lt;/h2&gt;
    &lt;p class="description"&gt;
    This day 8 years ago I started my first day as a Mechanical Engineer. I am so grateful for this journey that I have been able to have. There is no way that I could have planned this journey from the beginning.
    &lt;/p&gt;
    &lt;p class="url"&gt;
    &lt;span class="read-more"&gt;read more&lt;/span&gt;  waylonwalker.com
    &lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;</span>
</code></pre>
<h2 id="first-step">First step</h2>
<p>My first attempt was to make my own transformer for <code>gatsby-remark-embedder</code>. I previously set this up on my site for Twitter and YouTube.  I tried to get some custom transformers going, to do what I wanted for my own website, but failed.  I really struggled to understand what data was coming in and out of the transformer.  My lack of js/node debugging skills was really showing.</p>
<blockquote>
<p>using gatsby-remark-embedder to expand Twitter/YouTube</p>
</blockquote>
<h2 id="redirects">Redirects</h2>
<p>It also works with redirects. I have a redirect to my "latest" post.  It's something that I don't do the best job at keeping up to date, but when I feel really proud of a post I make it the latest.</p>
<blockquote>
<p>this post is a redirect to my "latest post"</p>
</blockquote>
<h2 id="client-side">Client Side</h2>
<p>I started out by running this card expansion client side. This was the strategy that I used to find the list of elements that should be transformed.</p>
<ul>
<li>get all anchors</li>
<li>get all paragraphs</li>
<li>filter paragraphs where the content is one of the links</li>
<li>filter paragraphs where there is only one element in the paragraph</li>
<li>filter to paragraphs with links that <code>shouldTransform</code></li>
<li>These elements should have the <code>oneLineLinkCard</code> applied.</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> oneLineLinks = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> linkText = [...document.querySelectorAll(<span class="hljs-string">'.post-body p a'</span>)].map(
    <span class="hljs-function">(<span class="hljs-params">p</span>) =&gt;</span> p.innerText
  )
  <span class="hljs-keyword">const</span> paragraphs = <span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">'.post-body p'</span>) <span class="hljs-comment">//</span>

  <span class="hljs-keyword">const</span> regex = <span class="hljs-regexp">/^https?:\/\/waylonwalker\.com\//</span>
  <span class="hljs-keyword">const</span> shouldTransform = <span class="hljs-function">(<span class="hljs-params">url</span>) =&gt;</span> regex.test(url)

  <span class="hljs-keyword">const</span> anchorOnly = [...paragraphs].filter(
    <span class="hljs-function">(<span class="hljs-params">p</span>) =&gt;</span> linkText.includes(p.innerText) &amp;&amp; p.childElementCount === <span class="hljs-number">1</span>
  )

  anchorOnly
    .filter(<span class="hljs-function">(<span class="hljs-params">p</span>) =&gt;</span> shouldTransform(p.firstElementChild.href))
    .map(
      <span class="hljs-keyword">async</span> (p) =&gt;
        (p.outerHTML = <span class="hljs-keyword">await</span> oneLineLinkCard(p.firstElementChild.href))
    )
}
</code></pre>
<h2 id="styles">Styles</h2>
<p>CSS is not my strong suit, but I can generally hammer something into a shape that I am happy with.  For this one, I did struggle a bit with how it looked on various screens, particularly because I was holding the cover image size to a hard 300px.  I ended up with more media queries than I needed, but it works.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.onelinelink</span> + <span class="hljs-selector-tag">blockquote</span> {
  <span class="hljs-attribute">position</span>: relative;
  <span class="hljs-attribute">left</span>: <span class="hljs-number">2rem</span>;
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, .<span class="hljs-number">2</span>);
  <span class="hljs-attribute">margin</span>: -<span class="hljs-number">6rem</span> auto <span class="hljs-number">1rem</span>;
  <span class="hljs-attribute">padding-top</span>: <span class="hljs-number">3rem</span>;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid goldenrod;
  <span class="hljs-attribute">border-top</span>: <span class="hljs-number">2px</span> solid goldenrod;

  <span class="hljs-attribute">max-width</span>: <span class="hljs-number">300px</span>;
  @media (<span class="hljs-attribute">max-width</span>: <span class="hljs-number">350px</span>) {
  left: <span class="hljs-number">0rem</span>;
  <span class="hljs-attribute">margin-left</span>: .<span class="hljs-number">4rem</span>;
  <span class="hljs-attribute">margin-right</span>: .<span class="hljs-number">4rem</span>;
  }
  <span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">800px</span>) {
    <span class="hljs-selector-tag">max-width</span>: 600<span class="hljs-selector-tag">px</span>;
  }
  <span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">900px</span>) {
    <span class="hljs-selector-tag">max-width</span>: 700<span class="hljs-selector-tag">px</span>;
  }
  <span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">1000px</span>) {
    <span class="hljs-selector-tag">max-width</span>: 800<span class="hljs-selector-tag">px</span>;
  }
  <span class="hljs-selector-tag">border-radius</span>: 15<span class="hljs-selector-tag">px</span>/45<span class="hljs-selector-tag">px</span>;
  <span class="hljs-selector-tag">display</span>: <span class="hljs-selector-tag">block</span>;
  }

}

<span class="hljs-selector-class">.onelinelink</span> {
  <span class="hljs-attribute">position</span>: relative;
  <span class="hljs-attribute">z-index</span>: <span class="hljs-number">2</span>;
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">4rem</span>;
  <span class="hljs-attribute">overflow</span>: hidden;
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">2px</span> solid <span class="hljs-built_in">rgba</span>(<span class="hljs-number">255</span>, <span class="hljs-number">50</span>, <span class="hljs-number">50</span>, .<span class="hljs-number">1</span>);
  <span class="hljs-attribute">background</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">255</span>, <span class="hljs-number">50</span>, <span class="hljs-number">50</span>, .<span class="hljs-number">015</span>);
  <span class="hljs-attribute">background</span>: <span class="hljs-number">#262236</span>;
  <span class="hljs-attribute">text-decoration</span>: none;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">8px</span>;
  <span class="hljs-attribute">max-height</span>: <span class="hljs-number">126px</span>;

  @media (<span class="hljs-attribute">max-width</span>: <span class="hljs-number">800px</span>) {
    flex-direction: column;
    <span class="hljs-attribute">max-height</span>: <span class="hljs-number">800px</span>;
    <span class="hljs-attribute">max-width</span>: <span class="hljs-number">300px</span>;
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">4rem</span> auto;

  }

  <span class="hljs-selector-tag">h2</span> {
    <span class="hljs-attribute">top</span>: -<span class="hljs-number">1.2rem</span>;
    <span class="hljs-attribute">postition</span>: relative;
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">font-size</span>: .<span class="hljs-number">8rem</span>;
    <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">400</span>;

  }

  <span class="hljs-selector-class">.right</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">5px</span> <span class="hljs-number">15px</span>;
  }
  <span class="hljs-selector-class">.description</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1rem</span>;
    <span class="hljs-attribute">line-height</span>: <span class="hljs-number">1.2rem</span>;
    <span class="hljs-attribute">height</span>: <span class="hljs-built_in">calc</span>(<span class="hljs-number">100%</span> - <span class="hljs-number">31px</span> - <span class="hljs-number">1rem</span>);
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">padding-bottom</span>: <span class="hljs-number">1rem</span>;
    <span class="hljs-attribute">padding-top</span>: .<span class="hljs-number">1rem</span>;
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
  }
  <span class="hljs-selector-class">.url</span> {
    <span class="hljs-attribute">padding-right</span>: <span class="hljs-number">30px</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">255</span>, <span class="hljs-number">255</span>, <span class="hljs-number">255</span>, .<span class="hljs-number">1</span>);
    <span class="hljs-attribute">text-align</span>: right;
    <span class="hljs-attribute">position</span>: relative;
    <span class="hljs-attribute">z-index</span>: <span class="hljs-number">2</span>;
    <span class="hljs-attribute">background</span>: <span class="hljs-number">#262236</span>;
  }

  <span class="hljs-selector-tag">img</span> {
    <span class="hljs-attribute">max-width</span>: <span class="hljs-number">300px</span>;
    <span class="hljs-attribute">max-height</span>: <span class="hljs-number">126px</span>;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">8px</span> <span class="hljs-number">0</span> <span class="hljs-number">0</span> <span class="hljs-number">8px</span>;
  }
  <span class="hljs-selector-class">.read-more</span> {
    <span class="hljs-attribute">font-size</span>: .<span class="hljs-number">6rem</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">255</span>, <span class="hljs-number">255</span>, <span class="hljs-number">255</span>, .<span class="hljs-number">08</span>);
  }
}
</code></pre>
<h3 id="final-look">Final Look</h3>
<p>On mobile, it renders vertically.</p>
<p><img src="https://waylonwalker.com/one-line-link-vertical.png" alt="mobile" /></p>
<p>On desktop, it renders horizontally.</p>
<p><img src="https://waylonwalker.com/one-line-link-horizontal.png" alt="desktop" /></p>
<h2 id="expansion">Expansion</h2>
<p>I'm sure that all of this can be better, my js skills are still forming.  It's quite humbling to see how hard it is to think in an unfamiliar language.  The following <code>oneLineLineCard</code> renders a string template literal from a paragraph with a single anchor to a card that contains some of that pages meta information.  The <code>getDescription</code> function uses a fetch to get the metadata right from the content of the page.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> getDescription = <span class="hljs-function">(<span class="hljs-params">url</span>) =&gt;</span>
  fetch(url)
    .then(<span class="hljs-function">(<span class="hljs-params">r</span>) =&gt;</span> r.text())
    .then(<span class="hljs-function">(<span class="hljs-params">html</span>) =&gt;</span> {
      <span class="hljs-keyword">let</span> parser = <span class="hljs-keyword">new</span> DOMParser()
      <span class="hljs-keyword">let</span> doc = parser.parseFromString(html, <span class="hljs-string">'text/html'</span>)
      <span class="hljs-keyword">let</span> meta = doc.querySelectorAll(<span class="hljs-string">'meta'</span>)
      <span class="hljs-keyword">const</span> description = [...meta].filter(
        <span class="hljs-function">(<span class="hljs-params">m</span>) =&gt;</span> m.name === <span class="hljs-string">'og:description'</span>
      )[<span class="hljs-number">0</span>].content
      <span class="hljs-keyword">const</span> image = [...meta].filter(<span class="hljs-function">(<span class="hljs-params">m</span>) =&gt;</span> m.name === <span class="hljs-string">'og:image'</span>)[<span class="hljs-number">0</span>]?.content
      <span class="hljs-keyword">const</span> sm_image = [...meta].filter(<span class="hljs-function">(<span class="hljs-params">m</span>) =&gt;</span> m.name === <span class="hljs-string">'og:sm_image'</span>)[<span class="hljs-number">0</span>]
        ?.content
      <span class="hljs-keyword">const</span> url = [...meta].filter(<span class="hljs-function">(<span class="hljs-params">m</span>) =&gt;</span> m.name === <span class="hljs-string">'og:url'</span>)[<span class="hljs-number">0</span>]?.content
      <span class="hljs-keyword">const</span> title = [...meta].filter(<span class="hljs-function">(<span class="hljs-params">m</span>) =&gt;</span> m.name === <span class="hljs-string">'title'</span>)[<span class="hljs-number">0</span>]?.content
      <span class="hljs-keyword">return</span> { description, image, url, title, sm_image }
    })

<span class="hljs-keyword">const</span> oneLineLinkCard = <span class="hljs-function">(<span class="hljs-params">url</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> getDescription(url).then(
    <span class="hljs-function">(<span class="hljs-params">meta</span>) =&gt;</span>
      <span class="hljs-string">`&lt;a class="onelinelink" href=<span class="hljs-subst">${meta.url}</span>&gt;
  &lt;img src='<span class="hljs-subst">${meta.sm_image ? meta.sm_image : meta.image ? meta.image : <span class="hljs-string">''</span>}</span>' alt='cover image for <span class="hljs-subst">${meta.title ? meta.title : <span class="hljs-string">''</span>}</span>&gt;
  &lt;div class="right"&gt;
    &lt;h2&gt;<span class="hljs-subst">${meta.title ? meta.title : <span class="hljs-string">''</span>}</span>&lt;/h2&gt;
    &lt;p class='description'&gt;
      <span class="hljs-subst">${meta.description ? meta.description : <span class="hljs-string">''</span>}</span>
    &lt;/p&gt;
    &lt;p class="url"&gt;
       &lt;span class='read-more'&gt;read more&lt;/span&gt;  waylonwalker.com
    &lt;/p&gt;
  &lt;/div&gt;

&lt;/a&gt;
  `</span>
  )
}
</code></pre>
<h2 id="it-works">It works...</h2>
<p>And it works.  Whenever I reference my own blog with just a single link on a line in markdown I get a nice card link out to the other post, with a small image sized for the card, the title, and the description of the post.</p>
<h2 id="but">But</h2>
<ul>
<li>too much client-side</li>
<li>does not work well with cross-posting</li>
</ul>
<p>For every link I do this with the client will pull the full page just to get a bit of metadata.  I am already doing a bit more than I want to do client-side for a blog, so I would prefer to do it ahead of time.</p>
<p>Additionally, since it is done client-side it does not translate well when I copy my markdown to various other blogging platforms.  If it were rendered right into the markdown cross-posting would be much easier.</p>
<h2 id="future-state">Future State</h2>
<p><em>actually already implemented at this point</em></p>
<p>The direction I am going to try is to use python to load each post, look for lines that contain only a link, then render this same markup right in the markdown.  For this I am going to use a language I am more familiar with, python, and do this inside of GitHub actions just before build time so that the markdown I write stays the same, the cards will only be rendered in prod.</p>
<h2 id="why-python">Why Python 🐍</h2>
<p>Python is my every day what I know, I work much more efficiently and cleanly with it.  Also the more I blog the more abstractions I am seeing and the lazier I am getting.  Things like description, SEO, cover images are all getting automated. Gatsby really doesn't like to run when some of those things are missing, probably due to my lack of JS error handling skills.  I find it much easier to load up all the pages and patch up the frontmatter in python before
build time.</p>
<p>I am kinda curious if eventually, I can re-create everything I need in python because I am honestly not using react for much more than a glorified templating system, besides search.  If I can pre-render everything in python</p>
<h2 id="what-do-you-think">What do you think??</h2>
<p>Do they look good?  Could they be better?</p>
]]></content:encoded></item><item><title><![CDATA[Large Refactor At The Command Line]]></title><description><![CDATA[As projects grow patterns that worked early on break and we need to change things to make the project easier to work with, and more welcoming to new…]]></description><link>https://h.waylonwalker.com/large-refactor-at-the-command-line</link><guid isPermaLink="true">https://h.waylonwalker.com/large-refactor-at-the-command-line</guid><category><![CDATA[Linux]]></category><category><![CDATA[Bash]]></category><category><![CDATA[command line]]></category><category><![CDATA[Git]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Tue, 12 Jan 2021 14:46:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610462539228/K9_xSmi9d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As projects grow patterns that worked early on break and we need to change things to make the project easier to work with, and more welcoming to new developers.</p>
<h2 id="git">git</h2>
<p>Before you start mucking up a project with wild commands at the terminal check that you have a super clean git status. We may make some mistakes and need a way to undo 100's files and git makes it really easy if you start with a clean history.</p>
<pre><code class="lang-bash">git status
</code></pre>
<p>If we are ready to begin work we should see a response like this.</p>
<pre><code class="lang-bash">On branch main
nothing to commit, working tree clean
</code></pre>
<p>It would also be wise to do this inside of a branch.  The minute you try to do something wild in your working branch someone will walk by and ask you to do a five-minute task, but your deep in refactoring and haven't left yourself a clean way back.</p>
<pre><code class="lang-bash">git branch my-big-refactor
</code></pre>
<h2 id="grepr">grepr</h2>
<p>Time for the meat of this refactor replacing text across our project.  I often will pop this bash function into my terminal session and tweak it as needed. This function is called <code>grepr</code> for <code>grep</code> then <code>replace</code>.  It will recursively search for a given pattern inside your working directory, then use <code>sed</code> to replace that pattern with another.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">grepr</span></span>() {grep -iRl <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> | xargs sed -i <span class="hljs-string">"s/<span class="hljs-variable">$1</span>/<span class="hljs-variable">$2</span>/g"</span>}
</code></pre>
<p>If your pattern contains <code>/</code> characters such as for URLs you can swap the <code>/</code>'s in the <code>sed</code> command for <code>|</code>'s.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">grepr</span></span>() {grep -iRl <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> | xargs sed -i <span class="hljs-string">"s|<span class="hljs-variable">$1</span>|<span class="hljs-variable">$2</span>|g"</span>}
</code></pre>
<p>You can find this function and more of my bash notes.</p>
<p></p><table><tr><td>
<a class="onelinelink" href="https://waylonwalker.com/bash/">
<img src="https://waylonwalker.com/static/c4381601d570bb796e3fceb606b40e06/9dc27/hannah-gibbs-BINLgyrG_fI-unsplash.jpg" alt="article cover" /><p></p>
<p></p><div class="right">
    <h2>Bash</h2>
    <p>
    Waylon Walker's Bash Notes
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
</a>
</td></tr></table><p></p>
<h2 id="example">Example</h2>
<p>I recently flattened this blog so blogs are under the top-level rather than under <code>/blog</code> and I used this technique to swap internal links to the new format.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">grepr</span></span>() {grep -iRl <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> | xargs sed -i <span class="hljs-string">"s|<span class="hljs-variable">$1</span>|<span class="hljs-variable">$2</span>|g"</span>}


grepr <span class="hljs-string">"https://waylonwalker.com/blog/"</span> <span class="hljs-string">"https://waylonwalker.com/"</span>
</code></pre>
<h2 id="git-diff">git diff</h2>
<p>After running the replace command the first thing I want to see is everything that changed.  Looking at git diff will highlight exactly what changed since our last commit.</p>
<pre><code class="lang-bash">git diff
</code></pre>
<h2 id="work-in-small-steps">Work in small steps</h2>
<p>If you're happy with the results commit them now.  It's best to do these commands that have a large effect on the entire project in small steps.</p>
<pre><code class="lang-bash">git add .
git commit -m <span class="hljs-string">"moved routes from /blog to /"</span>
</code></pre>
<p>Working in small steps gives us an easy way to undo steps that may have been a mistake before it's too late.</p>
<p></p><table><tr><td>
<a class="onelinelink" href="https://waylonwalker.com/master-no-more/">
<img src="https://waylonwalker.com/static/656b0f429bd13770249a8e39f7dee184/630fb/master-no-more-xmas2020.png" alt="article cover" /><p></p>
<p></p><div class="right">
    <h2>Master No More</h2>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
</a>
</td></tr></table><p></p>
<blockquote>
<p>I used the technique from this post to switch master to main on my blog.</p>
</blockquote>
<h2 id="git-reset">git reset</h2>
<p><em>How I do Mass Undo</em></p>
<p><strong>be careful</strong> work from a branch, make sure you started clean</p>
<p>Let's say I wanted to change every occurrence of one variable name to another.
Lets try to replace replace <code>pandas.CSVDataSet</code> with <code>pandas.ParquetDataSet</code>.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">grepr</span></span>() {grep -iRl <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> | xargs sed -i <span class="hljs-string">"s|<span class="hljs-variable">$1</span>|<span class="hljs-variable">$2</span>|g"</span>}


grepr <span class="hljs-string">"pandas.CSVDataSet"</span> <span class="hljs-string">"pandas.ParquetDataSet"</span>
</code></pre>
<p>Upon inspection of the <code>git diff</code> we notice that there was an unintentional change to the <code>docs/standard-storage.md</code> file. To revert the entire change we can run.</p>
<p><strong>note</strong> These resets are irreversible.  Make sure that you started with a clean <code>git status</code> and you are confident that you didn't have any work on your machine, not in the remote repo.</p>
<p><em>match the remote and wipe out any changes</em></p>
<pre><code class="lang-bash">git reset --hard origin/main
</code></pre>
<p><em>match our last commit</em></p>
<pre><code class="lang-bash">git reset --hard HEAD
</code></pre>
<h2 id="agr">agr</h2>
<p>I have an alternative version that I occasionally use as well that utilizes the silver searcher <code>ag</code>.  It does a great job at following your .gitignore rules with no fuss, and can filter down to file extensions simply with flags like <code>--md</code></p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">agr</span></span>() {ag -l <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> | xargs sed -i <span class="hljs-string">"s/<span class="hljs-variable">$1</span>/<span class="hljs-variable">$2</span>/g"</span>}
</code></pre>
<h2 id="git-clean">git clean</h2>
<p><em>how I remove untracked files</em></p>
<p>Sometimes our refactoring requires moving files around. If we want to undo steps like this git will not clean up untracked files.</p>
<pre><code class="lang-bash">mv conf/base/sales-catalog.yml conf/base/sales/catalg.yml
</code></pre>
<p><em>clean up untracked files</em></p>
<pre><code class="lang-bash">git clean -f
</code></pre>
<p><em>clean up untracked directories</em></p>
<pre><code class="lang-bash">git clean -d
</code></pre>
<p><em>clean up ignored files</em></p>
<pre><code class="lang-bash">git clean -x
</code></pre>
<p><code>-x</code> can be a bit dangerous, be careful with it.  You can lose significant time by wiping out a <code>node_modules</code>, <code>venv</code>, or credentials.</p>
<h2 id="git-checkout">git  checkout</h2>
<p><em>How I undo single files</em></p>
<p>If our command was mostly successful, but just a few extra files were touched I will manually revert them with <code>git checkout &lt;filename&gt;</code></p>
<pre><code class="lang-bash">git checkout conf/base/supply-catalog.yml
</code></pre>
<h2 id="git-checkout">git checkout --</h2>
<p><em>How I undo an entire directory</em></p>
<p>Sometimes we need to undo an entire directory.  This command will undo changes to all of the tracked files in the repo.</p>
<pre><code class="lang-bash">git checkout -- /src/pages/blog
</code></pre>
<h2 id="gitui">gitui</h2>
<p>I really love using <code>gitui</code> as a handy terminal interface to browse logs, diffs, and commit a few files at a time.  It starts up crazy fast and is very intuitive to navigate through diffs of changes like this one file at a time if the <code>git diff</code> gets too overwhelming.</p>
]]></content:encoded></item><item><title><![CDATA[Quickly Change Conda Env With Fzf]]></title><description><![CDATA[Changing conda environments is a bit verbose, I use a function with fzf that both lists environments and selects the one I want in one go. I have used…]]></description><link>https://h.waylonwalker.com/quickly-change-conda-env-with-fzf</link><guid isPermaLink="true">https://h.waylonwalker.com/quickly-change-conda-env-with-fzf</guid><category><![CDATA[Python]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Mon, 11 Jan 2021 15:18:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610378296837/bAGK09lYo.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Changing conda environments is a bit verbose, I use a function with fzf that both lists environments and selects the one I want in one go.</p>
<h2 id="conda">Conda</h2>
<p>I have used conda as a virtual environment tool for years now.  I started using conda for its simplicity to install packages on windows, but now that has gotten so much better and it's been years since I have run a <code>conda install</code> command.  I'm sure that I could use a different environment manager, but it works for me and makes sense.</p>
<blockquote>
<p>What environment manager do you use for python?</p>
</blockquote>
<p>Conda environments are stored in a central location such as <code>~/miniconda3/envs/</code> and not with the project.  They contain both the python interpreter and packages for that env.</p>
<h2 id="conda-create">Conda create</h2>
<p>Conda environments are created with the <code>conda create</code> command.  At this point, you will need to name your env and select the python version.</p>
<pre><code class="lang-bash">conda create -n my_env python=3.8
</code></pre>
<p>After running this command you will have a directory <code>~/miniconda3/envs/my_env</code> with a base python install.  It will not be active yet.</p>
<h2 id="list-environments">List environments</h2>
<p>Before activating an environment I often want to list the environments that I have installed which are often upwards of 70, so it's hard to remember them all.</p>
<pre><code class="lang-bash">conda info --envs
</code></pre>
<p>After running this command you will see something like the following.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># conda environments:</span>
<span class="hljs-comment">#</span>
base                     /home/waylon/miniconda3
my_env                   /home/waylon/my_env
</code></pre>
<h2 id="activating-an-environment">Activating an environment</h2>
<p>Activating a conda environment will do some magic to your current shells <code>$PATH</code> variable to ensure that the environment that you select is preferred over the base environment.</p>
<pre><code class="lang-bash">conda activate my_env
</code></pre>
<h2 id="ready-to-work">Ready to work</h2>
<p>Now you can install packages for your project in an isolated environment safe from wrecking another project or being wrecked by another project.</p>
<pre><code class="lang-bash">pip install -r requirements.txt
</code></pre>
<h2 id="using-fzf">Using fzf</h2>
<p><em>a bit less verbose</em></p>
<p><a target="_blank" href="https://github.com/junegunn/fzf">fzf</a> is an amazing tool for the terminal that is a generic fuzzy matcher.  It is super performant and can handle insane amounts of text and is brilliant at figuring out what you mean with just a few characters.  We can use it here to list out all of our conda environments and select the one we want to activate with just a few keystrokes.</p>
<h3 id="selecting-the-environment">Selecting the environment.</h3>
<p>Piping our list of environments directly into <code>fzf</code> gives us a fuzzy selection where we can type a few characters and it will return the row we were looking for.</p>
<pre><code class="lang-bash">conda info --envs | fzf
</code></pre>
<p>This returns us something like this which also includes the path where it is located.</p>
<pre><code class="lang-bash">my_env                 /home/walkews/miniconda3/envs/my_env
</code></pre>
<h3 id="getting-just-the-environment-name">getting just the environment name</h3>
<p>To get just the name without the path I pipe the output into awk.  There are many ways to do this in bash, this is the way that worked for me at the time I made this function.</p>
<pre><code class="lang-bash">conda info --envs | fzf | awk <span class="hljs-string">'{print $1}'</span>
</code></pre>
<h3 id="time-to-activate">Time to activate</h3>
<p>Functions that use <code>fzf</code> can be a bit odd, running them in a subshell with the $() syntax generally makes it super simple to utilize the output.  No matter how many times I have tried without running it in a subshell it's always buggy without it.</p>
<pre><code class="lang-bash">conda activate <span class="hljs-string">"<span class="hljs-subst">$(conda info --envs | fzf | awk '{print $1}')</span>"</span>
</code></pre>
<p>This will now run conda activate on the environment that we select with fzf.</p>
<h3 id="make-it-a-function">Make it a function</h3>
<p>We don't want to type that out every time we want to activate an environment. I keep a function called <code>a</code> in my <code>~/.bashrc</code> and <code>~/.zshrc</code> so that I can activate an environment with a single character.  Yes, I switch environments often enough to justify the valuable namespace of a single character.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">a</span></span> () {
  conda activate <span class="hljs-string">"<span class="hljs-subst">$(conda info --envs | fzf | awk '{print $1}')</span>"</span>
}
</code></pre>
<blockquote>
<p>For more information on writing reusable bash check out one of my favorite articles I have done <a target="_blank" href="https://dev.to/waylonwalker/creating-reusable-bash-scripts-5fgo">Creating Reusable Bash Scripts</a></p>
</blockquote>
<p>I am always on the lookout for cool new use cases for <code>fzf</code>, if you have one please share it with me.</p>
]]></content:encoded></item><item><title><![CDATA[Vim Replace Visual Star]]></title><description><![CDATA[cover: /static/vim-replace-visual-star-xmas2020.png cover_image: published: true status: published tags:]]></description><link>https://h.waylonwalker.com/vim-replace-visual-star</link><guid isPermaLink="true">https://h.waylonwalker.com/vim-replace-visual-star</guid><category><![CDATA[vim]]></category><category><![CDATA[Linux]]></category><category><![CDATA[command line]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Sun, 10 Jan 2021 16:22:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610295416445/GDoBjfs4q.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p>cover: /static/vim-replace-visual-star-xmas2020.png
cover_image: https://waylonwalker.com//static/vim-replace-visual-star.png
published: true
status: published
tags:</p>
<ul>
<li>vim</li>
<li>linux</li>
<li>bash
templateKey: blog-post
title: Vim Replace Visual Star</li>
</ul>
<hr />
<p>Replacing text based on what's in the current search register is a quite handy tool that I use often.  I believe I picked this tip up from Nic Janetakis, check out his YouTube channel for some amazing vim tips.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=fP_ckZ30gbs&amp;feature=emb_title">https://www.youtube.com/watch?v=fP_ckZ30gbs&amp;feature=emb_title</a></div>
<p>If there is one thing that I Like most about vim it's the ability to hack on it and make it work well for you.</p>
<h2 id="replacing-text-in-vim">Replacing text in vim</h2>
<p>Vim can often be a bit verbose, but that's ok because we can hack on it, and make our own shortcuts and keybindings.  For instance, finding and replacing text requires using a command at the vim command-line <code>:</code>.  Replacing foo with
bar looks like this <code>:%s/foo/bar/g</code>, the final g means all of the foos, not just the first one on the line.</p>
<h2 id="making-it-better">making it better</h2>
<p>I have a keybinding in my <code>init.vim</code> that will allow me to search for a pattern with the usual <code>/</code> character, page through them as normal with <code>n</code> and <code>N</code>, but when I press <code>&lt;C-R&gt;</code> it will populate the replace command for me so that all I need to do is type out the new text.</p>
<pre><code class="lang-vim">nnoremap &lt;c-r&gt; :%s/&lt;C-R&gt;///g&lt;Left&gt;&lt;Left&gt;
</code></pre>
<h2 id="note-on-the-lessc-rgreater">Note on the <code>&lt;C-R&gt;/</code></h2>
<p>In command mode <code>:</code> vim allows you to paste any text from any register into the current command.  The <code>&lt;C-R&gt;/</code> will paste the text from the current search register into the command.</p>
<p><code>&lt;C-R&gt;</code> in command mode can paste text from any register, you can see what registers are in use with the <code>:reg</code> command.  There are a lot of them and many get populated automatically as you yank text or create macros.</p>
<blockquote>
<p>Also see how to use  to save macros to key bindings easily</p>
</blockquote>
<table><tr><td>
<a class="onelinelink" href="https://waylonwalker.com/save-vim-macro/">
<img src="https://waylonwalker.com/static/de331984b5e3d37beacd574593394ca3/630fb/save-vim-macro-xmas2020.png" alt="article cover" />
<div class="right">
<h2>Save Vim Macro</h2>
<p>
If you are like me, you have created a macro or two that is pure glory, and you forget how you made it after a day or so
</p>
<p>
<span class="read-more">read more</span>  waylonwalker.com
</p>
</div>
</a>
</td></tr></table>

]]></content:encoded></item><item><title><![CDATA[If Tmux]]></title><description><![CDATA[I do much of my work from tmux, I love it so much that I want to setup some functionality that puts me in tmux even if I didnt ask for it. Bash function to…]]></description><link>https://h.waylonwalker.com/if-tmux</link><guid isPermaLink="true">https://h.waylonwalker.com/if-tmux</guid><category><![CDATA[Linux]]></category><category><![CDATA[cli]]></category><category><![CDATA[command line]]></category><category><![CDATA[Bash]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Sat, 09 Jan 2021 16:57:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610211398739/axJSN3fME.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I do much of my work from tmux, I love it so much that I want to setup some functionality that puts me in tmux even if I didnt ask for it.</p>
<h2 id="bash-function">Bash Function</h2>
<p>Bash function to check if the shell is in a tmux session.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">in_tmux</span></span> () {
  <span class="hljs-keyword">if</span> [ -n <span class="hljs-string">"<span class="hljs-variable">$TMUX</span>"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">return</span> 0
  <span class="hljs-keyword">else</span>
    <span class="hljs-built_in">return</span> 1
  <span class="hljs-keyword">fi</span>
  }
</code></pre>
<h2 id="using-the-bash-function">Using the bash function</h2>
<p>I often open up vim to do some quick edits, but before I know it I have several splits open and I need access to another shell utility, but I forgot to start in tmux.  This function makes sure that I start in tmux every time.</p>
<p>Using <code>if_tmux</code> to ensure vim is opened in tmux.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">vim</span></span> () { 
  in_tmux \
    &amp;&amp; nvim \
    || bash -c <span class="hljs-string">"\
    tmux new-session -d;\
    tmux send-keys nvim Space +GFiles C-m;\
    tmux -2 attach-session -d;
    "</span>
  }
</code></pre>
<p>I am not quite sure if this is proper use of the <code>&amp;&amp;</code> and <code>||</code>, let me know if you have a better way to do one thing if <code>in_tmux</code> returns true and another if it returns faslse.</p>
]]></content:encoded></item><item><title><![CDATA[Custom Ipython Prompt]]></title><description><![CDATA[I've grown tired of the standard ipython prompt as it doesn't do much to give me any useful information. The default one gives out a line number that only…]]></description><link>https://h.waylonwalker.com/custom-ipython-prompt</link><guid isPermaLink="true">https://h.waylonwalker.com/custom-ipython-prompt</guid><category><![CDATA[Python]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Fri, 08 Jan 2021 14:53:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610116419854/RUig6LY0A.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I've grown tired of the standard <code>ipython</code> prompt as it doesn't do much to give me any useful information.  The default one gives out a line number that only seems to add anxiety as I am working on a simple problem and see that number grow to several hundred.  I start to question my ability 🤦‍♂️.</p>
<h2 id="configuration">Configuration</h2>
<p>If you already have an <code>ipython</code> config you can move on otherwise check out this post on creating an <code>ipython</code> config.</p>
<p><a class="onelinelink" href="https://waylonwalker.com/ipython-config/">
<img src="https://waylonwalker.com/static/63e488bb5ac06727314c998f0ef9066b/630fb/ipython-config-xmas2020.png" alt="article cover" /></a></p>
<p></p><div class="right">
    <h2>Ipython-Config</h2>
    <p>
    I use my ipython terminal daily.  It's my go to way of running python most of the time.  After you use it for a little b
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
<p></p>
<h2 id="the-dream-prompt">The Dream Prompt</h2>
<p>I want something similar to the starship prompt I am using in the shell.  I want to be able to quickly see my python version, environment name, and git branch.</p>
<ul>
<li>python version</li>
<li>active environment</li>
<li>git branch</li>
</ul>
<p><img src="https://waylonwalker.com/my-zsh-prompt.png" alt="my zsh prompt" /></p>
<blockquote>
<p>This is my <code>ZSH</code> prompt I am using for inspiration</p>
</blockquote>
<h2 id="basic-prompt">Basic Prompt</h2>
<p>This is mostly boilerplate that I found from various google
searches, but this gets me a basic green chevron as my prompt.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> IPython.terminal.prompts <span class="hljs-keyword">import</span> Prompts, Token

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyPrompt</span>(<span class="hljs-params">Prompts</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
        <span class="hljs-keyword">return</span> [ ( Token.Prompt, <span class="hljs-string">"❯ "</span>,), ]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">out_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
        <span class="hljs-keyword">return</span> []

ip = get_ipython()
ip.prompts = MyPrompt(ip)
</code></pre>
<blockquote>
<p>The rest of this post will build off of this boilerplate and add
to the <code>in_prompt_tokens</code> method of MyPrompt</p>
</blockquote>
<h2 id="colors">Colors</h2>
<p>I mostly set the colors of my prompt throughout this post by guessing and trying different attributes under the Token.</p>
<h2 id="red-if-error">Red If Error</h2>
<p>I found that the <code>Prompts</code> subclass has many of the same methods as the python object, so I would often use that for inspection.  Looking through the python class I found a boolean under <code>shell.last_execution_succeeded</code> that would give me if the last execution was successful or not.  I did an inline if statement to set the color to a <code>Token.Generic.Error</code> if this was false.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
    <span class="hljs-keyword">return</span> [
        (
            Token.Prompt
            <span class="hljs-keyword">if</span> self.shell.last_execution_succeeded
            <span class="hljs-keyword">else</span> Token.Generic.Error,
            <span class="hljs-string">"❯ "</span>,
        ),
    ]
</code></pre>
<h2 id="python-version">Python Version</h2>
<p>Next up to list out the python version that is running.  I grabbed the version from <code>platform.python_version</code>, this seemed to get me the most concise version that I was looking for to match the starship prompt.</p>
<p><em>update imports</em></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> platform <span class="hljs-keyword">import</span> python_version
</code></pre>
<p><em>update prompt</em></p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
    <span class="hljs-keyword">return</span> [
        (
            (Token.Name.Class, <span class="hljs-string">"v"</span> + python_version()),
            (Token, <span class="hljs-string">" "</span>),
            Token.Prompt
            <span class="hljs-keyword">if</span> self.shell.last_execution_succeeded
            <span class="hljs-keyword">else</span> Token.Generic.Error,
            <span class="hljs-string">"❯ "</span>,
        ),
    ]
</code></pre>
<h2 id="python-environment">Python environment</h2>
<p>Since I use conda for my environments I chose to pull the name of the environment from the <code>CONDA_DEFAULT_ENV</code> environment variable that is set by conda when you change your environment.</p>
<p><em>update imports</em></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> platform <span class="hljs-keyword">import</span> python_version
<span class="hljs-keyword">import</span> os
</code></pre>
<p><em>update prompt</em></p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
    <span class="hljs-keyword">return</span> [
        (
            (Token.Prompt, <span class="hljs-string">"©"</span>),
            (Token.Prompt, os.environ[<span class="hljs-string">"CONDA_DEFAULT_ENV"</span>]),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Name.Class, <span class="hljs-string">"v"</span> + python_version()),
            (Token, <span class="hljs-string">" "</span>),
            Token.Prompt
            <span class="hljs-keyword">if</span> self.shell.last_execution_succeeded
            <span class="hljs-keyword">else</span> Token.Generic.Error,
            <span class="hljs-string">"❯ "</span>,
        ),
    ]
</code></pre>
<h2 id="git-branch">Git Branch</h2>
<p>Git branch was a bit tricky.  There might be a better way to get it, but I was sticking with things I knew, the git cli and python.  I did need to do a bit of googling to figure out that git has a
<code>--show-current</code> option.</p>
<p><em>getting the current git branch</em></p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_branch</span>():</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-keyword">return</span> (
            subprocess.check_output(
                <span class="hljs-string">"git branch --show-current"</span>, shell=<span class="hljs-literal">True</span>, stderr=subprocess.DEVNULL
            )
            .decode(<span class="hljs-string">"utf-8"</span>)
            .replace(<span class="hljs-string">"\n"</span>, <span class="hljs-string">""</span>)
        )
    <span class="hljs-keyword">except</span> BaseException:
        <span class="hljs-keyword">return</span> <span class="hljs-string">""</span>
</code></pre>
<p><strong>NOTE</strong>  If this is run form a non-git directory you will quickly find git errors after every command as this function tries to ask for the git branch. Sending stderr to devnull will avoid this inconvenience.</p>
<p><em>add git branch to prompt</em></p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
    <span class="hljs-keyword">return</span> [
        (
            (Token.Generic.Subheading, <span class="hljs-string">"↪"</span>),
            (Token.Generic.Subheading, get_branch()),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Prompt, <span class="hljs-string">"©"</span>),
            (Token.Prompt, os.environ[<span class="hljs-string">"CONDA_DEFAULT_ENV"</span>]),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Name.Class, <span class="hljs-string">"v"</span> + python_version()),
            (Token, <span class="hljs-string">" "</span>),
            Token.Prompt
            <span class="hljs-keyword">if</span> self.shell.last_execution_succeeded
            <span class="hljs-keyword">else</span> Token.Generic.Error,
            <span class="hljs-string">"❯ "</span>,
        ),
    ]
</code></pre>
<h2 id="add-current-directory-name">Add current directory name</h2>
<p>I am a big fan of <code>pathlib</code> so that is what I will use to get the path. If I planned on using python <code>&lt;3.6</code> I would probably use something else, but this is what I know and I can't think of the last time I used <code>&lt;3.6&gt;</code> for anything.</p>
<p><em>update imports</em></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
</code></pre>
<p><em>add git branch to prompt</em></p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
    <span class="hljs-keyword">return</span> [
        (
            (Token, <span class="hljs-string">""</span>),
            (Token.OutPrompt, Path().absolute().stem),
            (Token, <span class="hljs-string">""</span>),
            (Token.Generic.Subheading, <span class="hljs-string">"↪"</span>),
            (Token.Generic.Subheading, get_branch()),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Prompt, <span class="hljs-string">"©"</span>),
            (Token.Prompt, os.environ[<span class="hljs-string">"CONDA_DEFAULT_ENV"</span>]),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Name.Class, <span class="hljs-string">"v"</span> + python_version()),
            (Token, <span class="hljs-string">" "</span>),
            Token.Prompt
            <span class="hljs-keyword">if</span> self.shell.last_execution_succeeded
            <span class="hljs-keyword">else</span> Token.Generic.Error,
            <span class="hljs-string">"❯ "</span>,
        ),
    ]
</code></pre>
<h2 id="final-script">Final Script</h2>
<p>That's it for my prompt at the moment.  I have been using it for about a week. It seems to have everything I need so far and skips on things I don't need.</p>
<p>Enjoy the full script.</p>
<p><em>my final prompt</em></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> IPython.terminal.prompts <span class="hljs-keyword">import</span> Prompts, Token
<span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> platform <span class="hljs-keyword">import</span> python_version
<span class="hljs-keyword">import</span> subprocess

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_branch</span>():</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-keyword">return</span> (
            subprocess.check_output(
                <span class="hljs-string">"git branch --show-current"</span>, shell=<span class="hljs-literal">True</span>, stderr=subprocess.DEVNULL
            )
            .decode(<span class="hljs-string">"utf-8"</span>)
            .replace(<span class="hljs-string">"\n"</span>, <span class="hljs-string">""</span>)
        )
    <span class="hljs-keyword">except</span> BaseException:
        <span class="hljs-keyword">return</span> <span class="hljs-string">""</span>


<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyPrompt</span>(<span class="hljs-params">Prompts</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">in_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
        <span class="hljs-keyword">return</span> [
            (Token, <span class="hljs-string">""</span>),
            (Token.OutPrompt, Path().absolute().stem),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Generic.Subheading, <span class="hljs-string">"↪"</span>),
            (Token.Generic.Subheading, get_branch()),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Prompt, <span class="hljs-string">"©"</span>),
            (Token.Prompt, os.environ[<span class="hljs-string">"CONDA_DEFAULT_ENV"</span>]),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Name.Class, <span class="hljs-string">"v"</span> + python_version()),
            (Token, <span class="hljs-string">" "</span>),
            (Token.Name.Entity, <span class="hljs-string">"ipython"</span>),
            (Token, <span class="hljs-string">"\n"</span>),
            (
                Token.Prompt
                <span class="hljs-keyword">if</span> self.shell.last_execution_succeeded
                <span class="hljs-keyword">else</span> Token.Generic.Error,
                <span class="hljs-string">"❯ "</span>,
            ),
        ]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">out_prompt_tokens</span>(<span class="hljs-params">self, cli=None</span>):</span>
        <span class="hljs-keyword">return</span> []


ip = get_ipython()
ip.prompts = MyPrompt(ip)
</code></pre>
<p>Once we have added this, here is the final result.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/i/nfhhhtlkvu2vwmq7n0mb.png" alt="Final Result" /></p>
]]></content:encoded></item><item><title><![CDATA[Ipython-Config]]></title><description><![CDATA[I use my ipython terminal daily. It's my go-to way of running python most of the time. After you use it for a little bit you will probably want to set up a…]]></description><link>https://h.waylonwalker.com/ipython-config</link><guid isPermaLink="true">https://h.waylonwalker.com/ipython-config</guid><category><![CDATA[Python]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Thu, 07 Jan 2021 21:08:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1610053652326/CRLg0WYXgI.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I use my ipython terminal daily.  It's my go-to way of running python most of
the time.  After you use it for a little bit you will probably want to set up a
bit of your own configuration.</p>
<h2 id="install-ipython">install ipython</h2>
<p>Activate your virtual environment of choice and pip install it.  Any time you are running your project in a virtual environment, you will need to install ipython inside it to access those packages from ipython.</p>
<pre><code class="lang-bash">pip install ipython
</code></pre>
<blockquote>
<p>You are using a virtual environment right? Virtual environments like venv or conda can save you a ton of pain down the road.</p>
</blockquote>
<h2 id="profiledefault">profile_default</h2>
<p>When you install ipython you start out with no config at all.  Running <code>ipython profile create</code> will start a new profile called <code>profile_default</code> that contains all of the default configuration.</p>
<pre><code>ipython profile <span class="hljs-keyword">create</span>
</code></pre><p>This command will create a directory <code>~/.ipython/profile_default</code></p>
<h2 id="multiple-configurations">multiple configurations</h2>
<p>You can run multiple configurations by naming them with <code>ipython profile create [profile_name]</code> This command will create a directory <code>~/.ipython/[profile_name]</code></p>
<pre><code>ipython profile <span class="hljs-keyword">create</span> my_profile
ipython <span class="hljs-comment">--profile=my-profile</span>
</code></pre><h2 id="startup">startup</h2>
<p>Inside the profile, there will be a startup directory <code>~/.ipython/profile_default/startup</code>.  Ipython will execute each of the files in this directory on startup.  This is particularly handy to create custom prompts, search, or import packages automatically for certain profiles.</p>
<p><a class="onelinelink" href="https://waylonwalker.com/custom-ipython-prompt/">
<img src="https://waylonwalker.com/custom-ipython-prompt-xmas2020.png" alt="article cover" /></a></p>
<p></p><div class="right">
    <h2>Custom Ipython Prompt</h2>
    <p>
    I've grown tired of the standard ipython prompt as it doesn't do much to give me any useful information.  The default on
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
<p></p>
<blockquote>
<p>This post creates a custom ipython prompt by creating a <code>~/.ipython/profile_default/startup/prompt.py</code> file.</p>
</blockquote>
<h2 id="ipythonconfigpy">ipython_config.py</h2>
<p>There are tons of options that are in the <code>ipython_config.py</code> file.  My favorite is to automatically enable my favorite magic command autoreload.</p>
<p><a class="onelinelink" href="https://waylonwalker.com/autoreload-ipython/">
<img src="https://waylonwalker.com/static/de227ffcb7da2e5c1170a8434163bec9/630fb/autoreload-ipython-xmas2020.png" alt="article cover" /></a></p>
<p></p><div class="right">
    <h2>Autoreload in Ipython</h2>
    <p>
    Autoreload in python
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
<p></p>
<pre><code class="lang-python">c.InteractiveShellApp.extensions = [<span class="hljs-string">'autoreload'</span>
c.InteractiveShellApp.exec_lines = []<span class="hljs-string">'%autoreload 2'</span>]
c.InteractiveShellApp.exec_lines.append(<span class="hljs-string">'print("Warning: disable autoreload in ipython_config.py to improve performance.")'</span>)
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Windowing Python Lists]]></title><description><![CDATA[In python data science we often will reach for pandas a bit more than necessary. While pandas can save us so much there are times where there are…]]></description><link>https://h.waylonwalker.com/windowing-python-lists</link><guid isPermaLink="true">https://h.waylonwalker.com/windowing-python-lists</guid><category><![CDATA[Python]]></category><dc:creator><![CDATA[Waylon Walker]]></dc:creator><pubDate>Wed, 06 Jan 2021 14:48:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1609944446177/6T21NR-7Z.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In python data science we often will reach for pandas a bit more than necessary. While pandas can save us so much there are times where there are alternatives that are much simpler.  The <code>itertools</code> and <code>more-itertools</code> are full of cases of this.</p>
<p>This post is a walkthrough of me solving a problem with <code>more-itertools</code> rather than reaching for a for loop, or pandas.</p>
<p>I am working on a  one-line-link expander for my blog.  I ended up doing it, just by modifying the markdown with python.  I first split the post into lines with <code>content.split('\n')</code>, then look to see if the line appears to be just a link.  One more safety net that I wanted to add was to check if there was whitespace around the line, this could not simply be done in a list comprehension by itself.  I need just a bit of knowledge of the surrounding lines, enter <code>more-itertools</code>.</p>
<h2 id="simplified-rendering-function">simplified rendering function</h2>
<p>I have a function that will check to see if the line should be expanded, then render the correct template.  First step is to check 
 if the line contains no spaces and starts with <code>https</code>, if it
does render the template. </p>
<p>The real expand_line function uses requests to pull some metadata about the post to insert into the card, more on that in another post.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">expand_line</span>(<span class="hljs-params">line</span>):</span>
   <span class="hljs-string">"""
   Check if the line should be expanded then render a template
   """</span>

   <span class="hljs-keyword">if</span> <span class="hljs-string">' '</span> <span class="hljs-keyword">in</span> line <span class="hljs-keyword">and</span> line.startswith(<span class="hljs-string">'https'</span>):
      <span class="hljs-keyword">return</span> line

  <span class="hljs-keyword">return</span> <span class="hljs-string">f"&lt;a href='<span class="hljs-subst">{line}</span>' class='card'&gt;"</span>
</code></pre>
<h2 id="initial-implementation">initial implementation</h2>
<p>My first implementation was to load in the content as a single string and use a list comprehension to expand each line.</p>
<pre><code class="lang-python">expanded_content = <span class="hljs-string">"\n"</span>.join(
    [expand_line(line) <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> content]
)
</code></pre>
<h2 id="the-issue">The issue.</h2>
<p>Sometimes I write my posts in vim without wordwrap on and just use <code>gq</code> to wrap them to the current <code>textwidth</code>.  If I have a link that happens to be really long it ends up on its own line.  I do not want one line links to expand if they are in the middle of a paragraph.</p>
<pre><code class="lang-markdown"><span class="hljs-section">## sample paragraph</span>

This is a paragraph that has a really long link
https://waylonwalker.com/not-a-real-link-just-a-silly-example-for-this-post
inside of it that ends up on its own line
</code></pre>
<blockquote>
<p>I need a bit of knowledge about the lines around the link.</p>
</blockquote>
<h2 id="windowing">windowing</h2>
<p><code>more-itertools</code> comes with a windowing function that will slide over an iterable with a width of n.</p>
<pre><code class="lang-python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> more_itertools <span class="hljs-keyword">import</span> windowed
<span class="hljs-meta">&gt;&gt;&gt; </span>all_windows = windowed([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>], <span class="hljs-number">3</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>list(all_windows)
[(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>), (<span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>), (<span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>)])]
</code></pre>
<blockquote>
<p>this example is copied from the <a target="_blank" href="https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.windowed">more-itertools docs</a></p>
</blockquote>
<h2 id="sliding-through-my-content">sliding through my content</h2>
<p><em>in chunks of three</em></p>
<p>The one extra that we need is padding at the front and back of the list so that we ensure that every value ends up in the middle position at least once.</p>
<pre><code class="lang-python">expanded_content = <span class="hljs-string">"\n"</span>.join(
    [expand_line(*line) <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> windowed(<span class="hljs-string">f'\n<span class="hljs-subst">{content}</span>\n'</span>, <span class="hljs-number">3</span>)]
)
</code></pre>
<p><strong>meta</strong>: 👇  This is an example of a one-line-link card that we are trying to achieve.</p>
<p><a class="onelinelink" href="https://waylonwalker.com/python-args-kwargs/">
<img src="https://waylonwalker.com/static/8c73a5e2f384efdcd17762c52faff94f/630fb/python-args-kwargs-xmas2020.png" alt="article cover" /></a></p>
<p></p><div class="right">
    <h2>understanding python <em>args and **kwargs</em></h2>
    <p>
    Python `args<code>and</code><strong>kwargs` are super useful tools, that when used properly can make you code much simpler and easier to maintain.  Large manual conversions from a dataset to function arguments can be packed and unpacked into lists or dictionaries. Beware though, this power </strong>can** lead to some really unreadable/unusable code if done wrong.
    </p>
    <p>
    <span class="read-more">read more</span>  waylonwalker.com
    </p>
</div>
<p></p>
<blockquote>
<p>Not sure what *line is, check out this article.</p>
</blockquote>
<h2 id="update-expandline">update expand_line</h2>
<p>Now that we are calling <code>expand_line</code> with all three lines.  We need to update the function signature and add a guarding clause to return early if before or after lines are not blank.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">expand_line</span>(<span class="hljs-params">before, line, after</span>):</span>
   <span class="hljs-string">"""
   Check if line should be expanded then render a template
   """</span>
    <span class="hljs-keyword">if</span> before != <span class="hljs-string">''</span> <span class="hljs-keyword">and</span> after != <span class="hljs-string">''</span>:
      <span class="hljs-keyword">return</span> line


    <span class="hljs-keyword">if</span> <span class="hljs-string">' '</span> <span class="hljs-keyword">in</span> line <span class="hljs-keyword">and</span> line.startswith(<span class="hljs-string">'https'</span>):
      <span class="hljs-keyword">return</span> line

    <span class="hljs-keyword">return</span> <span class="hljs-string">f"&lt;a href='<span class="hljs-subst">{line}</span>' class='card'&gt;"</span>
</code></pre>
<p>Hope you liked this walk-through of solving a problem I had with <code>more-itertools</code>, If you learned something be sure to share it.</p>
]]></content:encoded></item></channel></rss>