<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Digital Dev Blog]]></title><description><![CDATA[Digital Dev Blog]]></description><link>https://www.digitaldev.blog</link><image><url>https://cdn.hashnode.com/uploads/logos/6a5f4a722e470c360a3c5268/6ab3ceed-7672-4963-a7ee-bd0554ad9f27.png</url><title>Digital Dev Blog</title><link>https://www.digitaldev.blog</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 21:02:04 GMT</lastBuildDate><atom:link href="https://www.digitaldev.blog/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Option vs Result in Rust: What’s the Real Difference?]]></title><description><![CDATA[If you’ve written Rust for more than a few days, you’ve probably hit this moment: You’re writing a function, something might fail, and now you’re staring…]]></description><link>https://www.digitaldev.blog/option-vs-result-in-rust-what-s-the-real-difference</link><guid isPermaLink="true">https://www.digitaldev.blog/option-vs-result-in-rust-what-s-the-real-difference</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sun, 26 Oct 2025 08:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/90bce187-b387-427a-ad3e-7cd2355a2ebd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you’ve written Rust for more than a few days, you’ve probably hit this moment: You’re writing a function, something might fail, and now you’re staring at your screen thinking,</p>
<blockquote>
<p>“Should I return an Option or a Result?”</p>
</blockquote>
<p>They both kind of mean “something might go wrong,” but they’re not interchangeable. Let’s break it down in plain English.</p>
<h2>Option — Sometimes There’s Just Nothing</h2>
<p>Option is Rust’s gentle way of saying, “Hey, there might be nothing here, and that’s okay.”No crash, no drama, no stack trace — just an empty box.</p>
<p>You’d use it when:</p>
<ul>
<li><p>You’re looking something up that might not exist (e.g., HashMap, database, etc.).</p>
</li>
<li><p>A function might have nothing meaningful to return</p>
</li>
<li><p>You want to represent something optional or “not set yet”</p>
</li>
</ul>
<pre><code class="language-rust">fn find_user(id: u32) -&gt; Option&lt;User&gt;
    DATABASE.get(&amp;id).cloned()
}
</code></pre>
<p>If that user doesn’t exist, you get None. That’s not a bug — it’s just reality. Nothing went wrong.</p>
<h2>Result&lt;T, E&gt; — When Something Actually Failed</h2>
<p>Result is for real failures — cases where something was supposed to work, but didn’t. And now you need to know why.</p>
<p>Think:</p>
<ul>
<li><p>Reading a file that isn’t there</p>
</li>
<li><p>Parsing data that’s in the wrong format</p>
</li>
<li><p>Making a network call that times out</p>
</li>
</ul>
<pre><code class="language-rust">fn read_config(path: &amp;str) -&gt; Result&lt;Config, std::io::Error {
    let contents = std::fs::read_to_string(path)?;
    serde_json::from_str(&amp;contents)
}
</code></pre>
<p>Here, multiple things could go wrong — a missing file, unreadable content, or invalid JSON — and each requires a different response. That’s what Result is for.</p>
<h2>The Real Difference</h2>
<p>Option means “no value, but that’s fine.”Result means “something went wrong, and here’s what happened.”</p>
<p>They’re easy to confuse because both use similar patterns (map, and_then, unwrap_or), but the intent is totally different.</p>
<p>A common mistake I see is using Option where a Result should be:</p>
<pre><code class="language-rust">// Not great — error info is gone
fn parse_number(s: &amp;str) -&gt; Option&lt;i32&gt; {
    s.parse().ok()
}
</code></pre>
<p>That .ok() throws away valuable error info. Instead, keep it:</p>
<pre><code class="language-rust">// Better — preserves the actual reason
fn parse_number(s: &amp;str) -&gt; Result&lt;i32, ParseIntError&gt; {
    s.parse()
}
</code></pre>
<p>Now, if parsing fails, you’ll actually know why. Which, trust me, future-you will thank you for.</p>
<h2>Handy Tricks</h2>
<p>Both Option and Result come loaded with handy methods (map, unwrap_or, and_then, etc.), so you can chain transformations without nesting endless match statements.</p>
<p>And yes, everyone uses .unwrap() sometimes. It’s fine when prototyping or writing throwaway tools. But in production? Be nice to your users (and your logs). Handle your errors properly.</p>
<h2>TL;DR</h2>
<ul>
<li><p>Option → absence is normal</p>
</li>
<li><p>Result → something failed, and you need to know why</p>
</li>
<li><p>Don’t drop error info — it’ll save you hours later</p>
</li>
</ul>
<h2>Final Thoughts</h2>
<p>Rust gives you Option and Result because not everything that goes “wrong” is actually an error. Sometimes it’s just nothing there. Other times, something broke. Knowing which one you’re dealing with, and communicating that clearly in your code, is a huge part of writing idiomatic Rust.</p>
<p>And once you get the hang of it, you’ll start to appreciate how clean and explicit Rust’s approach really is. No exceptions, no hidden gotchas, just two simple, powerful types that make your intent crystal clear.</p>
]]></content:encoded></item><item><title><![CDATA[How to use pretty_assertions for Rust test cases]]></title><description><![CDATA[Below, you’ll find a set of exercises designed to help you practice with the pretty_assertion crate in Rust. Each exercise focuses on a commonly used…]]></description><link>https://www.digitaldev.blog/how-to-use-pretty-assertions-for-rust-test-cases</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-use-pretty-assertions-for-rust-test-cases</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 01 Feb 2025 08:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/fb6d5519-3762-401e-9f6a-eacead873ea0.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Below, you’ll find a set of exercises designed to help you practice with the pretty_assertion crate in Rust. Each exercise focuses on a commonly used feature of <code>pretty_assertions</code> and follows the structure:</p>
<ol>
<li><p>Feature Explanation</p>
</li>
<li><p>Working Example</p>
</li>
<li><p>Exercise</p>
</li>
<li><p>Solution (with detailed explanation)</p>
</li>
</ol>
<p>Make sure you add <code>pretty_assertions</code> to your development dependencies in <code>Cargo.toml</code>:</p>
<pre><code class="language-rust">[dev-dependencies]
pretty_assertions = "1.3"
</code></pre>
<p>Import its macros in your test files:</p>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};
</code></pre>
<h2>Basic <code>assert_eq!</code> with Pretty Printed Differences</h2>
<h3>Feature Explanation</h3>
<p>At its core, <code>pretty_assertions</code> replaces the standard <code>assert_eq!</code> and <code>assert_ne!</code> macros with a version that highlights differences in a much more straightforward, color-coded way. This is extremely helpful when you compare large strings or data structures. The usage is almost identical to Rust’s built-in <code>assert_eq!</code> and <code>assert_ne!</code>, but if the test fails, you get a pretty diff.</p>
<h3>Example</h3>
<p>In the following test, we intentionally have a failure scenario to show off the diff. We’ll see a better diff than the default when comparing two different strings.</p>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
#[should_panic]
fn test_failure_example() {
    let actual = "Hello, Rust!";
    let expected = "Hello, World!";
    assert_eq!(actual, expected);
}
</code></pre>
<p>f you run this, you’ll see a panic that includes colored highlights showing what’s different between <em><strong>"Rust!"</strong></em> and <em><strong>"World!"</strong></em>.</p>
<h3>Exercise - 1</h3>
<p><strong>Goal</strong>: Create a test that compares two <em>identical</em> strings, e.g., <em><strong>"Hello, World!"</strong></em> vs. <em><strong>"Hello, World!"</strong></em>, and ensures they are equal using <strong>assert_eq!</strong>. Name the test something like <strong>test_equal_strings</strong>. The test should <strong>pass</strong>, not panic.</p>
<h3>Example</h3>
<p>In the snippet below, we check that the two strings are unequal. If they were the same, we’d see a panic with a diff highlighting that there's no difference.</p>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
fn test_ne_example() {
    let s1 = "Apple";
    let s2 = "Orange";
    assert_ne!(s1, s2);
}
</code></pre>
<h3>Exercise - 2</h3>
<p><strong>Goal</strong>: Write a test that uses <strong>assert_ne!</strong> to check that two integers <strong>10</strong> and <strong>20</strong> are not equal. Name the test <strong>test_numbers_not_equal</strong>. The test should pass if the integers differ.</p>
<h2>Comparing Multiline Strings</h2>
<h3>Feature Explanation</h3>
<p>One of the best features of <strong>pretty_assertions</strong> is how it highlights differences between large or multiline strings. Regular assert_eq! can be hard to read when outputs are multiline. With <strong>pretty_assertions</strong>, you get line-by-line diffs, similar to a Git diff.</p>
<h3>Example</h3>
<p>In this example, we compare two multiline strings. One has an extra comma that causes them to differ. If the test fails, you’ll see exactly which line is different, with coloring (if your terminal supports it).</p>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
#[should_panic]
fn test_multiline_example() {
    let multi1 = "Line1\nLine2\nLine3";
    let multi2 = "Line1\nLine2,\nLine3";
    assert_eq!(multi1, multi2);
}
</code></pre>
<h3>Exercise - 3</h3>
<p><strong>Goal</strong>: Create a new test named <strong>test_multiline_strings</strong> in which you compare two multiline strings that are <em>identical</em>. Use a string with at least three lines. The test should pass. This will illustrate that <strong>pretty_assertions</strong> can handle multiline strings without showing a diff if they match perfectly.</p>
<h2>Comparing Complex Data Structures (e.g., Vectors or HashMaps)</h2>
<h3>Feature Explanation</h3>
<p><strong>pretty_assertions</strong> also prettifies diffs for complex data structures (such as Vec, HashMap, and custom structs that implement Debug). If you have large nested data, the differences are shown in a more structured and readable format.</p>
<h3>Example</h3>
<p>Below, we demonstrate how to compare two vectors of integers. If they differ, you’ll see a clear, line-by-line breakdown of which items mismatch:</p>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
#[should_panic]
fn test_vector_example() {
    let v1 = vec![1, 2, 3, 4];
    let v2 = vec![1, 2, 5, 4];
    assert_eq!(v1, v2);
}
</code></pre>
<h3>Exercise - 4</h3>
<p><strong>Goal:</strong> Write a test that compares two <strong>HashMap&lt;u32, &amp;str&gt;</strong>. They should be <em>identical.</em> Name the test <strong>test_hashmap_equality</strong>, and verify that <strong>pretty_assertions</strong> can handle the comparison without error. Include at least two key-value pairs.</p>
<blockquote>
<p><strong>Tip</strong>: Don’t forget to <strong>use std::collections::HashMap</strong> at the top.</p>
</blockquote>
<h2>Custom Types that Implement Debug</h2>
<h3>Feature Explanation</h3>
<p><strong>pretty_assertions</strong> relies on types implementing the <strong>Debug</strong> trait to render differences. For your custom structs, as long as they implement <strong>Debug</strong>, the crate can show a diff if they differ.</p>
<h3>Example</h3>
<p>Here, we have a struct <strong>Point</strong> with <strong>x</strong> and <strong>y</strong> coordinates. If we compare two different instances, we’ll see a color-coded difference highlighting which fields differ:</p>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[derive(Debug)]
struct Point {
    x: i32,
    y: i32,
}

