<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
 xmlns:content="http://purl.org/rss/1.0/modules/content/"
 xmlns:wfw="http://wellformedweb.org/CommentAPI/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
 xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
 xmlns:georss="http://www.georss.org/georss"
 xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
 xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<atom:link href="https://www.ballpointcarrot.net/posts/rss.xml" rel="self" type="application/rss+xml" />
<title>Ballpointcarrot.net</title>
<link>https://www.ballpointcarrot.net</link>
<description><![CDATA[Personal blog with some tech, some ranting and random extra bits.]]></description>
<language>en</language>
<lastBuildDate>Fri, 10 Apr 2026 21:47:53 -0700</lastBuildDate>
<generator>Emacs 30.2 org-publish-rss.el 0.8</generator>
<item>
<title>Reinvesting (in this space)</title>
<link>https://www.ballpointcarrot.net/posts/2025-08-13-reinvesting.html</link>
<pubDate>Wed, 13 Aug 2025 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2025-08-13-reinvesting.html</guid>
<description>
<![CDATA[<p>
It's been nearly two years since my last post, and I'm due for a status update.
Seems like it's standard practice for me to remember that this exists every
couple of years, so I'm glad for anyone willing to read and be patient with me.
</p>
<div id="outline-container-org0eb9249" class="outline-2">
<h2 id="org0eb9249"><span class="section-number-2">1.</span> What's changed?</h2>
<div class="outline-text-2" id="text-1">
<p>
2024 was a tumultuous year. Shortly after my last post (still technically 2023)
I was part of my second RIF-style layoff, and hit the job market once again. I
found my way into a contract job working primarily making a new project
scaffolder and CI/CD pipeline via AWS CDK, but the lack of provided insurance,
low likelihood for conversion to FTE, and the lower pay range for that company
soon had me scouring the market for better options. I started digging around and
made the fool's choice to jump into an AI-based startup.
</p>

<p>
Now I'm not going to name and shame, but that place did not understand the
concept of a proper work/life balance. I could tell fairly early on that they
were more used to burning out their internal devops people rather than allow
them time to prepare useful solutions (also why I think the person before me
doing the same work also left? <i>mock shocked face goes here</i>).
</p>

<p>
I managed to last there for 4-5 months; the same day that I got the notice that
my current company was going to hire me, my manager was not asking me, but
<b>telling me</b> about the upcoming weekend's worth of work that they were handing
me that day (a Tuesday, so not a lot of notice) in order to help replace a core
system library within their monorepo. Imagine jacking up the Great Pyramids at
Giza, only to replace the bottom layer, and hope that when you drop it back
down, it doesn't generate any problems. Fortunately, after informing said
manager about the nascent change in employment, I suddenly didn't need to do the
weekend work, and they offboarded me the day after, which IMO was fairly abrupt,
but I wasn't too sad about having the extra days to &#x2026; not deal with their
shit. :D 
</p>

<p>
I've been with <code>$CUR_JOB</code> since October, working on an internal portal for
tracking the software created by the company. It's all based in <a href="https://backstage.io/docs">Backstage</a>,
which is something I grew familiar with at Startup #2. The team is solid, if not
a little on the less-experienced side, but that gives me the ability to serve as
a mentor in places (and further extol the virtues encoded in <i><a href="https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/">The Pragmatic Programmer</a></i>, which anyone in my past work history would tell you I quote
just a little <i>too</i> much).
</p>
</div>
</div>
<div id="outline-container-org8737fc0" class="outline-2">
<h2 id="org8737fc0"><span class="section-number-2">2.</span> Any new site features?</h2>
<div class="outline-text-2" id="text-2">
<p>
I've enjoyed the new styles, so that is sticking around. Page loads are super
snappy, it is (or at least seems to be?) easy to follow, and it doesn't involve
React. :D
</p>

<p>
I've added a <a href="https://www.ballpointcarrot.net/posts/../../pages/uses.html">Uses page</a> to allow keeping an up-to-date list of the things
that I make use of on a daily basis. I try to keep this up to date, and it has a
timestamp of the last update (so <i>technically</i> I have updated since two
years back, just not longform&#x2026;). I'm hoping that as I surface more of the
things that I use frequently, it prompts me to use this space more frequently,
too.
</p>

<p>
The <a href="https://www.ballpointcarrot.net/posts/../../pages/social.html">social</a> page also has had updates, as I've moved my Fediverse home over
to the <i>awesome</i> <a href="https://home.omg.lol">omg.lol</a> community. It's a group of people who seem to
enjoy the simpler times of the Internet, including IRC, a <a href="https://url.town">web directory / link board</a>, and simple approaches to personal content (eg: <a href="https://some.pics">images</a>). I still
enjoy doing self-hosted things, but I may look into ways to more tightly weave
those systems and this space together. If nothing else, it's leading me to think
about how I use my own internet space, and spurring me on to do more investment
in my own domains (like this one!).
</p>

<p>
Most recently, I've been migrating all of my code that I care about (sadly far
less than the total repo count) away from github/gitlab, and into <a href="https://codeberg.org">codeberg</a>.
I don't need my data feeding AI systems or providing extra traffic to platforms
with questionable moral steering (the GitLab exec <a href="https://www.msn.com/en-us/money/companies/companies-warn-investors-that-doge-s-federal-cuts-might-hurt-business/ar-AA1Ay925">professing his support of
DOGE at the bottom of this article</a> was a pretty quick call for me to exit).
</p>
</div>
</div>
<div id="outline-container-org95c9390" class="outline-2">
<h2 id="org95c9390"><span class="section-number-2">3.</span> What's next?</h2>
<div class="outline-text-2" id="text-3">
<p>
I'm currently getting ready to do an internal networking upgrade to boost to
2.5gbps traffic throughout (including at the uplink). Once that's complete, I'll
be re-re-re-revamping my homelab (which I'm going to try to do as a public
exercise). Hoping that means more content here. :D
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Dusting Off The Cobwebs</title>
<link>https://www.ballpointcarrot.net/posts/2023-09-26_dusting-off-the-cobwebs.html</link>
<pubDate>Mon, 26 Jun 2023 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2023-09-26_dusting-off-the-cobwebs.html</guid>
<description>
<![CDATA[<p>
I've been meaning to come back to this space and give it the standard periodic cleaning (as <a href="https://www.ballpointcarrot.net/posts/file:///posts/im-still-here">has been done</a> in <a href="https://www.ballpointcarrot.net/posts/file:///posts/well-i-shouldve-been">the past</a> a <a href="https://www.ballpointcarrot.net/posts/file:///posts/yearly-refresh-time">couple of times</a>).
</p>
<div id="outline-container-orgc116c8c" class="outline-2">
<h2 id="orgc116c8c"><span class="section-number-2">1.</span> What's changed?</h2>
<div class="outline-text-2" id="text-1">
<p>
Since the last post in 2021 (which I'm super proud of, it was the
best-performing post I've had), I've helped raise a kid to 2 years old (he was
1 month old when that last post landed), changed jobs (went through a layoff,
and found new employment elsewhere); my primary social media platform was
purchased by a person with more money and ego than sense, and has turned it
into a cesspool of fascist propaganda and hate speech; and the world has
continued dealing with the continuing COVID pandemic. 
</p>
</div>
</div>
<div id="outline-container-org61219df" class="outline-2">
<h2 id="org61219df"><span class="section-number-2">2.</span> No, I mean what's changed on the <b>site</b>?</h2>
<div class="outline-text-2" id="text-2">
<p>
Oh, right.
</p>

<p>
Well, the very obvious one is there's a new style and theme attached. Gone is
the smooth lines and colorful graphics, and now we have a simple text-forward
site. <span class="underline">This is by choice.</span> I've stumbled down a rabbit hole of blog posts
containing concerns that "web pages are too large", and some <a href="https://www.reddit.com/r/webdev/comments/mkewwn/this_motherfucking_website_no_seriously_a_must/gtfjtrt/">satirical and expletive-laden</a>
examples to the contrary.
</p>

<p>
The overall sense that I got from the above is that, the less amount of
unnecessary data being requested by your users, the better. So, the
simplification of this site tracks with that goal. We have a simple font
selection set (which will render mostly the same); the colors are inspired by
the Catppuccin color theme (which I'm using all over my tools, it's seriously
great), and I've tried to limit image usage to only the necessary places.
</p>
</div>
</div>
<div id="outline-container-org788bc1c" class="outline-2">
<h2 id="org788bc1c"><span class="section-number-2">3.</span> What's next?</h2>
<div class="outline-text-2" id="text-3">
<p>
Being a parent sucks a lot of the free time away from tinkering, so likely not
a ton. That said, I've admired what <a href="https://werd.io">Ben Werdmuller</a> does, and
I've been a fan of the Indieweb movement in general, so I'll likely do some work to 
enable more of this site to use Indieweb-related functionality. I think I've
taken a bit of a step back with this recent change, and so I'll do some cleanup
in the near term to get be back to some level of microformats usage (right now,
I'm just wanting to get the style change out the door, and I'll iterate on that
in later days).
</p>

<p>
And hey, <a href="https://www.ballpointcarrot.net/posts/file:///tags/advent-of-code">Advent of Code</a> comes back here in December, so I'll maybe have some
things to write there. Gonna have a think on which language to use&#x2026;
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Rust, by a non-systems programmer</title>
<link>https://www.ballpointcarrot.net/posts/2015-03-08-rust-non-systems-programmer.html</link>
<pubDate>Sun, 08 Mar 2015 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2015-03-08-rust-non-systems-programmer.html</guid>
<description>
<![CDATA[<p>
I've been working on trying to teach myself Rust for the past 4 months or so. It's been slow-going, because I'm having to
teach myself things that would have been common knowledge for anyone with previous experience doing systems-level programming
in C or C++. Instead, this will be more or less of a brain dump of a rubyist that is picking up some systems-level knowledge.
</p>
<div id="outline-container-org2b81062" class="outline-2">
<h2 id="org2b81062"><span class="section-number-2">1.</span> String I/O</h2>
<div class="outline-text-2" id="text-1">
<p>
Coming from a scripting language like Ruby, basic string input and output is fairly straightforward:
</p>

<div class="org-src-container">
<pre class="src src-ruby">puts "How old are you?"
age = gets.strip
puts "You've said #{age} years, which is #{(age.to_i*365.25).to_i} days."
</pre>
</div>

<p>
In Rust, this becomes significantly more involved:
</p>

<div class="org-src-container">
<pre class="src src-rust">#![feature(old_io)]
use std::old_io::stdin;
use std::str::FromStr;

fn main() {
    println!("How old are you?");
    let mut input = match stdin().read_line() {
        Ok(v) =&gt; v,
        Err(_) =&gt; panic!("Couldn't get STDIN!")
    };
    input = input.trim()
    let age_days:usize = match FromStr::from_str(input.trim()) {
        Ok(v) =&gt; (v * 365.25) as usize,
        Err(_) =&gt; panic!("Couldn't convert to usize!")
    };

    println!("You've said {} years, which is {} days", input.trim(), age_days)
}
</pre>
</div>

<p>
In Rust, the placement of the variable in stack or heap memory is important to the Rust compiler's understanding of
</p>

<ul class="org-ul">
<li>how long the variable lives (it's "lifetime"), and</li>
<li>who owns the memory that the variable uses (the "ownership").</li>
</ul>

<p>
There are <a href="https://doc.rust-lang.org/book/ownership.html">plenty</a>
<a href="http://rustbyexample.com/move.html">of</a>
<a href="https://doc.rust-lang.org/book/strings.html">posts</a>
<a href="http://nercury.github.io/rust/guide/2015/01/19/ownership.html">available</a>
which will explain these terms to enough detail; for practical purposes, we have to manage two separate types of strings.
Each type gets used in subtly different ways, but will cause you some problems when building out programs.
</p>

<p>
The more commonly used string type is <code>&amp;str</code>, also known as the "string slice". This string is allocated to the stack, and
is accessed through a reference to the stored string, much like a C-like character array.
</p>

<p>
The second string type, <code>String</code>, is used when you want to maintain ownership over the string value. <code>String</code> s are allocated on the heap, and
are "growable" - that is, they can be added to as mutable variables.
</p>

<p>
Be careful to understand what type of string you'll be dealing with; functions generally operate on the more general <code>&amp;str</code> type,
so you may need to convert back and forth between the two types with <code>String::as_slice</code> or <code>"".to_string()</code>.
</p>
</div>
<div id="outline-container-org942b74b" class="outline-3">
<h3 id="org942b74b"><span class="section-number-3">1.1.</span> Handling input possibilities</h3>
<div class="outline-text-3" id="text-1-1">
<p>
Because Rust does not have a built-in concept of "null", you cannot assign a non-guaranteed value to a variable. Instead,
Rust provides the Result type, which wraps the successful value in an <code>Ok()</code>-wrapped response; otherwise, an error will be
provided with the relevant error details.
</p>

<p>
This means that reads from <code>STDIN</code> will be quite a bit more verbose than you're used to,
but the compiler now forces the checking of invalid situations for a value, which can take more off of your mind.
</p>
</div>
</div>
<div id="outline-container-orgaa5d260" class="outline-3">
<h3 id="orgaa5d260"><span class="section-number-3">1.2.</span> Changing I/O Library</h3>
<div class="outline-text-3" id="text-1-2">
<p>
One of the last changes to the Rust Standard Library was an overhaul of the IO subsystem. Most documentation (including the
official docs) request that you continue to use <code>std::old_io</code> until the overhaul is complete.
</p>
</div>
</div>
</div>
<div id="outline-container-orgbc59b91" class="outline-2">
<h2 id="orgbc59b91"><span class="section-number-2">2.</span> Memory Management</h2>
<div class="outline-text-2" id="text-2">
<p>
One of the larges differences between the two languages is the presence/absence of a Garbage Collector. In Ruby (and other GC'd
languages), the GC is used to clean up expired references from the runtime, to periodically free unused memory from the
application being run.
</p>

<p>
In Rust, there is no GC. Instead, the compiler has a notion of "ownership," as we discussed earlier. Check out the following
snippet:
</p>

<div class="org-src-container">
<pre class="src src-rust">let x = Box::new(5);
{
    let y = x;
}

println!("x == {}", x);
</pre>
</div>

<p>
In line 1, we create a new heap-allocated variable, and store 5 into it. Because it's on the heap, the value of x is really
a pointer to the memory location of the "Box" - the owned variable. Now, in line 3, we create the variable y, and store x's value
into it; this is considered by the Rust compiler to be a "move" - both pointers point to the data, but rust treats y as the
new owner of the Box, as x has transferred ownership. Because of this, line 6 fails to compile correctly, as the value owner
has been moved:
</p>

<div class="org-src-container">
<pre class="src src-nil">src/main.rs:7:25: 7:26 error: use of moved value: `x`
src/main.rs:7     println!("x == {}", x);
                                      ^
note: in expansion of format_args!
&lt;std macros&gt;:2:43: 2:76 note: expansion site
&lt;std macros&gt;:1:1: 2:78 note: in expansion of println!
src/main.rs:7:5: 7:28 note: expansion site
src/main.rs:4:13: 4:14 note: `x` moved here because it has type `Box&lt;i32&gt;`, which is moved by default
src/main.rs:4         let y = x;
                          ^
src/main.rs:4:14: 4:14 help: use `ref` to override
error: aborting due to previous error
</pre>
</div>

<p>
Because of this, you need to keep track of what values you're using where, who's got the ownership of the value, and how long
the value is alive.
</p>
</div>
</div>
<div id="outline-container-org7af657c" class="outline-2">
<h2 id="org7af657c"><span class="section-number-2">3.</span> Documentation!</h2>
<div class="outline-text-2" id="text-3">
<p>
This will be something that comes with more use and more exposure, but right now, outside of the <a href="http://doc.rust-lang.org/">Rust standard documentation</a>, there
isn't much for explanations on how/where to do things is, in comparison to the Ruby ecosystem on the Internet. As I get more
into it, I'm hoping to have more posts like this, where I can go into greater detail on how to do things in a rust-like way.
</p>

<p>
Moving into Systems programming is weird for me; I know there's some things that I'm missing, and I have a lot more power to
play around with the system at a lower level, but I struggle with finding projects to work on. Either I choose something
substantially big, or it ends up being examples on <a href="http://reddit.com/r/dailyprogrammer">/r/dailyprogrammer</a>. I'd like to put
together something in the middle soon.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>The DIY Web</title>
<link>https://www.ballpointcarrot.net/posts/2017-08-21-the-diy-web.html</link>
<pubDate>Mon, 21 Aug 2017 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2017-08-21-the-diy-web.html</guid>
<description>
<![CDATA[<blockquote>
<p>
TL;DR: Building on basic email, and with the advent of Mastodon, XMPP, Matrix and more,
using and building federated networks could bring immesurable improvements to the Internet.
</p>
</blockquote>
<div id="outline-container-org5e0aa8e" class="outline-2">
<h2 id="org5e0aa8e"><span class="section-number-2">1.</span> On Walled Gardens</h2>
<div class="outline-text-2" id="text-1">
<p>
One of the more controversial decisions I've made for myself in the past few years
was to take myself off of the Facebook platform. While this makes it far harder for
friends and family to scout me out on the Internet as a whole, I had reservations
about using their platform, and ultimately deactivated my account in early 2011. The reason for this mostly stems out of two main points:
</p>

<ul class="org-ul">
<li>The first takes us way back to April of 2010. Back then, Facebook</li>
</ul>
<p>
<a href="http://lifehacker.com/5549394/how-to-return-facebook-privacy-settings-to-what-you-signed-up-for">introduced a change</a> to their platform; as a result, all users' permissions defaulted to be <a href="https://www.wired.com/2010/05/facebook-rogue/">public by default</a>. This
caused a fair amount of backlash at the time, and ultimately caused the FTC <a href="https://www.ftc.gov/news-events/press-releases/2011/11/facebook-settles-ftc-charges-it-deceived-consumers-failing-keep">to sanction Facebook</a>
as a result of this and earlier privacy concerns.
</p>
<ul class="org-ul">
<li>The second is due to their need to create a wide break between content on the inside of</li>
</ul>
<p>
their platform and the rest of the Internet (the "walled garden", as is often used). As a
result of this separation, users who either are not on Facebook at all, or may be logged
out for the time being, lose the ability to access media and content stored there.
</p>

<p>
The Internet was founded with the principle of enabling people to share ideas - the existence
of some of the largest Internet companies today started out by enabling people to find and
share information. By limiting access to resources, data and content to only a select subset
of individuals, you restrict the ability for people to grow from those ideas. I'm not saying that
there can't be some access limits (although, if you want to keep something private, maybe putting
it on a global network isn't the best idea - better argument for a different day, though);
content creators want to retain use and control of their content. However, at the scale in which
Facebook exists, the limitations of access to those resources is stifling to those who could
use it.
</p>
</div>
</div>
<div id="outline-container-orgc57d3b9" class="outline-2">
<h2 id="orgc57d3b9"><span class="section-number-2">2.</span> On Centralization</h2>
<div class="outline-text-2" id="text-2">
<p>
Facebook, as well as Twitter, Instagram, Google, etc. all share something in common: they have
one point of access. When that access is cut off or limited (think of Github outages, which have
been dubbed "developer holidays" based on their impact to the tech community), it can be disruptive
to a large amount of people. In addition, by selecting one route to access for these services,
the companies that run them can start to dictate consumption:
</p>

<ul class="org-ul">
<li>Twitter heavily limits access for third-party phone apps into the platform</li>
<li>Snapchat doesn't provide a Windows Phone app, but <a href="http://www.pcworld.com/article/2862088/snapchat-cracks-down-on-windows-phone-imitator-apps.html">requested Microsoft pull third-party apps</a> providing
that functionality from their app store</li>
<li>the implementation, backlash and subsequent removal of YouTube's <a href="https://gigaom.com/2013/11/11/users-outraged-over-youtubes-switch-to-google-real-names-policy/">"Real Name" policy</a>.</li>
</ul>

<p>
This centralization shows that, as we allow sole consumption from these groups, we risk reducing access
to them; as a way of providing robustness to the Internet, there should be more than these single
players in their respective spaces, so that we can operate in the event something goes down.
</p>
</div>
</div>
<div id="outline-container-org9d29950" class="outline-2">
<h2 id="org9d29950"><span class="section-number-2">3.</span> Federation</h2>
<div class="outline-text-2" id="text-3">
<p>
This spring, Twitter made the (unfortunate) decision to update some of their UI - most notably,
they <a href="https://motherboard.vice.com/en_us/article/d7qkmx/the-new-twitter-replies-are-giving-me-an-ulcer">removed usernames from replies in messages</a>.
People didn't enjoy this (as noted above). Whenever there's a big event like this (Reddit has had them
a number of time in their past, too), a subset of users start to look for competing products. Around this time,
people discovered the Mastodon project, which provides a Twitter-like interaction style, but with a
couple of major shake-ups:
</p>

<ul class="org-ul">
<li>You had 500 characters (If you've tried it after years on Twitter - it's SO MUCH SPACE).</li>
<li>There's a "Content Warning" function, which hides things that may be offensive or may cause discomfort.</li>
</ul>

<p>
The major difference (for the sake of our discussion) was that, instead of being one service,
it is a network of separate running copies of the server software, run independently (called mastodon
"instances"). This brings in some tradeoffs: for example, since you can organize communities on separate instances,
those communities can start to build on specific topics. However, this doesn't mean you're limited to just the
people on your instance. Through a process called "Federation", users on one instance can follow users from another;
the server then keeps that user and their instance up to date for the users that follow them on their home instance.
</p>

<blockquote>
<p>
NB: The author of the above article tried out Mastodon around this time too - <a href="https://motherboard.vice.com/en_us/article/783akg/mastodon-is-like-twitter-without-nazis-so-why-are-we-not-using-it">you should see her take on it</a>.
</p>
</blockquote>

<p>
A big driver for me after being introduced to Mastodon is the power to do things your way. I run my own personal instance
(at <a href="https://social.ballpointcarrot.net">https://social.ballpointcarrot.net</a>); this gives me the ability to personalize and customize my instance to how I
need it to operate. However, due to the communication protocol (GNU Social) underlying it, all instances have the capability
to communicate with each other.
</p>

<blockquote>
<p>
Note from the future: as of the time of this blog migration (2026-01-23), the above instance is no longer running. I've moved
most of my personal stuff onto the <a href="https://home.omg.lol">omg.lol</a> platform.
</p>
</blockquote>
</div>
</div>
<div id="outline-container-orgcfc8b80" class="outline-2">
<h2 id="orgcfc8b80"><span class="section-number-2">4.</span> The DIY Web</h2>
<div class="outline-text-2" id="text-4">
<p>
I would love to take this concept of widespread, federated or decentralized services, which define a common protocol for
communication, and see them grow on the Internet. Moreover, since these give you the ability to host them for personal or
individual use, I would love to see the rise of the "DIY Web" - media, content and resources shared the way you want them
to be. I see great benefits to having these platforms: Technology literacy, Robustness of content, Better software as a
result of the needs around these platforms, all while retaining the social aspect of interacting and showing our voices.
</p>

<p>
Email is exactly this. Not everyone has (or even wants, in cases) a Gmail account. There is no absolute requirement that
your email go to Yahoo/Hotmail/Gmail/etc. - Running an email server is something you can do for your self, your household,
your extended family. The requirements are straightforward:
</p>

<ul class="org-ul">
<li>Set up the software to receive the email.</li>
<li>Set up the accounts to have the mail delivered to.</li>
<li>Tell everyone how to get their email (configure the clients).</li>
</ul>

<p>
The problem here is, those steps are <b><b>hard</b></b>. Most people aren't taught how installing packages on their desktop goes -
getting them to install and configure a mail server would be insane.
</p>

<p>
With the current technology teaching path, that is.
</p>

<p>
Think about a curriculum that uses setting up a project like this as its goal. In it, this gives you the ability to talk
about many concepts about computing that would largely go untouched. Networking (how do things go in and out to the Internet),
configuration of software (not just installing it), understanding how the messages are created and handed off from
place to place - there's a <b><b>lot</b></b> of detailed information that can be learned, just by trying to solve this as an exercise.
Once these people who have gone though this new training, they're going to be better set for dealing with technology out
in their daily lives (and hopefully with less of the "oh I'm not good with computers" hand-waving affectation).
</p>

<p>
At the same time, this is a place where those in the technology space can help. Part of the difficulty in this process
is that the resources that are being dealt with are built in a way that "technology people" know how to control. If
we can take some time and energy to make explaining the concepts here easier, and to simplify the process of building
out these types of applications, then we can make it easier to extend these types of federated networks out to the
world writ large. This is a perfect place for something like Docker - a premade container of a suite of coordinated
services will help to allow easy installation and execution of systems that would otherwise take hours to properly
set up and activate - hours that some at the target end don't have to spend in the review of those setup instructions.
Once these improvements are in place, we can then turn to making the communications protocols that these systems will
use more stable, more robust, and provide new features and extensions to them.
</p>

<p>
I'm excited to see where federated applications like this can take us. The more these can be used, the better off
we are in terms of open platform access, robustness (as the data propagates out to other nodes), and the benefits
brought in from the learning landscape, as well as benefits to the software itself.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>I'm Still Here / Careless Copying</title>
<link>https://www.ballpointcarrot.net/posts/2015-09-09-im-still-here.html</link>
<pubDate>Wed, 09 Sep 2015 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2015-09-09-im-still-here.html</guid>
<description>
<![CDATA[<p>
tags: metablog, systems, whoops
</p>

<p>
I've identified that a considerable time has gone by since the last update. I'm going to put some adequate time into resolving that this month and into the future. I've been sitting on a couple of topics that I want to dig into (regarding how I handle <a href="http://notmuchmail.org">email</a> and some work I've been doing with <a href="http://clojure.org">Clojure</a>).
</p>

<p>
In the interim, I'll leave you with a little anecdote/tale of caution.
</p>

<p>
<span class="underline">_</span>
</p>

<p>
My wife and I (oh yeah, by the way, I got married in April. I really need to work on updates.) frequently play video games together to pass the time. I'm not normally terribly competitive, and she's not into the traditional multiplayer model of games, so I try to look for games we can play that are multiplayer co-op, or more turn-based (I've gotten us both hopelessly addicted to <a href="http://www.civilization.com/">Civilization</a>).
</p>

<p>
Recently, with a lapse in new ideas for games, we bought her a copy of <a href="http://store.steampowered.com/sub/32848/">Borderlands 2 on Steam</a> so that we could play through the storyline together. I had played shortly after it came out, and with friends both in the Midwest and in the PNW, so I had a number of game saves on my desktop.
</p>

<p>
<span class="underline">Complication #1</span>: When we play games, normally Jordan gets the desktop, so that she has a better experience with the game. Having already played it, I get relegated to my laptop (running integrated Intel graphics) when I play along.
</p>

<p>
<span class="underline">Complication #2</span>:  The group that did the porting of the game to Linux (<a href="http://www.aspyr.com/">Aspyr Media</a>, who should get amazing credit for their work in extending video games to the Linux world) does not allow for Steam Cloud saves to cross platforms. As such, I had no access to the work I've put into the game previously.
</p>

<p>
<span class="underline">_</span>
</p>

<p>
We come to the events of tonight.
</p>

<p>
Jordan is away on a work trip, and Christopher is home alone. Christopher decides, "Hey, it's been forever since I've actually gotten to use my desktop for games, and I've been playing BL2 recently; let's play that."
</p>

<p>
An hour passes as Christopher enjoys playing one of his old characters, which is close in level to where he's at with Jordan.
</p>

<p>
Christopher: "Hey - I should see if I can copy over the character data to the laptop, so I have the option to play with those characters when Jordan gets back."
</p>

<p>
After researching, Christopher finds that the character data is saved in files called <code>save&lt;nnnn&gt;.sav</code>. Easy enough to copy from one location to the next.
</p>

<p>
Christopher copies the save data to a shared filesystem so he can access it on his laptop, and then fires off the following command:
</p>

<div class="org-src-container">
<pre class="src src-bash">cp save*.sav ~/.local/share/aspyr-media/borderlands 2/willowgame/savedata/&lt;numerical id&gt;/
</pre>
</div>

<p>
After thinking about this, Christopher realizes in horror that <span class="underline">he's just saved over his character data he's been playing with his wife for the majority of the last week</span>.
</p>

<p>
Because the <code>cp</code> command doesn't default the <code>-i/--interactive</code> option, which would prompt on overwrite, it is easy to fall into this trap. In my case, both game saves were named "save0001.sav", and the <code>cp</code> call replaced my character data with the old one.
</p>

<p>
I scoured the Internet for methods of data recovery (there's a <a href="http://superuser.com/questions/211301/recovery-of-overwritten-file">really</a> <a href="http://unix.stackexchange.com/a/150423">cool</a> <a href="http://unix.stackexchange.com/questions/101237/how-to-recover-files-i-deleted-now-by-running-rm">tangent</a> to take here on how <code>mv/rm/cp</code> actually behave), and most things I found referred to using text contained in the file to find the details. That'd be great, but the data files for those characters are <a href="http://gaming.stackexchange.com/a/84732">encrypted</a>.
</p>

<p>
Fortunately (for me), this story has a happy ending. Borderlands 2 has support for <a href="https://en.wikipedia.org/wiki/Steam_%28software%29#cite_ref-39">Steam Cloud</a>. As a last-ditch effort, I removed <span class="underline">all</span> save data from the folder on the laptop, and restarted the game. Upon loading, it detected a game save within Steam Cloud that didn't exist locally, and happily copied that save down to the local machine. I'm even more pleased to say that it was a recent save too, so I didn't lose my place!
</p>

<p>
<span class="underline">_</span>
</p>

<p>
So, the moral of today's story: make sure you use (or better yet, alias) cp to <code>cp -i</code>, so that when you write to a directory, you pause before overwriting.
</p>
]]>
</description></item>
<item>
<title>Advent Of Code (Day 1)</title>
<link>https://www.ballpointcarrot.net/posts/2018-12-01-advent-of-code-day-1.html</link>
<pubDate>Sat, 01 Dec 2018 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2018-12-01-advent-of-code-day-1.html</guid>
<description>
<![CDATA[<p>
Spurred on by:
</p>

<ol class="org-ol">
<li>a lack of posting in this space,</li>
<li>the chance to show off the new backend/theme to my blog (I did work</li>
</ol>
<p>
on this while nobody was looking, and started building an RSS feeed!), and
</p>
<ol class="org-ol">
<li>after finding <a href="https://twitter.com/ASpittel/status/1068869815333527557?s=20">this Tweet</a> by <a href="https://www.alispit.tel/#/">Ali Spittel</a>,</li>
</ol>

<p>
I decided that doing this <a href="https://adventofcode.com/">"Advent of Code"</a> was something to do. First, it gives me a nice thing to practice on. Second,
it gives me a reason to make some frequent posts on here (which, given the year+ lack of content, may not be a bad
idea). Finally, it helps me build out some public code, which I've been bad at doing - even if they're solutions to set
problems. I'll be using GitHub gists for posting my solutions, and embedding them here.
</p>
<div id="outline-container-org0ffbed1" class="outline-2">
<h2 id="org0ffbed1"><span class="section-number-2">1.</span> Problem the First</h2>
<div class="outline-text-2" id="text-1">
<p>
The <a href="https://adventofcode.com/2018/day/1">first problem</a> is summarized as follows: you're an Elf travelling back in time
to fix anomalies in history, in order to "save Christmas". However, in order to get the time travel device working
correctly, it first needs calibrated.
</p>

<p>
Given a series of "frequency changes", like <code>+1 -2 +3 -1</code>, the following changes would occur:
</p>

<ul class="org-ul">
<li>Current frequency  <code>0</code>, change of <code>+1</code>; resulting frequency  <code>1</code>.</li>
<li>Current frequency  <code>1</code>, change of <code>-2</code>; resulting frequency <code>-1</code>.</li>
<li>Current frequency <code>-1</code>, change of <code>+3</code>; resulting frequency  <code>2</code>.</li>
<li>Current frequency  <code>2</code>, change of <code>+1</code>; resulting frequency  <code>3</code>.</li>
</ul>

<p>
This provies a resulting frequency of <code>3</code>.
</p>

<p>
With those rules in place, the Advent of Code site has you log in (thanks, Login with Github) and get a link for sample
input. The input file was larger than I expected, but the rules simple enough to come up with this small Clojure
snippet:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn calibrate [input-file]
  (let [raw-input (slurp input-file)
        freqs (map #(Integer. %) (clojure.string/split-lines raw-input))]
    (reduce + freqs)))
</pre>
</div>

<p>
The above reads the file into a string (using <code>slurp</code>), then converts each individual number (separated with a newline
character) into a Java Integer. Finally, everything is summed up via <code>reduce</code> to get the full set of adjustments for a
final frequency.
</p>
</div>
</div>
<div id="outline-container-orgcbb6083" class="outline-2">
<h2 id="orgcbb6083"><span class="section-number-2">2.</span> Problem the Second</h2>
<div class="outline-text-2" id="text-2">
<p>
Within your input, you now need to keep track of the active value, and look for the first time you encounter the same
value twice. Additionally, this means that your list can loop; for example, take the input <code>+3, +3, +4, -2, -4</code>. As you
run through this the first time, you generate intermediate values of <code>3, 6, 10, 8 4</code>, and there are no matches within
that set. So, you take the last offset of <code>4</code>, and start the original list over again, returning <code>7, 10, ...</code>. When you've reached <code>10</code>
again, you have found your "twice match", and return that value. Now, using the same test input, we get to find the
first value we hit twice.
</p>

<p>
Clojure gets to harness the power of lazy infinite sequences here. Using the clojure <a href="https://clojuredocs.org/clojure.core/cycle"><code>cycle</code></a> function, the list of
frequencies gets to be repeated indefinitely. Obviously, we can't eager load a list of infinite values - there's not
enough memory space to do that; what we <span class="underline">can</span> do, however, is let that list populate as needed, only providing the next
number until we need it.
</p>

<p>
I built a function that generates a list of the intermediate points, and loops to find a solution:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn frequency-adjustments [freqs]
  (reductions + (cycle freqs)))

(defn calibrate [freqs]
  (loop [n 2]
    (let [steps (take n (frequency-adjustments freqs))
          step-counts (frequencies (rest steps))
          repeats (filter (fn [[k v]] (if (= v 2) k)) step-counts)]
      (if-not (empty? repeats)
        (first (keys repeats))
        (recur (inc n))))))
</pre>
</div>

<p>
I was happy with how things looked. I went to a REPL and tested the logic with some of the samples, which seemed to get
the answer I was looking for. <code>frequency-adjustments</code> was nice, actually, because you could see effectively a new list
of how each step processes, which was great for visual analysis. I then fired it off with the test data.
</p>

<p>
And waited. Quite a while in fact.
</p>

<p>
Turns out that, when you have a high enough input, trying to build the list over and over again is somewhat taxing on
the system doing that calculation. Obviously, this wasn't the solution I was looking for. At this point, I did a little
bit of cheating (hey, it's the Internet, and I'm not proud) and checked <a href="https://www.reddit.com/r/adventofcode/comments/a20646/2018_day_1_solutions/">the reddit post</a> where people were posting solutions, and came across a separate Clojure
solution by <a href="https://www.reddit.com/r/adventofcode/comments/a20646/2018_day_1_solutions/eau9gjm/">zqvt</a> (slightly
modified to fit my input parameters below):
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn calibrate2 [freqs]
  (loop [xs (cycle freqs) seen #{} total 0]
    (if (contains? seen total)
      total
      (recur (rest xs) (conj seen total) (+ total (first xs))))));
</pre>
</div>

<p>
This generates a set of values we've come across, as well as keeps a running total of where we're at while we're
generating. The key here that I didn't even think about (let alone thought possible) was the use of <code>rest</code> to generate
further sequences while not including the items processed. That was clever, and this solution very quickly provided a
response.
</p>

<p>
Lessons learned:
</p>

<ol class="org-ol">
<li>My initial thought was to build a set of values that I'd seen going through the list calculated with</li>
</ol>
<p>
<code>reductions</code>, but I really wanted to try something that I could do without maintaining state outside of the loop. That
led me down the path of regenerating the list each time, which made it impossible to run effectively. I probably
should've gone with that easier thought process, as it would've worked faster (and I would've spent less time on the
solution).
</p>
<ol class="org-ol">
<li>Good to be posting stuff again, and practice always helps.</li>
<li>Honesty - it hurt to come clean about looking for solutions, but sometimes you have to suck it up. Also, I felt really
dumb after seeing the painful performance of my implementation vs. the one that I found. But I wanted to highlight a
successful implementation, both to show that there are good ways to do it, and to give myself something to look
forward to improving upon. I'm hoping to not need the crutch next time.</li>
</ol>
</div>
</div>
]]>
</description></item>
<item>
<title>Tooling Around</title>
<link>https://www.ballpointcarrot.net/posts/2014-05-23-tooling-around.html</link>
<pubDate>Fri, 23 May 2014 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2014-05-23-tooling-around.html</guid>
<description>
<![CDATA[<p>
So, I traded in my work laptop today to replace it with a new one. I'm glad I made the switch, as there were things that
I didn't need on the old one, and I didn't want to have to mess with a major upgrade path and the inevitable breaks that
were to come with it. Additionally, my workflow and suite of tools works better with the new hardware (I've switched to
an Ubuntu laptop from an OSX one), and it will centralize my daily work (email and communication, scheduling and
planning) around the laptop instead of the desktop, which can then be devoted to other tasks (like running development
projects).
</p>

<p>
Because of the switch, it got me to thinking about the tooling that I use on a daily basis, and how to most smoothly
move into getting that installed on a new system. Replacing hardware is tough work for a developer/engineer, and that
would be time otherwise spent working on problems or creating new things. I'm going to provide a rundown of my toolchain
and how I orchestrate the installation of the tools.
</p>

<p>
Note that, as this is tied to Linux, the tools will obviously be Linux-based. There are different flows for other OSs;
each ecosystem operates differently. This is my solution for myself; YMMV.
</p>
<div id="outline-container-orgb722721" class="outline-2">
<h2 id="orgb722721"><span class="section-number-2">1.</span> Communication</h2>
<div class="outline-text-2" id="text-1">
<p>
Being able to send and receive messages is key. Ten minutes after receiving my laptop today, I had a meeting that I had
to run to, and to send an email containing some details to one of the attendees. I run my email from the office Exchange server to my desktop (and now the laptop) using
<a href="http://fetchmail.berlios.de/">fetchmail</a> and <a href="http://www.procmail.org/">procmail</a>. While these may seem esoteric, and
not terribly user-friendly, it gives me a strength that no other email client has - I can run scripts around my
email. Procmail handles the filtering of the incoming fetchmail setup, and separates the email into the various folders
for easy filtering rules (based on sender, topic in subject, etc.). Emails sent specifically to me in the To: header get
a bit more prevalence, and emails with calendar invites as attachments get the attachment parsed and sent to a
calendar. Since everything was using a standard Maildir format for storage on the laptop, migrating the email was as
easy as running rsync between the two systems.
</p>

<p>
This covers only the receipt of email, not sending. Since December (referencing
<a href="http://www.ballpointcarrot.net/blog/2014/02/07/learning-a-new-editor/">an earlier post</a>), I've been using Emacs to do
more and more things - this has grown to include IRC chat (via the <a href="http://www.emacswiki.org/wiki/ERC">ERC</a> plugin) and
email (using a pair of utilities called <a href="http://www.djcbsoftware.nl/code/mu/mu4e.html">mu and mu4e</a>). While normally I'd
entertain jokes here (like "emacs is a good OS, it just needs a decent text editor."), I have to say that it's handy to
have a single place to go for all the work you need to do. mu is external to Emacs, and is a search engine over your
Maildir folders; you can use it on the command line to pick out emails that pertain to certain topics, and filter them
by specific recipients and whether they're new/flagged/unread/etc. Mu4e wraps that logic in an easy to use mail client
from within Emacs, and it's been much nicer than sifting through Outlook.
</p>
</div>
</div>
<div id="outline-container-org4fb5946" class="outline-2">
<h2 id="org4fb5946"><span class="section-number-2">2.</span> Environment</h2>
<div class="outline-text-2" id="text-2">
<p>
So I've got some software&#x2026; now I have to customize what I run it in. Rather than stay with Unity (the default Ubuntu
installed WM, which I frankly feel is counter-intuitive), I choose to go to a lesser known window manager called
<a href="http://awesome.naquadah.org/">"Awesome."</a> Appropriately named, as I haven't left it since I found it. By using a tiling
window manager, I don't have to worry about resizing things to fit. Additionally, the entire interface is programmable
via Lua, so defining custom shortcut keys and startup programs is fairly simple:
</p>

<div class="org-src-container">
<pre class="src src-lua">-- ...
-- Hotkeys for handling window resizing and management:
clientkeys = awful.util.table.join(
awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
awful.key({ modkey,           }, "q",      function (c) c:kill()                         end),
awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
awful.key({ modkey,           }, "n",
    function (c)
        -- The client currently has the input focus, so it cannot be
        -- minimized, since minimized clients can't have the focus.
        c.minimized = true
    end),
awful.key({ modkey,           }, "m",
    function (c)
        c.maximized_horizontal = not c.maximized_horizontal
        c.maximized_vertical   = not c.maximized_vertical
    end)
)
-- Autostarts
awful.util.spawn_with_shell("/usr/bin/startup-script.sh")
awful.util.spawn_with_shell("~/bin/runme")
</pre>
</div>

<p>
Awesome's libraries have amusing names: "awful", "naughty", and "vicious", to name a few. Currently, I have this
attached to the GNOME session layer, so I get the benefit of GNOME's background and icon management, but the window
management of awesome.
</p>
</div>
</div>
<div id="outline-container-orgc78a894" class="outline-2">
<h2 id="orgc78a894"><span class="section-number-2">3.</span> Code</h2>
<div class="outline-text-2" id="text-3">
<p>
A programmer can't do much unless he has languages to write in. For me, that means having to add some additional
packages:
</p>

<ul class="org-ul">
<li><a href="https://github.com/sstephenson/rbenv">rbenv</a> - this manages various installations of Ruby and the ecosystem around
it. Similar to RVM, this uses shim binaries to point to rotating Ruby versions, so that I can use one version with
one app, and use a legacy version to work on an older one.</li>

<li><a href="https://github.com/creationix/nvm">nvm</a> - Same idea as rbenv, but for node.js. These libraries give me the
flexibility of using different runtimes for different applications, and makes it easier to install the languages than
with the system-provided binaries (which can either be out of date or harder to manage).</li>

<li>I've already mentioned it, but Emacs is in here, too. Being able to easily see language and typographical issues with
flycheck, syntax highlighting for languages available via <a href="https://github.com/dimitri/el-get">el-get</a>, and being able
to launch a simple shell within the editor to run a test is a blessing to getting things done.</li>
</ul>
</div>
</div>
<div id="outline-container-org543175c" class="outline-2">
<h2 id="org543175c"><span class="section-number-2">4.</span> Tomorrow</h2>
<div class="outline-text-2" id="text-4">
<p>
This was just for the first day, too. Things like browser plugins (which we use a myriad of for work) will likely come
soon enough, and there will be tweaks to all of the stuff listed as what I need in the environment changes. Let me know
if you have any questions on any of this, and I'll do what I can to answer them.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Rust (part 2 of n): 'match' and Tuples</title>
<link>https://www.ballpointcarrot.net/posts/2015-03-14-rust-nsp-matchers.html</link>
<pubDate>Sat, 14 Mar 2015 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2015-03-14-rust-nsp-matchers.html</guid>
<description>
<![CDATA[<p>
In order to keep practicing and make sure I keep sharp on what I'm learning, I like to dig through problem sets and write solutions for them. At first, the best resource for these was <a href="https://projecteuler.net">Project Euler</a>, but as time went on, new projects came about that presented problems in slightly different ways:
</p>

<ul class="org-ul">
<li><a href="http://codewars.com">Codewars</a> gamifies the process a bit, by rating the difficulty of each item; those determine the amount of credit you get by solving them.</li>
<li><a href="http://codekata.com">CodeKata</a>, which is more of an exercise in repeated solutions to common problems, with the understanding that the repeated practice, you become better over time</li>
</ul>

<p>
Most recently, I've been running through problems on Reddit's <a href="http://reddit.com/r/dailyprogrammer">DailyProgrammer</a> subreddit. These are community-submitted challenges, separated into easy, medium, and difficult problems. Each of these problems can extend within themselves to offer more flexibility or allow the user more options.
</p>

<p>
Today, I had the opportunity to work on the <a href="http://www.reddit.com/r/dailyprogrammer/comments/2ygsxs/20150309_challenge_205_easy_friendly_date_ranges/">most recent 'easy' DailyProgrammer challenge</a>. In it, when provided two separate dates, you need to make a pretty printout of the range between them. For example:
</p>

<div class="org-src-container">
<pre class="src src-plain">2015-03-14, 2015-03-15 =&gt; March 14th - 15th
2015-03-14, 2016-02-28 =&gt; March 14th - February 28th
2015-03-14, 2016-03-15 =&gt; March 14th, 2015 - March 15th, 2016
</pre>
</div>

<p>
Within the set values, you'll notice that years can be omitted when they match the current year, but only within a year's time. In addition, within a single month, you don't need to print out the month twice (the value is inferred).
</p>
<div id="outline-container-orgee3f9e0" class="outline-2">
<h2 id="orgee3f9e0"><span class="section-number-2">1.</span> Rust: 'match'</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org520e840" class="outline-3">
<h3 id="org520e840"><span class="section-number-3">1.1.</span> TODO: FIX Crosslinks</h3>
<div class="outline-text-3" id="text-1-1">
<p>
During my solution to this problem, I had two problems to solve:
</p>

<ul class="org-ul">
<li>How do I handle the ordinal values (1st, 2nd, 3rd, etc.) for the dates?</li>
<li>How do I compare the dates from the original strings to determine the output?</li>
</ul>

<p>
For both, Rust has some strong utilities for helping with the solution. To solve the ordinal issue, rust provides a 'match' keyword, which acts as a more flexible form of most languages' switch/case statements. Within it, we can set matching values, or matching ranges of values, in order to retrieve what we're looking for.
</p>

<p>
In this case, we need 1st, 2nd, and 3rd to be unique, and 4 -&gt; 20 to use 'th' (think about it&#x2026; 11th, 12th, &#x2026;). However, we then reach 21, and that ends up using an 'st' again. Since our problem only concerns itself with days of a month, we can limit ourselves to an upper bound of 31, as the example below shows:
</p>

<div class="org-src-container">
<pre class="src src-rust">fn ordinal(value: usize) -&gt; Option&lt;String&gt; {
    match value {
        0 =&gt; Some(String::from_str("th")),
        1 =&gt; Some(String::from_str("st")),
        2 =&gt; Some(String::from_str("nd")),
        3 =&gt; Some(String::from_str("rd")),
        4...20 =&gt; Some(String::from_str("th")),
        21...31 =&gt; ordinal(value % 10),
        _ =&gt; None
    }
}
</pre>
</div>

<p>
Some things to point out from the example:
</p>

<ul class="org-ul">
<li>the fifth matcher uses a range from 4 to 20 inclusive, and will respond with a 'th'. This satisfies the requirement for the teens.</li>
<li>the sixth matcher removes the tens place from the value, and recurses. when it responds, it will have the matcher for just that last place, which fulfilles the rule of 21, 22, etc.</li>
<li>the last matcher is a <b>catch-all</b> or <b>don't-care</b> matcher; as we are unconcerned with the value, we just handle the case without the value. This will become more important in the next section.</li>
</ul>

<p>
Another point of note here is that the function is returning an Option value - as discussed <a href="https://www.ballpointcarrot.net/posts/file:///2015/03/rust-non-systems-programmer">in the last post</a>, an <code>Option</code> value is used in situations where you are uncertain about the resultant value, in order to avoid a situation where <code>null</code> would traditionally be used. Finally, the function does not have an explicit <code>return</code> keyword, because the match is acting as an expression and not a statement. By omitting the semicolon, the selected match logic is returned on its own.
</p>
</div>
</div>
</div>
<div id="outline-container-org1731c00" class="outline-2">
<h2 id="org1731c00"><span class="section-number-2">2.</span> Rust: Tuples</h2>
<div class="outline-text-2" id="text-2">
<p>
Now that we have the ordinal solved, we can go about formatting the actual output. In order to do so, we need to compare the values of the dates to find the differences between them (less than a month, less than a year, more than a year, etc.). In order to solve this, I arranged the date properties into a <b>tuple</b> - a structure with multiple data points within it.
</p>

<div class="org-src-container">
<pre class="src src-rust">let (start_yr, start_mo, start_dy) = start_values[0], start_values[1], start_values[2];
</pre>
</div>

<p>
Tuples in Rust can be used in many ways; often, they're used to provide multiple values as a return of a function, or to store data that is paired or grouped together (like (x,y) coordinates).
</p>

<p>
My limited example above is referred to as a <b>destructuring</b> of a tuple - it allows creation of multiple variables from the tuple they were defined from. In other words, I can now use <code>start_yr</code> and <code>start_mo</code> in my code in other spots.
</p>

<p>
This example doesn't show much of the power of what is being done, but watch what happens when you pair it with the <code>match</code> statement from above:
</p>

<div class="org-src-container">
<pre class="src src-rust">match (end_yr-start_yr, (end_mo as isize)-(start_mo as isize), (end_dy as isize)-(start_dy as isize)) {
    (0, 0, 0) =&gt; format!("{} {}",
                         MONTHS[start_mo-1],
                         print_ordinal(start_dy)),
    (0, 0, _) =&gt; format!("{} {} - {}",
                         MONTHS[start_mo-1],
                         print_ordinal(start_dy),
                         print_ordinal(end_dy)),
    (0, _, _) =&gt; format!("{} {} - {} {}",
                         MONTHS[start_mo-1],
                         print_ordinal(start_dy),
                         MONTHS[end_mo-1],
                         print_ordinal(end_dy)
</pre>
</div>

<p>
Here, we generate a tuple that acts as the difference between the year, month, and day values. Given the assumption that our ranges move forward in time, we present three cases:
</p>

<ul class="org-ul">
<li>The start and end days are the same. In this case, just print the month and day (you don't need to print the end day, as it's the same).</li>
<li>The difference of the start and end month and year are both zero. In this case, we're within the same month, so we don't need to print it twice. Instead, we print the range between the start and end day.</li>
<li>The year is the same, but we have two different months. In this case, print both months and days.</li>
</ul>

<p>
Notice that we don't care about what values we have in the month and day. In a situation where we <b>need</b> that calculation, we can assign variables to it, as well:
</p>

<div class="org-src-container">
<pre class="src src-rust">(1, month, day) =&gt; {
    let use_yr = match (0.cmp(&amp;month) , 0.cmp(&amp;day)) {
        (Ordering::Greater, _) =&gt; false,
        (Ordering::Equal, Ordering::Greater) =&gt; false,
        (_,_) =&gt; true
    };
    if use_yr {
        format!("{} {}, {} - {} {}, {}",
                MONTHS[start_mo-1],
                print_ordinal(start_dy),
                start_yr,
                MONTHS[end_mo-1],
                print_ordinal(end_dy),
                end_yr)
    } else {
        format!("{} {} - {} {}",
                MONTHS[start_mo-1],
                print_ordinal(start_dy),
                MONTHS[end_mo-1],
                print_ordinal(end_dy))
    }
}
</pre>
</div>

<p>
Here, we need to know the difference between month and day, as the year changed. However, if the month difference is less than zero (eg: from 2015-12-01 to 2016-03-01), then the year is assumed to be changing, and not printed. By extension, we will do the same with the date (eg: 2015-12-31 -&gt; 2016-12-25).
</p>

<p>
We capture those differences from the matcher in the month and day variables, and then use those to make further determinations in the matcher's block. First, we figure out if we are using the year, based on the conditions above. Then, we choose a format for the date based on if we're using the year.
</p>
</div>
</div>
<div id="outline-container-org4d4b340" class="outline-2">
<h2 id="org4d4b340"><span class="section-number-2">3.</span> Testing</h2>
<div class="outline-text-2" id="text-3">
<p>
Rust includes a strong preprocessor, which will examine and selectively compile parts of your code. Based on this, you can keep your unit tests contained within your source file, and they will only be compiled when you run in a test configuration (usually using 'cargo test').
</p>

<p>
You can find the crate for my solution <a href="https://github.com/ballpointcarrot/rust-dailyprogrammer/tree/205">on my github repository</a>. Note that there are different branches - I'll hopefully add more solutions to new branches for each problem that's solved.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Redesign, and Goals</title>
<link>https://www.ballpointcarrot.net/posts/2014-05-23-redesign-and-goals.html</link>
<pubDate>Fri, 23 May 2014 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2014-05-23-redesign-and-goals.html</guid>
<description>
<![CDATA[<div id="outline-container-org701981e" class="outline-2">
<h2 id="org701981e"><span class="section-number-2">1.</span> New Site Layout!</h2>
<div class="outline-text-2" id="text-1">
<p>
Hey everyone! After taking time to look through and see what it would take to maintain the old ballpointcarrot.net site (residing on a mostly-dormant 1-dyno Heroku install), I've decided to forgo it and run everything on Octopress. Let me know if you have positives/negatives to say about the changes. I feel it's a positive step, and it's one less account to keep open for me. Bonus.
</p>
</div>
</div>
<div id="outline-container-orgcff7b4c" class="outline-2">
<h2 id="orgcff7b4c"><span class="section-number-2">2.</span> Goals</h2>
<div class="outline-text-2" id="text-2">
<p>
I realize I don't post much on here, so I want to set a goal for myself for new blog posts. So, starting today, until the end of June, I'll strive to make a post every 2 days. You should expect to see something Friday. This will allow me to get some of my mind dumped out to the Internet, and expose my thinking to approaches for software. It will also give me time to put down things I've learned while working at AWS - expect a lot of the posts to be covering issues with CloudFormation, Elastic Beanstalk, Auto Scaling and more. Plus, I'll probably have some talk on new JS frameworks, Docker, Ruby gotchas, and anything else I can think of.
</p>

<p>
I still should be pretty reachable via the site - the sidebar for posts has my G+, Twitter and email nearby to click on. I've also added Disqus comments below, so let me know what you think of the new layout, and my future content.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Yearly Refresh Time!</title>
<link>https://www.ballpointcarrot.net/posts/2015-02-28-yearly-refresh-time.html</link>
<pubDate>Sat, 28 Feb 2015 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2015-02-28-yearly-refresh-time.html</guid>
<description>
<![CDATA[<p>
I don't know if it's the digital form of spring cleaning, or if there's a standing need to clean things up
and keep them looking nicely, but I found it time this weekend to update the visual and functional aspects
of my blog. With that being said, welcome to ballpointcarrot.net, version&#x2026;4, I think?  I haven't done a
terribly good job of keeping an active archive, and haven't consulted the Internet Archive to see if they
have any of the previous iterations.
</p>

<p>
With the new layout comes a new backend engine for producing the contents - I've moved from Octopress
(which, while nice, dictated a structure and tooling a little more than necessary) to a Node.js static
site generator called <a href="http://harpjs.com/">Harp</a>.
</p>

<p>
Because this is a site generator first, the structure used for blog-like things, such as tags, feeds, etc.
come as extras; It took a little bit of searching to find a theme and pattern I liked, and still didn't
fit 100%. Fortunately, because of the flexibility provided, I adjusted the structure of how data was read
and inserted, and made it truly my own.
</p>
<div id="outline-container-org817a24d" class="outline-2">
<h2 id="org817a24d"><span class="section-number-2">1.</span> About the new platform</h2>
<div class="outline-text-2" id="text-1">
<p>
As I mentioned, the base of the new platform is Harp. The <a href="https://github.com/kennethormandy/hb-casper">base theme</a>
is a port of <a href="https://github.com/TryGhost/Casper">Casper</a>, which is the default theme for the
<a href="https://ghost.org/">Ghost</a> blogging platform. In addition, I've added a more flexible syntax
highlighting library called <a href="http://prismjs.com/">Prism</a> to help with code snippets (which I'll be able
to use more frequently, I'm hoping!).
</p>

<div class="org-src-container">
<pre class="src src-javascript">christopher.blog_upgrade = true;
</pre>
</div>

<p>
Overall, the site is still set to run on GitHub Pages; I appreciate
that they allow hosting like that, and moreover, allow the Hostname redirection that they do.
</p>

<p>
Migration of the actual data from the old platform to the new one worked pretty well. As they say, the
best knowledge transfer medium is plain text. No reading from databases, no conversions; just a little bit
of modification of the markdown files in one platform to the other.
</p>
</div>
</div>
<div id="outline-container-orgb3daffb" class="outline-2">
<h2 id="orgb3daffb"><span class="section-number-2">2.</span> Now the question - <span class="underline">will he keep updating it?</span></h2>
<div class="outline-text-2" id="text-2">
<p>
That will remain to be seen. I had a goal of writing every two days; we saw how well that went. But, I've
been working on teaching myself new things in the intervening time, and I think it may prove to be good
not just for me, but for people reading, to start putting my thoughts to paper, so to speak.
</p>

<p>
I'm cautiously optimistic that I can do a better job of updating things. We'll see if I can make a pattern
out of it.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Advent Of Code 2018 - Day 2</title>
<link>https://www.ballpointcarrot.net/posts/2018-12-02-advent-of-code-2018-2.html</link>
<pubDate>Sun, 02 Dec 2018 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2018-12-02-advent-of-code-2018-2.html</guid>
<description>
<![CDATA[<p>
Welcome back! Today, we're continuing the <a href="https://ladventofcode.com">Advent of Code</a> challenges. I found these challenges through the awesome people I've found at the <a href="https://dev.to">dev.to</a> community, which has been embracing these challenges, providing discussion boards, and more.
</p>
<div id="outline-container-org76cf34d" class="outline-2">
<h2 id="org76cf34d"><span class="section-number-2">1.</span> Day 2, Problem the First</h2>
<div class="outline-text-2" id="text-1">
<p>
The long-and-short of the second day's problem is thus:
</p>

<p>
You are given a list of box IDs, which are series of letters. In order to verify the contents of the boxes in total, you count the number of IDs with "exactly two of any letter", and separately count "exactly three of any letter" to make a checksum of the values. Using the example from the problem statement:
</p>

<p>
For example, if you see the following box IDs:
</p>

<ol class="org-ol">
<li><code>abcdef</code> contains no letters that appear exactly two or three times.</li>
<li><code>bababc</code> contains two a and three b, so it counts for both.</li>
<li><code>abbcde</code> contains two b, but no letter appears exactly three times.</li>
<li><code>abcccd</code> contains three c, but no letter appears exactly two times.</li>
<li><code>aabcdd</code> contains two a and two d, but it only counts once.</li>
<li><code>abcdee</code> contains two e.</li>
<li><code>ababab</code> contains three a and three b, but it only counts once.</li>
</ol>

<p>
As a result, we have four IDs which contain exactly two repeated letters (2, 3, 5, and 6), and three IDs which contain three repeats (2, 4, 7). If you multiply these values together <code>4 x 3 = 12</code>, so 12 is your checksum value. You are now asked to calculate the checksum value of the test input.
</p>

<p>
Not to be bitten by the trouble yesterday, I wanted to set up a full project (with the ability to test). This took a fair bit longer than I had intended, because I rabbit-holed into "how do I get this to provide test results automatically?" (where I spent about 20m), and "Why the hell isn't this test executing correctly?" (which took substantially longer).
</p>

<p>
Once I finally had my environment up and running correctly, I went about putting some test cases down:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(ns aoc.aoc2-test
  (:require [aoc.aoc2 :as sut]
            [clojure.test :refer [deftest testing is]]))

(deftest aoc2-part1
  (testing "the example statement"
    (let [input ["abcdef" "bababc"
                 "abbcde" "abcccd"
                 "aabcdd" "abcdee"
                 "ababab"]]
      (is (= 12 (sut/checksum input)))))
  (testing "a simple second example"
    (let [input ["abab" "abaa" "aab"
                 "aac" "aaa" "abc"]]
      (is (= 6 (sut/checksum input))))))
</pre>
</div>

<p>
This uses the example scenario given in the problem, as well as a small example I cooked up myself. Armed with tests that executed on file save, I was ready to build out the solution.
</p>

<p>
Once again, this problem lends well to the <a href="https://clojuredocs.org/clojure.core/frequencies">frequencies</a> function provided by Clojure - it will automatically group the values within the string by how frequent they show up. Since we only care about twos and threes, however, we need to search those results for those values. The <a href="https://clojuredocs.org/clojure.core/reduce">reduce</a> function (of "map/reduce" fame) is where we want to be - it gives us an easy way to take a list of things and make a scalar value out of it. In our case, we want to reduce each map to its existence of twos and threes; ideally, <code>{:a 3 :b 1 :c 2}</code> would result in <code>{:threes 1 :twos 1}</code>.
</p>

<p>
Building out a complicated <code>reduce</code> function generally is painful; because the inner function to a reduce is exactly that (a function), I defined it outside the logic. Because clojure values are generally immutable, I needed an easy way to maintain the state during the loop - <code>transient</code> helped out here, because I treat the map as temporarily mutable, but only within the bounds of the function and the lifetime of the transient binding.
</p>

<p>
Here's what I ended up with for the part 1 solution:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(ns aoc.aoc2)

(defn reduce-twos-threes
  "check the given frequency map n for twos or threes matches, and update
   the memo map to indicate if the string has a match. Used for a reducer."
  [memo n]
  (let [t-memo (transient memo)]
    (if (some (fn [[k v]] (= v 2)) n) (assoc! t-memo :twos (inc (:twos t-memo))))
    (if (some (fn [[k v]] (= v 3)) n) (assoc! t-memo :threes (inc (:threes t-memo))))
    (persistent! t-memo)))

(defn checksum [input]
  (let [sum-maps (map frequencies input)
        twos-threes (reduce reduce-twos-threes {:twos 0 :threes 0} sum-maps)]
    (* (:twos twos-threes) (:threes twos-threes))))
</pre>
</div>

<p>
This makes the <code>checksum</code> function read really straightforward: find the frequencies of each input value, find the numbers of twos and threes (stored in a map), then finally multiply the twos and threes values together.
</p>
</div>
</div>
<div id="outline-container-orgc2deac4" class="outline-2">
<h2 id="orgc2deac4"><span class="section-number-2">2.</span> Day 2 Problem 2 (Electric Boogaloo)</h2>
<div class="outline-text-2" id="text-2">
<p>
Distilling the problem statement again:
</p>

<p>
Given your list of IDs, the particular IDs you're searching for differ by just one character; for example, "text" and "tent" fit this requirement, because you only need to replace the "x" and "n" characters. The example given in the problem is this:
</p>

<ul class="org-ul">
<li>`abcde`</li>
<li>`fghij`</li>
<li>`klmno`</li>
<li>`pqrst`</li>
<li>`fguij`</li>
<li>`axcye`</li>
<li>`wvxyz`</li>
</ul>

<p>
where `fghij` and `fguij` are "adjacent" boxes.
Any problem where you're comparing closeness of matching strings <b><b>screams</b></b> <a href="https://people.cs.pitt.edu/~kirk/cs1501/Pruhs/Spring2006/assignments/editdistance/Levenshtein%20Distance.htm">Levenshtein Distance</a>. The Levenshtein distance of two strings is a measure of the minimum number of changes required to turn one string into another - this is generally counting insertion, deletion, and substitution, but our needs solely require substitution (better known as Hamming Distance - two separate mathematicians studying the same area of string differences. This is done by comparing values in each string, and adding 1 to each difference you encounter - a pretty simple comparison function.
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn hamming
  "Compute the Hamming Distance between two equal length
   strings."
  [str1 str2]
  (if-not (= (count str1) (count str2))
    (throw (IllegalArgumentException. "Strings must be equal size.")))
  (loop [s1 str1
         s2 str2
         score 0]
    (if (empty? s1)
      score
      (recur (rest s1) (rest s2)
             (+ score (if (= (first s1) (first s2)) 0 1))))))
</pre>
</div>

<p>
This uses Clojure's tail-recursive optimizing functions <code>loop</code> and <code>recur</code> to compare the strings one-by-one, and calculate their Hamming distance (we've got a check in there to make sure they're the same length, and throw an error if not).
</p>

<p>
Once that was complete, I built out a way to sift through the list of boxes to find just the ones with a Hamming distance of 1. This returns a two-item sequence, one for each swap of matching (there's probably an optimization there to not go through the entire list):
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn find-christmas-boxes [input]
  (keep identity (map (fn [base-str]
                        (let [target-box (filter #(= 1 (hamming % base-str)) input)]
                          (if-not (empty? target-box)
                            [base-str (first target-box)]))) input)))
</pre>
</div>

<p>
There's a couple of cool things to point out here. First, the base <code>map</code> function will return a lot of <code>nil</code> (Clojure's <code>null</code> value). In order to get rid of those, we use the <code>identity</code> function (which basically says "return true if truthy"; it's effectively a cleaner <code>(not (nil? thing))</code>). Another thing to point out for non-Clojurists is that shorthand function declaration used in the <code>filter</code> call:
</p>

<div class="org-src-container">
<pre class="src src-clojure">;; These two are equivalent:
#{+ % 3}

(fn [arg] (+ arg 3))
</pre>
</div>

<p>
Finally, the AoC puzzle asks for the common characters between the two strings. This is close to the Hamming Distance function above, but we just need to drop a character if it doesn't match. This got reduced to the following:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn remove-uncommon-letter [s1 s2]
  (apply str (keep-indexed #(if (= (get s2 %1) %2) %2) s1)))

;; To execute everything:
;; (apply remove-uncommon-letter (first find-christmas-boxes input))
;; where input is the raw input string from the project.
</pre>
</div>

<p>
<code>apply</code> is the cool bit here - using <code>apply</code> allows you to use vector (read: array) entries as arguments to a function:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(let [numbers-to-add [1 2 3 4 5 6]]
 (apply + numbers-to-add)) =&gt; 21
</pre>
</div>

<p>
And hey - no borrowing from anyone else today, and right before day 3 releases. I'm saving that for tomorrow, though. :D The Github Gist for today's problems is <a href="https://gist.github.com/ballpointcarrot/8bec8ebd2bfe8b3a0739eba824eeed1b">right here</a>.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Well, I should've been paying attention</title>
<link>https://www.ballpointcarrot.net/posts/2013-08-09-well-i-shouldve-been.html</link>
<pubDate>Mon, 19 Aug 2013 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2013-08-09-well-i-shouldve-been.html</guid>
<description>
<![CDATA[<p>
So, I guess on 30 April 2013, Posterous Spaces was shuttered. You should see <a href="http://www.posterous.com">what's there now</a>.
</p>

<p>
Then, a full three months later, someone tells me that ballpointcarrot.net isn't functioning.
I figure, "I can check it when I find some time. It's been busy."
</p>

<p>
Cue almost a <b>month</b> after that, and I find that Posterous is gone (as is the content on the old blog).
Now, I'm working to rebuild and reset different platforms/ideas that can both provide me CNAME linking
to <a href="http://blog.ballpointcarrot.net">blog.ballpointcarrot.net</a>, and I ran across Github Pages and Octopress.
I'm gonna give it a try for a while, and see what happens.
</p>

<p>
Meanwhile, the main ballpointcarrot site has to go through a redesign, as the automatic feed parsing thing has
broken enough times that it's time to replace it. Expect a new look (but the same old logo) sometime when I find
some more time again - so November, maybe. :S
</p>
]]>
</description></item>
<item>
<title>Learning a New Editor</title>
<link>https://www.ballpointcarrot.net/posts/2014-02-07-learning-a-new-editor.html</link>
<pubDate>Fri, 07 Feb 2014 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2014-02-07-learning-a-new-editor.html</guid>
<description>
<![CDATA[<div id="outline-container-orgb2f89dc" class="outline-2">
<h2 id="orgb2f89dc"><span class="section-number-2">1.</span> Background</h2>
<div class="outline-text-2" id="text-1">
<p>
I often fall back to my (now well-worn) copy of <a href="http://pragprog.com/book/tpp/the-pragmatic-programmer">The Pragmatic Programmer</a> to take a look at things I can do to hone my abilities as a programmer. Recently, the two rules that have most recently hit me as things I haven't put much focus on are <b>Invest Regularly in Your Knowledge Portfolio</b>, and <b>There Are No Final Decisions</b>. In a fit of Christmas downime enegry, I decided to incorporate these principles by taking myself out of my normal comfort zone, and cutting out one of my most widely used tools - vim.
</p>

<p>
I've been a vimmer for many years, and I've incorporated utilities passed down from greater minds than I (Tim Pope, the guys at Pivotal, etc.) and had become comfortable in how I used my text editor day-to-day. I had a nice workflow set up, utilizing multiple vim tabs and separate sessions within tmux windows, and life was pretty good.
</p>

<p>
Then, in December, the challenge was set: strip vim out of my workflow for good, and find something else.
</p>

<p>
Naturally, and guided by one of my coworkers, I managed to settle on what is generally considered to be the prime competitor to vim - Emacs.
</p>
</div>
</div>
<div id="outline-container-org965298c" class="outline-2">
<h2 id="org965298c"><span class="section-number-2">2.</span> Baby Steps</h2>
<div class="outline-text-2" id="text-2">
<p>
I've had forays into learning Emacs before, but I've always shied away, after playing with some basic tooling, and forgetting how to close it more often than I care to admit. This time was different, though; I had more years of experience under my belt, and it was more about getting myself into an uncomfortable place before I gain more knowledge.
</p>

<p>
My first thought was to find some type of starting guide. While the Emacs tutorial helped in terms of understanding navigation and simple editing, it didn't really show me the true power of the environment that I had gained. A cursory google search brought me to the <a href="https://github.com/technomancy/emacs-starter-kit">Emacs Starter Kit</a>. This toolkit provides some default setting to get you started with the environment; I used the documentation around it to gain knowledge of things like Melpa and Marmalade, which act as Emacs Package Managers of sorts.
</p>

<p>
Following my initial setup with the starter kit, I started delving into the <a href="http://www.emacswiki.org/emacs/">emacs wiki</a>. This became a much more handy resource to me, as it provided me with multiple provided solutions to given issues that I've encountered while converting my vim-based mind to a constantly-insert-enabled editor. When I'd run into an issue where I found something I'd like to do similar to vim, I'd head to the wiki to find what analogs are available. Once I'd find a package which did what I looked for, I'd test it out with an M-x pacakge-install, and incorporate it into my init.el when I felt I had it down.
</p>
</div>
<div id="outline-container-orgdcd493f" class="outline-3">
<h3 id="orgdcd493f"><span class="section-number-3">2.1.</span> Evil?</h3>
<div class="outline-text-3" id="text-2-1">
<p>
I had been asked while converting why I decided not to use a vi-like editor package for Emacs (like Evil or Viper). I felt that, if I were to do this, it would be skimping out on what I should be learning, and I'd get less of an understanding of Emacs because I was sticking to my old method of doing things. Thus, I opted for Emacs's standard of editing, and no vi-emulation modes.
</p>
</div>
</div>
</div>
<div id="outline-container-org4394bc2" class="outline-2">
<h2 id="org4394bc2"><span class="section-number-2">3.</span> Post-move</h2>
<div class="outline-text-2" id="text-3">
<p>
These are the things that I've discovered in the two months since I switched:
</p>

<ul class="org-ul">
<li>Split pane support. I actually like the way that Emacs splits its windows better than vim. A C-x 2 or C-x 3 is an easy way to remember it; coupled with the 'workgroups2' package, configurations can be stored across sessions, too.</li>
<li>Lisp. This has been a slow one for me, but I'm becoming more interested in learning Lisp and Lisp-like languages, like Clojure. I have a lot of work to do here, and that will be something to work on in the future.</li>
<li>Tramp. Being able to edit files across an SSH tunnel is a fantastic feature.</li>
<li>Buffers without files. Since the editor is meant to live on indefinitely, it's nice to spin up a new buffer and set the mode(s) I want, and let it reside in memory for a while before saving it. If I need to, a save is close enough away, but it works wonders for when I need to take some quick notes.</li>
<li>ERC. I no longer need a separate IRC cilent; Emacs handles it for me. This is fantastic for me at work, where we frequently use chat to talk around.</li>
</ul>

<p>
Things I wish I had from Vim:
</p>

<ul class="org-ul">
<li>Sentence-like movement. I've sort of rebuilt this on my own with a combination of line-jumps (M-x goto-line) and ace-jump-mode, but being able to translate "<sup>3wci</sup>(" into what it can do in Vim is a skill I have yet to master.</li>
<li>Mixing modes in HTML. This was noticeably less of a problem in Vim, but I don't know if it was due to the editor or my lack of noticing that showed just how difficult it is to switch contexts from HTML/CSS/JS all in the same file. I've tried doing the nXML hack and multiple modes, but those have worked to no avail.</li>
<li>Closing the editor. True, I can leave Emacs. But, I miss popping up a new window for one file, and then leaving right after a quick edit.</li>
<li>Workspace management. Because of the way I separated files into tabs in Vim, I knew each tab matched a different section of what I was working on (or another project entirely).  I lack this with the way that buffers are managed by default in Emacs. I'm still looking for better ways of handling this management, though - workgroups2 has been a nice start.</li>
</ul>

<p>
Things I know I still have yet to learn:
</p>

<ul class="org-ul">
<li>More Lisp. I've gotten a good start, but that's a deep rabbit hole.</li>
<li>Shell, email within Emacs. I used to use a lot of separate tools - now that Emacs contains most of them, I'd like to get better at handling those tasks within Emacs.</li>
<li>Org-mode. I've seen my coworker pull off some crazy things with scheduling and notes within Org-mode, and I'd love to get to the point where I can do them, too.</li>
<li>Macros and scripting. My next Pragmatic tenet is <b>Write Code That Writes Code</b>; I think getting your editor set to facilitate your programming counts. :)</li>
</ul>

<p>
We'll see what the next few months hold.
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>Making the Shell Less Scary - Starting out</title>
<link>https://www.ballpointcarrot.net/posts/2019-03-31-shell-less-scary-first-commands.html</link>
<pubDate>Sun, 31 Mar 2019 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2019-03-31-shell-less-scary-first-commands.html</guid>
<description>
<![CDATA[<p>
I will fully admit that I grew up comfortable working on a computer without a GUI. From my early days, I had an old computer that I mainly used to play games (some things never change, but current ones don't come on 5 1/4" floppies); in order to get those games to run, I learned from my Mom how to access the correct drive, and the commands to run in order to start up the game.
</p>

<p>
Today, even though we have fancy GUI apps to do a lot of the work that we need to get done on a daily basis, I still find that it's easier for me to quickly open a terminal window, enter a few commands, and complete whatever task I was doing. Not everything benefits from this approach (imagine doing image editing with a text editor!), but tasks involving finding files, moving files around the system, and working on remote systems works are things that I would much prefer a terminal for.
</p>

<p>
Today I'm going to dive into a few of the commands that do just the things that I was talking about. These are some of the commands that you would end up using on  a day-to-day basis in a terminal window; hopefully I can shine some light on some corners of them that you don't expect.
</p>
<div id="outline-container-org59766d4" class="outline-2">
<h2 id="org59766d4"><span class="section-number-2">1.</span> Directories and Files</h2>
<div class="outline-text-2" id="text-1">
<p>
Let's say you're an avid photographer - you'll have a lot of photos collected. In order to make sense of your collection, you're going to want to organize those photos. If they were physical photos, you'd want to collect them by the event that you took them at:
</p>

<ul class="org-ul">
<li>Tim's birthday party</li>
<li>Joe's wedding</li>
<li>Vacation photos from Las Vegas</li>
<li>random photos of food</li>
<li>far too many cat pictures</li>
<li>etc.</li>
</ul>

<p>
Additionally, let's say these photos happened over the course of a few years.
</p>

<p>
Borrowing from the physical realm, we can place these photos into different folders, or <b>directories</b>, in order to keep them organized. Let's lay them out like so:
</p>

<ul class="org-ul">
<li>2018
<ul class="org-ul">
<li>Joe's Wedding</li>
<li>I &amp;lt;3 Food</li>
<li>My Cat</li>
</ul></li>
<li>2019
<ul class="org-ul">
<li>Tim's Bday Bash</li>
<li>Vegas trip</li>
<li>My Cat</li>
<li>I &lt;3 Food</li>
</ul></li>
</ul>

<p>
You'll notice there are duplicate names here - that's okay, because they're nested within two different folders.
</p>

<p>
Now, all of these folder names are legit as they stand, but they'll be a little harder to deal with when on the command line with some of the special characters and spaces. It's a standard convention to replace spaces and special characters in names to make it easy to deal with, while retaining most of the meaning that was present in the original names; most of the replacements are things like dashes or underscores. This would be my likely replacement:
</p>

<ul class="org-ul">
<li>2018
<ul class="org-ul">
<li>joe-wedding</li>
<li>i-heart-food</li>
<li>my-cat</li>
</ul></li>
<li>2019
<ul class="org-ul">
<li>tim-bday-bash</li>
<li>vegas-trip</li>
<li>my-cat</li>
<li>i-heart-food</li>
</ul></li>
</ul>

<p>
Syntactically very similar, and much easier to deal with while typing.
</p>

<p>
So rather than pulling up a file manager window, let's make this structure out of commands at a terminal.
</p>
</div>
</div>
<div id="outline-container-org9c565c2" class="outline-2">
<h2 id="org9c565c2"><span class="section-number-2">2.</span> <code>mkdir</code> makes the dirs</h2>
<div class="outline-text-2" id="text-2">
<p>
the <code>mkdir</code> command is used to make a directory. The basic invocation is very straightforward:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mkdir &lt;folder-name&gt;
</pre>
</div>

<p>
This command will create a new directory with the given name based on the directory you're currently in (referred to as your 'Current Working Directory' or 'Present Working Directory'). Sometimes the terminal you're using will tell you where you are as part of the prompt; even if not, you can find out by running the command <code>pwd</code> to give you that directory.
</p>

<div class="org-src-container">
<pre class="src src-plain">$ pwd
/home/ballpointcarrot
</pre>
</div>

<p>
So let's make our photo collection structure:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mkdir 2018

</pre>
</div>

<p>
Wait&#x2026; Nothing came back. Did it do anything?
</p>
</div>
</div>
<div id="outline-container-orgc9937d0" class="outline-2">
<h2 id="orgc9937d0"><span class="section-number-2">3.</span> add <code>ls</code> to the list</h2>
<div class="outline-text-2" id="text-3">
<p>
<code>ls</code> is a versatile command - it gives you a listing of your PWD. This becomes handy when you're looking around you filesystem, and generally know where something is located. If we do an <code>ls</code> where we are now, you'll see something like:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ ls
2018/   Desktop/        Downloads/      Notes/          Videos/
Books/  Documents/      Music/          Photos/
</pre>
</div>

<p>
Oops&#x2026; that 2018 isn't in the right spot. Let's move it with <code>mv</code>:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mv 2018 Photos
</pre>
</div>

<p>
Again, we get no output signifying anything. However, on the next <code>ls</code>:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ ls
Books/          Documents/      Music/  Photos/
Desktop/        Downloads/      Notes/  Videos/
</pre>
</div>

<p>
Now we can see that the 2018 folder is no longer here. We want to make sure that it's in the Photos directory though, so we'll check there, too:
</p>

<p>
&gt; Note: this shows that the <code>ls</code> command can be used on folders - meaning you don't have to be <b>in</b> the folder to use <code>ls</code>. That gets handy when you're searching a lot of subfolders.
</p>

<div class="org-src-container">
<pre class="src src-plain">$ ls Photos
10262018_0001.JPG  10262018_0035.JPG  10262018_0069.JPG  10262018_0103.JPG  10262018_0137.JPG  10262018_0171.JPG  10262018_0205.JPG  10262018_0239.JPG  10262018_0273.JPG  10262018_0307.JPG
10262018_0002.JPG  10262018_0036.JPG  10262018_0070.JPG  10262018_0104.JPG  10262018_0138.JPG  10262018_0172.JPG  10262018_0206.JPG  10262018_0240.JPG  10262018_0274.JPG  10262018_0308.JPG
10262018_0003.JPG  10262018_0037.JPG  10262018_0071.JPG  10262018_0105.JPG  10262018_0139.JPG  10262018_0173.JPG  10262018_0207.JPG  10262018_0241.JPG  10262018_0275.JPG  10262018_0309.JPG
10262018_0004.JPG  10262018_0038.JPG  10262018_0072.JPG  10262018_0106.JPG  10262018_0140.JPG  10262018_0174.JPG  10262018_0208.JPG  10262018_0242.JPG  10262018_0276.JPG  10262018_0310.JPG
...
</pre>
</div>

<p>
Whoa! Where's the 2018 folder? These are all just JPG files (the photos that I've been dumping without organizing into the Photos folder). Fortunately, I can filter out the type of object returned from <code>ls</code>:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ ls -d */
2018//
</pre>
</div>

<p>
There's our folder. Now let's explain that command: the <code>-d</code> within the command tells <code>ls</code> that we just want directories, and not files. However, <code>ls</code> isn't smart enough on its own to just grab the directories on its own; we have to explicitly say grab "all directories", which is where <code>*/</code> comes in - it signifies "anything in the current directory" with the asterisk (also called a star or wildcard), and the forward slash is for anything designated a folder.
</p>

<p>
Let's get to work on the rest of those folders. First, let's put ourselves in the right place.
</p>
</div>
</div>
<div id="outline-container-org809d0f3" class="outline-2">
<h2 id="org809d0f3"><span class="section-number-2">4.</span> <code>cd</code> - not just for music</h2>
<div class="outline-text-2" id="text-4">
<p>
The <code>cd</code> command changes our current working directory. By changing directories, it gives us the ability to change context with what we're doing on the filesystem. In our case, we'll change to the Photos directory, because we're working in the context of organizing our Photos. Makes sense.
</p>

<div class="org-src-container">
<pre class="src src-plain">$ cd Photos

</pre>
</div>

<p>
Again, the command has now output, but we can do a <code>pwd</code> and see that we've changed places:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ pwd
/home/ballpointcarrot/Photos
</pre>
</div>

<p>
Now let's finish up our 2018 folders. Me, being lazy, want to do everything in one shot - fortunately, <code>mkdir</code> lets us do just that:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mkdir 2018/joe-wedding 2018/i-heart-food 2018/my-cat
</pre>
</div>

<p>
This creates three folders, all nested neatly under the 2018 folder. "Great!", we say, and we go to do 2019:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mkdir 2019/tim-bday-bash 2019/vegas-trip 2019/my-cat 2019/i-heart-food
mkdir: cannot create directory ‘2019/tim-bday-bash’: No such file or directory
mkdir: cannot create directory ‘2019/vegas-trip’: No such file or directory
mkdir: cannot create directory ‘2019/my-cat’: No such file or directory
mkdir: cannot create directory ‘2019/i-heart-food’: No such file or directory
</pre>
</div>

<p>
Uh oh&#x2026; because we never created the parent 2019 folder, it's not allowing us to build the rest of the directories. We can outwit it though; <code>mkdir</code> has a parameter option <code>-p</code>, which gives us the ability to make parent directories within the same call:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mkdir -p 2019/tim-bday-bash 2019/vegas-trip 2019/my-cat 2019/i-heart-food

</pre>
</div>

<p>
All good. Just to double-check:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ ls 2019
tim-bday-bash/  vegas-trip/     my-cat/         i-heart-food/
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd75d74f" class="outline-2">
<h2 id="orgd75d74f"><span class="section-number-2">5.</span> Moving the files in</h2>
<div class="outline-text-2" id="text-5">
<p>
So now we've got our directory structure in the Photos directory, with a boatload of random JPG files. How are we going to get them organized? It looks like a lot of them are around the same dates (look at all the 10262018<sub>xxxx</sub> files we have up there). Let's take a look at one or two of them to get a sample, to make sure it's the right event. 
</p>

<blockquote>
<p>
Note: This step will be different depending on the platform you're on, so I'll give both.
</p>
</blockquote>

<div class="org-src-container">
<pre class="src src-sh"># OSX example
$ open 10262018_0001.JPG

# Linux example
$ xdg-open 10262018_0001.JPG
</pre>
</div>

<p>
Both of these commands do the same thing - they ask the current environment to figure out who the best person to open a JPG file is, and then executes that program. Ideally, you'll see a window with your picture loaded.
</p>
</div>
<div id="outline-container-org7792b79" class="outline-3">
<h3 id="org7792b79"><span class="section-number-3">5.1.</span> <span class="todo TODO">TODO</span> Update image link</h3>
<div class="outline-text-3" id="text-5-1">
<p>
![miles](/images/miles.jpg)
</p>

<p>
Oh look, it's a cat photo. We know where those are supposed to go. I'm going to assume the 300+ photos around this time period are all cat photos (don't judge). We're going go go back to using the `mv` command. However, instead of individually moving the files one-by-one (which would take <b>forever</b>), we'll make use of our friend the wildcard, and make all of the files move on their own:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ mv 10262018_* 2018/my-cat

</pre>
</div>

<p>
Again, we get nothing back as output, so let's double-check:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ ls 2018/my-cat
10262018_0001.JPG  10262018_0035.JPG  10262018_0069.JPG  10262018_0103.JPG  10262018_0137.JPG  10262018_0171.JPG  10262018_0205.JPG  10262018_0239.JPG  10262018_0273.JPG  10262018_0307.JPG
10262018_0002.JPG  10262018_0036.JPG  10262018_0070.JPG  10262018_0104.JPG  10262018_0138.JPG  10262018_0172.JPG  10262018_0206.JPG  10262018_0240.JPG  10262018_0274.JPG  10262018_0308.JPG
10262018_0003.JPG  10262018_0037.JPG  10262018_0071.JPG  10262018_0105.JPG  10262018_0139.JPG  10262018_0173.JPG  10262018_0207.JPG  10262018_0241.JPG  10262018_0275.JPG  10262018_0309.JPG
10262018_0004.JPG  10262018_0038.JPG  10262018_0072.JPG  10262018_0106.JPG  10262018_0140.JPG  10262018_0174.JPG  10262018_0208.JPG  10262018_0242.JPG  10262018_0276.JPG  10262018_0310.JPG
...
</pre>
</div>

<p>
Great - all our cat photos are now pleasantly sorted.
</p>

<p>
I'll leave us here for now. I want to make this a continuing series of posts, so please let me know if there's a command that you're interested in. I know that this one may be a little too basic for a lot of dev-types, but hey - everyone has to start somewhere, right? As long as someone makes use of it, I'm happy.
</p>
</div>
</div>
</div>
]]>
</description></item>
<item>
<title>Tracking while you Gogo</title>
<link>https://www.ballpointcarrot.net/posts/2017-01-09-tracking-while-you-gogo.html</link>
<pubDate>Mon, 09 Jan 2017 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2017-01-09-tracking-while-you-gogo.html</guid>
<description>
<![CDATA[<p>
I'm flying a lot more as part of my current job. As I write this, I'm on a flight from Seattle to Salt Lake City (first of a connection). I enjoy the fact that I can connect to the internet while going over 500 MPH at nearly 30,000 feet in the air - it's a wonder of science that I can do these things.
</p>

<p>
However, sometimes the cost of getting the in-flight internet is a little over-the-top. Most of the time, I'll connect to the hotspot, but then use my laptop offline (<a href="http://devdocs.io">http://devdocs.io</a> offline mode is perfect for this).
</p>

<p>
&#x2014;
</p>

<p>
On one of my last flights, though, I wanted to see just what I had access to. On Delta flights, there's a flight status tracker on the web portal during the flight, which provides details about how the flight is going, times to arrival, and other flight data. A data nerd by nature, this is something I want, and normally pull up on the seat-back entertainment system (instead of watching a movie like a normal human being.)
</p>

<p>
So, I chose to dive in to the Gogo portal to see what was possible. A quick look at the dev console in Chrome shows how the flight data page loads:
</p>

<p>
![Chrome tools](/assets/img/delta-gogo-chrome-devtools.png)
</p>

<p>
To my delight, not only do we have JSON requests for data, but they're straightforward, easy to parse GET requests (easier to deal with than POSTs). To see how these are requested, I ran a quick `dig` call against each of the FQDNs that were presented.
</p>

<div class="org-src-container">
<pre class="src src-plain">Dig responses:
airborne.gogoinflight.com: 10.241.xxx.xxx
utils.gogoinflight.com: 10.241.xxx.xxx
d.sda.gogoinflight.com: -&gt; gogoair-d3.openxenterprise.com -&gt; 173.241.xxx.xxx
fig.gogoinflight.com:
        10.246.118.xxx
        10.246.119.xxx
        10.246.120.xxx
</pre>
</div>

<p>
Everything is in private class addressing space, meaning all of this routes internally within Gogo's network. Meaning, we should be able to make these requests both inside and outside of the browser.
</p>

<p>
The first we'll look at, "statusTray", doesn't even need any parameters:
<code>curl http://airborne.gogoinflight.com/abp/ws/absServices/statusTray</code> gives me a straight JSON output of random details, including (amusingly) "gogoFacts", a random fact that Gogo provides as interesting info (and a little bit of advertisement).
</p>

<div class="org-src-container">
<pre class="src src-json">{
   "Response" : {
      "serviceInfo" : {
         "service" : "Inactive",
         "remaining" : 0
      },
      "status" : 200,
      "gogoFacts" : "The world record for the longest Wi-Fi connection is" +
      "237 miles, held by Ermanno Pietrosemoli of Venezuela, who transferred"+
      "about 3 MB of data between the mountaintops of El Aguila and Platillon.",
      "flightInfo" : {
         "tailNumber" : "N3753",
         "HSpeed" : 576.4907,
         "longitude" : -119,
         "utcTime" : "2017-01-09T18:36:18.583Z",
         "expectedArrival" : "2017-01-09T19:34:14Z",
         "airlineCode" : "DAL",
         "acpuVersion" : "10.4.0",
         "altitude" : 33882.277,
         "flightNumberInfo" : "DAL1319",
         "latitude" : 45.37,
         "videoService" : false,
         "abpVersion" : "7.0.1",
         "departureAirportCode" : "KSEA",
         "destinationAirportCode" : "KSLC",
         "VSpeed" : 0.6136283
      }
   }
}
</pre>
</div>

<blockquote>
<p>
Interestingly enough, this response was different on my flight today vs. the flight last week I played around with these requests. Your response(s) may be different. For instance, my new flight only responded with ICAO airport codes, and no IATA (3-letter) codes. The second request can use either, from what I can tell.
</p>
</blockquote>

<p>
Based on this output, we can use a number of these values to craft the request for the "flightStatusByLeg" request:
</p>

<div class="org-src-container">
<pre class="src src-ruby">"http://utils.gogoinflight.com/flightService/flightStatusByLeg?"+
"flightNum=#{data["Response"]["flightInfo"]["flightNumberInfo"]}"+
"&amp;depDate=#{Time.now.strftime("%Y-%m-%d")}"+
"&amp;originCode=#{data["Response"]["flightInfo"]["departureAirportCode"]}"+
"&amp;destCode=#{data["Response"]["flightInfo"]["destinationAirportCode"]}"
</pre>
</div>

<p>
This request comes back as JSONP, or a JSON block wrapped in an executable function (a common method of executing code on callback in an AJAX request). If you're parsing it as JSON, you'll have to remove the function call before parsing:
</p>

<div class="org-src-container">
<pre class="src src-ruby">data2json = JSON.parse(data2.gsub!("DLFSCallback (","").gsub!(/\);$/, ""))
</pre>
</div>

<p>
This data set is much larger; mostly, because it gives you a sequenced point-to-point data stream of latitude, longitude, ground speed, and altitude! This data could be plotted and graphed in any way you see fit (my goal for next flight is to tie it to D3.js to plot my flight status :D).
</p>

<div class="org-src-container">
<pre class="src src-json">{
   "flightStatusResponse" : {
      "flightStatusByLegResponse" : {
         "flightStatusTO" : {
            "flightOriginDate" : "2017-01-09T00:00:00.001-05:00",
            "flightNumber" : "1319",
            "changeOfAircraft" : "false",
            "flightPositionTO" : {
               "altitude" : "37000",
               "inFlightTimeMinutes" : "55",
               "actualPositions" : [
                  {
                     "timeOver" : "0",
                     "sequence" : "1",
                     "latitude" : "47.4488",
                     "groundSpeed" : "0",
                     "longitude" : "-122.30944",
                     "altitude" : "433"
                  },
                  {
                     "groundSpeed" : "0",
                     "latitude" : "47.4462",
                     "sequence" : "2",
                     "timeOver" : "1483985273",
                     "longitude" : "-122.3081",
                     "altitude" : "300"
                  },
                  {
                     "longitude" : "-122.3082",
                     "altitude" : "1700",
                     "latitude" : "47.424",
                     "groundSpeed" : "0",
                     "timeOver" : "1483985303",
                     "sequence" : "3"
                  },
                  {
                     "altitude" : "1800",
                     "longitude" : "-122.3072",
                     "groundSpeed" : "187",
                     "latitude" : "47.42333",
                     "timeOver" : "1483985305",
                     "sequence" : "4"
                  },
                  //...
</pre>
</div>

<p>
Anyway, this is all retrievable without paying for the Gogo wifi; just a way to keep you entertained during the flight.
</p>
]]>
</description></item>
<item>
<title>Running Rust on AWS Lambda on ARM64</title>
<link>https://www.ballpointcarrot.net/posts/2021-10-06-rust-arm-lambdas.html</link>
<pubDate>Wed, 06 Oct 2021 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2021-10-06-rust-arm-lambdas.html</guid>
<description>
<![CDATA[<div id="outline-container-orgf8cc197" class="outline-2">
<h2 id="orgf8cc197"><span class="section-number-2">1.</span> TODO: fix image links</h2>
<div class="outline-text-2" id="text-1">
<blockquote>
<p>
TL;DR: Rust on ARM64 Lambda: check out <a href="https://github.com/ballpointcarrot/lambda-rust-arm64">my example repo</a>
</p>
</blockquote>

<p>
I've been a hobbyist Rust developer for a while now, playing with random tools and mostly having false starts on projects that I'd like to build, but then the energy to do so wanes before I can complete them. Because of that, I always look for new applications for Rust to fit somewhere in my day-to-day, so that I can give myself some practice.
</p>

<p>
I also work very closely with AWS Serverless tooling in my daily work at <a href="https://stedi.com">Stedi</a>. Recently, AWS posted an update to the Lambda service that they were providing <a href="https://aws.amazon.com/about-aws/whats-new/2021/09/better-price-performance-aws-lambda-functions-aws-graviton2-processor/">Graviton2-based Lambda functions</a> as part of the service, and I immediately thought to myself, "How would I do a Rust lambda that way?"
</p>

<p>
Lambda gives you the ability to create a <a href="https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html">"Custom" runtime</a> - all you need to do is provide a executable that acts as a bootstrap for running the function (aptly named "bootstrap" in the runtime code). By building that as a rust binary with the correct architecture, we can run Rust code natively on the Lambda!
</p>
</div>
<div id="outline-container-org56520a8" class="outline-3">
<h3 id="org56520a8"><span class="section-number-3">1.1.</span> Project Setup</h3>
<div class="outline-text-3" id="text-1-1">
<p>
I started with a vanilla cargo project, and added the following into the cargo.toml:
</p>

<div class="org-src-container">
<pre class="src src-toml">[[bin]]
name = "bootstrap"
path = "src/main.rs"

[dependencies]
lambda_runtime = "^0.4"
tokio = "^1"
serde = { version = "^1", features = ["derive"] }
serde_json = "^1"
</pre>
</div>

<p>
The <code>[[bin]]</code> section allows us to specify the binary filename for what's built (and saves us renaming the file after compilation). The dependencies are all references and dependencies of <a href="https://github.com/awslabs/aws-lambda-rust-runtime">the AWS Rust runtime crates</a> - that's where the code for the function we'll be using is pulled from.
</p>

<p>
we just have one file in the source directory, at <code>src/main.rs</code>:
</p>

<div class="org-src-container">
<pre class="src src-rust">use lambda_runtime::{handler_fn, Context, Error};
use serde_json::{json, Value};

#[tokio::main]
async fn main() -&gt; Result&lt;(), Error&gt; {
    let funct = handler_fn(func);
    lambda_runtime::run(funct).await?;
    Ok(())
}

async fn func(event: Value, _: Context) -&gt; Result&lt;Value, Error&gt; {
    let first_name = event["firstName"].as_str().unwrap_or("world");
    Ok(json!({"message": format!("Hello, {}!", first_name)}))
}
</pre>
</div>

<p>
For those less savvy with Rust code, this defines the 'bootstrap' runtime under <code>main()</code>, and calls the async function <code>func()</code> to act as the lambda function body. Our function responds with a message of "Hello, World!" in a JSON response by default, or can respond with a specific greeting when passed a "firstName" JSON value as part of its input.
</p>

<p>
Now, you could build this locally, but because of the way that the lambda function is called, local runs will panic:
</p>

<div class="org-src-container">
<pre class="src src-plain">± cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.39s
     Running `target/debug/bootstrap`
thread 'main' panicked at 'Missing AWS_LAMBDA_RUNTIME_API env var: NotPresent', /home/ckruse/.asdf/installs/rust/stable/registry/src/github.com-1ecc6299db9ec823/lambda_runtime-0.4.1/src/lib.rs:57:58
</pre>
</div>

<p>
The immediate goal here is to run it in lambda, and not locally, so we'll save testing it out on our own for a later time.
</p>
</div>
<div id="outline-container-orgae213e0" class="outline-4">
<h4 id="orgae213e0"><span class="section-number-4">1.1.1.</span> Cross-Compiling</h4>
<div class="outline-text-4" id="text-1-1-1">
<p>
The example that is provided in the AWS Rust runtime repository shows them using a <a href="https://github.com/awslabs/aws-lambda-rust-runtime#aws-cli">custom linker and rustup target</a> in order to cross-compile for x86-based lambdas. I attempted to dive into how to get a arm64-based linker, but in the process of trying to figure out how to get that linker installed locally (no convenient packages for Ubuntu, sorry), I stumbled across a project that provides cross-compilation tooling for various platforms via Docker. That made my life a lot easier - Using the <a href="https://github.com/messense/rust-musl-cross">rust-musl-cross</a> Docker container, all I have to do is wrap the call to <code>cargo build</code>, and it builds for the proper architecture:
</p>

<div class="org-src-container">
<pre class="src src-sh">#!/bin/sh

build_arch=aarch64-musl

docker run --rm -it -v "$(pwd)":/home/rust/src messense/rust-musl-cross:$build_arch $@
</pre>
</div>

<p>
Armed with that (pardon the pun), I can now call <code>./musl-build cargo build --release</code>, and I get a resulting binary at <code>target/aarch64-unknown-linux-musl/release/bootstrap</code>.
</p>

<p>
The final step, as called out in the AWS Rust runtime docs, is to bundle that executable up in a Zip file, so that the Lambda service can construct what it needs to on its side. I've made the `package.sh` file in the repo to handle that and act as a basic build script (I'll probably convert this to a Makefile later when feeling energetic):
</p>

<div class="org-src-container">
<pre class="src src-sh">#!/bin/sh

mkdir -p dist

if [ ! -d target/aarch64-unknown-linux-musl ]; then
  ./musl-build cargo build --release
fi

# TODO: use vars for arch folder and binary name
cp target/aarch64-unknown-linux-musl/release/bootstrap dist/
cd dist &amp;&amp; zip package.zip bootstrap &amp;&amp; cd ..
</pre>
</div>

<p>
Now, after running that command, I can grab the file at <code>dist/package.zip</code> and go take that to AWS Lambda to run:
</p>

<p>
With no arguments provided:
</p>

<p>
![Rust Lambda without name](./rust-arm-lambda-default.png)
</p>

<p>
With a name provided:
</p>

<div class="org-src-container">
<pre class="src src-json">{
  "firstName": "Christopher"
}
</pre>
</div>

<p>
![Rust Lambda with firstName](./rust-arm-lambda-name.png)
</p>
</div>
</div>
</div>
<div id="outline-container-org84ea7d3" class="outline-3">
<h3 id="org84ea7d3"><span class="section-number-3">1.2.</span> Conclusion</h3>
<div class="outline-text-3" id="text-1-2">
<p>
I hope you can use this to make a running start building out lambda function code on the new Graviton2-based Lambda runners. Let me know if this helped you out!
</p>
</div>
</div>
</div>
]]>
</description></item>
<item>
<title>Advent of Code 2018 - Day 3</title>
<link>https://www.ballpointcarrot.net/posts/2028-12-03-advent-of-code-2018-3.html</link>
<pubDate>Mon, 03 Dec 2018 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2028-12-03-advent-of-code-2018-3.html</guid>
<description>
<![CDATA[<div id="outline-container-org53ff2d6" class="outline-2">
<h2 id="org53ff2d6"><span class="section-number-2">1.</span> <span class="todo TODO">TODO</span> fix image links</h2>
<div class="outline-text-2" id="text-1">
<p>
Solving these problems has been more difficult than I originally imagined - these aren't your FizzBuzz-level problems; they're asking for a little bit more (especially the second halves). I got a little bit of a head start on day three, as I'm three hours behind the release of the problems, and that means I get to have some time before bed to think about them. This proved bad, as I was laying in bed thinking about solving things (which makes sleeping nigh impossible :D).
</p>

<p>
On this particular night/day, I had some issues with work (and I was on-call for my team at the time), so I got a second chance to look at them early in the morning (3am-ish local time). But, once I was up, I was up, so once the work problem subsided, I took a crack at getting the rest of the problem solved.
</p>

<p>
This is my first of these writeups to take place after-the-fact, so let me know if there's any issues with how it was covered here vs. the previous days.
</p>
</div>
<div id="outline-container-orgf764402" class="outline-3">
<h3 id="orgf764402"><span class="section-number-3">1.1.</span> Day 3, Part 1</h3>
<div class="outline-text-3" id="text-1-1">
<p>
After we saved the cloth from the previous problem, it's now up to the Elves to figure out how to cut it optimally. The problem statement makes the first assertion that the fabric is a square of 1000x1000 square inches. This proved useful to my method of solving the problem, as you'll see below.
</p>

<p>
Each elf makes a claim on the fabric to designate a rectangle they want to cut. The claims have the following format:
</p>

<p>
<code>#12 @ 3,4: 5x6</code>
</p>

<p>
Which is to be interpreted as "Claim number <code>12</code>, with the top corner location of <code>(x,y) = (3,4)</code>, has a width of <code>5</code> and a height of <code>6</code>."
</p>

<p>
To make sense of this, I used a <a href="https://www.regular-expressions.info/quickstart.html">regular expression</a> to isolate the various numerical terms (while <a href="https://xkcd.com/208/">regex is a superpower</a>, it is also a bit of a rabbit-hole, and I won't cover its general concepts here). Unfortunately, while Java 7+ has support for a regex feature called <a href="https://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#group%28java.lang.String%29">named capture groups</a>, Clojure does not have that support out of the box. However, the regex with the named groups still functions, but I can only get positional arguments. I built out a function that took an input claim, and built out a rather interesting set of responses:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defrecord Claim [claim-number squares])

(defn convert-to-grid
  "Converts a claim into a sequence of 'taken' squares."
  [claim grid-width]
  ;; Named groups would be great here, but Clojure doesn't support this natively.
  (let [matcher #"#(?&lt;claim&gt;\d+)\s@\s(?&lt;x&gt;\d+),(?&lt;y&gt;\d+):\s(?&lt;width&gt;\d+)x(?&lt;height&gt;\d+)$"
        matches (re-find matcher claim)
        [_ claim horiz vert width height] matches
        x (Integer. horiz)
        y (Integer. vert)
        w (Integer. width)
        h (Integer. height)
        rows (take h (iterate inc y))]
    (-&gt;&gt; (map #(range (+ x (* grid-width %)) (+ (+ x w) (* grid-width %))) rows)
         (flatten)
         (set)
         (Claim. (Integer. claim) ))))
</pre>
</div>

<p>
Let's walk through this example a little.
</p>

<p>
The first thing we see is the definition of a clojure <a href="https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/defrecord">record</a> (similar to a struct). Because Clojure lives on the JVM, this builds out effectively a Java class and allows you to instantiate objects of that type. The problem above could have been solved with a simple map, but I wanted to give readers of the codebase an easier way to have a mental model of the transformed claim. Additionally, this helps us keep track of the claim number, which is not important in Part 1, but makes a re-appearance in Part 2.
</p>

<p>
Because we know the width of the field we'll be working with in units, I made a choice to build out the "rectangle" that a claim represented by identifying the cells that the rectangle makes up. For example, in a 5x5 grid, with a claim of <code>#1 @ 2,0: 3x3</code>:
</p>

<p>
![5x5-grid](grid-set-example.png)
</p>

<p>
This leaves us with a set of squares: <code>#{2 3 4 7 8 9 12 13 14}</code>. The practical upshot here is now we can use set logic (difference, intersection, union) to manipulate the rectangles and calculate our details for overlaps. And that's just what I did:
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn get-overlap
  "returns the amount of overlap based on calculated inputs.
   Answer provided in square units matching the units entered
   (for the case of the problem, square inches)."
  [claims]
  ;; Perform intersection to find any matches, then union to combine; repeat through the list.
  (loop [mapped-area (map #(convert-to-grid % 1000) claims)
         shared-fabric #{}
         intersections #{}]
    (if (empty? mapped-area)
      intersections
      (let [intersect (set/intersection shared-fabric (:squares (first mapped-area)))
            union (set/union shared-fabric (:squares (first mapped-area)))]
        (recur (rest mapped-area) union (set/union intersections intersect))))))
</pre>
</div>

<p>
Again we see our friends <code>loop</code> and <code>recur</code> from Day 2. This section highlights one of my favorite things about Clojure - maniuplating data in bulk. We pass into this a vector of claim strings, that are parsed in the function above it. In just one <code>map</code> call, however, we were able to convert each of those strings into a grid area 1000x1000 wide. Once we have objects we can compute easily against, we go about calculating. :)
</p>

<p>
The <code>set/intersection</code> notation is new to these examples, because <code>clojure.set</code> is outside of Clojure's "Core" namespace - up until now we've been using functions packaged in <code>clojure.core</code>, which is loaded by default for a Clojure runtime. Since <code>clojure.set</code> isn't, we have to import it into the namespace (and in our case, provide it a nice short name to use when calling):
</p>

<div class="org-src-container">
<pre class="src src-clojure">(ns aoc.aoc3
  (:require [clojure.set :as set]))
</pre>
</div>

<p>
This allows us to call <a href="http://clojuredocs.org/clojure.set">functions in clojure.set</a> by using <code>set/fn-name</code>. For each iteration of the loop, we do three things:
</p>

<ol class="org-ol">
<li>We check against the "shared fabric". This is done by doing a set intersection between the current rectangle (defined by <code>(first mapped-area)</code>) and all of the rectangles that came before it.</li>
<li>We define the "shared fabric" by adding the current rectangle to the rectangles that have already been added by a set union.</li>
<li>When we cut back into the next iteration, we take the union of all found intersections in previous iterations, and the intersections we've found in this run. <b><b>This</b></b> piece is what gives us our total overlap at the end, as we're constantly accumulating more overlap; because it's a set, however, we're not recounting the same values, we're just including them as "overlapped" already.</li>
</ol>

<p>
Once this was done, I was able to solve Part 1 quickly.
</p>
</div>
</div>
<div id="outline-container-org96a84c9" class="outline-3">
<h3 id="org96a84c9"><span class="section-number-3">1.2.</span> Day 3, Part 2 (Sports Team: 0)</h3>
<div class="outline-text-3" id="text-1-2">
<p>
Now that we've found the overlapping area, our challenge is to find the rectangle which does <b>not</b> have any overlapping area within the list of claims. This is where keeping that claim number comes in handy.
</p>

<p>
I <b>wanted</b> to come up with a clever way of using the set notation used above to make a lightning-quick function for processing the list of rectangles to find one with no overlap, but nothing came to mind. (If anyone finds one, let me know and I'll owe you a coffee.) Instead, I used a little more of a brute force method: compare each grid to the list of grids, and cut out when you find no set intersections. This was a little more computationally intensive (<code>O(n^2)</code>), but given the count limit in the sample input, it wasn't too bad to sit for a few seconds while the laptop pounded it out.
</p>

<p>
I had one hiccup as I was putting this together - how do I managed the list of claims so that I don't run an intersection with myself? That would cause even the "no overlap" rectangle to match (as it's matching itself). What I ended up doing was breaking out the function that handled the overlapping calculation to have a check at the top that said "if you're the same rectangle by claim number, then return <code>nil</code>" - this allows you to pass the full list and not worry about matching yourself.
</p>

<div class="org-src-container">
<pre class="src src-clojure">(defn overlapping-claim [c1 c2]
  (cond
    (= (:claim-number c1) (:claim-number c2)) nil
    (not-empty (set/intersection (:squares c1) (:squares c2))) c2))

(defn find-no-overlap
  "given a set of input claims, find the claim that has no overlap
  with any other claims."
  [claims]
  (let [grid-claims (map #(convert-to-grid % 1000) claims)]
    (loop [idx 0 ignores #{}]
      (if-not (contains? (:claim-id (nth grid-claims idx)) ignores)
        (if-let [overlap (some #(overlapping-claim (nth grid-claims idx) %) grid-claims)]
          (recur (inc idx) (conj ignores (:claim-number overlap)))
          (:claim-number (nth grid-claims idx)))
        (recur (inc idx) ignores)))))
</pre>
</div>

<p>
Cool Clojure-y things to point out here:
</p>

<ol class="org-ol">
<li><code>cond</code>. Think of <a href="http://clojuredocs.org/clojure.core/cond">cond</a> as a bit of a <code>if/else</code> on steroids. It allows you to pass a pair of items: test expression, and success expression. If the test expression passes (ie, returns <code>true</code>), then the success expression is evaluated and returned (immediately - it does not fall through to other condition pairs). This means I don't have to nest <code>if</code> calls, which makes it easier to read (IMO).</li>
<li><p>
<code>if-let</code>. This is basically a conditional binding (think variable) assignment: if the binding value is not <code>nil</code>, then assign the value that binding for the scope of the <code>if-let</code>. It saves you from the all-too-common pattern of:
</p>

<div class="org-src-container">
<pre class="src src-ruby">my_var = doThingPossibly()
if my_var
# do other things
end
</pre>
</div>
<p>
or
</p>
<div class="org-src-container">
<pre class="src src-python">if (doExpensiveThing()):
    repeatItForVariable = doExpensiveThing()
    # do other things
</pre>
</div></li>
</ol>

<p>
And again, my code is available in a <a href="https://gist.github.com/ballpointcarrot/aa5aa68f616811381499519b74a6cca9">Github Gist</a>. Until tomorrow!
</p>
</div>
</div>
</div>
]]>
</description></item>
<item>
<title>Exploring Nixos</title>
<link>https://www.ballpointcarrot.net/posts/2016-02-01-exploring-nixos.html</link>
<pubDate>Mon, 01 Feb 2016 00:00:00 -0800</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2016-02-01-exploring-nixos.html</guid>
<description>
<![CDATA[<p>
Late-ish last year (around November, if memory serves), I read about a new OS project which
allowed its users a stark departure from traditional Linux methods. Called <a href="http://nixos.org">Nixos</a>,
the unique claim that it brought to the table was that the system configuration was managed declaratively, through
functional configuration files. This includes things like package management, services executed, and user configuration.
</p>

<p>
To fit along with my foray into the world of functional programming (my <a href="https://www.ballpointcarrot.net/posts/./2015-03-08-rust-non-systems-programmer.html">jumps</a> into <a href="https://www.ballpointcarrot.net/posts/./2015-03-14-rust-nsp-matchers.html">Rust</a>
starting a mental shift, and recent dives into <a href="http://clojure.org/">Clojure</a> sealing the deal), I wanted to give it a shot. There were
a couple of strong draws for me:
</p>

<ul class="org-ul">
<li>Defining a configuration for everything leads me to be able to port my configs from place to place</li>
<li>The comfort to screw up; that is, the ability to roll back in case things got weird</li>
<li>A new learning experience - it's been a long time since I've installed something new just to give it a shot.</li>
</ul>

<p>
I finally made the jump around mid-December, so I've been on it on my laptop for about a month and a half. Not constantly, but enough
that I could make the configuration my own, and start to find out where things have been good, and what still needs to improve (both
my understanding of Nixos and in the system).
</p>
<div id="outline-container-orgb10c471" class="outline-2">
<h2 id="orgb10c471"><span class="section-number-2">1.</span> Packaging and Installation</h2>
<div class="outline-text-2" id="text-1">
<p>
Nixos provides an ISO from their website, as is often the case with linux distros. The only qualm that I had in this stage is that,
because I wanted to do a <a href="https://nixos.org/wiki/Installing_NixOS_from_a_USB_stick">UEFI installation via USB</a>, I had to jump through a
few extra hoops in order to get things working correctly. This is less of a problem with Nixos specifically, and more endemic to the
linux community as a whole - we need to make UEFI boot media easier to create. I miss the days of <code>dd if=&lt;iso&gt; of=&lt;flash-drive&gt;</code>. :)
</p>

<p>
I was pleasantly surprised to see that you could boot into a graphical environment using the boot media. This is something that some
<a href="https://www.archlinux.org/">major distributions</a> still seem to miss, and I was impressed to see a relatively young distro include a UI,
even if it didn't handle the installation that way. At the very least, it gives you a sense of "try before you buy."
</p>

<p>
The initial read-through of the <a href="http://nixos.org/nixos/manual/index.html#sec-installation">Nixos Manual</a> were useful, but sparse in places where more
information (particularly for a new user) would have been helpful. As you can see, the first 9 steps are pretty straightforward - hard disk setup, loading
options for runtime, etc.
</p>

<p>
<b>Then there's step 10.</b>
</p>

<p>
"Edit this file" has a lot of openness to it. They do give you some resources around here (links to detailed configuration docs, a
very barebones initial config, and links to "real-world installations" to compare to), but as your first foray into the format
of the configuration.nix file, I would have <b><b>loved</b></b> a "guided tour" here, giving insight into why the file structure is how it is,
common configuration options for particular installation types, and a more "this is a normal base installation" config instead of the bare
config provided in the manual.
</p>

<p>
In my mind, this is where <b>the magic</b> of Nixos happens - the documentation should highlight the magic,
calling out its importance and showcasing how the features work. Imagine my surprise (and delight!) when I found I could enable xorg with a single line:
</p>

<div class="org-src-container">
<pre class="src src-plain">services.xserver.displayManager.sddm.enable = true;
</pre>
</div>

<p>
Having fast, impacting implementations of large swaths of software fed through because a single option was enabled? Again, that's <b>magic</b>, and that's what needs advertised here.
</p>

<p>
Other first-order-of-business options for me at installation are things like:
</p>

<ul class="org-ul">
<li>Adjusting the keyboard layout (Dvorak)</li>
<li>Setting timezone and verifying current time (with optional NTP)</li>
<li>laptop configuration (thinkpad module, touchpad config)</li>
</ul>

<p>
These were all fairly easy to find though the nixos wiki - when you've had other users run into the same configurations,
it's always nice to have them easy to find.
</p>

<p>
The rest of the installation was a breeze - you run nixos-install, set your root password at the end, and then reboot into your new OS.
</p>
</div>
</div>
<div id="outline-container-org4585e4d" class="outline-2">
<h2 id="org4585e4d"><span class="section-number-2">2.</span> Using it</h2>
<div class="outline-text-2" id="text-2">
<p>
Now I had a base working system, and it only took me a few generations of building and rebooting. After about generation 6-7 or so, I had
things down to where I liked them for a start. From here, it was time to dig into what I could do with it.
</p>
</div>
<div id="outline-container-org1c398af" class="outline-3">
<h3 id="org1c398af"><span class="section-number-3">2.1.</span> Getting comfortable&#x2026;</h3>
<div class="outline-text-3" id="text-2-1">
<p>
My laptop is used for a couple of things:
</p>

<ul class="org-ul">
<li>Internet browsing</li>
<li>Programming projects</li>
<li>Photo editing</li>
</ul>

<p>
Setting up to get these tasks done wasn't terribly hard. However, a <b>Really Cool Thing™</b> about Nixos is that you can do these <b>per user</b>.
</p>

<p>
Let me reiterate that:
</p>

<blockquote>
<p>
<b>Package installation can be done at the per-user level!</b>
</p>
</blockquote>

<p>
That's huge in my mind, for multiple reasons. First, I'm sure I'm not the only one who will end up using this laptop. In the event that I need to <b>share</b>, this gives me a way to keep my configuration and structure completely isolated from another users, where I can have only the things I want installed for me. In addition, I don't have to muck about with installing everything system-wide, so I don't have to use the shared folders (and `sudo` calls everywhere) to do it. Finally, I like to configure tools in ways that could be confusing to others. This way, I can not only have the tool's configuration, but <b>the tool itself</b> in my user account.
</p>

<p>
In an effort to unite the ability to do this with the Nixos "declarative by nature" package management, `nix-env` was born:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ nix-env -qaP nitrogen       # a package for setting wallpapers for non-standard WMs.
nixos.nitrogen        nitrogen-1.5.2
nixos-15.09.nitrogen  nitrogen-1.5.2

$ nix-env -i nitrogen         # to install
</pre>
</div>

<p>
The end result is that the package has been added to the user environment, and a reference to the package has been added to the user manifest inside of their Nix profile. As an odd side-effect of how nix packages are stored, take a look at my system $PATH variable:
</p>

<div class="org-src-container">
<pre class="src src-plain">$ echo $PATH
/home/ckruse/bin:/var/setuid-wrappers:/home/ckruse/.nix-profile/bin:/home/ckruse/.nix-profile/sbin:/home/ckruse/.nix-profile/lib/kde4/libexec:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/nix/var/nix/profiles/default/lib/kde4/libexec:/run/current-system/sw/bin:/run/current-system/sw/sbin:/run/current-system/sw/lib/kde4/libexec
</pre>
</div>

<p>
Looking through that, you'll see the conspicuous absence of our friends in <code>/bin</code>, <code>/usr/bin</code>, and <code>/usr/local/bin</code>. These directories aren't used - instead, packages get built in their own compartmentalized sections, and then are symlinked into the running context (system-wide, at <code>/run/current-system/sw/bin</code>, and for each user, at <code>/home/&lt;user&gt;/.nix-profile/bin</code>). This is awesome for generating your environments while in the nix context, but it can have some troubles.
</p>
</div>
</div>
<div id="outline-container-org285f752" class="outline-3">
<h3 id="org285f752"><span class="section-number-3">2.2.</span> &#x2026;and uncomfortable</h3>
<div class="outline-text-3" id="text-2-2">
<p>
About 2 weeks ago, I wanted to sit down and create this very blog post, detailing the experiences that I had with migrating things over. I mentioned this <a href="https://www.ballpointcarrot.net/posts/./2015-02-28-yearly-refresh-time.html">in the past</a>, but my blog posts are generated code based on Harp, a NodeJS static site generator.
</p>

<p>
In the past, I used to manage my node installations with the wonderful <a href="https://github.com/creationix/nvm">nvm</a> version manager, a set of shell scripts which shim versions of node to be used. However, this spectacularly failed with my Nixos installation. Versions of node installed via nvm did not have access to runtime libs that they would need, and so proper symlinking and running of these node versions failed, and failed hard.
</p>

<p>
While stuck with this problem, I realized I could settle for using the system-provided Node version. However, this led to its own problems, because now we have two separate package managers (nix and npm). There is <a href="http://blog.lastlog.de/posts/nodejs_on_nixos_status/">a push</a> to incorporate npm packages into nix using the npm2nix utility, but I feel that, especially given separate development projects have their own dependency manifests, this is a step in the wrong direction.
</p>

<p>
As a separate method to approach this problem, I read up on creating separate script profiles for running your development projects in. I thought, "Great! I'll spin this up with the system node.js, install harp, and run with it." Unfortunately, the harp install fell through, because I didn't have write access to the global install directory for node (as I shouldn't, because then the implementation leaks out into the package build).
</p>

<p>
For now, I'm using a separate dev host + ssh to update here. I'll want to dig into this further to see if I can get a good solution figured out. As of now, I know that <code>npm install -g &lt;whatever&gt;</code> isn't a good idea. Now I either find a better way (Docker could be a fun insert here), I change the blog backend again, or I wipe and start with a fresh installation of "new distro ++".
</p>
</div>
</div>
</div>
]]>
</description></item>
<item>
<title>Finding my Loaf of Bread</title>
<link>https://www.ballpointcarrot.net/posts/2019-05-07-finding-my-loaf-of-bread.html</link>
<pubDate>Tue, 07 May 2019 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2019-05-07-finding-my-loaf-of-bread.html</guid>
<description>
<![CDATA[<div id="outline-container-orgf80d791" class="outline-2">
<h2 id="orgf80d791"><span class="section-number-2">1.</span> <span class="todo TODO">TODO</span> fix broken image links</h2>
<div class="outline-text-2" id="text-1">
<p>
I made my first loaf of bread last Saturday.
</p>

<p>
I've been watching a lot of <a href="https://thegreatbritishbakeoff.co.uk/">"The Great British Bakeoff"</a> (or "Baking Show" if you're in the US, because of <a href="http://www.pbs.org/publiceditor/blogs/pbs-public-editor/whats-in-a-name/">trademark reasons</a>). Watching people on your television make intricate, creative, and most importantly <b>delicious-looking</b> baked goods, the desire to try it yourself becomes irresistable. Both my wife and I have tried some things we've seen on the show, to decent result. However, I've never really been a "Baker" - I've generally avoided the big hot box that sits underneath the stove, and would tell people that me and that box didn't really get along well.
</p>

<p>
Despite this, the drive to try it out was too much to handle. I made use of the fact that my wife was out of town this past weekend to give me some buffer time: if things turned out well, I'd have a nice surprise for her when she returned; if I screwed up things or made a complete mess of the kitchen, I'd have time to destroy the evidence. :D
</p>

<p>
My project took about 3 hours from start to finish; I began later than I really should have (around 8pm), but since I wasn't disturbing anyone by my late-night "breadscapade", I kept at it. I won't go into too much of the process, as photos can provide more insight here:
</p>

<p>
The dough sat for about an hour to rise:
</p>

<p>
![pre-rise](IMG<sub>20190504</sub><sub>210312.jpg</sub>)
</p>

<p>
![post-rise](IMG<sub>20190504</sub><sub>220141.jpg</sub>)
</p>

<p>
After rising, the recipe I was following directed me to braid 3 strands of the loaf together:
</p>

<p>
![braided, but unbaked](IMG<sub>20190504</sub><sub>221614.jpg</sub>)
</p>

<p>
Then, after an egg wash, it was in the oven for a half-hour. The end result:
</p>

<p>
![glorious looking bread](IMG<sub>20190504</sub><sub>225522.jpg</sub>)
</p>

<p>
Needless to say, I'm happy with how everything turned out.
</p>

<p>
Now, this is being posted on <a href="https://dev.to/">dev.to</a>, so what does <b>any</b> of this have to do with programming?
</p>

<p>
Reflecting on the process I had doing the above: the timeframe it took, the level of familiarity, determining what I could take away from the experience for next time - I began to wonder what my programming "Loaf of bread" is. Reviewing the criteria I had:
</p>

<ul class="org-ul">
<li>took about 3 hours start-to-finish</li>
<li>dealt with something unfamiliar</li>
<li>a safe way to clean up the mess in case it failed</li>
<li>the ability to <a href="https://twitter.com/ballpointcarrot/status/1124895392288477184">chronicle the process</a></li>
<li>I can share it with others if it turns out well</li>
<li>I should have fun doing it</li>
</ul>

<p>
For me, the hardest thing in converting this metaphor to programming is the time slot. Learning something new in the programming world (new language/framework/technique/etc.) takes a signifigantly longer amount of time, and I'm generally the type to read through and find tutorials and materials to get a sufficient level of understanding before trying to crank something out on my own. Taking only a 3h timeslot and trying to do learn something meaningful in a new language seems impossible to fit. Maybe I need to expand the time. I could reduce the scope on what I'm learning, but then I feel like I don't capture enough to make what I've learned meaningful with just a tiny piece. This is my normal problem with katas - I can figure out how to solve the problem, but it feels external to how you would deal with a "real problem" in that language.
</p>

<p>
I also struggle with a aversion to failure - that's why I had to make sure I had time alone to try the bread, and have sufficient time in case of disaster. I struggle with wanting to do cool things, but not wanting to mess up things in the process. Even though I consciously know that no software project ever works this way, I subconsiously want the thing I build to have a well-thought-out design, and be more-or-less right the first time. Software has the remarkable ability to evolve; I just need to learn to embrace it. With the bread, if I screwed it up I could toss it out, and nobody would know.
</p>

<p>
I'm working on ways to handle tracking progress when building something new. I'm usually willing to post in-progress things up on Twitter or the Fediverse, and used some free time on the weekend to set up everything I needed to run livecoding sessions on Twitch. However, there's a big jump between preparing to do that, and actually pulling the trigger.
</p>

<p>
An example: I've got a project that I've had for a year that I have started a number of times, but never actually created anything meaningful on. In the latest incantation, I was working on it using Elixir (my language to learn for the year, which I'm doing a bad job of considering it's almost half-over). Once I had my livestream stuff set up, I became terribly nervous - I don't know this language, so the majority of the stream is just going to be me reading through docs, which won't be terribly interesting. I over-indexed on this, and then ended up deciding to just move on to the next household project instead of working on it.
</p>

<p>
I'm inside my head a lot here - In my case, I wouldn't have anyone watching to begin with, so streaming out to the void and reading docs may have been okay. And hey, maybe someone jumping in could assist.
</p>

<p>
I'd be interested to hear any of your coding "loaves of bread". What kind of projects do you use for trying things out? Is it worth doing a bigger-scope, longer-term thing to build up knowledge? Should I alter my scope of what I consider a "real problem" for a language, so that I can just do?
</p>
</div>
</div>
]]>
</description></item>
<item>
<title>On Enjoying the Process</title>
<link>https://www.ballpointcarrot.net/posts/2026-03-17-on-enjoying-the-process.html</link>
<pubDate>Tue, 17 Mar 2026 00:00:00 -0700</pubDate>
<guid>https://www.ballpointcarrot.net/posts/2026-03-17-on-enjoying-the-process.html</guid>
<description>
<![CDATA[<div id="outline-container-org1bb5e89" class="outline-2">
<h2 id="org1bb5e89"><span class="section-number-2">1.</span> Yep, another "I rebuilt the blog" post.</h2>
<div class="outline-text-2" id="text-1">
<p>
Apparently, the most likely time for me to update my own corner of the web is
when I need to update how I post things into my corner of the web.
</p>

<p>
This post is intended less as a "life status" post, and more specific to the
core details around the blog itself, and the new process that I've been building
to manage it. It may get a little tangentially philosophical, too, so be warned
ahead of time. :)
</p>
</div>
</div>
<div id="outline-container-org1c0e0ee" class="outline-2">
<h2 id="org1c0e0ee"><span class="section-number-2">2.</span> Reaching for simplicity, stability, joy</h2>
<div class="outline-text-2" id="text-2">
<p>
In the last iteration of the blog engine, I was still using a static site
generator (zola) to upload the contents of the site to Netlify. This worked, but
as mentioned in the <a href="https://www.ballpointcarrot.net/posts/./2025-08-13-reinvesting.html">previous post</a>, I've been enjoying the community over at
<a href="https:omg.lol">omg.lol</a>. One of the things that has resonated with me is the sense of
simplicity: a lot of what is made in that community is small, single-focused and
simple sites that serve mainly to be enjoyable.
</p>

<p>
I realized that reaching to simpler processes would make the time spent with my
own space on the web would make working in it something to look forward to,
instead of something that I need to prove myself with. I've been missing the joy
in software and computing, and I needed to shove off a lot of added baggage to
get to a point where I can find some fun again. This led to finding more ways to
simplify, and keep what I'm doing close to the standard workflow that I've
already built out for myself. There's no sense in me trying to learn a new suite
of tooling for this. It's just for me, so I might as well let it live where I
do. The end goals here:
</p>

<ul class="org-ul">
<li>If you enjoy doing it, you'll do it more often.</li>
<li>Don't feel pressure around adding things, nobody's judging you.</li>
<li>Open up and be more authentic.</li>
</ul>

<p>
When I'm on a computer, I more or less live within an Emacs session. I've seen
other blogs that are made solely from Org mode documents, so I decided to make
this site in the same method.
</p>

<p>
David Duncan: I blame you for being the starting point of all this. :P
</p>
</div>
</div>
<div id="outline-container-orgc260f6c" class="outline-2">
<h2 id="orgc260f6c"><span class="section-number-2">3.</span> Blogging in Org Mode</h2>
<div class="outline-text-2" id="text-3">
<p>
This site/blog/space to throw my inanities is now fully built from <a href="https://orgmode.org">Org mode</a>.
While designed as a way to handle tree-style note taking, it is a full markup
language like Markdown in terms of flexibility. On top of that (and relevant for
this space), it can also be used as an environment for <a href="https://en.wikipedia.org/wiki/Literate_programming">literate programming</a>,
which is useful given both my profession and occasional interest in hosting
advent of code<sup><a id="fnr.1" class="footref" href="#fn.1" role="doc-backlink">1</a></sup> solutions here.
</p>

<p>
I did a fair amount of diving into research on how best to establish my use of
Org mode as a full blogging platform, so I want to throw out links to the blogs
that gave me inspiration for building mine out in the way I did:
</p>

<ul class="org-ul">
<li><a href="https://systemcrafters.net/publishing-websites-with-org-mode/building-the-site">https://systemcrafters.net/publishing-websites-with-org-mode/building-the-site</a></li>
<li><a href="https://www.ereslibre.es/blog/2019/09/building-a-personal-website-with-org-mode.html">https://www.ereslibre.es/blog/2019/09/building-a-personal-website-with-org-mode.html</a></li>
<li><a href="https://pavpanchekha.com/blog/org-mode-publish.html">https://pavpanchekha.com/blog/org-mode-publish.html</a></li>
<li><a href="https://zwpdbh.github.io/emacs/org-to-blog-using-org-publish.html">https://zwpdbh.github.io/emacs/org-to-blog-using-org-publish.html</a></li>
<li><a href="https://llazarek.github.io/blog/2018/11/org-export-processing.html">https://llazarek.github.io/blog/2018/11/org-export-processing.html</a></li>
<li><a href="https://commonplace.doubleloop.net/setting-up-a-literate-publish-el-with-org-babel?stack=my-publish-el-configuration&amp;stack=how-i-publish-my-wiki-with-org-publish#org94967b6">https://commonplace.doubleloop.net/setting-up-a-literate-publish-el-with-org-babel?stack=my-publish-el-configuration&amp;stack=how-i-publish-my-wiki-with-org-publish#org94967b6</a></li>
</ul>
</div>
</div>
<div id="outline-container-org4ae5ed9" class="outline-2">
<h2 id="org4ae5ed9"><span class="section-number-2">4.</span> Building the blog by talking about building the blog</h2>
<div class="outline-text-2" id="text-4">
<p>
Taking that literate programming mentality into account, I spun up an org file
explicitly designed to describe how I wanted to build out the blog. Starting in
January, I went through a number of iterations in how I wanted to approach building the site:
</p>

<ul class="org-ul">
<li>Org -&gt; Hugo -&gt; some host/cdn/etc.</li>
<li>Org -&gt; markdown -&gt; weblog.lol</li>
<li>finally: Org -&gt; Html -&gt; CDN</li>
</ul>

<p>
While attempting building these out, I used the org file to not only describe
the tasks that I still had to accomplish, but also embedded the code that was
used to generate the site itself. Having both together allowed me to plan ahead
for things that aren't complete yet and discuss approaches before trying them
out.
</p>

<p>
You can find the <a href="https://source.tube/ballpointcarrot/code-snippets/src/branch/main/build-site.org">full contents of the file here</a><sup><a id="fnr.2" class="footref" href="#fn.2" role="doc-backlink">2</a></sup>, but both as a way to see if I
can do it usefully, and as a way to give you a taste without leaving, here's an excerpt:
</p>

<div class="org-src-container">
<pre class="src src-org">** DONE Make the HTML not ugly
I want my templated theme back. :'(

There's arguments on whether to use overrides for parts of the html template
baked into org-publish, or to just override the entire template.

First off, let's load our CSS:
#+begin_src elisp :tangle bpc-blog.el
(defun bpc/stylesheet-link (path)
  (format "&lt;link rel=\"stylesheet\" type=\"text/css\" defer href=\"%s\" /&gt;" path))

(defun bpc/highlightjs-head ()
  (with-temp-buffer
    (insert-file-contents "templates/head.html")
    (buffer-string)))

(setq-local bpc/html-head-extra
            (string-join 
                    (cons (bpc/highlightjs-head)
                          (mapcar #'bpc/stylesheet-link
                            '(
                              "/assets/styles/styles.css"
                              "/assets/styles/catppuccin-frappe-pre.css"))
                          )
                    "\n")
            )
#+end_src

Applying a ~#+TITLE: &lt;page title&gt;~ to the pages grants each a nice H1 heading.
I've added that to the relevant pages.
</pre>
</div>

<p>
Syntax highlighting there is a little odd, but I don't blame the highlighting tool.
</p>
</div>
</div>
<div id="outline-container-org7b75593" class="outline-2">
<h2 id="org7b75593"><span class="section-number-2">5.</span> Migrating the old content</h2>
<div class="outline-text-2" id="text-5">
<p>
Because the previous iteration of the blog used Markdown as a format for the
contents of the blog, moving to org wasn't terrible. Each file required tweaks, but they weren't major.
</p>

<p>
Frontmatter had to be handled in a different way - instead of using a block at the top of the page, Org mode uses metadata values like this:
</p>
<div class="org-src-container">
<pre class="src src-org">#+title: Page Title Goes Here
#+date: &lt;2026-03-17 Tue&gt;
</pre>
</div>

<p>
The other major thing was syntax changes around links. Fortunately, my years in vim prior to Emacs taught me how to do quick macros. Switching from
</p>
<div class="org-src-container">
<pre class="src src-markdown">[link title](https://example.com)
</pre>
</div>
<p>
to
</p>
<div class="org-src-container">
<pre class="src src-org">[[https://example.com][link title]]
</pre>
</div>
<p>
wasn't too bad.
</p>

<p>
The positive benefit to only posting a couple of times every few years: I didn't have many posts to fix. :) 
</p>
</div>
</div>
<div id="outline-container-orgf3cdd05" class="outline-2">
<h2 id="orgf3cdd05"><span class="section-number-2">6.</span> Things left to take care of</h2>
<div class="outline-text-2" id="text-6">
<p>
I have some things left to do to polish all the features that I want to get done:
</p>

<ul class="org-ul">
<li>RSS Feed(s)</li>
<li>Tags pages</li>
<li>Better metadata rendering on posts</li>
<li>Supporting images better</li>
</ul>

<p>
I'll get to them, and because I'm making it myself, and I'm not putting too much
stress on myself to complete it, it'll get there when it's needed.
</p>
</div>
</div>
<div id="footnotes">
<h2 class="footnotes">Footnotes: </h2>
<div id="text-footnotes">

<div class="footdef"><sup><a id="fn.1" class="footnum" href="#fnr.1" role="doc-backlink">1</a></sup> <div class="footpara" role="doc-footnote"><p class="footpara">
Once I have support for tag pages, this would be a great place to link to those posts.
</p></div></div>

<div class="footdef"><sup><a id="fn.2" class="footnum" href="#fnr.2" role="doc-backlink">2</a></sup> <div class="footpara" role="doc-footnote"><p class="footpara">
Caveat: this copy is pulled from the actual repo, which is private. It may not be up to date. If you're bothered about it, poke me via <a href="https://ballpointcarrot.net/social.html">my socials</a> and I'll update it.
</p></div></div>


</div>
</div>]]>
</description></item>
</channel>
</rss>