#[test]
#[should_panic]
fn test_custom_struct_example() {
    let p1 = Point { x: 1, y: 2 };
    let p2 = Point { x: 1, y: 3 };
    assert_eq!(p1, p2);
}
</code></pre>
<h3>Exercise - 5</h3>
<p><strong>Goal</strong>: Create a struct named <strong>User</strong> with fields <strong>id: u32</strong> and <strong>name: String</strong>. Implement <strong>Debug</strong> (derive it) for the struct. Write a test <strong>test_user_struct_equality</strong> comparing two <em>identical</em> <strong>User</strong> instances. The test should pass.</p>
<h2>Solutions</h2>
<p>In this section, you can find the solutions to the exercises above.</p>
<h3>Solution - 1</h3>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
fn test_equal_strings() {
    let actual = "Hello, World!";
    let expected = "Hello, World!";
    assert_eq!(actual, expected);
}
</code></pre>
<p><strong>Explanation</strong>:</p>
<ul>
<li><p>We import <strong>assert_eq</strong> from <strong>pretty_assertions</strong>.</p>
</li>
<li><p>We compare two identical strings.</p>
</li>
<li><p>Because they’re equal, the test passes, and you won’t see any diff output.</p>
</li>
<li><p>The point is to illustrate the usage of <strong>assert_eq</strong> from <strong>pretty_assertions</strong> in a test that succeeds.</p>
</li>
</ul>
<h3>Solution - 2</h3>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
fn test_numbers_not_equal() {
    let num1 = 10;
    let num2 = 20;
    assert_ne!(num1, num2);
}
</code></pre>
<p><strong>Explanation</strong>:</p>
<ul>
<li><p>We’re verifying that <strong>10</strong> and <strong>20</strong> are unequal.</p>
</li>
<li><p><strong>assert_ne!(num1, num2)</strong> will pass since the values differ.</p>
</li>
<li><p>If they were the same, we’d see a diff that highlights zero differences (which is ironically helpful if you made a mistake in your test logic).</p>
</li>
</ul>
<h3>Solution - 3</h3>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[test]
fn test_multiline_strings() {
    let expected = "foo\nbar\nbaz";
    let actual = "foo\nbar\nbaz";
    assert_eq!(expected, actual);
}
</code></pre>
<p><strong>Explanation</strong>:</p>
<ul>
<li><p>We define two multiline strings, <em>expected</em> and <em>actual</em>.</p>
</li>
<li><p>Both strings are identical.</p>
</li>
<li><p>Because they match exactly, <strong>assert_eq!</strong> succeeds silently (no diff needed).</p>
</li>
</ul>
<h3>Solution - 4</h3>
<pre><code class="language-rust">use std::collections::HashMap;
use pretty_assertions::{assert_eq, assert_ne};


#[test]
fn test_hashmap_equality() {
    let mut map1 = HashMap::new();
    map1.insert(1, "one");
    map1.insert(2, "two");

    let mut map2 = HashMap::new();
    map2.insert(1, "one");
    map2.insert(2, "two");

    // They are identical, so this will pass silently
    assert_eq!(map1, map2);
}
</code></pre>
<p><strong>Explanation:</strong></p>
<ul>
<li><p>We create two <strong>HashMap&lt;u32, &amp;str&gt;</strong> with the same key-value pairs.</p>
</li>
<li><p><strong>assert_eq!(map1, map2)</strong> passes without showing any diff.</p>
</li>
<li><p>If there was a difference, we’d see a pretty-printed structure comparison.</p>
</li>
</ul>
<h3>Solution - 5</h3>
<pre><code class="language-rust">use pretty_assertions::{assert_eq, assert_ne};

#[derive(Debug)]
struct User {
    id: u32,
    name: String,
}


#[test]
fn test_user_struct_equality() {
    let user1 = User {
        id: 101,
        name: String::from("Alice"),
    };

    let user2 = User {
        id: 101,
        name: String::from("Alice"),
    };

    // Since user1 == user2, the test passes silently
    assert_eq!(user1.id, user2.id);
    assert_eq!(user1.name, user2.name);

    // Optionally, you could also do:
    // assert_eq!(user1, user2);
    // But that requires PartialEq on the struct as well!
}
</code></pre>
<p><strong>Note</strong>: If you want to compare the User instances directly (not just their fields), also derive PartialEq so that Rust knows how to determine the equality of your struct:</p>
<pre><code class="language-rust">#[derive(Debug, PartialEq)]
struct User { ... }
</code></pre>
<p>Then you can do <strong>assert_eq!(user1, user2);</strong> directly.</p>
<p><strong>Explanation:</strong></p>
<ul>
<li><p>We define <strong>struct User</strong> with <strong>derive(Debug)</strong> so it can be printed.</p>
</li>
<li><p>We create two identical instances, <strong>user1</strong> and <strong>user2</strong>.</p>
</li>
<li><p>We compare their fields with <strong>assert_eq!</strong>.</p>
</li>
<li><p>Alternatively, if we derived <strong>PartialEq</strong>, we could compare the structs directly.</p>
</li>
</ul>
<p>This exercise shows how <strong>pretty_assertions</strong> can help you debug differences in custom types, provided those types implement <strong>Debug</strong> (and optionally <strong>PartialEq</strong> if you want to compare them directly).</p>
<h2>Wrap-Up</h2>
<p>By working through these exercises, you’ve practiced many of the key features of <strong>pretty_assertions</strong>:</p>
<ul>
<li><p>Replacing standard <strong>assert_eq!</strong> and <strong>assert_ne!</strong> macros to get prettier diffs.</p>
</li>
<li><p>Comparing everything from basic data (ints, strings) to complex data structures (vectors, hash maps) and custom types.</p>
</li>
<li><p>Observing how multiline strings and large data structures get clearer, color-coded highlights for any differences.</p>
</li>
</ul>
<blockquote>
<p>You can have a look at the code examples above on GitHub here: <a href="https://github.com/DigitalDevBlog/pretty%5C_assertions%5C_examples.git">https://github.com/DigitalDevBlog/pretty\_assertions\_examples.git</a></p>
</blockquote>
<p>Enjoy more explicit test failures—and debug faster!</p>
]]></content:encoded></item><item><title><![CDATA[How to use Git Conventional Commits Messages]]></title><description><![CDATA[type: Describes the category of the commit (e.g., feat, fix, docs, style, refactor, test, build, ci, perf, chore, revert). scope (optional): A short…]]></description><link>https://www.digitaldev.blog/how-to-use-git-conventional-commits-messages</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-use-git-conventional-commits-messages</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 25 Jan 2025 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/cb2d7032-5017-400d-81cd-414292d6b3d5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Core Structure of Git Conventional Commit Message</h2>
<pre><code class="language-plaintext">&lt;type&gt;(&lt;scope&gt;): &lt;subject&gt;
&lt;BLANK LINE&gt;
&lt;body&gt; (optional)
&lt;BLANK LINE&gt;
&lt;footer&gt; (optional&gt;
</code></pre>
<ol>
<li><p><strong>type</strong>: Describes the category of the commit (e.g., feat, fix, docs, style, refactor, test, build, ci, perf, chore, revert).</p>
</li>
<li><p><strong>scope</strong> (optional): A short identifier for the section or module of the codebase that was changed. Placed inside parentheses immediately after the type.</p>
</li>
<li><p><strong>subject</strong>: A brief summary of the changes (preferably no more than ~72 characters). Written in the imperative mood (“change”, “add”, “fix”, not “changed”, “added”, “fixed”).</p>
</li>
<li><p><strong>body</strong> (optional): Used for more extensive descriptions of what and why. Explains the changes in detail if needed.</p>
</li>
<li><p><strong>footer</strong> (optional): Commonly used to reference issues (e.g., “Closes #123”) or to signal a <strong>BREAKING CHANGE</strong>.</p>
</li>
</ol>
<h2>Common <strong>Types</strong></h2>
<ul>
<li><p><strong>feat</strong>: A new feature.</p>
</li>
<li><p><strong>fix</strong>: A bug fix.</p>
</li>
<li><p><strong>docs</strong>: Documentation changes (e.g., README updates).</p>
</li>
<li><p><strong>style</strong>: Changes that don’t affect functionality (whitespace, formatting, etc.).</p>
</li>
<li><p><strong>refactor</strong>: Code changes that neither fix a bug nor add a feature.</p>
</li>
<li><p><strong>perf</strong>: Changes that improve performance.</p>
</li>
<li><p><strong>test</strong>: Adding or correcting tests.</p>
</li>
<li><p><strong>build</strong>: Changes that affect the build system or dependencies.</p>
</li>
<li><p><strong>ci</strong>: Changes to CI configuration (GitHub Actions, Jenkins, etc.).</p>
</li>
<li><p><strong>chore</strong>: Routine task changes (e.g., updating .gitignore, minor cleanup).</p>
</li>
<li><p><strong>revert</strong>: Reverts a previous commit.</p>
</li>
</ul>
<h2>Examples</h2>
<ol>
<li><p><strong>With a scope</strong>:</p>
<pre><code class="language-plaintext">feat(auth): add JWT verification for user login
</code></pre>
<ul>
<li><p><strong>type</strong>: feat</p>
</li>
<li><p><strong>scope</strong>: auth</p>
</li>
<li><p><strong>subject</strong>: add JWT verification for user login</p>
</li>
<li><p>Telling your team you’ve added a feature to the authentication module.</p>
</li>
</ul>
</li>
<li><p><strong>Without a scope</strong>:</p>
<pre><code class="language-plaintext">fix: handle null pointer exception in login flow
</code></pre>
<ul>
<li><p><strong>type</strong>: fix</p>
</li>
<li><p><strong>subject</strong>: handle null pointer exception in login flow</p>
</li>
</ul>
</li>
<li><p><strong>With body and footer</strong>:</p>
<pre><code class="language-plaintext">refactor(database): improve connection handling on shutdown

This refactor ensures connections are closed gracefully to prevent memory leaks under high-load scenarios.

Closes #123
</code></pre>
<ul>
<li><p><strong>type</strong>: refactor</p>
</li>
<li><p><strong>scope</strong>: database</p>
</li>
<li><p><strong>subject</strong>: improve connection handling on shutdown</p>
</li>
<li><p><strong>body</strong>: Explanation.</p>
</li>
<li><p><strong>footer</strong>: Issue reference.</p>
</li>
</ul>
</li>
<li><p><strong>Breaking change</strong> (shown in the footer):</p>
<pre><code class="language-plaintext">feat(auth): remove deprecated Oauth 1.0 support

BREAKING CHANGE: The commit removes OAuth 1.0. All applications must mirgate to Oauth 2.0 endpoints.
</code></pre>
</li>
</ol>
<h2>Best Practices</h2>
<ol>
<li><p><strong>Scope</strong>:</p>
<ul>
<li><p>Use <strong>parentheses</strong> for the scope if you want to call out the specific part of the code changed (e.g., (auth), (database)).</p>
</li>
<li><p>Keep it short—one word or small phrase.</p>
</li>
</ul>
</li>
<li><p><strong>Subject</strong>:</p>
<ul>
<li><p>Keep the subject line short (≤ 72 characters).</p>
</li>
<li><p>Use <strong>imperative</strong> tense (“add”, “update”, “fix”) rather than “added”, “updating”, “fixed”.</p>
</li>
<li><p>Avoid punctuation at the end of the subject (no period needed).</p>
</li>
</ul>
</li>
<li><p><strong>Body</strong>:</p>
<ul>
<li><p>Optional but recommended if you need to explain <strong>why</strong> a change was made, not just <strong>what</strong>.</p>
</li>
<li><p>Wrap text at around 72 characters for readability.</p>
</li>
</ul>
</li>
<li><p><strong>Footer</strong>:</p>
<ul>
<li><p>Use for references to issues (Closes #123, Fixes #45) or for large changes that break backward compatibility (BREAKING CHANGE:).</p>
</li>
<li><p>Keep it short and to the point.</p>
</li>
</ul>
</li>
<li><p><strong>When to Use Breaking Change</strong>:</p>
<ul>
<li><p>If any commit requires users or developers to update their code, environment, or configuration for the software to continue working correctly, it’s a <strong>BREAKING CHANGE</strong>.</p>
</li>
<li><p><em>Example:</em> removing a deprecated feature, changing a method signature, or altering a configuration format.</p>
</li>
</ul>
</li>
<li><p><strong>Consistency</strong>:</p>
<ul>
<li><p>Align with your team’s or project’s guidelines for scopes and how detailed the body should be.</p>
</li>
<li><p>Enforce a commit message style checker (like <strong>commitlint</strong>) for consistency</p>
</li>
</ul>
</li>
</ol>
<h3>Quick Reference Summary</h3>
<pre><code class="language-plaintext">&lt;type&gt;(&lt;scope&gt;): &lt;subject&gt;

&lt;body&gt;

&lt;footer&gt;
</code></pre>
<ul>
<li><p><strong>Types</strong>: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.</p>
</li>
<li><p><strong>Scope</strong> (optional): Define the part of the code changed (in parentheses).</p>
</li>
<li><p><strong>Subject</strong>: Short imperative description (≤ 72 chars).</p>
</li>
<li><p><strong>Body</strong> (optional): Longer explanation of changes if necessary.</p>
</li>
<li><p><strong>Footer</strong> (optional): References or BREAKING CHANGE notes.</p>
</li>
</ul>
<p>Use this cheat sheet to keep your commit messages consistent, clear, and meaningful!</p>
]]></content:encoded></item><item><title><![CDATA[Rust Basics of Checking Command-Line Arguments]]></title><description><![CDATA[In Rust, you typically read command-line arguments using the standard library’s std::env::args() function. This function returns an iterator over the…]]></description><link>https://www.digitaldev.blog/rust-basics-of-checking-command-line-arguments</link><guid isPermaLink="true">https://www.digitaldev.blog/rust-basics-of-checking-command-line-arguments</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 18 Jan 2025 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/53924b61-0efb-4fb6-a3fd-2e5d6b4a15ad.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Rust, you typically read command-line arguments using the standard library’s <a href="https://doc.rust-lang.org/std/env/fn.args.html">std::env::args()</a> function. This function returns an iterator over the arguments passed to your program (with the first argument conventionally being the path to the executable itself). Below is a basic example of how to check for and handle command-line arguments:</p>
<pre><code class="language-rust">use std::env;

fn main() {
    // Collect arguments into a vector of strings
    let args:  Vec&lt;String&gt; = env::args().collect();

    // The first element (args[0]) is the path to the executable,
    // so actual "user" arguments start from index 1.
    match args.len() {
        // If len == 1, it means there's only the executable name
        // and no additional arguments.
        1 =&gt; {
            println!("No arguments provided.");
        }
        _ =&gt; {
            println!("Number of arguments: {}", args.len() -1);
            println!("Arguments: {:?}", &amp;args[1..]);
        }
}
</code></pre>
<h3>Key Points</h3>
<ol>
<li><p><strong>std::env::args()</strong></p>
<ul>
<li><p>Returns an iterator over the command-line arguments.</p>
</li>
<li><p>The first argument (args[0]) is typically the name or path of the executable.</p>
</li>
</ul>
</li>
<li><p><strong>Skipping the Program Name</strong></p>
<ul>
<li><p>Often, you only care about the arguments after the executable name.</p>
</li>
<li><p>You can skip the first argument with something like: let mut args = std::env::args().skip(1);</p>
</li>
<li><p>Or, after collecting them into a vector, look at args[1..].</p>
</li>
</ul>
</li>
<li><p><strong>Checking Argument Count</strong></p>
<ul>
<li><p>Use args.len() to see how many arguments exist (including the program name).</p>
</li>
<li><p>If args.len() &lt; 2, there are no “extra” arguments.</p>
</li>
</ul>
</li>
<li><p><strong>Parsing</strong></p>
<ul>
<li>If you need more advanced command-line parsing (handling flags, subcommands, etc.), you can use community crates like <a href="https://crates.io/crates/clap">clap</a> or <a href="https://crates.io/crates/structopt">structopt</a> (now integrated into clap as derive macros). These provide features such as automatically handling --help or --version flags.</li>
</ul>
</li>
</ol>
<h3>Example with clap</h3>
<pre><code class="language-rust">[dependencies]
clap = "4.2"  # or the latest version
</code></pre>
<pre><code class="language-rust">use clap::{Arg, Command};

fn main() {
    let matches = Command::new("myapp")
        .version("1.0")
        .author("Your Name &lt;you@example.com&gt;")
        .about("An example of argument parsing in Rust")
        .arg(
            Arg::new("file")
                .help("Specifies the input file")
                .required(false)
                .index(1),
        )
        .get_matches();

    if let Some(file) = matches.get_one::&lt;String&gt;("file") {
        println!("Received file argument: {}", file);
    } else {
        println!("No file argument provided");
    }
}
</code></pre>
<p>With Clap, you get a full-featured way to define, validate, and document your command-line interfaces. However, using the standard library is usually enough to check the number of arguments or access them directly.</p>
<p>I will follow up with a more detailed post about how to use Clap.</p>
]]></content:encoded></item><item><title><![CDATA[My Vim Basics Cheat Sheet]]></title><description><![CDATA[Learning Vim is beneficial if you often use Unix or Linux systems. The following cheat sheet will help you get started with the basic commands you'll…]]></description><link>https://www.digitaldev.blog/my-vim-basics-cheat-sheet</link><guid isPermaLink="true">https://www.digitaldev.blog/my-vim-basics-cheat-sheet</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 04 Jan 2025 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/01fffb53-8562-4154-9c5f-6f4d76ce9db8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Learning Vim is beneficial if you often use Unix or Linux systems. The following cheat sheet will help you get started with the basic commands you'll likely use most frequently.</p>
<p>Here is my Vim cheat sheet. You can also find a download link at the bottom of this page.</p>
<table style="min-width:765px"><colgroup><col style="width:370px"></col><col style="width:370px"></col><col style="min-width:25px"></col></colgroup><tbody><tr><td><p><strong>Description</strong></p></td><td><p><strong>Command</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Moving around</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Move the cursor two words left</p></td><td><p><strong>2w</strong></p></td><td><p></p></td></tr><tr><td><p>Move the cursor to the end of the 3rd word</p></td><td><p><strong>3e</strong></p></td><td><p></p></td></tr><tr><td><p>Move the cursor to the start of the line</p></td><td><p><strong>0</strong></p></td><td><p></p></td></tr><tr><td><p>Move to the start of the next word</p></td><td><p><strong>w</strong></p></td><td><p></p></td></tr><tr><td><p>Move to the end of the next word</p></td><td><p><strong>e or E</strong></p></td><td><p></p></td></tr><tr><td><p>Move a word backward</p></td><td><p><strong>b or B</strong></p></td><td><p></p></td></tr><tr><td><p>Move the screen up by one line</p></td><td><p><strong>Ctrl-y</strong></p></td><td><p></p></td></tr><tr><td><p>Move the screen down by one line</p></td><td><p><strong>Ctrl-e</strong></p></td><td><p></p></td></tr><tr><td><p>Move the cursor &amp; screen up ½ page</p></td><td><p><strong>Crtl-u</strong></p></td><td><p></p></td></tr><tr><td><p>Move the cursor &amp; screen down ½ page</p></td><td><p><strong>Ctrl-d</strong></p></td><td><p></p></td></tr><tr><td><p>Move the screen up one page,<br />cursor to the last line</p></td><td><p><strong>Ctrl-b</strong></p></td><td><p></p></td></tr><tr><td><p>Move the screen down one page,<br />cursor to the first line</p></td><td><p><strong>Ctrl-f</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Deleting</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>d &lt;number&gt; &lt;motion&gt;</p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Delete until the end of the line</p></td><td><p><strong>d$</strong></p></td><td><p></p></td></tr><tr><td><p>Delete until the start of the next word</p></td><td><p><strong>dw</strong></p></td><td><p></p></td></tr><tr><td><p>Delete until the end of the current word</p></td><td><p><strong>de</strong></p></td><td><p></p></td></tr><tr><td><p>Delete the next two words</p></td><td><p><strong>d2w</strong></p></td><td><p></p></td></tr><tr><td><p>Delete the current line</p></td><td><p><strong>dd</strong></p></td><td><p></p></td></tr><tr><td><p>Delete the next two lines</p></td><td><p><strong>2dd</strong></p></td><td><p></p></td></tr><tr><td><p>Delete character at the cursor</p></td><td><p><strong>x</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Undo/Redo</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Undo last change</p></td><td><p><strong>u</strong></p></td><td><p></p></td></tr><tr><td><p>Undo the whole line</p></td><td><p><strong>U</strong></p></td><td><p></p></td></tr><tr><td><p>Redo</p></td><td><p><strong>Crtl-r</strong></p></td><td><p></p></td></tr><tr><td><p>Put (paste)</p></td><td><p><strong>p</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Replace</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Replace the character at the cursor</p></td><td><p><strong>r</strong></p></td><td><p></p></td></tr><tr><td><p>Replace more than one character</p></td><td><p><strong>R</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Changing</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>c &lt;number&gt; &lt;motion&gt;</p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Change until the end of the word</p></td><td><p><strong>ce</strong></p></td><td><p></p></td></tr><tr><td><p>Change until the end of the line</p></td><td><p><strong>c$</strong></p></td><td><p></p></td></tr><tr><td><p>Change the next two words</p></td><td><p><strong>c2w</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Cursor location and file status</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Show location in file and status</p></td><td><p><strong>Ctrl-g</strong></p></td><td><p></p></td></tr><tr><td><p>Move to the bottom of the file</p></td><td><p><strong>G</strong></p></td><td><p></p></td></tr><tr><td><p>Move to the start of the file</p></td><td><p><strong>gg</strong></p></td><td><p></p></td></tr><tr><td><p>Move to line number</p></td><td><p><strong>&lt;number&gt;G</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Search</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Search the word at the cursor</p></td><td><p><strong>*</strong></p></td><td><p></p></td></tr><tr><td><p>Search forwards + phrase</p></td><td><p><strong>/&lt;phrase&gt;</strong></p></td><td><p></p></td></tr><tr><td><p>Search backward + phrase</p></td><td><p><strong>?&lt;phrase&gt;</strong></p></td><td><p></p></td></tr><tr><td><p>Search the next word (forward)</p></td><td><p><strong>n</strong></p></td><td><p></p></td></tr><tr><td><p>Search the previous word (backward)</p></td><td><p><strong>N</strong></p></td><td><p></p></td></tr><tr><td><p>Go back to where you came from backwards</p></td><td><p><strong>Crtl-o</strong></p></td><td><p></p></td></tr><tr><td><p>Go back to where you came from forwards</p></td><td><p><strong>Crtl-i</strong></p></td><td><p></p></td></tr><tr><td><p>Disable search highlight temporarily (cmd-mode)</p></td><td><p><strong>:noh</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Matching parentheses search</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Type % to find the matching ) } ]</p></td><td><p><strong>%} or %] or %)</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Substitute (Search and replace)</strong></p></td><td><p><strong>:s</strong></p></td><td><p></p></td></tr><tr><td><p>Substitute 'old' with 'new'</p></td><td><p><strong>:s/old/new</strong></p></td><td><p></p></td></tr><tr><td><p>Substitute 'thee' with 'the' globally in the line</p></td><td><p><strong>:s/old/new/g</strong></p></td><td><p></p></td></tr><tr><td><p>Substitute between line numbers # and #</p></td><td><p><strong>#,#s/old/new/g</strong></p></td><td><p></p></td></tr><tr><td><p>Substitute every occurrence in the whole file</p></td><td><p><strong>:%s/old/new/g</strong></p></td><td><p></p></td></tr><tr><td><p>Substitute every occurrence in the whole file and prompt to confirm</p></td><td><p><strong>:%s/old/new/gc</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Executing external commands</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Write file (default has no filename for nvim)</p></td><td><p><strong>:w</strong></p></td><td><p></p></td></tr><tr><td><p>Write file &lt;FILE&gt;</p></td><td><p><strong>:w FILE</strong></p></td><td><p></p></td></tr><tr><td><p>Writing a selection to a file (start visual selection <strong>v</strong> and enter <strong>:</strong> until you see <strong>'&lt;,'&gt;</strong> at the bottom of the screen</p></td><td><p><strong>'&lt;,'&gt;w FILE</strong></p></td><td><p></p></td></tr><tr><td><p>Opening and reading a file `&lt;FILE&gt;`</p></td><td><p><strong>:r FILE</strong></p></td><td><p></p></td></tr><tr><td><p>Merging a file at the current position in the current file</p></td><td><p><strong>:r FILE</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Open Command</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Move the cursor to the next line and switch</p></td><td><p>(insert mode)</p></td><td><p><strong>o</strong></p></td></tr><tr><td><p>Move the cursor to the previous line and switch (insert mode)</p></td><td><p><strong>O</strong></p></td><td><p></p></td></tr><tr><td><p>Append from the cursor (insert mode)</p></td><td><p><strong>a</strong></p></td><td><p></p></td></tr><tr><td><p>Append at the end of the line (insert mode)</p></td><td><p><strong>A</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Copy &amp; Paste</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Use visual select <strong>v</strong> and highlight what you want to copy and press <strong>y</strong> for yank to copy</p></td><td><p><strong>y</strong></p></td><td><p></p></td></tr><tr><td><p>Copy the next word</p></td><td><p><strong>yw</strong></p></td><td><p></p></td></tr><tr><td><p>Paste after the cursor</p></td><td><p><strong>p</strong></p></td><td><p></p></td></tr><tr><td><p>Paste before the cursor</p></td><td><p><strong>P</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Set options</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Enable ignore case (for search)</p></td><td><p><strong>:set ic</strong></p></td><td><p></p></td></tr><tr><td><p>Disable ignore case</p></td><td><p><strong>:set noic</strong></p></td><td><p></p></td></tr><tr><td><p>Enable highlight search</p></td><td><p><strong>:set hlsearch</strong></p></td><td><p></p></td></tr><tr><td><p>Disable highlight search</p></td><td><p><strong>:set nohlsearch</strong></p></td><td><p></p></td></tr><tr><td><p>Enable show partial matches search</p></td><td><p><strong>:set inc</strong></p></td><td><p></p></td></tr><tr><td><p>Disable show partial matches search</p></td><td><p><strong>:set noinc</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Getting help</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Open the help</p></td><td><p><strong>F1 or :help</strong></p></td><td><p></p></td></tr><tr><td><p>Find help for &lt;topic&gt;</p></td><td><p><strong>:help &lt;topic&gt;</strong></p></td><td><p></p></td></tr><tr><td><p>Move to the next window pane</p></td><td><p><strong>Ctrl-w</strong></p></td><td><p></p></td></tr><tr><td><p>Command completion (command mode)</p></td><td><p><strong>Ctrl-d (e.g. :w Ctrl-d shows all commands starting with w)</strong></p></td><td><p></p></td></tr><tr><td><p><strong>Quitting</strong></p></td><td><p></p></td><td><p></p></td></tr><tr><td><p>Quit vim</p></td><td><p><strong>:q</strong></p></td><td><p></p></td></tr><tr><td><p>Quit and ignore changes made to the file</p></td><td><p><strong>:q!</strong></p></td><td><p></p></td></tr><tr><td><p>Quit and write changes made to the file</p></td><td><p><strong>:qw</strong></p></td><td><p></p></td></tr></tbody></table>]]></content:encoded></item><item><title><![CDATA[Rust’s println!: Way More Powerful Than You Think]]></title><description><![CDATA[When I started learning Rust, I treated println! like a simple print statement. You know, “just show some text” and move on. Turns out it’s a lot more than…]]></description><link>https://www.digitaldev.blog/rust-s-println-way-more-powerful-than-you-think</link><guid isPermaLink="true">https://www.digitaldev.blog/rust-s-println-way-more-powerful-than-you-think</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Mon, 12 Aug 2024 08:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/ca678e7c-de46-4efc-a284-5e7cae83c6a9.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I started learning Rust, I treated <strong>println!</strong> like a simple print statement. You know, <em>“just show some text”</em> and move on. Turns out it’s a lot more than that. It’s basically a <strong>mini language for string formatting</strong>, and once you actually get what it can do, it’s powerful to use.</p>
<p>If you’ve played with Python’s f-strings or .format(), you’ll recognize the vibe. But Rust adds a layer of precision and safety that’s surprisingly satisfying once it clicks.</p>
<h2>Start with the Basics</h2>
<p>You’ve seen this one:</p>
<pre><code class="language-rust">println!("Hello, {}!", "world");
</code></pre>
<p>Nothing to explain here, just a simple substitution. But what’s hiding underneath is a complete formatting system that can do <em>way</em> more.</p>
<h2>Argument Positioning</h2>
<p>You can reuse values by their index:</p>
<pre><code class="language-rust">println!("{0}, {1}, {0} again!", "Hello", "world");
// Hello, world, Hello again!
</code></pre>
<p>Or use named arguments if you prefer something more readable (and future-proof):</p>
<pre><code class="language-rust">println!("{greeting}, {name}!", greeting="Hello", name="world");
</code></pre>
<p>Honestly, once you start using named arguments, it’s hard to go back. They make long-format strings <em>way</em> less painful to read six months later.</p>
<h2>Alignment Magic</h2>
<p>Now it gets fun. You can align text left, right, or center:</p>
<pre><code class="language-rust">println!("{:&lt;6}", "Hi");  // "Hi    "
println!("{:&gt;6}", "Hi");  // "    Hi"
println!("{:^6}", "Hi");  // "  Hi  "
</code></pre>
<p>This is helpful when you want your console output to look neat, like printing a small table or aligning values in logs. It’s one of those “little touches” that make your CLI feel better.</p>
<h2>Custom Padding Characters</h2>
<p>Want to go beyond spaces? You can pick your own padding character:</p>
<pre><code class="language-rust">println!("{:*&lt;6}", "Hi");  // "Hi****"
println!("{:*^6}", "Hi");  // "**Hi**"
</code></pre>
<p>I don’t use this daily, but now and then I’ll pad things with <strong>-</strong> or <strong>*</strong> just to visually separate sections in debug output. It’s a small thing, but it helps.</p>
<h2>Precision Control</h2>
<p>For floats, .precision controls decimal places:</p>
<pre><code class="language-rust">println!("{:.2}", 3.14159);  // "3.14"
</code></pre>
<p>But here’s the fun part — it also works on strings (yep, for truncation):</p>
<pre><code class="language-rust">println!("{:.4}", "Hello, world!");  // "Hell"
</code></pre>
<p>I’ve used this trick for quick-and-dirty text truncation in tables. Not the cleanest approach, but when you’re hacking on CLI tools, speed wins.</p>
<p>You can also mix width and precision:</p>
<pre><code class="language-rust">println!("{:6.2}", 3.14159);  // "  3.14"
</code></pre>
<h2>Numbers: The Good Stuff</h2>
<p>Formatting numbers is where println! shines. Binary, octal, hex — all built in:</p>
<pre><code class="language-rust">println!("{:b}", 42);  // "101010"
println!("{:o}", 42);  // "52"
println!("{:x}", 42);  // "2a"
println!("{:X}", 42);  // "2A"
</code></pre>
<p>Need zero-padding? Easy:</p>
<pre><code class="language-rust">println!("{:06}", 42);  // "000042"
</code></pre>
<p>Perfect for logs, file counters, or pretending you’re building a retro mainframe interface.</p>
<h2>Debug Output — Your New Best Friend</h2>
<p>This one you’ll use all the time:</p>
<pre><code class="language-rust">println!("{:?}", (42, "Hello"));
</code></pre>
<p>That <strong>:?</strong> flag prints the <em>debug</em> representation of anything that implements Debug.</p>
<p>Structs, enums, tuples, it doesn’t matter; if it’s Debug, it prints.</p>
<p>At this point, I’m not even consciously typing it anymore. It’s just muscle memory.</p>
<h2>Making Custom Types Printable</h2>
<p>If you want to make your own structs printable, you’ve got two options: Display and Debug.</p>
<p>Display is for nice, human-readable output:</p>
<pre><code class="language-rust">use std::fmt;
struct Point {
    x: i32,
    y: i32,
}
impl fmt::Display for Point {
    fn fmt(&amp;self, f: &amp;mut fmt::Formatter) -&gt; fmt::Result {
        write!(f, "({}, {})", self.x, self.y)
    }
}
let p = Point { x: 1, y: 2 };
println!("{}", p);  // (1, 2)
</code></pre>
<p>But unless you’re writing user-facing output, you’ll be fine just slapping #[derive(Debug)] on your struct and using <strong>{:?}</strong>. Life’s too short to handcraft fmt impls for everything.</p>
<h2>Combining Everything</h2>
<p>Here’s a pattern I use constantly — printing nicely aligned columns:</p>
<pre><code class="language-rust">println!("{:&lt;10} | {:^10} | {:&gt;10}", "left", "center", "right");
// left       |   center   |      right
</code></pre>
<p>Okay, you probably won’t need that last one, but it’s neat to know it works.</p>
<h2>Quick Cheatsheet</h2>
<p>If you’re like me and constantly forget the syntax:</p>
<ul>
<li><p><strong>:&lt;**, **:&gt;</strong>, <strong>:^</strong> — alignment (left, right, center)</p>
</li>
<li><p>:width — field width</p>
</li>
<li><p>:.precision — decimals or string truncation</p>
</li>
<li><p>:+ — always show sign</p>
</li>
<li><p>:0width — zero-padding</p>
</li>
<li><p>:b, :o, :x — binary, octal, hex</p>
</li>
<li><p><strong>:?</strong> — debug output (you’ll overuse this one)</p>
</li>
</ul>
<h2>Wrapping Up</h2>
<p>The println! formatting system is one of those things that <em>feels excessive</em> at first, and then you wonder how you ever lived without it. <a href="http://it.It">It</a> turns messy string concatenations into clean, readable output, and Rust’s compiler keeps you honest by catching format errors at compile time. <a href="http://time.You">You</a> don’t need to memorize everything. Just start small, experiment, and let the rest fall into place as you go.</p>
<h3>Summary Table</h3>
<table style="width:739px"><colgroup><col style="width:260px"></col><col style="width:479px"></col></colgroup><tbody><tr><td><p><strong>Format Specifier</strong></p></td><td><p><strong>Description</strong></p></td></tr><tr><td><p>:&lt;</p></td><td><p>Left-align the value within the width.</p></td></tr><tr><td><p>:&gt;</p></td><td><p>Right-align the value within the width.</p></td></tr><tr><td><p>:^</p></td><td><p>Center-align the value within the width.</p></td></tr><tr><td><p>:&lt;width&gt;</p></td><td><p>Specify minimum width.</p></td></tr><tr><td><p>:&lt;fill&gt;&lt;align&gt;</p></td><td><p>Specify fill character and alignment.</p></td></tr><tr><td><p>:.&lt;precision&gt;</p></td><td><p>Set precision for floats or limit string length.</p></td></tr><tr><td><p>:+</p></td><td><p>Always show a sign for numbers.</p></td></tr><tr><td><p>:</p></td><td><p>Show a space for positive numbers.</p></td></tr><tr><td><p>:b</p></td><td><p>Binary format.</p></td></tr><tr><td><p>:o</p></td><td><p>Octal format.</p></td></tr><tr><td><p>:x/:X</p></td><td><p>Hexadecimal (lowercase/uppercase).</p></td></tr><tr><td><p>:?</p></td><td><p>Debug representation.</p></td></tr><tr><td><p>:06</p></td><td><p>Zero-padded to width 6.</p></td></tr></tbody></table>

<p>This flexibility allows println! to handle a wide range of formatting needs!</p>
]]></content:encoded></item><item><title><![CDATA[Are Pull Requests Sabotaging Your Development Productivity?]]></title><description><![CDATA[In software engineering collaboration, platforms like GitHub, Azure DevOps, and GitLab have given us a formidable tool: Pull Requests. They've become the…]]></description><link>https://www.digitaldev.blog/are-pull-requests-sabotaging-your-development-productivity</link><guid isPermaLink="true">https://www.digitaldev.blog/are-pull-requests-sabotaging-your-development-productivity</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Wed, 27 Mar 2024 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/359e2291-724a-41fc-9429-ff3618c4d30a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In software engineering collaboration, platforms like GitHub, Azure DevOps, and GitLab have given us a formidable tool: Pull Requests. They've become the cornerstone for many engineers, a stronghold of quality control before merging code into the main or developed branches.</p>
<p>But let's entertain a notion that often goes unnoticed amidst the enthusiasm for Pull Requests - they can be the silent speed bumps on the road to productivity. "Hold your horses!" you might protest, "Pull Requests are indispensable. They catch errors and ensure code integrity."</p>
<p>That's a fair point, to some extent. But here's the thing: Have we ever stopped to think that maybe, just maybe, relying too much on Pull Requests is like putting a Band-Aid on a deeper issue? Could it be that we're using them to cover up skill gaps rather than bridging them?</p>
<p>Enter an age-old contender from the annals of eXtreme Programming: pair programming. Despite its proven benefits, it remains the black sheep for many engineers—the fear of distraction or the discomfort of someone peeking over their shoulder at their code. But let's be real here - pair programming is like a free course in coding, with the added bonus of having someone to bounce ideas off of. It's like having your own personal brainstorming session but with code. Sure, you have GitHub CoPilot or some AI programming tool these days, but where is the fun in that?</p>
<p>Pair programming and its cousin, Mob Programming, is like pair programming on steroids, but in a good way. Imagine tackling those brain-busting coding problems with a whole squad of colleagues. It's like assembling the Avengers for your codebase. They're akin to on-the-job training, a free-flowing exchange of ideas that can unravel the complexities of coding faster than solitary efforts. As my esteemed colleague Tim Ottinger puts it, they're the antidote to what he aptly dubs "multi-brain problems" - challenges best tackled with collective intellect.</p>
<p>Don't get me wrong—Pull Requests are handy. But sometimes, they can be like that one slowpoke in the fast lane—slowing down the whole process. You know, when you're waiting on that one senior dev to give the green light before you can move forward? Yeah, that.</p>
<p>The Achilles' heel of Pull Requests lies in their queuing mechanism. In the lean philosophy, we've long understood the perils of queues, often manifesting as bottlenecks. Regrettably, this bottleneck scenario isn't uncommon in engineering teams, where a select few seniors find themselves burdened with reviewing the work of their peers.</p>
<p>Pull Requests, in essence, breed a culture of distrust. And perhaps, in some cases, rightfully so. What if a single misstep halts the entire team's progress, all because someone slipped through the cracks? It's a chilling prospect indeed.</p>
<p>However, it's time to rethink our reliance on Pull Requests. After all, trust is good, but a little faith in our fellow devs can go a long way. It might just be the boost our productivity needs.</p>
<p><a href="https://www.pexels.com/photo/a-bearded-man-pulling-a-rope-attached-to-his-harness-8700841/">Photo by Konstantin Mishchenko</a></p>
]]></content:encoded></item><item><title><![CDATA[Choosing the Right Path: A Comparison of Git Submodules and Conan for Dependency Management]]></title><description><![CDATA[In software development, managing dependencies is crucial yet often challenging. When it comes to version control systems like Git, developers have a…]]></description><link>https://www.digitaldev.blog/choosing-the-right-path-a-comparison-of-git-submodules-and-conan-for-dependency-management</link><guid isPermaLink="true">https://www.digitaldev.blog/choosing-the-right-path-a-comparison-of-git-submodules-and-conan-for-dependency-management</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sun, 24 Mar 2024 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/01414b60-c9a2-4540-805a-8e3ed9ff121b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In software development, managing dependencies is crucial yet often challenging. When it comes to version control systems like Git, developers have a variety of tools at their disposal. One such tool is Git submodules, which offer a way to include external repositories within a main repository. While Git submodules can be beneficial in certain scenarios, they also come with their fair share of complexities and challenges.</p>
<p>Picture this: you're working on a project, and you decide to incorporate Git submodules to manage dependencies. However, as you delve deeper, you realize that navigating submodule relationships, dealing with branching and merging complexities, and ensuring visibility into submodule content isn't as straightforward as you initially thought.</p>
<p>Git submodules introduce additional layers of complexity to your repository, making it harder for developers to understand and work with the codebase. Moreover, the submodule workflow may not fit seamlessly into all projects, leading to limitations and frustrations. Lack of visibility into submodule changes and the overhead of maintenance further add to the challenges.</p>
<p>Given these complexities and challenges, what alternatives exist for managing dependencies effectively? One such alternative gaining traction in the development community is Conan 2.x, a powerful package manager specializing in dependency management for C and C++ projects.</p>
<p>Conan 2.x simplifies dependency management by offering a centralized package repository and a declarative approach to defining dependencies in a project. With Conan, developers can specify dependencies, their versions, and settings in a `conanfile.py` file, reducing manual efforts and streamlining the process.</p>
<p>Conan 2.x provides a comprehensive solution to many of the challenges faced with Git submodules, offering a streamlined approach to dependency management.</p>
<p><strong>Exploring the Benefits</strong></p>
<ol>
<li><p><strong>Reduced Complexity:</strong> Conan 2.x simplifies dependency management, mitigating the complexities associated with submodule relationships and workflow limitations.</p>
</li>
<li><p><strong>Ease of Learning:</strong> With comprehensive documentation and community support, Conan 2.x offers an accessible learning curve for developers new to package management.</p>
</li>
<li><p><strong>Flexible Workflow:</strong> Conan 2.x provides a customizable workflow that accommodates various project requirements and build systems, thereby enhancing developer productivity.</p>
</li>
<li><p><strong>Enhanced Visibility:</strong> With explicit versioning and metadata for each package, Conan 2.x improves visibility into dependencies, facilitating easier tracking and understanding.</p>
</li>
<li><p><strong>Minimized Maintenance Overhead:</strong> Automated dependency fetching and version resolution in Conan 2.x reduce manual efforts, ensuring smoother maintenance and updates.</p>
</li>
</ol>
<p><strong>Conclusion</strong></p>
<p>In the battle of dependency management tools, Conan 2.x emerges as a compelling alternative to Git submodules. By leveraging Conan 2.x, developers can simplify their workflows, enhance visibility, and minimize maintenance overhead, ultimately improving the overall development experience. So, the next time you're faced with the complexities of managing dependencies, consider Conan 2.x as your solution for smoother sailing.</p>
<p>I can go into a lot more detail about the challenges of working with Git submodules. Drop me a message if you want me to zoom in on that topic.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding #[derive(Debug)]]]></title><description><![CDATA[In Rust, #[derive(Debug)] is an attribute macro used to automatically generate an implementation of the Debug trait for a custom data structure (usually a…]]></description><link>https://www.digitaldev.blog/understanding-derive-debug</link><guid isPermaLink="true">https://www.digitaldev.blog/understanding-derive-debug</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Fri, 12 Jan 2024 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/a3a3dd73-fb9a-4097-8b7f-b79eb51df6d6.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Rust, <strong>#[derive(Debug)]</strong> is an attribute macro used to automatically generate an implementation of the <strong>Debug</strong> trait for a custom data structure (usually a struct or an enum). The Debug trait is part of Rust's standard library and is used to format values for debugging purposes.</p>
<p>Here's what <strong>#[derive(Debug)]</strong> does:</p>
<ol>
<li><p><strong>Automated Implementation</strong>: When you apply <strong>#[derive(Debug)]</strong> to a struct or an enum, the Rust compiler automatically generates code to implement the Debug trait for that type.</p>
</li>
<li><p><strong>Pretty Printing</strong>: The <strong>Debug</strong> trait provides an fmt method, which formats the type's value as a string for human consumption during debugging. This means that you can use the <strong>println!</strong> macro or other debugging tools to display the content of instances of the type in a readable format.</p>
<p>For example, printing a struct is impossible without <strong>#[derive(Debug)]</strong>. When a struct or an enum is printed using <strong>println!("{:?}", instance);</strong> Rust attempts to format it using the <strong>Debug</strong> trait. Suppose the Debug trait is not implemented for the struct or enum. In that case, Rust will produce a compilation error indicating that the <strong>Debug</strong> trait is missing and suggest implementing it manually or using <strong>#[derive(Debug)]</strong>.</p>
<p>So, the purpose of <strong>#[derive(Debug)]</strong> is to automatically generate an implementation of the <strong>Debug</strong> trait for a struct or an enum, allowing it to be printed using<br /><strong>println!("{:?}", instance);</strong> without additional manual implementation. This makes debugging easier by providing a default way to print the contents of the struct or enum.</p>
<p>With <strong>#[derive(Debug)]</strong>, it becomes:</p>
<pre><code class="language-rust">MyStruct { field1: 42, field2: "Hello" }
</code></pre>
</li>
<li><p><strong>Customization</strong>: While <strong>#[derive(Debug)]</strong> provides a default implementation that displays all the fields of the struct or enum in a basic format, you can also manually implement the <strong>Debug</strong> trait for more complex formatting or custom types.</p>
<p>Here's an example of how to use <strong>#[derive(Debug)]</strong>:</p>
<pre><code class="language-rust">#[derive(Debug)] // Automatically generate Debug implementation
struct MyStruct {
    field1: i32,
    field2: String,
}
fn main() {
    let instance = MyStruct {
        field1: 42,
        field2: String::from("Hello"),
    };
    // Using Debug implementation to print the struct
    println!("{:?}", instance);
}
</code></pre>
</li>
</ol>
<p>In this example, the <strong>#[derive(Debug)]</strong> attribute macro automatically generates the <strong>Debug</strong> implementation for the <strong>MyStruct</strong> type, allowing you to print the <em>instance</em> using<br /><strong>println!("{:?}", instance);</strong>.</p>
<p>Using <strong>#[derive(Debug)]</strong>, you can save yourself the effort of manually implementing the <strong>Debug</strong> trait for simple data structures and make debugging your code more straightforward.</p>
]]></content:encoded></item><item><title><![CDATA[Published an AlmaLinux 9.1 Vagrant box for Parallels Desktop on Mac M1]]></title><description><![CDATA[I use a MacBook Pro M1 for my development and am a happy user. I am developing training materials and want to provide pre-cooked virtual machines for…]]></description><link>https://www.digitaldev.blog/published-an-almalinux-9-1-vagrant-box-for-parallels-desktop-on-mac-m1</link><guid isPermaLink="true">https://www.digitaldev.blog/published-an-almalinux-9-1-vagrant-box-for-parallels-desktop-on-mac-m1</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Thu, 27 Apr 2023 08:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/aaddb34d-6ab0-4eee-9af5-1828fc3037a9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I use a MacBook Pro M1 for my development and am a happy user. I am developing training materials and want to provide pre-cooked virtual machines for students to experiment with various exercises in a sandboxed environment.</p>
<p>On an Intel-based Mac, I used VirtualBox because of its easy availability of images, but there are no recent VirtualBox environments for M1. Besides, today's VirtualBox for M1 is in beta and still pretty unreliable in my brief experience. So, I need an alternative. I tried QEMU, but I am also not happy with the results.</p>
<p>I am also a long-time user of Parallels Desktop. It just works. And I love software that works. I thought it would be logical to switch to Parallels Desktop to deal with this lack of a properly working VirtualBox environment. To my surprise, it was hard to impossible to find some Vagrant boxes for M1. I got surprised that there are very few M1 boxes and even fewer for Parallels Desktop.</p>
<p>It's still puzzling to me why there are so few Vagrant boxes after so many years of M1 and M2 processors for Apple devices. I know quite a few developers that mainly work on a Mac, so you'd think there is sufficient need for such boxes.</p>
<p>Anyway, I created an AlmaLinux 9.1 Vagrant base box for a Parallels provider to run on a Mac M1 because I want such a box myself. I had never made a Vagrant box before, so it took some time and learning, but today I published version 0.2 of this box. You can find it here: <a href="https://app.vagrantup.com/wijnandsruud/boxes/AlmaLinux-9.1-aarch64/versions/0.2">https://app.vagrantup.com/wijnandsruud/boxes/AlmaLinux-9.1-aarch64/versions/0.2</a>.</p>
<p>This box is based on AlmaLinux 9.1-update-1-aarch64-minimal. The base image claims about 2 GB of disk space and linked clones about 86 MB. I may try to shrink the disk space required in the future, but I have no plans for that now.</p>
<p>I will share a tutorial post soon on how I created this Vagrant box.</p>
<p>I hope you enjoy it.</p>
]]></content:encoded></item><item><title><![CDATA[How to work with multiple GitHub Accounts and ssh keys]]></title><description><![CDATA[If you need to work with different GitHub accounts, e.g., when you have personal and work accounts, you may want to create separate ssh keys for each…]]></description><link>https://www.digitaldev.blog/how-to-work-with-multiple-github-accounts-and-ssh-keys</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-work-with-multiple-github-accounts-and-ssh-keys</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 18 Mar 2023 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/ad8ec170-47ef-4324-bf6f-4d614d5ba40a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you need to work with different GitHub accounts, e.g., when you have personal and work accounts, you may want to create separate ssh keys for each account. You can do this by creating multiple keys as usual. (see <a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent">Generating a new SSH key and adding it to the ssh-agent</a>).</p>
<h2>Check if the ssh-agent is running.</h2>
<pre><code class="language-shell">eval "$(ssh-agent -s)"
</code></pre>
<h2>Add your ssh keys to ssh-agent</h2>
<p>You can create separate keys and add them manually by:</p>
<pre><code class="language-shell">$ ssh-add --apple-use-keychain ~/.ssh/id_work
$ ssh-add --apple-use-keychain ~/.ssh/id_home
</code></pre>
<h2>Check if the keys were added to the ssh-agent successfully.</h2>
<pre><code class="language-shell">$ ssh-agent -L
</code></pre>
<p>The output may look as follow:</p>
<pre><code class="language-plaintext">ssh-ed25519 BBBBD3NzaC2lZDI1MTE7ACBAIDbADwSLXnei9x8AyNJ9W1AcXAgpz7ZDJOpO4WWnUnRK me@work.com
ssh-ed25519 BBBBD3NzaC2lZDI1NTE6AAAAIDbADwSLXmei9x8AyNJ9W1AcXAgpz7ZDJOpO4WWnUnRK me@home.com
</code></pre>
<h2>How to automatically add both keys when starting up</h2>
<p>Open and create `~/.ssh/config` and add both keys to the file.</p>
<pre><code class="language-plaintext">Host github.com                                                             
	HostName github.com
	AddKeysToAgent yes
	UseKeychain yes
	IdentityFile ~/.ssh/id_home
	User git

Host work
	HostName github.com
	AddKeysToAgent yes
	UseKeychain yes
	IdentityFile ~/.ssh/id_work
	User git
</code></pre>
<p>In this configuration, checking out a repo for your home use follows the standard format:</p>
<pre><code class="language-shell">$ git clone git@github.com:YourGitHubAccount/my-app.git
</code></pre>
<p>But if you want to checkout a repo from your work, you need to replace</p>
<pre><code class="language-plaintext">$ git clone git@work:YourGitHubAccount/my-app.git
</code></pre>
<h2>How to remove all keys from the ssh-agent</h2>
<pre><code class="language-shell">$ ssh-add -D
All identities removed.
</code></pre>
<p>Check if the keys were removed successfully:</p>
<pre><code class="language-shell">$ ssh-add -L
The agent has no identities.
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Mastering .ssh/config]]></title><description><![CDATA[10 SSH Config Tricks I Use Every Day]]></description><link>https://www.digitaldev.blog/mastering-ssh-config</link><guid isPermaLink="true">https://www.digitaldev.blog/mastering-ssh-config</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 18 Mar 2023 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/748fc965-48bf-42ea-adbc-15c0317410f9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <code>~/.ssh/config</code> file configures SSH settings for connecting to remote servers. It can be a powerful tool for customizing your SSH experience, allowing you to define shortcuts, set default options, and configure settings for individual hosts or all hosts.</p>
<p>Here is a tutorial on some of the most common options used in the <code>~/.ssh/config</code> file.</p>
<h2>Host</h2>
<p>The <code>Host</code> option defines one or more names or patterns that should match a host configuration. These are the names you use when running the <code>ssh</code> command. You can use custom aliases, fully qualified domain names, IP addresses, or wildcard patterns.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host production
    HostName prod.example.com
</code></pre>
<p>You can then connect using:</p>
<pre><code class="language-shell">ssh production
</code></pre>
<p>You can also use wildcard patterns:</p>
<pre><code class="language-sshconfig">Host *.example.com
    User myusername
</code></pre>
<p>Or configure settings that apply to all hosts:</p>
<pre><code class="language-sshconfig">Host *
    ServerAliveInterval 60
</code></pre>
<h2>HostName</h2>
<p>The <code>HostName</code> option specifies the actual hostname or IP address of the remote server. This is useful when you want to use a shorter or more memorable alias.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host gitlab
    HostName gitlab.company.com
</code></pre>
<p>This allows you to connect using:</p>
<pre><code class="language-shell">ssh gitlab
</code></pre>
<p>instead of:</p>
<pre><code class="language-shell">ssh gitlab.company.com
</code></pre>
<h2>User</h2>
<p>The <code>User</code> option specifies the username to use when connecting to the remote server.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host production
    HostName prod.example.com
    User deploy
</code></pre>
<p>This allows you to connect without specifying the username every time:</p>
<pre><code class="language-shell">ssh production
</code></pre>
<p>instead of:</p>
<pre><code class="language-shell">ssh deploy@prod.example.com
</code></pre>
<h2>IdentityFile</h2>
<p>The <code>IdentityFile</code> option specifies the private key to use when connecting to the remote server.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host production
    HostName prod.example.com
    User deploy
    IdentityFile ~/.ssh/id_ed25519_prod
    IdentitiesOnly yes
</code></pre>
<p>The <code>IdentitiesOnly</code> option ensures that SSH only uses the configured identity file and does not also try keys loaded in <code>ssh-agent</code> or other default key locations.</p>
<p>This allows you to connect using:</p>
<pre><code class="language-shell">ssh production
</code></pre>
<p>instead of:</p>
<pre><code class="language-shell">ssh -i ~/.ssh/id_ed25519_prod deploy@prod.example.com
</code></pre>
<h2>Port</h2>
<p>The <code>Port</code> option specifies the port number used when connecting to the remote server. By default, SSH uses port <code>22</code>, but some servers use a different port.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host production
    HostName prod.example.com
    User deploy
    Port 2222
</code></pre>
<p>You can now connect using:</p>
<pre><code class="language-shell">ssh production
</code></pre>
<p>instead of:</p>
<pre><code class="language-shell">ssh -p 2222 deploy@prod.example.com
</code></pre>
<h2>ProxyJump</h2>
<p>The <code>ProxyJump</code> option allows you to connect to a server through one or more intermediate SSH servers, often referred to as jump hosts or bastion hosts.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host bastion
    HostName bastion.example.com
    User jumpuser

Host production
    HostName prod.internal.example.com
    User deploy
    ProxyJump bastion
</code></pre>
<p>This allows you to connect directly to the internal server:</p>
<pre><code class="language-shell">ssh production
</code></pre>
<p>SSH will automatically establish the connection through the <code>bastion</code> host.</p>
<h2>ProxyCommand</h2>
<p>For more advanced networking scenarios, the <code>ProxyCommand</code> option allows you to specify a command that SSH should use to establish the underlying connection to the remote server.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host production
    HostName prod.internal.example.com
    User deploy
    ProxyCommand ssh -W %h:%p bastion
</code></pre>
<p>In this example, <code>%h</code> is replaced with the destination hostname and <code>%p</code> with the destination port.</p>
<p>In most situations, <code>ProxyJump</code> is easier to understand and maintain, but <code>ProxyCommand</code> remains useful for more advanced scenarios.</p>
<h2>ForwardAgent</h2>
<p>The <code>ForwardAgent</code> option allows your local SSH agent to be used on the remote server. This can be convenient when you need to SSH from one server to another without copying your private keys.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host bastion
    ForwardAgent yes
</code></pre>
<p>This allows you to do something like:</p>
<pre><code class="language-shell">ssh bastion
git clone git@gitlab.company.com:project/repository.git
</code></pre>
<p>without storing your private keys on the bastion host.</p>
<p>However, be careful when using agent forwarding. A compromised server may be able to use your forwarded agent while your session is active.</p>
<h2>ServerAliveInterval and ServerAliveCountMax</h2>
<p>These options help keep SSH connections alive and detect broken connections more quickly.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3
</code></pre>
<p>This configuration sends a keep-alive packet every 60 seconds. If three consecutive keep-alive packets fail, SSH will terminate the connection.</p>
<p>This is especially useful when working through unstable VPN connections or firewalls that aggressively close idle connections.</p>
<h2>ControlMaster, ControlPath and ControlPersist</h2>
<p>These options enable SSH connection multiplexing. Instead of creating a new TCP connection and authentication handshake every time, SSH can reuse an existing connection.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Host *
    ControlMaster auto
    ControlPath ~/.ssh/control-%C
    ControlPersist 10m
</code></pre>
<p>With this configuration, the first connection establishes a master session. Subsequent connections to the same host are nearly instantaneous.</p>
<p>For example:</p>
<pre><code class="language-shell">ssh production
scp file.txt production:/tmp
rsync files/ production:/opt/files
</code></pre>
<p>The <code>scp</code> and <code>rsync</code> commands can reuse the existing SSH connection, making them significantly faster.</p>
<h2>Include</h2>
<p>The <code>Include</code> option allows you to split your SSH configuration into multiple files. This is particularly useful if you manage many environments or want to separate personal and work-related configurations.</p>
<p>For example:</p>
<pre><code class="language-sshconfig">Include ~/.ssh/config.d/*.conf
</code></pre>
<p>You could then organize your configuration like this:</p>
<pre><code class="language-text">~/.ssh/
├── config
└── config.d/
    ├── work.conf
    ├── personal.conf
    ├── cloud.conf
    └── lab.conf
</code></pre>
<p>This makes your SSH configuration easier to maintain and allows you to share parts of it between systems.</p>
<h2>Complete Example</h2>
<p>A practical configuration might look like this:</p>
<pre><code class="language-sshconfig">Include ~/.ssh/config.d/*.conf

Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3
    ControlMaster auto
    ControlPath ~/.ssh/control-%C
    ControlPersist 10m

Host gitlab
    HostName gitlab.company.com
    User git
    IdentityFile ~/.ssh/id_ed25519_gitlab
    IdentitiesOnly yes

Host bastion
    HostName bastion.company.com
    User jumpuser
    ForwardAgent yes

Host production
    HostName prod.internal.company.com
    User deploy
    IdentityFile ~/.ssh/id_ed25519_prod
    IdentitiesOnly yes
    ProxyJump bastion
</code></pre>
<p>With this configuration, connecting to your servers becomes as simple as:</p>
<pre><code class="language-shell">ssh production
ssh gitlab
scp file.txt production:/tmp
</code></pre>
<p>The <code>~/.ssh/config</code> file supports many additional options, including local and remote port forwarding, dynamic SOCKS proxies, preferred authentication methods, and host key verification settings.</p>
<p>For a complete list of available options, consult the manual page:</p>
<pre><code class="language-shell">man ssh_config
</code></pre>
<p>Taking a little time to configure your <code>~/.ssh/config</code> file can significantly improve your productivity by reducing typing, avoiding mistakes, and making complex SSH setups much easier to manage.</p>
]]></content:encoded></item><item><title><![CDATA[What is Position-Independent Code (fPIC)?]]></title><description><![CDATA[fPIC stands for "Position-Independent Code" in the context of computer programming. It is a flag used when compiling code to create binary files that can…]]></description><link>https://www.digitaldev.blog/what-is-position-independent-code-fpic</link><guid isPermaLink="true">https://www.digitaldev.blog/what-is-position-independent-code-fpic</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sun, 12 Mar 2023 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/6e855517-bef9-4e14-8fd3-41a59746cdcf.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>fPIC stands for "Position-Independent Code" in the context of computer programming. It is a flag used when compiling code to create binary files that can be loaded and executed from any memory address in a computer's memory.</p>
<p>When code is compiled, it is typically linked to specific memory addresses that are hardcoded into the resulting binary file. This can cause issues when the binary file is loaded into a different memory location than intended. Position-independent code, however, is designed to be loaded into any memory location and still function correctly.</p>
<p>fPIC is often used in shared libraries, which are compiled separately and loaded dynamically at runtime by other programs. Shared libraries must be position-independent because they can be loaded into any memory location and function correctly regardless of where they are loaded in memory.</p>
<p>To enable fPIC when compiling code, you typically use a command-line option such as "-fPIC" when invoking the compiler. Microsoft Windows does not have this option.</p>
]]></content:encoded></item><item><title><![CDATA[How to Build a Linux Docker Container for Cross-Compiling C++ Code to macOS Mach-O 64-Bit]]></title><description><![CDATA[One way to build macOS-targeted binaries from a non-macOS environment is by using cross-compilation tools. This involves setting up a cross-compilation…]]></description><link>https://www.digitaldev.blog/how-to-build-a-linux-docker-container-for-cross-compiling-c-code-to-macos-mach-o-64-bit</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-build-a-linux-docker-container-for-cross-compiling-c-code-to-macos-mach-o-64-bit</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 11 Dec 2021 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/28fa89c4-0ff2-40d1-a122-f4edc73c34fd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<img src="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/f09e1291-dad0-42e1-9174-fb247a1fa916.png" alt="" style="display:block;margin:0 auto" />

<p>One way to build macOS-targeted binaries from a non-macOS environment is by using cross-compilation tools. This involves setting up a cross-compilation environment in a Linux-based Docker container to build 64-bit Mach-O binaries.</p>
<p><strong>osxcross</strong> is a cross-compiler for macOS. It enables you to compile for macOS on a Linux system. The setup involves:</p>
<ul>
<li><p>Acquiring the macOS SDK;</p>
</li>
<li><p>Building the <strong>osxcross</strong> toolchain with the macOS SDK;</p>
</li>
<li><p>Using the <strong>osxcross</strong> toolchain to compile your code into Mach-O binaries.</p>
</li>
</ul>
<p>However, there are legal and practical challenges:</p>
<ul>
<li><p><strong>Legal consideration</strong>: the macOS SDK is subject to Apple's licensing terms. Acquiring and using the SDK on non-Apple hardware might violate these terms.</p>
</li>
<li><p><strong>Complexity</strong>: setting up <strong>osxcross</strong> in a Docker container can be quite complex and may require significant manual configuration and maintenance.</p>
</li>
</ul>
<p>Creating a Docker container that can cross-compile to produce macOS-compatible Mach-O executables is very unusual and technically challenging. The primary reason for this complexity is that macOS uses a different executable format (Mach-O) and generally different libraries than those used by Linux, which Docker containers typically run on.</p>
<p>However, I can guide you through a theoretical approach using <strong>osxcross</strong>, a popular tool for cross-compiling to macOS from a Linux environment. Please be aware that this is an advanced, experimental setup that may require significant adjustments to work in your specific use case.</p>
<h2>Step 1 - Setting up the Dockerfile</h2>
<p>You'll start by creating a Dockerfile that sets up <strong>osxcross</strong>. This process involves downloading the macOS SDK and using it to build the cross-compilation toolchain. The example below assumes you want to compile for macOS Sonoma. This can be derived from the version number in the macOS SDK, which in this case is 14.0.</p>
<pre><code class="language-dockerfile">FROM ubuntu:latest

# Install dependencies
RUN apt-get update &amp;&amp; apt-get install -y \ clang \    llvm \    libxml2-dev \    uuid-dev \    libssl-dev \    bash \    make \    tar \    xz-utils \    bzip2 \    gzip \    sed \    cpio \    patch \    liblzma-dev \    libbz2-dev \    autoconf \    automake \    libtool \    cmake \    git \    python3 \    zlib1g-dev

# Set up the working directory
WORKDIR /osxcross

# Clone the osxcross repository
RUN git clone https://github.com/tpoechtrager/osxcross.git .

# NOTE: You need to provide the macOS SDK tarball, which must be obtained from Apple.

# Make sure you comply with Apple's licensing agreements.
COPY   MacOSX14.0.sdk.tar.xz /osxcross/tarballs/

# Build osxcross
RUN UNATTENDED=1 OSX_VERSION_MIN=14.0 ./build.sh

# Add osxcross to the PATHENV 
PATH="/osxcross/target/bin:${PATH}"
</code></pre>
<p>In this Dockerfile:</p>
<ul>
<li><p>We're using an Ubuntu-based image and installing dependencies required for <strong>osxcross</strong>.</p>
</li>
<li><p>We assume you have a legally obtained <strong>MacOSX14.0.sdk.tar.xz</strong> (or another version) from Apple and have added it to the Docker build context.</p>
</li>
<li><p>The <strong>git clone</strong> command clones the <strong>osxcross</strong> repository into <strong>/osxcross</strong>.</p>
</li>
<li><p>The macOS SDK tarball is copied into the <strong>tarballs</strong> directory within the cloned <strong>osxcross</strong> repository.</p>
</li>
<li><p>The <a href="http://build.sh"><strong>build.sh</strong></a> script is then executed in the <strong>/osxcross</strong> folder to build <strong>osxcross</strong> to set up the cross-compilation toolchain.</p>
</li>
</ul>
<h2>Step 2 - Build the Docker Image</h2>
<p>Build the Docker image using:</p>
<pre><code class="language-shell">docker build -t mac-cross-compiler .
</code></pre>
<h2>Step 3 - Cross-compiling your application</h2>
<p>With this Docker image, you can now attempt to cross-compile your application. Mount your source code into the Docker container and use the <strong>osxcross</strong> toolchain to build your application.</p>
<pre><code class="language-shell">docker run -it --rm -v /path/to/your/source:/source mac-cross-compiler
</code></pre>
<p>Inside the container, navigate to the mounted source directory and compile using the macOS toolchain (e.g., <strong>o64-clang++</strong> or <strong>o64-clang)</strong> for C++ and C projects, respectively.</p>
<h2>Important Considerations</h2>
<ol>
<li><p><strong>Legal Compliance</strong>: Ensure that you comply with Apple's licensing terms when obtaining and using the macOS SDK.</p>
</li>
<li><p><strong>Complexity and Limitations</strong>: This setup might not support all features or libraries available in a native macOS environment. It's primarily suitable for simpler applications.</p>
</li>
<li><p><strong>Testing</strong>: Extensive testing on actual macOS hardware is essential to ensure the compatibility and functionality of your cross-compiled application.</p>
</li>
<li><p><strong>Updates and Maintenance</strong>: The <strong>osxcross</strong> project and macOS SDKs get updated, so this process may need adjustments over time to stay current.</p>
</li>
</ol>
<p>This guide provides a high-level overview of the process. Still, due to the complexity and potential variability in requirements, you may need to make additional modifications to suit your specific project.</p>
<h2>Running the container with volume mounting</h2>
<p>Run the Docker container and mount your local code directory into it. Replace <strong>/path/to/your/source</strong> with the actual path to your source code on your host machine.</p>
<p>For C or C++ projects, it might look something like this:</p>
<pre><code class="language-shell">o64-clang++ -o myapp source_file.cpp
</code></pre>
<p>or</p>
<pre><code class="language-shell">o64-clang -o myapp source_file.c
</code></pre>
<h2>Accessing the compiled binary</h2>
<p>After compilation, the binary (myapp in the example) will be available in the /source directory inside the container, which is mapped to your local code directory. You can then run this binary on a macOS system to test it.</p>
<h2>Demo</h2>
<p><a class="embed-card" href="https://youtu.be/w3aaln35ehk">https://youtu.be/w3aaln35ehk</a></p>

<h3>References</h3>
<ul>
<li><p><a href="https://github.com/joseluisq/macosx-sdks">https://github.com/joseluisq/macosx-sdks</a></p>
</li>
<li><p><a href="https://github.com/tpoechtrager/osxcross">https://github.com/tpoechtrager/osxcross</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to install Git on macOS]]></title><description><![CDATA[There are several ways to install Git on macOS. To write this tutorial, I am using an iMac with macOS Catalina. On a fresh installation, macOS tells you…]]></description><link>https://www.digitaldev.blog/how-to-install-git-on-macos</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-install-git-on-macos</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 11 Dec 2021 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/c8c0074a-10f4-4380-b3fa-041795e45df4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There are several ways to install Git on macOS. To write this tutorial, I am using an iMac with macOS Catalina. On a fresh installation, macOS tells you that '<em>no developer tools were found requesting install.</em>' If you already have Xcode installed, you won't get this request. In that case, you probably already have an older version of Git installed.</p>
<p>There are six ways to install Git on macOS:</p>
<ol>
<li><p>Use the version that Apple ships with Xcode, typically an older Git release.</p>
</li>
<li><p>Use the git-osx-installer from Tim Harper, a slightly newer version of Git, but not the latest.</p>
</li>
<li><p>Use Homebrew to install Git to get the latest stable version.</p>
</li>
<li><p>Use MacPorts to install the latest stable version of Git.</p>
</li>
<li><p>Get the tarball from <a href="https://mirrors.edge.kernel.org/pub/software/scm/git/">kernel.org</a>, compile it, and manually install Git yourself.</p>
</li>
<li><p>Get the source code from GitHub using an already installed version of Git. This will allow you to compile and install the bleeding-edge version of Git.</p>
</li>
</ol>
<p><strong>Option (1)</strong> is the fastest way to get started and is the scope of this tutorial.</p>
<p><strong>Option (2)</strong> is not something I used because it also gets you a slightly older version of Git, and it looks to me like this project has quite a few open issues.</p>
<p><strong>Options (3) and (4)</strong> are probably the most common ways for developers to install the latest stable version of Git. I'll cover option 3 in a follow-up post. Stay tuned.</p>
<p><strong>Options (5) and (6)</strong> allow you to manually compile the code of Git and perform a manual installation. These options are a bit more hardcore and unnecessary for most developers, unless you are interested in studying the code or contributing to Git. Both options also require installing additional tools on your development system. Note that you can find Git on GitHub, but this project does not accept Pull Requests, unlike most open-source projects. Instead, you need to submit your contributions as patches to the Git mailing list for review. The Git maintainer manually applies your patch if accepted.</p>
<h2>How to install Git as shipped by Apple</h2>
<ul>
<li><p>Step 1 - Open the Terminal app.</p>
</li>
<li><p>Step 2 - Enter the following on the command line.</p>
</li>
</ul>
<pre><code class="language-shell">$ git
</code></pre>
<p>The video below shows what to expect for a fresh installation.</p>
<p><a class="embed-card" href="https://youtu.be/PUWHGnP15GU">https://youtu.be/PUWHGnP15GU</a></p>

<h2>How to check your Git installation</h2>
<p>You can figure out which installation of Git you have by finding its installation folder. You can do that using the <strong>which</strong> command in your Terminal.</p>
<pre><code class="language-shell">$ which git
</code></pre>
<p>The Apple-provided installation returns:</p>
<pre><code class="language-shell">/usr/bin/git
</code></pre>
<p>A user-installed version most likely returns:</p>
<pre><code class="language-shell">/usr/local/git
</code></pre>
<p>You can check the version of Git by typing:</p>
<pre><code class="language-shell">$ git --version
</code></pre>
<p>The response should look something like the following:</p>
<pre><code class="language-shell">git version 2.24.3 (Apple Git-128)
</code></pre>
<p>If your version came with the Xcode installation, it is most likely an older version of Git, as shown in the response above.</p>
]]></content:encoded></item><item><title><![CDATA[How to uninstall macOS Command Line Tools]]></title><description><![CDATA[This tutorial assumes you have the macOS command-line tools installed on your system. I tested the tutorial on a macOS Catalina installation. Removing the…]]></description><link>https://www.digitaldev.blog/how-to-uninstall-macos-command-line-tools</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-uninstall-macos-command-line-tools</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Sat, 11 Dec 2021 08:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/2d270209-92bb-4f64-b582-e464fa375bfb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This tutorial assumes you have the macOS command-line tools installed on your system. I tested the tutorial on a macOS Catalina installation.</p>
<p>Removing the Command Line Tools from your Mac is pretty simple. Just type the following command on the command line:</p>
<pre><code class="language-shell">$ rm -fR /Library/Developer/CommandLineTools/
</code></pre>
<p><em><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Warning: </mark></strong></em> <mark class="bg-yellow-200 dark:bg-yellow-500/30">Be careful with this command. </mark> <strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">rm -fR</mark></strong> <mark class="bg-yellow-200 dark:bg-yellow-500/30">is a forced and recursive removal of the path you enter. If you make a typo, you may regret removing something else. Because this is a forced removal, there is no way to recover the removed files.</mark></p>
<h2>How to verify the removal of the macOS Xcode Command Line Tools from your system</h2>
<p>If you are not sure this was successful, you can check this by opening your Terminal app and typing the following on your command line:</p>
<pre><code class="language-shell">$ sudo xcode-select -p
</code></pre>
<p><strong>Note</strong>: the <em><strong>sudo</strong></em> command means executing the <em><strong>xcode-select</strong></em> command as the admin/root user. This command asks you for your system's admin/root password.</p>
<p>The following error message indicates you do not have the command-line tools installed:</p>
<pre><code class="language-shell">xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)
</code></pre>
<p>Removing the command-line tools failed when you get the following response after confirming with the correct admin/root password.</p>
<pre><code class="language-shell">/Library/Developer/CommandLineTools
</code></pre>
<p>Another way to check if the command-line tools installation is by directly invoking one of the commands, e.g., <strong>git</strong>, in the following way:</p>
<pre><code class="language-shell">$ /Library/Developer/CommandLineTools/usr/bin/git --version
</code></pre>
<p>This command directly invokes the git version packaged with Apple's command-line tools. This command does not require locating <strong>git</strong> in your system's $PATH. The command-line tools were successfully removed from your system when this command returns something like the following:</p>
<pre><code class="language-plaintext">zsh: no such file or directory: /Library/Developer/CommandLineTools/usr/bin/git
</code></pre>
<p>When it returns something like the following, you did not successfully remove the command-line tools:</p>
<pre><code class="language-shell">git version 2.24.3 (Apple Git-128)
</code></pre>
<h2>How to reinstall the command-line tools</h2>
<p>If you regret removing the command-line tools or if you need them again, you can reinstall them with the following commands:</p>
<pre><code class="language-shell">$ xcode-select --install
</code></pre>
<p>You get the following pop-up. Click Install, then confirm to accept the terms and conditions. The installation takes a few minutes to complete.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/7bb9e39d-791e-4421-a05a-950baad29833.png" alt="" style="display:block;margin:0 auto" />

<p>Next, type the following command to reset the default command-line tool path.</p>
<pre><code class="language-shell">$ sudo xcode-select --reset
</code></pre>
<p>That should do the trick. You can use the tests above to verify that you installed the command-line tools correctly again.</p>
]]></content:encoded></item><item><title><![CDATA[How to give your zsh shell a productivity boost on macOS]]></title><description><![CDATA[In this little tutorial, I will show you how to give your zsh a significant productivity boost as a developer. There are four simple steps involved in this…]]></description><link>https://www.digitaldev.blog/how-to-give-your-zsh-shell-a-productivity-boost-on-macos</link><guid isPermaLink="true">https://www.digitaldev.blog/how-to-give-your-zsh-shell-a-productivity-boost-on-macos</guid><dc:creator><![CDATA[Digital Dev Blog]]></dc:creator><pubDate>Fri, 08 Jan 2021 09:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/c4ed8409-0f2c-4fad-8053-adc66a84b3ee.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this little tutorial, I will show you how to give your zsh a significant productivity boost as a developer. There are four simple steps involved in this process.</p>
<p><strong>Step 1</strong> - Make configuring your zsh easier by installing Zim. An alternative often used zsh configuration tool is Oh My Zsh, but this tutorial does not cover that framework.</p>
<p><strong>Step 2</strong> - Install a few open-source fonts that improve the readability of your zsh.</p>
<p><strong>Step 3</strong> - Add a little flavor to your zsh by installing Spaceship.</p>
<p><strong>Step 4</strong> - Tune Spaceship and Zim to your liking.</p>
<p>These steps will make your prompt configurable to show a lot of extra information and add many shortcut commands that help you speed up during development. Let's look at how to take all the necessary steps.</p>
<h2>Step 1 - Install Zim</h2>
<p>The first step in our process is to install Zim.</p>
<p><strong>Step 1A</strong> - Go to <a href="https://zimfw.sh.">https://zimfw.sh</a>.</p>
<p><strong>Step 1B</strong> - Download the Zim installation script and execute it like this:</p>
<pre><code class="language-shell">$ curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
</code></pre>
<p><strong>Curl</strong> is available by default on macOS, so there's no need to worry about additional installation steps. This command downloads the install script using curl and makes it the input for the zsh shell. The <strong>|</strong> (pipe) symbol takes the output from one command and uses it as the input for the following command.</p>
<h2>Step 2 - Install Powerline fonts</h2>
<p>The Powerline font sets are needed to handle a few special characters that Spaceship uses, e.g., to indicate that you are looking at a folder with git active.</p>
<p><strong>Step 2A</strong> - To install these fonts, clone the fonts from GitHub to a convenient folder. Once you've installed them, you can also remove the folder again.</p>
<pre><code class="language-shell">$ git clone https://github.com/powerline/fonts.git
</code></pre>
<p>Executing this command creates a <em>fonts</em> folder.</p>
<p><strong>Step 2B</strong> - Next, change into the <em>fonts</em> folder and run the following command:</p>
<pre><code class="language-shell">$ ./install.sh 
</code></pre>
<p>Executing this command installs a long list of fonts that support the characters used in programming languages such as Rust, Python, Dotnet, Java, Git, AWS, etc. Here is an example of changing into a folder under git version control with Rust code.</p>
<p>You have to change your Terminal configuration to use one of these fonts. You can do so by pressing <strong>⌘-comma</strong>. That command opens the Terminal configuration and looks like this. Change the font to one of the Powerline fonts. The picture below shows that I used Anonumice Powerline with font size 18.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/2c216e7f-a204-4d5a-97da-c318563c0698.png" alt="" style="display:block;margin:0 auto" />

<p>Now that we have configured our Terminal to use one of the Powerline fonts, we are ready to install Spaceship.</p>
<h2>Step 3 - Install Spaceship</h2>
<p><strong>Step 3A</strong> - Go to <a href="https://spaceship-prompt.sh">https://spaceship-prompt.sh</a>. This step created a file called .zimrc in your home folder. You can check this as follows:</p>
<pre><code class="language-shell">$ cat ~/.zimrc
</code></pre>
<p><strong>Step 3B</strong> - Add the following line to the .zimrc file you just created.</p>
<pre><code class="language-shell">$ echo "zmodule spaceship-prompt/spaceship-prompt --name spaceship" &gt;&gt; ~/.zimrc
</code></pre>
<p><strong>Step 3C</strong> - Run zimfw install.</p>
<pre><code class="language-shell">$ zimfw install
</code></pre>
<p>The output of running this command looks like this when successful:</p>
<pre><code class="language-shell">~
➜ Done with install. Restart your terminal for any changes to take effect.
</code></pre>
<p>Your prompt will look as follows after you restart:</p>
<pre><code class="language-shell">~
% 
</code></pre>
<p><strong>Step 3D</strong> - Terminate your Terminal, then restart to apply the above changes. You should already see a changed prompt after you continue.</p>
<h2>Step 4 - Configure and tune Spaceship.</h2>
<p>Now you are ready to configure and tune Spaceship to your liking.</p>
<p><strong>Step 4A</strong> - Tune-up Spaceship. Add the following at the end of your <strong>.zshrc</strong>. I recommend putting a <strong>#</strong> in front of every line of tools you don't use. Removing unnecessary modules improves your shell's performance.</p>
<pre><code class="language-plaintext">SPACESHIP_PROMPT_ORDER=(
  time          # Time stamps section
  user          # Username section
  dir           # Current directory section
  host          # Hostname section
  git           # Git section (git_branch + git_status)
  hg            # Mercurial section (hg_branch  + hg_status)
  package       # Package version
  gradle        # Gradle section
  maven         # Maven section
  node          # Node.js section
  ruby          # Ruby section
  elixir        # Elixir section
  xcode         # Xcode section
  swift         # Swift section
  golang        # Go section
  php           # PHP section
  rust          # Rust section
  haskell       # Haskell Stack section
  julia         # Julia section
  docker        # Docker section
  aws           # Amazon Web Services section
  gcloud        # Google Cloud Platform section
  venv          # virtualenv section
  conda         # conda virtualenv section
  python        # Python section
  dotnet        # .NET section
  ember         # Ember.js section
  kubectl       # Kubectl context section
  terraform     # Terraform workspace section
  ibmcloud      # IBM Cloud section
  exec_time     # Execution time
  line_sep      # Line break
  battery       # Battery level and status
  jobs          # Background jobs indicator
  exit_code     # Exit code section
  char          # Prompt character
)
</code></pre>
<p><em>* Updated March 12, 2023 - In previous versions of Spaceship, there was a vi_mode, which has been removed, but can still be installed by following</em> <a href="https://github.com/spaceship-prompt/spaceship-vi-mode"><em>these instructions</em></a><em>, and there was a pyenv section, which is replaced by a python section.</em></p>
<p><strong>Step 4B</strong> - Some more tuning and learning about shortcuts.</p>
<p>Both SpaceShip and Zim provide you with many options for customization and commands.</p>
<ul>
<li><p>Please have a look <a href="https://spaceship-prompt.sh/options/">here</a> for further tuning of your Spaceship configuration.</p>
</li>
<li><p>And please have a look at <a href="https://zimfw.sh/docs/cheatsheet/">this</a> cheat sheet from Zim to learn about the shortcut commands it provides.</p>
</li>
</ul>
<p>I always do one tune-up to put the zsh key bindings into Vim mode. You can do that by editing the .zshrc file and looking for the following lines. By default, the Zim installation will put the key mapping to Emacs, as you can see below. Replace <strong>-v</strong> with <strong>-e</strong> to switch to Vim mode.</p>
<pre><code class="language-shell"># Set editor default keymap to emacs (`-e`) or vi (`-v`)
bindkey -v
</code></pre>
<p>Changing the key binding to vim also changes your prompt to look like this:</p>
<pre><code class="language-shell">~ 
[I] ➜ 
</code></pre>
<p>The <strong>[I]</strong> means you are in insert mode. You can exit insert mode and switch to normal mode by pressing ESC to notice the difference. Pressing ESC also changes your prompt to look like this:</p>
<pre><code class="language-shell">~ 
[N] ➜ 
</code></pre>
<p>And you will immediately see the difference.</p>
<p>The picture below shows all of the steps we took into effect. It shows that I am in the folder <em>guessing_game</em> on the <em>master branch,</em> that there are no staged files, that the folder contains Rust code, and that I am using Rust version v1.57.0.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a5f4a722e470c360a3c5268/c10340ef-3fd2-4d92-b6d1-fb6b0f169528.png" alt="" style="display:block;margin:0 auto" />

<p>Isn't that neat?</p>
<hr />
<p>That's it. I hope you enjoy this tutorial. Feel free to drop me a line if you have any questions. Happy to help out where I can.</p>
]]></content:encoded></item></channel></rss>