<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Omer Wazir</title>
    <subtitle>Notes on code, photography, and whatever else.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://notes.omerwazir.com/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://notes.omerwazir.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-08-14T00:00:00+00:00</updated>
    <id>https://notes.omerwazir.com/atom.xml</id>
    <entry xml:lang="en">
        <title>Rust Ownership Exercises</title>
        <published>2026-08-14T00:00:00+00:00</published>
        <updated>2026-08-14T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/rust-ownership-exercises/"/>
        <id>https://notes.omerwazir.com/posts/rust-ownership-exercises/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/rust-ownership-exercises/">&lt;p&gt;I asked Claude to spin up 12 examples of ownership for me to read through and figure out if they&#39;d work or not. I added notes on what the problems were.&lt;/p&gt;
&lt;h1 id=&quot;ownership-borrowing-exercises&quot;&gt;Ownership &amp;amp; Borrowing Exercises&lt;/h1&gt;
&lt;p&gt;For each example, decide: &lt;strong&gt;does this compile?&lt;/strong&gt; If not, figure out &lt;em&gt;why&lt;/em&gt; (which rule it violates) before checking with &lt;code&gt;rustc&lt;/code&gt; or the playground.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-1&quot;&gt;Example 1&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s1&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s2&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span&gt; s1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This won&#39;t work because &lt;code&gt;String&lt;/code&gt; doesn&#39;t implement &lt;code&gt;Copy&lt;/code&gt;, so &lt;code&gt;let s2 = s1;&lt;/code&gt; moves ownership from &lt;code&gt;s1&lt;/code&gt; to &lt;code&gt;s2&lt;/code&gt; instead of copying it. If you need a read-only borrow of &lt;code&gt;s1&lt;/code&gt; in &lt;code&gt;s2&lt;/code&gt; instead, use &lt;code&gt;&amp;amp;&lt;/code&gt;, like &lt;code&gt;let s2 = &amp;amp;s1&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-2&quot;&gt;Example 2&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; x&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; y&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span&gt; x&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{} {}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; x&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; y&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works because &lt;code&gt;x&lt;/code&gt; is a primitive type, so it is copied by value.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-3&quot;&gt;Example 3&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; takes_ownership&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    takes_ownership&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;String&lt;/code&gt; doesn&#39;t implement &lt;code&gt;Copy&lt;/code&gt;, and &lt;code&gt;takes_ownership&lt;/code&gt; takes its parameter by value (&lt;code&gt;s: String&lt;/code&gt;), so calling &lt;code&gt;takes_ownership(s)&lt;/code&gt; moves ownership of &lt;code&gt;s&lt;/code&gt; into the function, then &lt;code&gt;s&lt;/code&gt; is no longer valid back in &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To avoid the move, borrow instead so change the param to &lt;code&gt;s: &amp;amp;str&lt;/code&gt; and call &lt;code&gt;takes_ownership(&amp;amp;s)&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-4&quot;&gt;Example 4&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; borrows&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    borrows&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works because a reference is used.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-5&quot;&gt;Example 5&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r1&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r2&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{} {}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r2&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since the reference for &lt;code&gt;r1&lt;/code&gt; is immutable and &lt;code&gt;r2&lt;/code&gt; is immutable this is ok, but just remove the &lt;code&gt;mut&lt;/code&gt; from &lt;code&gt;s&lt;/code&gt; since no mutations are happening.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-6&quot;&gt;Example 6&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r1&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r2&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{} {}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r2&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the difference is one immutable reference is live in r1 and a mutable reference is live in r2, and can&#39;t have the mutable and immutable borrows alive at the same time.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-7&quot;&gt;Example 7&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r1&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r2&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    r2&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;push_str&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot; world&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r2&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is ok, the immutable reference is dropped before the mutable reference is alive.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-8&quot;&gt;Example 8&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; dangle&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; -&amp;gt; &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;    &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; r&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; dangle&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; r&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;dangle&lt;/code&gt; creates &lt;code&gt;s&lt;/code&gt; and returns a reference to it, but &lt;code&gt;s&lt;/code&gt; goes out of scope and is dropped when the function returns, so the reference would be dangling. Rust rejects this at compile time — with &lt;code&gt;fn dangle() -&amp;gt; &amp;amp;String&lt;/code&gt;, there&#39;s no way to know what the returned reference would be borrowed from, so the compiler actually errors with &lt;code&gt;missing lifetime specifier&lt;/code&gt; before it even gets to check whether the reference would dangle.&lt;/p&gt;
&lt;p&gt;The way to fix this is to not return a reference &lt;code&gt;&amp;amp;String&lt;/code&gt; and return the owned &lt;code&gt;String&lt;/code&gt; instead, so return &lt;code&gt;s&lt;/code&gt; and change the function signature to &lt;code&gt;fn dangle() -&amp;gt; String&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-9&quot;&gt;Example 9&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let mut&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Vec&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;i32&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; vec!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; first&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span&gt;v&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    v&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;push&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; first&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;first&lt;/code&gt; holds an immutable reference to the first element of &lt;code&gt;v&lt;/code&gt;, and &lt;code&gt;v.push(4)&lt;/code&gt; needs a mutable borrow of &lt;code&gt;v&lt;/code&gt; while &lt;code&gt;first&lt;/code&gt; is still alive, which is an aliasing/mutability violation, the same rule as seen in Example 6. If &lt;code&gt;first&lt;/code&gt; were last used before the &lt;code&gt;push&lt;/code&gt; (or even created after it), this would be fine.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-10&quot;&gt;Example 10&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello world&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; word&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; = &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; word&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Same aliasing/mutability violation as Example 9, &lt;code&gt;word&lt;/code&gt; is an immutable borrow of &lt;code&gt;s&lt;/code&gt; and &lt;code&gt;s.clear()&lt;/code&gt; needs a mutable borrow of &lt;code&gt;s&lt;/code&gt; while &lt;code&gt;word&lt;/code&gt; is still alive.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-11&quot;&gt;Example 11&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s1&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; s2&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span&gt; s1&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;clone&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{} {}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s1&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; s2&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is ok.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;example-12&quot;&gt;Example 12&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; first_word&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #EBA0AC;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;: &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; -&amp;gt; &amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; bytes&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;as_bytes&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    for&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;..&lt;/span&gt;&lt;span&gt;bytes&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;        if&lt;/span&gt;&lt;span&gt; bytes&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;&amp;#39; &amp;#39; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #FAB387;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;..&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;    &amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let mut&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;hello world&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;    let&lt;/span&gt;&lt;span&gt; word&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; first_word&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    s&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;push_str&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    println!&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #A6E3A1;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; word&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is ok up until &lt;code&gt;s.push_str(&quot;!&quot;)&lt;/code&gt;, which needs a mutable borrow of &lt;code&gt;s&lt;/code&gt; while &lt;code&gt;word&lt;/code&gt; (an immutable borrow of &lt;code&gt;s&lt;/code&gt;) is still alive and used later in the &lt;code&gt;println!&lt;/code&gt;, aliasing/mutability violation, same as Examples 6, 9, and 10.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>14 days of Rust</title>
        <published>2026-08-11T00:00:00+00:00</published>
        <updated>2026-08-11T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/14-days-of-rust/"/>
        <id>https://notes.omerwazir.com/posts/14-days-of-rust/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/14-days-of-rust/">&lt;p&gt;9 years 4 months 6 days since last time I wrote a post, a lot has happened in between but right now I&#39;m writing Rust so that will be the focus for a while.&lt;/p&gt;
&lt;p&gt;I told Claude I was coming from zero and wanted to be able to write CLI, TUI and a simple Markdown → HTML formatter by the end. I like to use Exercism to give me hands on experience, and I&#39;m using the &lt;a rel=&quot;external&quot; href=&quot;https://rust-book.cs.brown.edu&quot;&gt;Rust-Book from Brown&lt;/a&gt; after I watched this &lt;a rel=&quot;external&quot; href=&quot;https://youtu.be/R0dP-QR5wQo&quot;&gt;Will Crichton: Rust for Everyone!&lt;/a&gt;. Specifically seeing the &lt;a rel=&quot;external&quot; href=&quot;https://cel.cs.brown.edu/aquascope/&quot;&gt;Aquascope Playground&lt;/a&gt; explain borrow checking was cool.&lt;/p&gt;
&lt;p&gt;The following is Claude&#39;s plan for 14 days of Rust, you can tell right away it&#39;s Claude. I wonder in a few years if it will &lt;em&gt;sound&lt;/em&gt; different. Some formatting had to be fixed
to render correctly here, but nothing about the content was changed.&lt;/p&gt;
&lt;h2 id=&quot;14-days-of-rust-from-zero-to-a-working-ssg&quot;&gt;14 Days of Rust — from zero to a working SSG&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Start:&lt;/strong&gt; Tue 11 Aug 2026&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;End:&lt;/strong&gt; Mon 24 Aug 2026 (14 consecutive days)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Budget:&lt;/strong&gt; ~2 hours/day&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tools:&lt;/strong&gt; RustRover, Exercism Rust track, The Rust Book&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-deal&quot;&gt;The deal&lt;/h2&gt;
&lt;p&gt;One project, three faces. You build a &lt;strong&gt;static site generator&lt;/strong&gt; as a single crate:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Piece&lt;/th&gt;&lt;th&gt;What it is&lt;/th&gt;&lt;th&gt;Days&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;lib.rs&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Markdown → HTML parser + site model&lt;/td&gt;&lt;td&gt;8–10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;src/main.rs&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;ssg build&lt;/code&gt; / &lt;code&gt;ssg new&lt;/code&gt; CLI&lt;/td&gt;&lt;td&gt;7, 13&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;src/bin/tui.rs&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Browse pages, live-preview the render&lt;/td&gt;&lt;td&gt;11–12&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Everything before Day 7 is loading the magazine. Days 7–14 are the project.&lt;/p&gt;
&lt;h2 id=&quot;daily-shape-2h&quot;&gt;Daily shape (~2h)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Week 1&lt;/strong&gt; — ~40 min read + type along · ~40 min Exercism · ~40 min consolidating.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Week 2&lt;/strong&gt; — ~30 min reading · ~90 min project. Exercism is optional and marked as such.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Two rules that don&#39;t change:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Type the code, don&#39;t paste it.&lt;/strong&gt; Typing is where the borrow checker teaches you.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;After each Exercism exercise, read 2–3 community solutions for it.&lt;/strong&gt; Single highest-leverage habit on the list.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Rust Book chapter &lt;em&gt;numbers&lt;/em&gt; shifted in the 2024 edition. Titles are stable — go by title if a number looks off.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-0-before-you-start-15-min-today&quot;&gt;Day 0 — before you start (15 min, today)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
&lt;code&gt;rustup update &amp;amp;&amp;amp; rustup component add clippy rustfmt rust-analyzer&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
&lt;code&gt;rustup doc --book&lt;/code&gt; — offline copy of the Book&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Install the Exercism CLI, &lt;code&gt;exercism configure --token=...&lt;/code&gt;, join the &lt;strong&gt;Rust track&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
In RustRover: enable &lt;strong&gt;Clippy&lt;/strong&gt; as the external linter (Settings → Rust → External Linters → Clippy, tick &quot;Run on save&quot;)&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Turn on &lt;strong&gt;Rustfmt on save&lt;/strong&gt; (Settings → Rust → Rustfmt)&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
&lt;code&gt;git init&lt;/code&gt; is already done — commit at the end of every single day, even broken code&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h1 id=&quot;week-1-the-language&quot;&gt;Week 1 — the language&lt;/h1&gt;
&lt;h2 id=&quot;day-1-tue-11-aug-cargo-syntax-the-shape-of-a-program&quot;&gt;Day 1 (Tue 11 Aug) — Cargo, syntax, the shape of a program&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 1–3 (Getting Started, Guessing Game, Common Programming Concepts)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Type out the guessing game by hand, end to end. Run it.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Know cold: &lt;code&gt;cargo new&lt;/code&gt;, &lt;code&gt;run&lt;/code&gt;, &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;test&lt;/code&gt;, &lt;code&gt;check&lt;/code&gt;, &lt;code&gt;clippy&lt;/code&gt;, &lt;code&gt;fmt&lt;/code&gt;, &lt;code&gt;add&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
&lt;code&gt;cargo check&lt;/code&gt; is your fast loop — bind it to a shortcut in RustRover&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Variables vs. mutability, shadowing, scalar/compound types, &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;loop&lt;/code&gt;/&lt;code&gt;while&lt;/code&gt;/&lt;code&gt;for&lt;/code&gt;, functions &amp;amp; expression-vs-statement&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism:&lt;/strong&gt; &lt;code&gt;hello-world&lt;/code&gt;, &lt;code&gt;two-fer&lt;/code&gt;, &lt;code&gt;reverse-string&lt;/code&gt;, &lt;code&gt;gigasecond&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Read the community solutions for &lt;code&gt;reverse-string&lt;/code&gt; — note the &lt;code&gt;.chars().rev()&lt;/code&gt; vs. bytes distinction. That&#39;s a UTF-8 lesson you&#39;ll need on Day 9.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; you can explain why &lt;code&gt;let x = 5; x = 6;&lt;/code&gt; fails and &lt;code&gt;let x = 5; let x = 6;&lt;/code&gt; doesn&#39;t.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-2-wed-12-aug-ownership-borrowing-slices&quot;&gt;Day 2 (Wed 12 Aug) — Ownership, borrowing, slices&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 4 (Understanding Ownership) — &lt;em&gt;slowly&lt;/em&gt;. This is the chapter.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Move vs. copy vs. clone&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
&lt;code&gt;&amp;amp;T&lt;/code&gt; vs. &lt;code&gt;&amp;amp;mut T&lt;/code&gt;; the &quot;one mutable XOR many immutable&quot; rule&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
&lt;code&gt;String&lt;/code&gt; vs. &lt;code&gt;&amp;amp;str&lt;/code&gt;, and why &lt;code&gt;&amp;amp;str&lt;/code&gt; is the right function parameter&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Deliberately write 3 programs that &lt;em&gt;fail&lt;/em&gt; to compile, and read each error out loud&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism:&lt;/strong&gt; &lt;code&gt;raindrops&lt;/code&gt;, &lt;code&gt;acronym&lt;/code&gt;, &lt;code&gt;pangram&lt;/code&gt;, &lt;code&gt;scrabble-score&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;/&gt;
Force yourself to take &lt;code&gt;&amp;amp;str&lt;/code&gt; and return &lt;code&gt;String&lt;/code&gt; where appropriate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; you can say what &lt;code&gt;fn longest(a: &amp;amp;str, b: &amp;amp;str) -&amp;gt; &amp;amp;str&lt;/code&gt; is missing without looking it up. (You&#39;ll fix it on Day 6.)&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-3-thu-13-aug-structs-enums-pattern-matching&quot;&gt;Day 3 (Thu 13 Aug) — Structs, enums, pattern matching&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 5–6 (Structs, Enums and Pattern Matching)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;impl&lt;/code&gt; blocks, associated functions vs. methods, &lt;code&gt;Self&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;#[derive(Debug, Clone, PartialEq)]&lt;/code&gt; and when each matters&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Option&amp;lt;T&amp;gt;&lt;/code&gt;, &lt;code&gt;match&lt;/code&gt; exhaustiveness, &lt;code&gt;if let&lt;/code&gt; / &lt;code&gt;let else&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Sketch (don&#39;t build) an enum for a markdown block: &lt;code&gt;Heading&lt;/code&gt;, &lt;code&gt;Paragraph&lt;/code&gt;, &lt;code&gt;CodeBlock&lt;/code&gt;, &lt;code&gt;Rule&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism:&lt;/strong&gt; &lt;code&gt;space-age&lt;/code&gt;, &lt;code&gt;high-scores&lt;/code&gt;, &lt;code&gt;allergies&lt;/code&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Nothing here needs a hand-written trait impl yet — traits are Day 6, and &lt;code&gt;clock&lt;/code&gt; waits until then.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; &lt;code&gt;match&lt;/code&gt; on an enum feels better than a chain of &lt;code&gt;if&lt;/code&gt;s. Keep that enum sketch; it becomes &lt;code&gt;Block&lt;/code&gt; on Day 8.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-4-fri-14-aug-collections-module-system&quot;&gt;Day 4 (Fri 14 Aug) — Collections + module system&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 7 (Managing Growing Projects) and ch. 8 (Common Collections)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Vec&amp;lt;T&amp;gt;&lt;/code&gt;, &lt;code&gt;String&lt;/code&gt;, &lt;code&gt;HashMap&amp;lt;K, V&amp;gt;&lt;/code&gt; — and the entry API&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;mod&lt;/code&gt;, &lt;code&gt;pub&lt;/code&gt;, &lt;code&gt;use&lt;/code&gt;, &lt;code&gt;crate::&lt;/code&gt; vs. &lt;code&gt;super::&lt;/code&gt;, file-per-module layout&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Split a toy project into &lt;code&gt;src/lib.rs&lt;/code&gt; + &lt;code&gt;src/main.rs&lt;/code&gt; and call the lib from the bin — you&#39;ll do exactly this for real on Day 7&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism:&lt;/strong&gt; &lt;code&gt;word-count&lt;/code&gt;, &lt;code&gt;nucleotide-count&lt;/code&gt;, &lt;code&gt;etl&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;word-count&lt;/code&gt; is a dry run for your tokenizer. Take it seriously.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; you know why &lt;code&gt;src/main.rs&lt;/code&gt; calls &lt;code&gt;mycrate::foo()&lt;/code&gt; and not &lt;code&gt;crate::foo()&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-5-sat-15-aug-error-handling&quot;&gt;Day 5 (Sat 15 Aug) — Error handling&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 9 (Error Handling)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;panic!&lt;/code&gt; vs. &lt;code&gt;Result&amp;lt;T, E&amp;gt;&lt;/code&gt;; when unwrap is honestly fine (tests, prototypes, provable invariants)&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
The &lt;code&gt;?&lt;/code&gt; operator and what it desugars to (&lt;code&gt;From::from&lt;/code&gt; on the error)&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Write one custom error enum by hand implementing &lt;code&gt;Display&lt;/code&gt; + &lt;code&gt;std::error::Error&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Then do it in 4 lines with &lt;code&gt;thiserror&lt;/code&gt; and feel the difference&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Crates:&lt;/strong&gt; &lt;code&gt;cargo add anyhow thiserror&lt;/code&gt; in a scratch project&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Rule of thumb you&#39;ll use all fortnight: &lt;strong&gt;&lt;code&gt;thiserror&lt;/code&gt; in the library, &lt;code&gt;anyhow&lt;/code&gt; in the binaries&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism:&lt;/strong&gt; &lt;code&gt;luhn&lt;/code&gt;, &lt;code&gt;matching-brackets&lt;/code&gt;, &lt;code&gt;roman-numerals&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; you can convert a function from &lt;code&gt;unwrap()&lt;/code&gt;-everywhere to &lt;code&gt;?&lt;/code&gt;-everywhere without thinking.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-6-sun-16-aug-generics-traits-lifetimes-tests&quot;&gt;Day 6 (Sun 16 Aug) — Generics, traits, lifetimes, tests&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 10 (Generic Types, Traits, Lifetimes) and ch. 11 (Writing Automated Tests)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Trait definitions, default methods, &lt;code&gt;impl Trait&lt;/code&gt; in argument and return position&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Trait bounds and &lt;code&gt;where&lt;/code&gt; clauses&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Lifetime annotations — go back and fix Day 2&#39;s &lt;code&gt;longest&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;#[cfg(test)] mod tests&lt;/code&gt;, &lt;code&gt;assert_eq!&lt;/code&gt;, &lt;code&gt;#[should_panic]&lt;/code&gt;, &lt;code&gt;-&amp;gt; Result&amp;lt;(), E&amp;gt;&lt;/code&gt; tests&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Table-driven tests: a &lt;code&gt;&amp;amp;[(input, expected)]&lt;/code&gt; array in a loop. You&#39;ll use this for every parser rule.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism:&lt;/strong&gt; &lt;code&gt;clock&lt;/code&gt; (this is your &lt;code&gt;impl Display&lt;/code&gt; + operator-trait exercise), &lt;code&gt;sublist&lt;/code&gt; (generics + bounds), &lt;code&gt;triangle&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; you&#39;ve written a generic function with a trait bound that compiles on first try.&lt;/p&gt;
&lt;hr /&gt;
&lt;h1 id=&quot;week-2-the-build&quot;&gt;Week 2 — the build&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;Week 2 is project-dominant: ~30 min reading, ~90 min building. Exercism entries below are optional — do them only if the project work finished early.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;day-7-mon-17-aug-cli-skeleton-pin-the-scope&quot;&gt;Day 7 (Mon 17 Aug) — CLI skeleton + &lt;strong&gt;pin the scope&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 12 (An I/O Project: Building a Command Line Program) — build &lt;code&gt;minigrep&lt;/code&gt; fully. Best 90 minutes in the Book. If time is tight, read it and build the argument-parsing half only.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project — &lt;code&gt;mdssg&lt;/code&gt; is born:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo new mdssg&lt;/code&gt; in this repo; add &lt;code&gt;src/lib.rs&lt;/code&gt; alongside &lt;code&gt;src/main.rs&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo add clap --features derive&lt;/code&gt; · &lt;code&gt;cargo add anyhow thiserror walkdir&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Define the CLI with clap&#39;s derive API:&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ssg build  --input &amp;lt;dir&amp;gt; --output &amp;lt;dir&amp;gt;   # default ./content -&amp;gt; ./public&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ssg new    &amp;lt;title&amp;gt;                        # scaffold a content/*.md file&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;--verbose&lt;/code&gt; flag, &lt;code&gt;-h&lt;/code&gt; output that reads well&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;build&lt;/code&gt; currently: walk &lt;code&gt;--input&lt;/code&gt; for &lt;code&gt;*.md&lt;/code&gt;, print each path, exit 0&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;main&lt;/code&gt; returns &lt;code&gt;anyhow::Result&amp;lt;()&amp;gt;&lt;/code&gt;; every error path carries &lt;code&gt;.context(&quot;...&quot;)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
RustRover: create a run configuration for &lt;code&gt;ssg build&lt;/code&gt; with args pre-filled&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Write &lt;code&gt;SPEC.md&lt;/code&gt; — this is the important half of today.&lt;/strong&gt; Fifteen lines, no more, stating exactly what your markdown dialect supports and what it doesn&#39;t. Draft:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Supported:  ATX headings (# .. ######), paragraphs, fenced code (``` with optional lang),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            thematic breaks (---), unordered lists (- *), ordered lists (1.),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            blockquotes (&amp;gt;), inline: *em* **strong** `code` [link](href) ![img](src), \escapes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Not supported: setext headings, reference links, HTML passthrough, tables,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            nested lists, lazy continuation, autolinks, footnotes&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Create &lt;code&gt;tests/fixtures/&amp;lt;feature&amp;gt;.md&lt;/code&gt; + &lt;code&gt;&amp;lt;feature&amp;gt;.html&lt;/code&gt; pairs for every &quot;supported&quot; line&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Write the test harness that walks the fixture directory and asserts each pair — &lt;strong&gt;it fails everything today, and that&#39;s the point.&lt;/strong&gt; Days 8–10 are &quot;make the fixtures pass.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; &lt;code&gt;cargo run -- build --input content&lt;/code&gt; lists your markdown files, and &lt;code&gt;SPEC.md&lt;/code&gt; has a line you can point at whenever you&#39;re tempted to add a feature.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-8-tue-18-aug-iterators-block-parser-part-1&quot;&gt;Day 8 (Tue 18 Aug) — Iterators + block parser, part 1&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 13 (Iterators and Closures)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;map&lt;/code&gt; / &lt;code&gt;filter&lt;/code&gt; / &lt;code&gt;filter_map&lt;/code&gt; / &lt;code&gt;fold&lt;/code&gt; / &lt;code&gt;collect&lt;/code&gt; / &lt;code&gt;take_while&lt;/code&gt; / &lt;code&gt;peekable&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Peekable&amp;lt;Lines&amp;gt;&lt;/code&gt; is the workhorse of a line-based block parser — get comfortable with it&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Closures: &lt;code&gt;Fn&lt;/code&gt; / &lt;code&gt;FnMut&lt;/code&gt; / &lt;code&gt;FnOnce&lt;/code&gt;, and why &lt;code&gt;move&lt;/code&gt; exists&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Project — the flat blocks only (&lt;code&gt;src/parser/block.rs&lt;/code&gt;):&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Define the AST, with list items deliberately flat for now:&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;pub enum&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Block&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;    Heading&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;span&gt; level&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt; u8&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; inlines&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Vec&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Inline&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt;    Paragraph&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Vec&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Inline&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;    CodeBlock&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;span&gt; lang&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Option&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;span&gt; code&lt;/span&gt;&lt;span style=&quot;color: #94E2D5;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;    Rule&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;font-style: italic;&quot;&gt;    // List and Quote land on Day 10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;pub fn parse_blocks(src: &amp;amp;str) -&amp;gt; Vec&amp;lt;Block&amp;gt;&lt;/code&gt; driven by a &lt;code&gt;Peekable&lt;/code&gt; line iterator&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Support &lt;strong&gt;four things only&lt;/strong&gt;: ATX headings, fenced code, &lt;code&gt;---&lt;/code&gt; rules, paragraphs as fallback&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Inlines stay raw for now — &lt;code&gt;Vec&amp;lt;Inline&amp;gt;&lt;/code&gt; holds a single &lt;code&gt;Inline::Text&lt;/code&gt; placeholder&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Table-driven tests including the ugly cases: empty file, no trailing newline, unterminated fence, &lt;code&gt;#&lt;/code&gt;-with-no-space&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Use the RustRover debugger.&lt;/strong&gt; Breakpoint inside the parse loop, step through a 10-line document, watch the &lt;code&gt;Peekable&lt;/code&gt; state. Twenty minutes here beats an hour of &lt;code&gt;println!&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism (optional):&lt;/strong&gt; &lt;code&gt;accumulate&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; those four block types parse correctly and their fixtures are the first ones passing.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-9-wed-19-aug-inline-parser-html-renderer&quot;&gt;Day 9 (Wed 19 Aug) — Inline parser + HTML renderer&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Rust By Example §&quot;Strings&quot;, plus the &lt;code&gt;std::str&lt;/code&gt; and &lt;code&gt;char&lt;/code&gt; docs. Skim &lt;code&gt;pulldown-cmark&lt;/code&gt;&#39;s docs to see how the pros model events — &lt;strong&gt;don&#39;t&lt;/strong&gt; add it as a dependency; you&#39;re writing this one.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;chars()&lt;/code&gt; vs. &lt;code&gt;bytes()&lt;/code&gt; vs. &lt;code&gt;char_indices()&lt;/code&gt;; why &lt;code&gt;&amp;amp;s[0..1]&lt;/code&gt; can panic&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;String::push_str&lt;/code&gt;, and &lt;code&gt;write!&lt;/code&gt; into a &lt;code&gt;String&lt;/code&gt; via &lt;code&gt;std::fmt::Write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Project — inlines and the first real HTML:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Define the inline enum:&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #CBA6F7;&quot;&gt;pub enum&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt; Inline&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; Text&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; Emph&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Vec&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Inline&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; Strong&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Vec&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;Inline&lt;/span&gt;&lt;span style=&quot;color: #89DCEB;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #89B4FA;font-style: italic;&quot;&gt; Code&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #F9E2AF;font-style: italic;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: #9399B2;&quot;&gt;) }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9399B2;font-style: italic;&quot;&gt;// Link and Image land on Day 10&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;parse_inlines(&amp;amp;str) -&amp;gt; Vec&amp;lt;Inline&amp;gt;&lt;/code&gt; handling &lt;code&gt;\&lt;/code&gt; escapes, &lt;code&gt;`code`&lt;/code&gt;, &lt;code&gt;**strong**&lt;/code&gt;, &lt;code&gt;*em*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Do escapes and code spans &lt;strong&gt;first&lt;/strong&gt; — they&#39;re unambiguous. Emphasis is the fiddly one; get the simple non-nested case working and move on. Nested &lt;code&gt;**a *b* c**&lt;/code&gt; is a stretch goal, not a today goal.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Wire it into Day 8&#39;s blocks (replace the placeholder)&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;render_html(&amp;amp;[Block]) -&amp;gt; String&lt;/code&gt; — recursive, writing into one &lt;code&gt;String&lt;/code&gt; buffer&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Escape &lt;code&gt;&amp;amp; &amp;lt; &amp;gt; &quot;&lt;/code&gt; in text and attributes.&lt;/strong&gt; Write the test that proves &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; in a paragraph comes out inert.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Exercism (optional):&lt;/strong&gt; &lt;code&gt;anagram&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; &lt;code&gt;md_to_html(&quot;# Hi\n\nsome **bold** text&quot;)&lt;/code&gt; produces exactly the HTML you&#39;d hand-write.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-10-thu-20-aug-recursive-blocks-catch-up-day&quot;&gt;Day 10 (Thu 20 Aug) — Recursive blocks + &lt;strong&gt;catch-up day&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 15 (Smart Pointers)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Box&amp;lt;T&amp;gt;&lt;/code&gt; for recursion — the reason &lt;code&gt;Block::Quote(Vec&amp;lt;Block&amp;gt;)&lt;/code&gt; compiles at all&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Rc&amp;lt;T&amp;gt;&lt;/code&gt; / &lt;code&gt;RefCell&amp;lt;T&amp;gt;&lt;/code&gt; and interior mutability; know when &lt;em&gt;not&lt;/em&gt; to reach for them&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Deref&lt;/code&gt; and &lt;code&gt;Drop&lt;/code&gt; — the &lt;code&gt;Drop&lt;/code&gt; half is what makes Day 11&#39;s terminal guard work&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;This is the slack day.&lt;/strong&gt; If Days 8–9 overran, spend the whole session finishing them and skip everything below except the last two boxes. Nothing downstream depends on lists or links.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project — the recursive cases:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Block::Quote(Vec&amp;lt;Block&amp;gt;)&lt;/code&gt; — strip the &lt;code&gt;&amp;gt;&lt;/code&gt; prefix, recurse into &lt;code&gt;parse_blocks&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Block::List { ordered: bool, items: Vec&amp;lt;Vec&amp;lt;Inline&amp;gt;&amp;gt; }&lt;/code&gt; — &lt;strong&gt;flat items, one paragraph each.&lt;/strong&gt; Nested lists are explicitly out of scope per &lt;code&gt;SPEC.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;Inline::Link { href, text }&lt;/code&gt; and &lt;code&gt;Inline::Image { src, alt }&lt;/code&gt;, with attribute escaping&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;MdError&lt;/code&gt; enum via &lt;code&gt;thiserror&lt;/code&gt;; the lib returns &lt;code&gt;Result&amp;lt;_, MdError&amp;gt;&lt;/code&gt;, the bin wraps it with &lt;code&gt;anyhow&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo clippy -- -W clippy::pedantic&lt;/code&gt; — fix what you understand, note the rest&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; every fixture from Day 7&#39;s &lt;code&gt;SPEC.md&lt;/code&gt; passes, or you&#39;ve knowingly moved a line from &quot;supported&quot; to &quot;not supported&quot; and deleted its fixture.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-11-fri-21-aug-tui-the-event-loop&quot;&gt;Day 11 (Fri 21 Aug) — TUI: the event loop&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; the &lt;code&gt;ratatui&lt;/code&gt; book — Getting Started + the &quot;Hello World&quot; and &quot;Counter&quot; tutorials&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo add ratatui crossterm&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Install the panic hook first.&lt;/strong&gt; Before anything else: a hook that restores the terminal on panic. Skip this and one crash leaves you in raw mode with no echo, typing blind.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Raw mode, alternate screen, and RAII teardown — a guard struct with a &lt;code&gt;Drop&lt;/code&gt; impl (Day 10 pays off)&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
The immediate-mode idea: you redraw the whole frame every tick; no widget state persists&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Project — &lt;code&gt;src/bin/tui.rs&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;App&lt;/code&gt; struct holding state: file list, selected index, scroll offset, mode&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Event loop: poll crossterm events, &lt;code&gt;q&lt;/code&gt;/&lt;code&gt;Esc&lt;/code&gt; quits, &lt;code&gt;j&lt;/code&gt;/&lt;code&gt;k&lt;/code&gt; + arrows move&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Two-pane &lt;code&gt;Layout&lt;/code&gt;: left = list of &lt;code&gt;content/*.md&lt;/code&gt;, right = placeholder&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Status bar showing the selected filename and a keybinding hint&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; you can navigate the file list and quit cleanly, with your terminal intact.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-12-sat-22-aug-tui-preview-then-earn-the-abstraction&quot;&gt;Day 12 (Sat 22 Aug) — TUI preview, then earn the abstraction&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; the trait-objects / OOP chapter (ch. 17 or 18 depending on edition) — &lt;code&gt;dyn Trait&lt;/code&gt; vs. generics, static vs. dynamic dispatch&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project — build it concrete, then refactor:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Right pane renders the selected file&#39;s &lt;strong&gt;parsed&lt;/strong&gt; content — walk &lt;code&gt;Vec&amp;lt;Block&amp;gt;&lt;/code&gt; and map to ratatui &lt;code&gt;Line&lt;/code&gt;/&lt;code&gt;Span&lt;/code&gt; with styles (headings bold, code dimmed, links underlined). Write this as a plain function, duplicating the HTML renderer&#39;s traversal shape.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Scrolling in the preview pane (&lt;code&gt;PageUp&lt;/code&gt;/&lt;code&gt;PageDown&lt;/code&gt;, &lt;code&gt;g&lt;/code&gt;/&lt;code&gt;G&lt;/code&gt;); &lt;code&gt;Tab&lt;/code&gt; switches focus, focused pane gets a highlighted border; &lt;code&gt;r&lt;/code&gt; reloads from disk&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Handle the sad paths: empty directory, unreadable file, file deleted while selected&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Now look at the two renderers side by side.&lt;/strong&gt; They walk the same AST with the same match arms and differ only in what they emit. &lt;em&gt;Now&lt;/em&gt; extract a &lt;code&gt;Renderer&lt;/code&gt; trait with &lt;code&gt;HtmlRenderer&lt;/code&gt; and &lt;code&gt;TuiRenderer&lt;/code&gt; impls — with two real implementors in front of you, you&#39;ll get the method signatures right.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Note what the trait can&#39;t cleanly express. That gap is the actual lesson about abstraction.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; one parser feeds two renderers through one trait, and you can browse a folder of markdown rendered in your terminal.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-13-sun-23-aug-the-full-build-pipeline&quot;&gt;Day 13 (Sun 23 Aug) — The full build pipeline&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Read:&lt;/strong&gt; Book ch. 14 (More About Cargo and Crates.io) — profiles, workspaces, features&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo add serde --features derive&lt;/code&gt; · &lt;code&gt;cargo add toml&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Project — turn a parser into an SSG:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Frontmatter:&lt;/strong&gt; strip a leading &lt;code&gt;---\n...\n---&lt;/code&gt; block, parse as TOML into &lt;code&gt;#[derive(Deserialize)] struct FrontMatter { title, date, tags, draft }&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Templating:&lt;/strong&gt; a &lt;code&gt;templates/page.html&lt;/code&gt; with &lt;code&gt;${title}&lt;/code&gt; / &lt;code&gt;${content}&lt;/code&gt; placeholders. Write the 20-line substituter yourself — no template crate.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Build:&lt;/strong&gt; &lt;code&gt;content/**/*.md&lt;/code&gt; → &lt;code&gt;public/**/*.html&lt;/code&gt;, preserving directory structure; copy &lt;code&gt;static/&lt;/code&gt; verbatim&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Index:&lt;/strong&gt; generate &lt;code&gt;public/index.html&lt;/code&gt; listing every non-draft page, newest first&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Error messages that name the offending file and line&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;ssg serve&lt;/code&gt; with file-watching is &lt;strong&gt;not&lt;/strong&gt; in the 14 days — it&#39;s a whole evening of &lt;code&gt;notify&lt;/code&gt; plus a socket server. It&#39;s first on the after-Day-14 list.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; &lt;code&gt;ssg build&lt;/code&gt; turns a folder of markdown into a site you can open in a browser.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;day-14-mon-24-aug-ship-it&quot;&gt;Day 14 (Mon 24 Aug) — Ship it&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Project:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Doc comments (&lt;code&gt;///&lt;/code&gt;) on every public item; &lt;code&gt;cargo test --doc&lt;/code&gt; passes; &lt;code&gt;cargo doc --open&lt;/code&gt; looks like a library you&#39;d publish&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo fmt --all&lt;/code&gt; · &lt;code&gt;cargo clippy --all-targets -- -D warnings&lt;/code&gt; — zero warnings&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo test&lt;/code&gt; green, including the fixture harness; add an integration test in &lt;code&gt;tests/&lt;/code&gt; that runs the real binary&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;README.md&lt;/code&gt;: what it is, install, usage, and link &lt;code&gt;SPEC.md&lt;/code&gt; for the supported subset&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;code&gt;cargo build --release&lt;/code&gt; and time a build of 100 files&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Dogfood: write the retro below &lt;em&gt;as a markdown file in &lt;code&gt;content/&lt;/code&gt;&lt;/em&gt; and build it with your own tool&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Tag it: &lt;code&gt;git tag v0.1.0&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Retro — write real answers:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Which compiler error did you hit most, and do you now understand it?&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
Where did you reach for &lt;code&gt;.clone()&lt;/code&gt; because you couldn&#39;t see the borrow-checker-friendly design?&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
What&#39;s the ugliest function in the codebase, and what would fix it?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Done when:&lt;/strong&gt; it&#39;s tagged, documented, and you&#39;d show it to someone.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;after-day-14-where-to-go-next&quot;&gt;After Day 14 — where to go next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;&lt;code&gt;ssg serve&lt;/code&gt;&lt;/strong&gt; — &lt;code&gt;notify&lt;/code&gt; for file watching plus a small &lt;code&gt;std::net::TcpListener&lt;/code&gt; server, then live reload. Cut from the fortnight on purpose; it&#39;s the natural next evening.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Parser depth:&lt;/strong&gt; nested emphasis, nested lists, setext headings, reference links, autolinks&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Spec compliance:&lt;/strong&gt; run the CommonMark test suite against your parser and see how far off you are. Humbling and instructive.&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Concurrency:&lt;/strong&gt; Book ch. 16 → parallelise the build with &lt;code&gt;rayon&lt;/code&gt; (one page per core), then Exercism&#39;s &lt;code&gt;parallel-letter-frequency&lt;/code&gt; properly&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Async:&lt;/strong&gt; the async chapter → &lt;code&gt;tokio&lt;/code&gt; + &lt;code&gt;axum&lt;/code&gt; for a real dev server&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Correctness:&lt;/strong&gt; fuzz the parser with &lt;code&gt;cargo-fuzz&lt;/code&gt;; property tests with &lt;code&gt;proptest&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot;/&gt;
&lt;strong&gt;Exercism hard mode:&lt;/strong&gt; &lt;code&gt;forth&lt;/code&gt;, &lt;code&gt;poker&lt;/code&gt;, &lt;code&gt;dominoes&lt;/code&gt;, &lt;code&gt;xorcism&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;
&lt;h3 id=&quot;crates-you-ll-install&quot;&gt;Crates you&#39;ll install&lt;/h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Crate&lt;/th&gt;&lt;th&gt;For&lt;/th&gt;&lt;th&gt;Day&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;clap&lt;/code&gt; (derive)&lt;/td&gt;&lt;td&gt;CLI args&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;anyhow&lt;/code&gt;&lt;/td&gt;&lt;td&gt;error handling in binaries&lt;/td&gt;&lt;td&gt;5, 7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;thiserror&lt;/code&gt;&lt;/td&gt;&lt;td&gt;error types in the library&lt;/td&gt;&lt;td&gt;5, 10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;walkdir&lt;/code&gt;&lt;/td&gt;&lt;td&gt;recursive file discovery&lt;/td&gt;&lt;td&gt;7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;ratatui&lt;/code&gt; + &lt;code&gt;crossterm&lt;/code&gt;&lt;/td&gt;&lt;td&gt;TUI&lt;/td&gt;&lt;td&gt;11&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;serde&lt;/code&gt; + &lt;code&gt;toml&lt;/code&gt;&lt;/td&gt;&lt;td&gt;frontmatter&lt;/td&gt;&lt;td&gt;13&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Deliberately &lt;strong&gt;not&lt;/strong&gt; used: &lt;code&gt;pulldown-cmark&lt;/code&gt;, &lt;code&gt;comrak&lt;/code&gt;, any template engine. Writing those is the point.&lt;/p&gt;
&lt;h3 id=&quot;the-loop-that-matters&quot;&gt;The loop that matters&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;cargo check&lt;/code&gt; → fix → &lt;code&gt;cargo test&lt;/code&gt; → &lt;code&gt;cargo clippy&lt;/code&gt; → commit. Every day.&lt;/p&gt;
&lt;h3 id=&quot;when-you-re-stuck&quot;&gt;When you&#39;re stuck&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Read the full error. Rust&#39;s errors are essays; the fix is usually in the &lt;code&gt;help:&lt;/code&gt; line.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rustc --explain E0502&lt;/code&gt; (or whatever the code is).&lt;/li&gt;
&lt;li&gt;Draw the ownership on paper — who owns it, who borrowed it, when does each drop?&lt;/li&gt;
&lt;li&gt;Ask &quot;what would this look like with no references at all?&quot; Get it compiling with &lt;code&gt;.clone()&lt;/code&gt;, then remove clones one at a time.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;triage-when-you-fall-behind&quot;&gt;Triage — when you fall behind&lt;/h3&gt;
&lt;p&gt;Days 8–10 are the parser and they &lt;em&gt;will&lt;/em&gt; be the tight ones. In priority order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Never cut&lt;/strong&gt; Days 8–9. Headings, paragraphs, code blocks, and basic inlines are the whole spine.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Day 10 is the buffer.&lt;/strong&gt; Spend all of it on unfinished Day 8–9 work if needed. Lists, quotes and links are optional — move them to &quot;not supported&quot; in &lt;code&gt;SPEC.md&lt;/code&gt; and delete their fixtures.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Then cut Day 12&#39;s polish&lt;/strong&gt; (scrolling, focus switching, reload) before cutting the trait extraction — the refactor is the lesson.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Last resort:&lt;/strong&gt; ship the CLI and parser without the TUI. Two of three faces is a real result.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Cut the Exercism block before the project block, always.&lt;/p&gt;
&lt;h3 id=&quot;rules-for-this-fortnight&quot;&gt;Rules for this fortnight&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Type the code, don&#39;t paste it.&lt;/li&gt;
&lt;li&gt;Commit daily, even when it&#39;s broken.&lt;/li&gt;
&lt;li&gt;Read other people&#39;s Exercism solutions after each exercise.&lt;/li&gt;
&lt;li&gt;When tempted by a markdown feature, check &lt;code&gt;SPEC.md&lt;/code&gt;. If it&#39;s not there, it&#39;s not today&#39;s problem.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;exercism-note&quot;&gt;Exercism note&lt;/h3&gt;
&lt;p&gt;Exercise names occasionally move or get retired on the Rust track. If one isn&#39;t there, pick the nearest equivalent from the same concept group — the concept is what matters, not the specific exercise.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Learning Elixir - things you can do in IEx</title>
        <published>2017-04-05T00:00:00+00:00</published>
        <updated>2017-04-05T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/learning-elixir-things-you-can-do-in-iex/"/>
        <id>https://notes.omerwazir.com/posts/learning-elixir-things-you-can-do-in-iex/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/learning-elixir-things-you-can-do-in-iex/">&lt;p&gt;If you don’t know what IEx is it’s the interactive elixir shell which is included when Elixir is installed on your computer. Since this post is based on a lightning talk I won’t cover every single feature but I will mention a few things that I think are good to know.&lt;/p&gt;
&lt;h2 id=&quot;a-few-of-the-things-iex-can-do-for-you&quot;&gt;A few of the things IEx can do for you&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://hexdocs.pm/iex/IEx.Helpers.html&quot;&gt;IEx Helpers&lt;/a&gt; which are AMAZING!&lt;/li&gt;
&lt;li&gt;Autocomplete with . (dot) lookup&lt;/li&gt;
&lt;li&gt;Help break incomplete expressions&lt;/li&gt;
&lt;li&gt;Shell Configuration&lt;/li&gt;
&lt;li&gt;Pry into code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of the features in IEx are detailed &lt;a href=&quot;https://hexdocs.pm/iex/IEx.html&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;h2 id=&quot;start-iex&quot;&gt;Start IEx&lt;/h2&gt;
&lt;p&gt;Open your terminal and launch iex by simply typing &lt;code&gt;iex&lt;/code&gt; and then enter. This
interactive mode evaluates any Elixir expression which makes it an excellent place to get comfortable with Elixir &amp;amp; OTP.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ iex&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Interactive Elixir (1.4.1) - press Ctrl+C to exit (type h() ENTER for help)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(1)&amp;gt; person = %{name: &amp;quot;Remo Williams&amp;quot;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;%{name: &amp;quot;Remo Williams&amp;quot;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(2)&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;iex-helpers&quot;&gt;IEx.helpers&lt;/h2&gt;
&lt;p&gt;One of the most useful helpers is the &lt;code&gt;h/1&lt;/code&gt; function available from the &lt;a href=&quot;https://hexdocs.pm/iex/IEx.Helpers.html#content&quot;&gt;IEx.Helpers&lt;/a&gt; module. To see everything that &lt;code&gt;IEx.Helpers&lt;/code&gt; provides run &lt;code&gt;h()&lt;/code&gt; inside IEx. To learn about IEx run &lt;code&gt;h(IEx)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Some examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;clear/0&lt;/code&gt; - clear the screen&lt;/li&gt;
&lt;li&gt;&lt;code&gt;h/1&lt;/code&gt; - get module docs&lt;/li&gt;
&lt;li&gt;&lt;code&gt;i/1&lt;/code&gt; - print stuff about a type&lt;/li&gt;
&lt;li&gt;&lt;code&gt;respawn/0&lt;/code&gt; - respawn shell&lt;/li&gt;
&lt;li&gt;&lt;code&gt;s/1&lt;/code&gt; - print specs for a module or function&lt;/li&gt;
&lt;li&gt;... 24 total helpers available&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;respawn()&lt;/code&gt; is another function which I use a lot to start a new shell process.
Take the time to become familiar with the helpers available from &lt;code&gt;IEx.Helpers&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;autocomplete&quot;&gt;Autocomplete&lt;/h2&gt;
&lt;p&gt;If you don&#39;t know what functions are available in a module, type the module name with a dot on the end and press tab to see a list of available functions.
I have an example of using the autocomplete feature with the &lt;code&gt;Map&lt;/code&gt; module, type &lt;code&gt;Map.&lt;/code&gt; and make sure there is a dot after &lt;code&gt;Map&lt;/code&gt;, then press tab and you should see a list of functions/arity pairs. Pretty neat!&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(1)&amp;gt; Map.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;delete/2             drop/2               equal?/2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fetch!/2             fetch/2              from_struct/1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;get/2                get/3                get_and_update!/3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;get_and_update/3     get_lazy/3           has_key?/2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;keys/1               merge/2              merge/3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;new/0                new/1                new/2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pop/2                pop/3                pop_lazy/3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;put/3                put_new/3            put_new_lazy/3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;split/2              take/2               to_list/1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;update!/3            update/4             values/1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;iex-break&quot;&gt;#iex:break&lt;/h2&gt;
&lt;p&gt;This is one of the best features.&lt;/p&gt;
&lt;p&gt;In the example below a Map is not closed properly, leaving the expression open and creating chaos. Typing &lt;code&gt;#iex:break&lt;/code&gt; will essentially break the expression and allow you to continue as if nothing happened. You will still need to type the expression in again and close it properly. This is probably my favorite feature and something I didn’t know until I started preparing for my talk.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(2)&amp;gt; %{user: &amp;quot;Artoo&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; name: &amp;quot;R2D2&amp;#39;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; type: &amp;#39;robot&amp;#39;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; .&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; ;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...(2)&amp;gt; #iex:break&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;** (TokenMissingError) iex:2: incomplete expression&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;shell-configuration&quot;&gt;Shell Configuration&lt;/h2&gt;
&lt;p&gt;Personally I have not configured my IEx shell and have left the default settings. It’s good to know what is configurable in case changes need to be made.&lt;/p&gt;
&lt;p&gt;This is a list of what you can change as of Elixir 1.4:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;:colors&lt;/li&gt;
&lt;li&gt;:inspect&lt;/li&gt;
&lt;li&gt;:width&lt;/li&gt;
&lt;li&gt;:history_size&lt;/li&gt;
&lt;li&gt;:default_prompt&lt;/li&gt;
&lt;li&gt;:alive_prompt&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;inspect&quot;&gt;:inspect&lt;/h3&gt;
&lt;p&gt;Inspect options used by the shell when printing results of expression evaluation. If you want to see everything during &lt;code&gt;IO.inspect/1&lt;/code&gt; then do this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;IEx.configure [inspect: [limit: :infinity]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See more here &lt;a href=&quot;https://hexdocs.pm/elixir/Inspect.Opts.html&quot;&gt;Inspect.Opts&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;note-different-kinds-of-inspects&quot;&gt;Note: different kinds of inspects&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;inspect/1&lt;/code&gt; and &lt;code&gt;i/1&lt;/code&gt; are different.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(2)&amp;gt; foo = %{ name: &amp;quot;Bruce Wayne&amp;quot;, location: &amp;quot;Gotham&amp;quot;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;%{location: &amp;quot;Gotham&amp;quot;, name: &amp;quot;Bruce Wayne&amp;quot;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(3)&amp;gt; inspect(foo)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;quot;%{location: \&amp;quot;Gotham\&amp;quot;, name: \&amp;quot;Bruce Wayne\&amp;quot;}&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;iex(4)&amp;gt; i(foo)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Term&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  %{location: &amp;quot;Gotham&amp;quot;, name: &amp;quot;Bruce Wayne&amp;quot;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Data type&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Map&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Reference modules&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Map&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Implemented protocols&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  IEx.Info, Collectable, Enumerable, Inspect&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;pry-into-code&quot;&gt;Pry into code&lt;/h2&gt;
&lt;p&gt;Debugging is entirely worthy of its own discussion but &lt;code&gt;IEx.pry&lt;/code&gt; should be briefly mentioned here. You will need to require &lt;code&gt;IEx&lt;/code&gt; in a module before you can use &lt;code&gt;pry/0&lt;/code&gt;. Notice in the example below that &lt;code&gt;require IEx&lt;/code&gt; and &lt;code&gt;IEx.pry&lt;/code&gt; are both used together. &lt;code&gt;pry/0&lt;/code&gt; was new to me since I did not have a background in Ruby, it’s a lot like &lt;code&gt;debugger;&lt;/code&gt; from JavaScript except when using &lt;code&gt;pry&lt;/code&gt; “&lt;span style=&quot;font-style:italic&quot;&gt;Setting variables or importing modules in IEx does not affect the caller the environment&lt;/span&gt;” (from the &lt;a href=&quot;https://hexdocs.pm/iex/IEx.html#pry/1&quot;&gt;pry docs&lt;/a&gt;).&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;defmodule say do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; require IEx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; do something() do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  IEx.pry&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  IO.puts(&amp;quot;Hello, World&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I hope you have learned a little bit more about what IEx offers to you, and you now know where to find out more. Things change with new releases so check with the latest documentation to know how a feature works. 😀&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Installing Kismet on a Raspberry Pi</title>
        <published>2017-01-04T00:00:00+00:00</published>
        <updated>2017-01-04T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/install-kismet-rpi/"/>
        <id>https://notes.omerwazir.com/posts/install-kismet-rpi/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/install-kismet-rpi/">&lt;h2 id=&quot;setup-rpi&quot;&gt;Setup RPi&lt;/h2&gt;
&lt;p&gt;Download the latest version of Raspian from &lt;a rel=&quot;external&quot; href=&quot;https://www.raspberrypi.org/downloads/raspbian/&quot;&gt;https://www.raspberrypi.org/downloads/raspbian/&lt;/a&gt; and follow the instructions for burning the image to an SD card. You can find instructions &lt;a rel=&quot;external&quot; href=&quot;https://www.raspberrypi.org/documentation/installation/installing-images/README.md&quot;&gt;here&lt;/a&gt;. I prefer to use the Raspbian Lite distrubution because I don’t use the desktop or any GUI applications.&lt;/p&gt;
&lt;h3 id=&quot;set-a-static-ip&quot;&gt;Set a static IP&lt;/h3&gt;
&lt;p&gt;It&#39;s useful to have a static IP so you can easily remember where to ssh.&lt;/p&gt;
&lt;p&gt;Open the &lt;code&gt;/etc/dhcpcd.conf&lt;/code&gt; file and at the bottom of the file add the following settings:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;interface eth0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;static ip_address=&amp;lt;some ip address&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;static routers=&amp;lt;router IP&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;static domain_name_servers=8.8.8.8 8.8.4.4 &amp;lt;or your network dns ip&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;apply-system-updates&quot;&gt;Apply system updates&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get upgrade&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;install-dependencies&quot;&gt;Install dependencies&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo apt-get install wget m4 vim libncurses5-dev libpcap-dev libpcre3-dev \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;libnl-dev ethtool iw rfkill build-essential autoconf openssl libssl-dev \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fop xsltproc unixodbc-dev git screen&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;increase-the-current-on-usb&quot;&gt;Increase the current on USB&lt;/h3&gt;
&lt;p&gt;In case your using an Alfa wireless antenna and you don&#39;t have a powered usb hub,
you will need to increase the power output that the rpi is delivering over usb.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo cp /boot/config.txt /boot/config.txt.bak&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo vim /boot/config.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Find max_usb_current and set the value to 1 &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;max_usb_current=1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;setup-kismet&quot;&gt;Setup Kismet&lt;/h2&gt;
&lt;h3 id=&quot;compile-install-kismet&quot;&gt;Compile &amp;amp; install Kismet&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd ~/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir kismet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pushd ./kismet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wget https://kismetwireless.net/code/kismet-2016-07-R1.tar.xz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar -xf ./kismet-2016-07-R1.tar.xz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm kismet-2016-07-R1.tar.xz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd ./kismet-2016-07-R1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;./configure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After running &lt;code&gt;./configure&lt;/code&gt; you should see at the end of output a list similar to the one below.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Configuration complete:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         Compiling for: linux-gnueabihf (armv7l)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;           C++ Library: stdc++&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   Installing as group: root&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Man pages owned by: man&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       Installing into: /usr/local&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          Setuid group: kismet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      Terminal Control: ncurses&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   Linux WEXT capture : yes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   OSX/Darwin capture : n/a (only OSX/Darwin)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   PCRE Regex Filters : yes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          pcap capture: yes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;       airpcap control: n/a (only Cygwin/Win32)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        PPI log format: yes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   privilege dropping): no&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;         Linux Netlink: yes (mac80211 VAP creation) - libnl-1 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Continue with the following commands:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;make dep &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;make&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# you can walk away for now, make will take a few minutes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo make suidinstall&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo adduser &amp;lt;user&amp;gt; kismet //add user that will run `kismet_server` to the `kismet` group&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;edit-kismet-conf&quot;&gt;Edit kismet.conf&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;popd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf ./kismet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Current directory should be your home folder i.e. ~/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir kismet_logs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo cp /usr/local/etc/kismet.conf /usr/local/etc/kismet.conf.bak&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo vim /usr/local/etc/kismet.conf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change line #14 to &lt;code&gt;~/kismet_logs&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Enable line #20 and make sure it is set to &lt;code&gt;hidedata=true&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Add &lt;code&gt;ncsource=wlan1mon&lt;/code&gt; under line 32. &lt;code&gt;wlan1mon&lt;/code&gt; will be configured with airmon-ng.&lt;/p&gt;
&lt;p&gt;Save and exit the file.&lt;/p&gt;
&lt;h2 id=&quot;setup-aircrack-ng&quot;&gt;Setup Aircrack-ng&lt;/h2&gt;
&lt;h3 id=&quot;compile-install-aircrack-ng&quot;&gt;Compile &amp;amp; install Aircrack-ng&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mkdir aircrack&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pushd ./aircrack&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wget http://download.aircrack-ng.org/aircrack-ng-1.2-rc4.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;tar -zxf aircrack-ng-1.2-rc4.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd ./aircrack-ng-1.2-rc4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;make&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo make install&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo airodump-ng-oui-update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;popd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;rm -rf ./aircrack&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;switch-wireless-device-to-monitor-mode&quot;&gt;Switch wireless device to monitor mode&lt;/h2&gt;
&lt;p&gt;Run &lt;code&gt;sudo airmon-ng&lt;/code&gt; to see a list of attached network devices.&lt;/p&gt;
&lt;p&gt;You should hopefully see a &lt;code&gt;wlan1&lt;/code&gt; device which is the usb wireless device attached to the rpi. There should also be a driver listed as well. If you see &lt;code&gt;??????&lt;/code&gt; listed as the driver it is likely that the wifi device can&#39;t be set to monitor mode.&lt;/p&gt;
&lt;p&gt;Run&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo airmon-ng check kill&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sudo airmon-ng start wlan1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If successful the &lt;code&gt;wlan1&lt;/code&gt; interface will have changed to &lt;code&gt;wlan1mon&lt;/code&gt;. Make sure the name of this interface matches the name set on line 33 in &lt;code&gt;/usr/local/etc/kismet.conf&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;using-kismet-server&quot;&gt;Using Kismet_Server&lt;/h2&gt;
&lt;p&gt;For development I just run the kismet server inside a &lt;code&gt;screen&lt;/code&gt; shell (or whatever the session is called).&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;screen&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# follow prompts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kismet_server&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# ctrl+a, d to exit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now &lt;code&gt;kismet_server&lt;/code&gt; should be running on the rpi.&lt;/p&gt;
&lt;h3 id=&quot;connecting-to-kismet-server-with-netcat&quot;&gt;Connecting to Kismet_Server with Netcat&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;netcat&lt;/code&gt; should already be installed on the rpi, to connect to the &lt;code&gt;kismet_server&lt;/code&gt; run&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nc localhost 2501&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and you should start to see the output from the &lt;code&gt;kismet_server&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can also send commands to the &lt;code&gt;kismet_server&lt;/code&gt; instructing it on the type of messages you want to see.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo -e &amp;#39;\n!0 enable CLIENT mac,firsttime,lasttime,signal_dbm&amp;#39; | nc localhost 2501 -i 1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and this will output messages from &lt;code&gt;kismet_server&lt;/code&gt; on a 1 second interval.&lt;/p&gt;
&lt;p&gt;To understand all of the messages you can get from kismet you can query a protocol for its capabilities.&lt;/p&gt;
&lt;p&gt;The structure of a capability inquiry message is&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; CAPABILITY &amp;lt;protocol&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So in the example below we are asking for the capability of CLIENT:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;echo -e &amp;#39;\n!2 CAPABILITY CLIENT&amp;#39; | nc localhost 2501&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#response from kismet is below&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*KISMET: 0.0.0 1483556987 pi101 pcapdump,netxml,nettxt,gpsxml,alert 1000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*PROTOCOLS: KISMET,ERROR,ACK,PROTOCOLS,CAPABILITY,TERMINATE,TIME,PACKET,STATUS,PLUGIN,SOURCE,ALERT,COMMON,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;TRACKINFO,WEPKEY,STRING,GPS,BSSID,SSID,CLIENT,BSSIDSRC,CLISRC,NETTAG,CLITAG,REMOVE,CHANNEL,INFO,BATTERY,CRITFAIL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*CAPABILITY: CLIENT bssid,mac,type,firsttime,lasttime,manuf,llcpackets,datapackets,cryptpackets,gpsfixed,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;minlat,minlon,minalt,minspd,maxlat,maxlon,maxalt,maxspd,agglat,agglon,aggalt,aggpoints,signal_dbm,noise_dbm,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;minsignal_dbm,minnoise_dbm,maxsignal_dbm,maxnoise_dbm,signal_rssi,noise_rssi,minsignal_rssi,minnoise_rssi,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;maxsignal_rssi,maxnoise_rssi,bestlat,bestlon,bestalt,atype,ip,gatewayip,datasize,maxseenrate,encodingset,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;carrierset,decrypted,channel,fragments,retries,newpackets,freqmhz,cdpdevice,cdpport,dot11d,dhcphost,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;dhcpvendor,datacryptset&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*ACK: 2 OK&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the response above you can also see PROTOCOLS returned from kismet, any of those protocols can be queried for capabilities.&lt;/p&gt;
&lt;p&gt;Now go build something 😀&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>How we built TwitBeat in 4 hours</title>
        <published>2015-07-23T00:00:00+00:00</published>
        <updated>2015-07-23T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/how-we-built-twitbeat-in-4-hours/"/>
        <id>https://notes.omerwazir.com/posts/how-we-built-twitbeat-in-4-hours/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/how-we-built-twitbeat-in-4-hours/">&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;http://cactushack.com/&quot;&gt;Cactus Hack&lt;/a&gt; took place in Tucson and there was a pretty good turnout. People started showing up around 9:00am, sometime between 10:00am or 10:30am the hosts started a presentation explaining the rules and awards of the hackathon. Teams had to build something that was a web-app, no console or desktop apps. And there had to be a cactus or cacti somewhere in the app. After the presentation people broke into self-made groups of 4 or 5 and started to brainstorm ideas. We were only allowed to code between 1:00pm and 5:00pm so there was quite a bit of time to plan, and eat. I partnered with my friends &lt;a rel=&quot;external&quot; href=&quot;https://github.com/bringking&quot;&gt;Charlie&lt;/a&gt; and &lt;a rel=&quot;external&quot; href=&quot;https://github.com/theshortcut&quot;&gt;Clay&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;what-should-we-build&quot;&gt;What should we  build?&lt;/h2&gt;
&lt;p&gt;I had no ideas at all. Charlie had an idea of a heartbeat app, something that displayed a line like you see in an &lt;a rel=&quot;external&quot; href=&quot;https://en.wikipedia.org/wiki/Electrocardiography&quot;&gt;ECG&lt;/a&gt; chart or &lt;a rel=&quot;external&quot; href=&quot;https://en.wikipedia.org/wiki/Oscilloscope&quot;&gt;Oscilloscope&lt;/a&gt;.Charlie thought we could hook into the &lt;a rel=&quot;external&quot; href=&quot;https://developer.github.com/v3/&quot;&gt;Github API&lt;/a&gt; and monitor the rate of stars on repos or something. There was some concern with rate limiting on the API so we turned towards Twitter. I’m not actually sure if the rate limiting would have been a problem, need to look into that later. There was concern again because the &lt;a rel=&quot;external&quot; href=&quot;https://dev.twitter.com/rest/public&quot;&gt;Twitter REST API&lt;/a&gt; has a rate limit on it, but I remembered from messing around with &lt;a rel=&quot;external&quot; href=&quot;http://storm.apache.org/&quot;&gt;Storm&lt;/a&gt; that Twitter has a &lt;a rel=&quot;external&quot; href=&quot;https://dev.twitter.com/streaming/overview&quot;&gt;Streaming API&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;what-tools-would-we-use&quot;&gt;What tools would we use?&lt;/h2&gt;
&lt;p&gt;We basically agreed that we would use the Twitter Streaming API to monitor tweets with “javascript” in them. Anytime the streaming API responded with a tweet, we&#39;d send the text of the tweet and some data about the tweet to the client UI. All three of us were comfortable using React for the UI, and Node for the server. Since I had some prior experience with &lt;a rel=&quot;external&quot; href=&quot;http://socket.io/&quot;&gt;Socket.io&lt;/a&gt; it was decided that was how we’d get data from the server to the UI. I started to look around npm and searched duckduckgo for any modules that helped connect to the Twitter Streaming API. I found several modules and decided to use &lt;a rel=&quot;external&quot; href=&quot;https://www.npmjs.com/package/twit&quot;&gt;Twit&lt;/a&gt; based on absolutely nothing. Since we could not start coding until 1:00pm I didn’t really have a chance to evaluate modules.&lt;/p&gt;
&lt;p&gt;We figured that the graph we were creating was going to be a SVG. I’ve worked with &lt;a rel=&quot;external&quot; href=&quot;http://d3js.org/&quot;&gt;D3&lt;/a&gt; and remembered that there are some excellent &lt;a rel=&quot;external&quot; href=&quot;https://github.com/mbostock/d3/wiki/Gallery&quot;&gt;examples&lt;/a&gt; to look at. I didn’t really see anything there of what we wanted to build but I then remembered that &lt;a rel=&quot;external&quot; href=&quot;http://bost.ocks.org/mike/&quot;&gt;Mike Bostock&lt;/a&gt; had written a blog post about &lt;a rel=&quot;external&quot; href=&quot;http://bost.ocks.org/mike/path/&quot;&gt;path transitions&lt;/a&gt; and the graph looked pretty close to what we wanted to build. Meanwhile Charlie remembered that &lt;a rel=&quot;external&quot; href=&quot;http://borisyankov.github.io/react-sparklines/&quot;&gt;React Sparklines&lt;/a&gt; was mentioned on the &lt;a rel=&quot;external&quot; href=&quot;http://www.reactiflux.com/&quot;&gt;Reactiflux Slack channel&lt;/a&gt; and the library provided all that we needed. So we started looking at how that component could be used. During all this time we just had to guess how everything was going to work, we couldn’t tinker and see how things were going to work.&lt;/p&gt;
&lt;h2 id=&quot;how-should-it-look&quot;&gt;How should it look?&lt;/h2&gt;
&lt;p&gt;I wish I took a picture of it, but we had sketched out a UI for the app and all we had was a squiggly line inside a rectangle. We also found some images like &lt;a rel=&quot;external&quot; href=&quot;https://duckduckgo.com/?q=ekg+graph&amp;amp;ia=images&amp;amp;iax=1&quot;&gt;this&lt;/a&gt; that provided guidance on what we were to build.&lt;/p&gt;
&lt;h2 id=&quot;collaborating-without-destruction&quot;&gt;Collaborating without destruction&lt;/h2&gt;
&lt;p&gt;Charlie had an existing React/Node project that had a gulpfile and package.json ready to go, so it made sense to just use whatever he had. We were going to use git/Github because there wasn’t enough time to stand up a Subversion server ☺. The plan was that at 1:00pm Charlie would build the file structure of our project, commit to Master and push to origin where everyone else could pull into their unique branches and start coding. Periodically we’d merge branches into Master and eventually end up with a working app inside Master ready to be presented.&lt;/p&gt;
&lt;h2 id=&quot;working-on-different-pieces&quot;&gt;Working on different pieces&lt;/h2&gt;
&lt;p&gt;Each of us had our own branch to work in and we just verbally decided who would work on what. We relied on Github as being our central location to push to. So we would work on our local branch, push to our branch on Github and when one of us reached a good stable point we’d let Charlie know to merge to Master. When one of us was done with a task we’d ask the others what they were working on and what we could help with. Having our own branches, making sure we were working on different tasks and frequently merging to Master were key to us finishing on time without failure. From what I understand some teams did not understand Git, or they didn’t branch/merge effectively and they were hindered by it.&lt;/p&gt;
&lt;p&gt;There’s definitely something about hackathons and working with a group that each person already needs to know a few things to be effective. Distribute source control and branching/merging really stood out as things you need to already know.&lt;/p&gt;
&lt;h2 id=&quot;we-didn-t-add-features-besides-one&quot;&gt;We didn’t add features (besides one)&lt;/h2&gt;
&lt;p&gt;By about 4:30pm we were already done working on TwitBeat. At 5:00pm teams were to present what they worked on so we finished with a lot of time to spare. While we were coding sometimes we’d have ideas of a feature that might make the app better, but realistically we all agreed that adding some features would require more time. While coding an app you start to think of a few dozen little additions that can make your app better but each addition takes time to include. We focused on making sure we would have a functioning app once time was up. Keeping scope in check with time allowed was really important.&lt;/p&gt;
&lt;h2 id=&quot;presentation-time&quot;&gt;Presentation time&lt;/h2&gt;
&lt;p&gt;So we presented our app which you can see &lt;a rel=&quot;external&quot; href=&quot;http://twitbeat.azurewebsites.net/&quot;&gt;here&lt;/a&gt;. It worked and we were happy with it given the time alloted. And we won with a unanimous decision.&lt;/p&gt;
&lt;h2 id=&quot;what-i-learned&quot;&gt;What I learned&lt;/h2&gt;
&lt;p&gt;Four hours to code an app is not a lot of time. There is no time to learn a new library or framework. So we had to use what we knew. I don’t really think there is any easier way to colloborate on a project without using distributed source control. Everyone has to agree with what they are going to build and communicate clearly who is working on what, and know what is still left to build. After merging branches to master it’s pretty important to make sure master works they way you all expect it to work. No broken changes should go into master. Hackathons don’t really prove much beyond which team can quickly put together something. TwitBeat is kind of a stupid little app that doesn’t do much itself but it does lead to other ideas.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Getting CoreOS to work properly with Vagrant and VirtualBox</title>
        <published>2015-02-23T00:00:00+00:00</published>
        <updated>2015-02-23T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/coreos-on-virtualbox-with-vagrant/"/>
        <id>https://notes.omerwazir.com/posts/coreos-on-virtualbox-with-vagrant/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/coreos-on-virtualbox-with-vagrant/">&lt;p&gt;I read the &lt;a rel=&quot;external&quot; href=&quot;https://coreos.com/docs/running-coreos/platforms/vagrant/&quot;&gt;instructions&lt;/a&gt; on setting up CoreOS on Vagrant. I followed the &lt;a rel=&quot;external&quot; href=&quot;https://coreos.com/docs/running-coreos/platforms/vagrant/#cloud-config&quot;&gt;cloud config&lt;/a&gt; steps because I wanted to see what it was like to work with a cluster. Then I followed the steps on &lt;a rel=&quot;external&quot; href=&quot;https://coreos.com/docs/running-coreos/platforms/vagrant/#start-up-coreos&quot;&gt;starting up CoreOS&lt;/a&gt; and I decided it was time to run &lt;code&gt;vagrant up&lt;/code&gt; and get things going. Well I ended up with &lt;code&gt;core-01&lt;/code&gt; not being able to authenticate...huh.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;vagrant up&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;==&amp;gt; core-01: Waiting for machine to boot. This may take a few minutes...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    core-01: SSH address: 127.0.0.1:2222&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    core-01: SSH username: vagrant&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    core-01: SSH auth method: private key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    core-01: Warning: Connection timeout. Retrying...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    core-01: Warning: Authentication failure. Retrying...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course I did what I always do and searched &lt;a rel=&quot;external&quot; href=&quot;https://duckduckgo.com/?q=authentication+failure+retrying+coreos&quot;&gt;DuckDuckGo for “authentication failure retrying coreos”&lt;/a&gt; and found this Stack Overflow answer: &lt;a rel=&quot;external&quot; href=&quot;http://stackoverflow.com/questions/24867490/coreos-authentication-failure-on-vagrant-up&quot;&gt;CoreOS Authentication failure on vagrant up&lt;/a&gt;. The answer indicated that I should have read the &lt;a rel=&quot;external&quot; href=&quot;https://coreos.com/docs/quickstart/&quot;&gt;quickstart&lt;/a&gt; part of the CoreOS documentation where it plainly states that if you were to use Vagrant you must do the following:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ ssh-add ~/.vagrant.d/insecure_private_key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After doing that &lt;code&gt;vagrant up&lt;/code&gt; worked correctly. I could &lt;code&gt;ssh&lt;/code&gt; into any core using &lt;code&gt;vagrant ssh core-&amp;lt;number&amp;gt; -- -A&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now that I can &lt;code&gt;ssh&lt;/code&gt; into a core I tried to write to &lt;code&gt;etcd&lt;/code&gt; following this &lt;a rel=&quot;external&quot; href=&quot;https://coreos.com/docs/quickstart/#service-discovery-with-etcd&quot;&gt;example&lt;/a&gt; but I ended up with another problem.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;curl -L http://127.0.0.1:4001/v1/keys/message -d value=&amp;quot;Hello world&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Failed connect to 127.0.0.1:4001; Connection refused&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Huh I missed something because this should be working. I searched issues on the CoreOS Github repo and found &lt;a rel=&quot;external&quot; href=&quot;https://github.com/coreos/docs/issues/21&quot;&gt;issue #21&lt;/a&gt; where &lt;a rel=&quot;external&quot; href=&quot;https://github.com/coreos/docs/issues/21#issuecomment-68761331&quot;&gt;this comment&lt;/a&gt; illustrated to me that I should have adjusted the &lt;code&gt;config.rb&lt;/code&gt; file before trying to test &lt;code&gt;etcd&lt;/code&gt;. I needed to uncomment lines to allow the following code to become functional.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$new_discovery_url=&amp;#39;https://discovery.etcd.io/new&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# To automatically replace the discovery token on &amp;#39;vagrant up&amp;#39;, uncomment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# the lines below:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;if File.exists?(&amp;#39;user-data&amp;#39;) &amp;amp;&amp;amp; ARGV[0].eql?(&amp;#39;up&amp;#39;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; require &amp;#39;open-uri&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; require &amp;#39;yaml&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; token = open($new_discovery_url).read&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; data = YAML.load(IO.readlines(&amp;#39;user-data&amp;#39;)[1..-1].join)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; data[&amp;#39;coreos&amp;#39;][&amp;#39;etcd&amp;#39;][&amp;#39;discovery&amp;#39;] = token&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; yaml = YAML.dump(data)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; File.open(&amp;#39;user-data&amp;#39;, &amp;#39;w&amp;#39;) { |file| file.write(&amp;quot;#cloud-config\n\n#{yaml}&amp;quot;) }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After fixing that I could run the following on core-01&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;curl -L http://127.0.0.1:4001/v1/keys/message -d value=&amp;quot;Hello world&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and I could read the value of &lt;code&gt;message&lt;/code&gt; across all of the cores. Pretty neat.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>getDOMNode in React is deprecated and replaced with findDOMNode.</title>
        <published>2015-02-04T00:00:00+00:00</published>
        <updated>2015-02-04T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/react-getdomnode-replaced-with-finddomnode/"/>
        <id>https://notes.omerwazir.com/posts/react-getdomnode-replaced-with-finddomnode/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/react-getdomnode-replaced-with-finddomnode/">&lt;p&gt;React 0.13.0-beta.1 supports writing ES6 classes instead of calling React.createClass. See this React blog &lt;a rel=&quot;external&quot; href=&quot;https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html&quot;&gt;post&lt;/a&gt; for more details. I’ve been building a little app with 0.13.0-beta.1 and spent some time getting Jest to work with the components (or are they elements now?) I wrote. I was able to get my tests to pass but a warning kept popping up.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;jest.dontMock(&amp;#39;../build/PokemonRow.react&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;describe(&amp;#39;PokemonRow&amp;#39;, function() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  it(&amp;#39;displays the name of the Pokemon&amp;#39;, function() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var React = require(&amp;#39;react/addons&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var PokemonRow = require(&amp;#39;../build/PokemonRow.react&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var TestUtils = React.addons.TestUtils;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    // Render a paragraph element with the name of a fake pokemon&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var pokemon = {name:&amp;#39;Wuzzy&amp;#39;};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var pokemonRow = TestUtils.renderIntoDocument(&amp;lt;PokemonRow pokemon={pokemon} key={pokemon.name}/&amp;gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    // Verify that it actually was made.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var name = TestUtils.findRenderedDOMComponentWithTag(pokemonRow,&amp;#39;p&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    expect(name.getDOMNode().textContent).toEqual(pokemon.name);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  });&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Using Jest CLI v0.2.2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; PASS  __tests__/PokemonRow-test.js (2.105s)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Warning: getDOMNode(...) is deprecated in plain JavaScript React classes.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Warning: getDOMNode(...) is deprecated in plain JavaScript React classes.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1 test passed (1 total)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Run time: 2.29s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The online documentation for React didn&#39;t say anything about &lt;code&gt;getDOMNode&lt;/code&gt; being deprecated. I figured that since I&#39;m using a beta version the docs aren&#39;t online yet. So I went to the React repo on Github and searched for the warning string &lt;code&gt;is deprecated in plain JavaScript React classes&lt;/code&gt;. I found the message in &lt;code&gt;react/src/modern/class/ReactComponent.js&lt;/code&gt; but I still didn&#39;t understand what to use instead of &lt;code&gt;getDOMNode&lt;/code&gt;. I searched for &lt;code&gt;getDOMNode&lt;/code&gt; and found a &lt;a rel=&quot;external&quot; href=&quot;https://github.com/facebook/react/pull/2802/files&quot;&gt;pull request&lt;/a&gt; updating the documentation to replace &lt;code&gt;getDOMNode&lt;/code&gt; with &lt;code&gt;React.findDOMNode&lt;/code&gt;. I replaced &lt;code&gt;getDOMNode&lt;/code&gt; and &lt;code&gt;findRenderedDOMComponentWithTag&lt;/code&gt; with just &lt;code&gt;React.findDOMNode&lt;/code&gt; and the warnings went away.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;jest.dontMock(&amp;#39;../build/PokemonRow.react&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;describe(&amp;#39;PokemonRow&amp;#39;, function() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  it(&amp;#39;displays the name of the Pokemon&amp;#39;, function() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var React = require(&amp;#39;react/addons&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var PokemonRow = require(&amp;#39;../build/PokemonRow.react&amp;#39;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var TestUtils = React.addons.TestUtils;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    // Render a paragraph element with the name of a fake pokemon&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var pokemon = {name:&amp;#39;Wuzzy&amp;#39;};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var pokemonRow = TestUtils.renderIntoDocument(&amp;lt;PokemonRow pokemon={pokemon} key={pokemon.name}/&amp;gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    // Verify that it actually was made with the right name.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    var name = React.findDOMNode(pokemonRow).textContent;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    expect(name).toEqual(pokemon.name);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  });&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Using Jest CLI v0.2.2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; PASS  __tests__/PokemonRow-test.js (2.047s)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1 test passed (1 total)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Run time: 2.243s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;NOTE: Initially I did a very dumb thing and forgot to run an ES6 to ES5 transpiler before running unit tests. I was running gulp-react to transform the JSX to Javascript but had a total brain fart about needing to convert the ES6 class definition. During my regular build process I use 6to5 during my Browserify packaging which happens after JSX. My unit tests just use the post-JSX files. I kept getting errors about and &lt;code&gt;Unexpected reserved word&lt;/code&gt; and I thought something about the html markup in my component was off. I realised my mistake and have JSX and 6to5 happening during the same gulp task.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>I started learning React and so far I like it.</title>
        <published>2015-02-03T00:00:00+00:00</published>
        <updated>2015-02-03T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/started-learning-react/"/>
        <id>https://notes.omerwazir.com/posts/started-learning-react/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/started-learning-react/">&lt;p&gt;##I should have been building atomic pieces
I’ve worked on projects in an  environment where we are told on Monday what needs to be working on Friday. Tuesday, Wednesday and Thursday are spent rapidly getting something to work without taking any time to plan how we really want to build our app. Functions get tossed in a ViewModel. Templates are placed somewhere. On Friday during an internal demo the app does what it is expected to do. Whenever we get time to take a step back and look at what we built we see that the ViewModel has 60 functions in it. Some functions are near duplicates of each other and some functions belong in another place. There are other major mistakes made but the mistake I want to talk about is that we started putting the whole app together without building atomic pieces of it first.&lt;/p&gt;
&lt;p&gt;##Sharing atomic pieces
An atomic piece is just the smallest piece of UI that on its own can do something. Similar to a React component. I would imagine having an internal site like Bootstrap’s &lt;a rel=&quot;external&quot; href=&quot;http://getbootstrap.com/components/&quot;&gt;Components&lt;/a&gt; where team members can see the pieces that are already developed and from there they can build larger components from the smaller pieces. So I could have a component that takes Lat/Long values and converts to &lt;a rel=&quot;external&quot; href=&quot;https://en.wikipedia.org/wiki/Military_grid_reference_system&quot;&gt;MGRS&lt;/a&gt;. That’s all it does and you can put it wherever you like. The conversion function and the UI are already put together just grab that component and place it wherever you want to. Don’t write a new UI for it. Just use what we have. The site would build off of existing code during CI so we could easily see if style sheets broke or if something doesn’t render correctly.&lt;/p&gt;
&lt;p&gt;##I think React will help me break apps into pieces
It’s pretty easy to see what an app needs to do and feel a little overwhelmed. It takes some practice to break the functionality of an app into the smallest piece that makes sense and build those pieces. So far with React it seems like I build the view into small components and let other components be composed of the little pieces. I haven’t spent any time with Flux yet so I’m not sure how well I’ll understand it. So far I’m liking React and I hope I can get to make some good use of it.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Adding custom icons to ionicons</title>
        <published>2014-10-29T00:00:00+00:00</published>
        <updated>2014-10-29T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/custom-icons-with-ionicons/"/>
        <id>https://notes.omerwazir.com/posts/custom-icons-with-ionicons/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/custom-icons-with-ionicons/">&lt;h2 id=&quot;download-the-ionicons-source&quot;&gt;Download the ionicons source&lt;/h2&gt;
&lt;p&gt;The repo for ionicons is &lt;a rel=&quot;external&quot; href=&quot;https://github.com/driftyco/ionicons&quot;&gt;here&lt;/a&gt;. Fork or straight up download the repo. We’ll need it to generate the ionicons for ionic. I assume ionicons is an entity like Voltron. The next step assumes you are using OS X and have Homebrew installed.&lt;/p&gt;
&lt;h2 id=&quot;install-some-dependencies&quot;&gt;Install some dependencies&lt;/h2&gt;
&lt;p&gt;Run the following commands to get Homebrew to install fontforge and ttfautohint.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;brew install fontforge ttfautohint&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;On my personal computer I encountered the error below so I had to install &lt;a rel=&quot;external&quot; href=&quot;https://xquartz.macosforge.org&quot;&gt;XQuartz&lt;/a&gt;. I have another work computer which didn’t need XQuartz probably because it was already installed.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Homebrew does not package XQuartz. Installers may be found at:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  https://xquartz.macosforge.org&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pango: Unsatisfied dependency: XQuartz 0.0.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Homebrew does not package XQuartz. Installers may be found at:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  https://xquartz.macosforge.org&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Error: Unsatisified requirements failed this build.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After XQuartz was installed it wanted me to logout. So I logged out and logged back in.&lt;/p&gt;
&lt;p&gt;Run the command &lt;code&gt;brew install fontforge ttfautohint&lt;/code&gt; again and wait since this could take a few minutes. Once that is over you will need to install Sass. You can run &lt;code&gt;gem install sass&lt;/code&gt; if you have &lt;code&gt;gem&lt;/code&gt; already working. If not then follow the &lt;a rel=&quot;external&quot; href=&quot;http://sass-lang.com/install&quot;&gt;Sass install&lt;/a&gt; instructions.&lt;/p&gt;
&lt;h2 id=&quot;add-your-custom-icon&quot;&gt;Add your custom icon&lt;/h2&gt;
&lt;p&gt;So with all of the above installed it’s time to add the custom icon to ionicons. Add your custom svg icon to the &lt;code&gt;src&lt;/code&gt; directory in the ionicons repo. I’m taking a public domain icon from &lt;a rel=&quot;external&quot; href=&quot;http://thenounproject.com&quot;&gt;The Noun Project&lt;/a&gt;. Make sure you understand the conditions of usage for icons on The Noun Project before you add them to your app. I’m going to add the &lt;a rel=&quot;external&quot; href=&quot;http://thenounproject.com/term/informal-learning/27471/&quot;&gt;Informal-Learning&lt;/a&gt; icon. Rename the svg file to something meaningful. Right now the icon file is named &lt;code&gt;icon_27471&lt;/code&gt; but that won’t be as useful to use with ionicons, since the build process will use the file name as the name of the icon. I’ve renamed the svg file to &lt;code&gt;informal-learning&lt;/code&gt; and have added it to the ionicons &lt;code&gt;src&lt;/code&gt; directory. With the custom file added to the &lt;code&gt;src&lt;/code&gt; directory it’s time to run ionicons build script.&lt;/p&gt;
&lt;h2 id=&quot;build-ionicons&quot;&gt;Build ionicons&lt;/h2&gt;
&lt;p&gt;In the root of the ionicons directory run the following command &lt;code&gt;python ./builder/generate.py&lt;/code&gt;. You should see output similar to this&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Load Manifest, Icons: 601&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;New Icon: &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - informal-learning&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - 0xf359&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: ios7-reload&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: load-a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: load-b&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: load-c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: load-d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: loop&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - Standard Width: refresh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Save Manifest, Icons: 602&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Save Build, Icons: 602&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate SCSS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate CSS From SCSS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate Minified CSS From SCSS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate LESS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate Cheatsheet&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate component.json&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate composer.json&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Generate bower.json&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;add-the-new-ionicons-files-to-your-ionic-project&quot;&gt;Add the new ionicons files to your ionic project&lt;/h2&gt;
&lt;p&gt;Now copy the files from these folders to the destination folders&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ionicons\css    -&amp;gt;    &amp;lt;ionicApp&amp;gt;/www/lib/ionic/css/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ionicons\fonts  -&amp;gt;    &amp;lt;ionicApp&amp;gt;/www/lib/ionic/fonts/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ionicons\scss   -&amp;gt;    &amp;lt;ionicApp&amp;gt;/www/lib/ionic/scss/ionicons/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It might seem like you wouldn’t need to copy the scss files. I thougth the same thing too but my icon wouldn’t work. So just copy them because they matter.&lt;/p&gt;
&lt;p&gt;Start your app with &lt;code&gt;ionic serve&lt;/code&gt; add the new icon with &lt;code&gt;icon=&quot;icon ion-informal-learning&quot;&lt;/code&gt; and behold such magical wizardry.&lt;/p&gt;
&lt;p&gt;If you encounter any problems just figure it out. These instructions worked for me on two different computers.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Problems running Homebrew on Yosemite</title>
        <published>2014-10-24T00:00:00+00:00</published>
        <updated>2014-10-24T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/fixing-brew-in-yosemite/"/>
        <id>https://notes.omerwazir.com/posts/fixing-brew-in-yosemite/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/fixing-brew-in-yosemite/">&lt;h2 id=&quot;my-first-problem-was-running-brew&quot;&gt;My first problem was running &lt;code&gt;brew&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Just trying to run &lt;code&gt;brew&lt;/code&gt; would cause this error to show up.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/usr/local/bin/brew: /usr/local/Library/brew.rb:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;bad interpreter: No such file or directory&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Easily enough I found how to fix the above error from &lt;a rel=&quot;external&quot; href=&quot;http://blog.ic3man.gr/2014/06/homebrew-ruby-bad-interpreter-no-such-file-or-directory/&quot;&gt;John Assael&lt;/a&gt;. I had to change the first line in the &lt;code&gt; /usr/local/Library/brew.rb&lt;/code&gt; file so that the path&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;was changed to use the &lt;code&gt;Current&lt;/code&gt; folder under &lt;code&gt;Versions&lt;/code&gt; like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0&lt;/code&gt;&lt;/p&gt;
&lt;h2 id=&quot;my-next-problem-was-running-brew-update&quot;&gt;My next problem was running &lt;code&gt;brew update&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Now &lt;code&gt;brew&lt;/code&gt; would run but I couldn’t run &lt;code&gt;brew update&lt;/code&gt; because of this error:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;brew update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: Your local changes to the following files would be overwritten by merge:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Library/brew.rb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Please, commit your changes or stash them before you can merge.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Aborting&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I found a way to fix this in &lt;a rel=&quot;external&quot; href=&quot;https://github.com/Homebrew/homebrew/issues/11448&quot;&gt;Brew issue #11448&lt;/a&gt;. All I had to do is listed below.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd `brew --prefix`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git remote add origin https://github.com/mxcl/homebrew.git&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git fetch origin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reset --hard origin/master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hopefully that fixes some of your problems with Homebrew on Yosemite.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Notes on Reducing Complexity</title>
        <published>2014-05-11T00:00:00+00:00</published>
        <updated>2014-05-11T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/reducing-complexity/"/>
        <id>https://notes.omerwazir.com/posts/reducing-complexity/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/reducing-complexity/">&lt;h2 id=&quot;how-to-reduce-code-complexity&quot;&gt;How to reduce code complexity&lt;/h2&gt;
&lt;h3 id=&quot;command-query-separation&quot;&gt;Command Query Separation&lt;/h3&gt;
&lt;p&gt;Start writing smaller functions by separating the actions that a method performs. Command query separation is about keeping command and query actions in different functions. Commands are functions that are similar to &lt;span class=&#39;italic&#39;&gt;setters&lt;/span&gt; in that they &lt;span class=&quot;italic&quot;&gt;do&lt;/span&gt; something. Queries then are similar to &lt;span class=&#39;italic&#39;&gt;getters&lt;/span&gt; in that they &lt;span class=&quot;italic&quot;&gt;return&lt;/span&gt; something. So you wouldn&#39;t want to combine &lt;span class=&quot;italics&quot;&gt;getters&lt;/span&gt; and &lt;span class=&quot;italics&quot;&gt;setters&lt;/span&gt; in one function. The benefit of this shows up once you try writing unit tests for functions where command query separation was maintained. You&#39;ll end up being able to write tests that are focused for each function.&lt;/p&gt;
&lt;h3 id=&quot;hinting-and-linting&quot;&gt;Hinting and Linting&lt;/h3&gt;
&lt;p&gt;Keep your code sane. Run JSHint (or JSLint) on it. From the &lt;a rel=&quot;external&quot; href=&quot;http://www.jshint.com/about/&quot;&gt;JSHint website&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Any code base eventually becomes huge at some point, and simple mistakes—that would not show themselves when written—can become show stoppers and waste hours of debugging. And this is when static code analysis tools come into play and help developers to spot such problems. JSHint scans a program written in JavaScript and reports about commonly made mistakes and potential bugs. The potential problem could be a syntax error, a bug due to implicit type conversion, a leaking variable or something else.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;cyclomatic-complexity&quot;&gt;Cyclomatic Complexity&lt;/h3&gt;
&lt;p&gt;The number of independent paths a piece of code can take. Cyclomatic complexity is calculated using numbers for each path, the higher the number the more complicated the code is. For each path you will need to write a test for it, so try not to have all of the tests just be for one function. Instead break up the function so that the tests are spread across functions. Maintaining the tests will then be simpler. Supposedly you should keep your cyclomatic complexity (sounds like a hair dryer) below 10. This is one thing that should never go to 11.&lt;/p&gt;
&lt;p&gt;Browsing npm for ‘complexity’ resulted in these two popular tools.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://www.npmjs.org/package/complexity-report&quot;&gt;complexity-report&lt;/a&gt; Software complexity analysis for JavaScript projects.&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://www.npmjs.org/package/plato&quot;&gt;plato&lt;/a&gt; JavaScript source analysis and visualizer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pay attention to the issues on Github to see which tool is actively being maintained.&lt;/p&gt;
&lt;h3 id=&quot;reusability&quot;&gt;Reusability&lt;/h3&gt;
&lt;p&gt;Try to rely on a library or framework instead of writing code that does the same thing. jQuery, lo-dash, underscore,backbone,angular,knockout,node all do their job extremely well. Writing code to mimic what they do for your application is just a bad idea. You already have plenty to worry about in writing code for your project. So reuse what&#39;s already available.&lt;/p&gt;
&lt;p&gt;Reusability also goes to your own code. You might have some code inside a function that converts GMT to Mountain Standard time. You might have another place in your code which converts Nepal Time to Tuvalu time. The code is probably nearly identical except for the timezones that are being converted from and to. Just write a timezone converter function that has it&#39;s logic in one place. And call that function from wherever you were converting time zones. That way if timezone calculations change you change the code in one place, not eleven different places.&lt;/p&gt;
&lt;h3 id=&quot;fan-out&quot;&gt;Fan-Out&lt;/h3&gt;
&lt;p&gt;The number of dependencies your function directly and indirectly depends on or references. Dependencies are in the form of external modules or objects. Tight coupling can be seen in an object or function with high fan-out. To reduce tight coupling you can use dependency injection or eventing. To reduce fan-out you can use a &lt;a rel=&quot;external&quot; href=&quot;http://addyosmani.com/resources/essentialjsdesignpatterns/book/#facadepatternjavascript&quot;&gt;facade pattern&lt;/a&gt;. Testing code with high fan-out is difficult since mocking and stubbing dependencies is required. Yes really when you spend more time writing mocks and stubs you&#39;ll soon be making changes in your code. It&#39;s that obvious of a problem.&lt;/p&gt;
&lt;h3 id=&quot;fan-in&quot;&gt;Fan-In&lt;/h3&gt;
&lt;p&gt;Think of fan-in as the inverse of fan-out. It counts how many modules reference a function or object. I&#39;ve taken the official definition of fan-in from the book Testable Javascript:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The fan-in of procedure A is the number of local flows into procedure A plus the number of data structures from which procedure A retrieves information.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;High fan-in should exist for common or utility functions, think of something like authorization checks,logging, formatting, conversions etc... Those are tasks that can be called from anywhere or called frequently. They should have high fan-in. Code that isn&#39;t called frequently such as initialization code should have low fan-in. The idea being that code that isn&#39;t utilized frequently shouldn&#39;t be called or depended on a lot by other modules.&lt;/p&gt;
&lt;h3 id=&quot;coupling&quot;&gt;Coupling&lt;/h3&gt;
&lt;p&gt;So fan-out counts the number of dependencies a module has, coupling is the relationship between modules. From my experience tight coupling makes it really hard to edit code since changing one thing usually requires editing code in a bunch of other unrelated places too. At first you&#39;ll wonder why in the world is this piece of code referenced all the way in this other place. And hey it&#39;s referenced here too but in a different way and it&#39;s not even used the way it&#39;s supposed to. Then you cry for a day or two and swear you&#39;ll never write tightly coupled code. Of course you don&#39;t write tightly coupled code. It&#39;s always someone else who did it and left you with a maintenance nightmare.&lt;/p&gt;
&lt;h4 id=&quot;the-six-levels-of-coupling-in-descending-order-of-tightness&quot;&gt;The six levels of coupling &lt;small&gt;in descending order of tightness&lt;/small&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Content Coupling. When you call a method/function on an external object directly, or mutate the object by adding or editing it&#39;s properties.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Common Coupling. Your object is commonly coupled if it shares a global value with another object.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Control Coupling. The object changes behavior based on an external flag or condition.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Stamp Coupling. Passing an object to an external object, when the external object only utilizes a few properties but was sent properties it doesn&#39;t use.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Data Coupling. Objects pass messages to each other with no transfer of control to an external object. I didn&#39;t really understand this the first time I read it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No Coupling. Easiest to understand.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Instantiation. Not exactly a form of coupling but it still does couple code to an object. Every time you instantiate and object your code is now responsible for the life cycle of that object. You should at least make sure it&#39;s capable of being garbage collected. Closures are important to watch out for since they make garbage collection difficult even if their parent object goes out of scope.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To move from tight coupling to loose coupling you can use dependency injection. You can also utilize the &lt;a rel=&quot;external&quot; href=&quot;http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/#factorypatternjavascript&quot;&gt;factory pattern&lt;/a&gt; (and abstract factory) to make it easier to just ask for an object.&lt;/p&gt;
&lt;h3 id=&quot;dependency-injection&quot;&gt;Dependency Injection&lt;/h3&gt;
&lt;p&gt;Dependency injection helps release the coupling of an object from it&#39;s dependencies. An object is handed it&#39;s dependencies instead of needing to instantiate them locally. If you aren&#39;t familiar with dependency injection you can read the &lt;a rel=&quot;external&quot; href=&quot;http://en.wikipedia.org/wiki/Dependency_injection&quot;&gt;wikipedia article&lt;/a&gt; and another explanation of dependency injection at the &lt;a rel=&quot;external&quot; href=&quot;https://docs.angularjs.org/guide/di&quot;&gt;AngularJS docs&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;comments&quot;&gt;Comments&lt;/h3&gt;
&lt;p&gt;Commenting code is critical. Just because there is a test for the code that doesn&#39;t mean you are free from commenting your functions. You need to explain to other programmers what is going on. Testable Javascript mentions the following tools for converting comments to documents&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http://yui.github.io/yuidoc/&quot;&gt;YUIDoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http://usejsdoc.org/&quot;&gt;JSDoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http://jashkenas.github.io/docco/&quot;&gt;Docco&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;http://rtomayko.github.io/rocco/&quot;&gt;Rocco&lt;/a&gt; - Ruby port of Docco&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;peer-review&quot;&gt;Peer review&lt;/h3&gt;
&lt;p&gt;Finally have someone else review your code. If another programmer can&#39;t understand your code than there&#39;s a real obvious problem with complexity.&lt;/p&gt;
&lt;h3 id=&quot;naming-your-variables&quot;&gt;Naming your variables&lt;/h3&gt;
&lt;p&gt;I&#39;d like to add my own little thing here for reducing complexity. Use proper naming conventions for variables, objects, functions. Please don&#39;t do this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;var c = SomeFunction();&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I have no clue at all what kind of thing c is supposed to be. Will it be an object, a number, a boolean. What is it for? Also don&#39;t do this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;var value = AnotherFunction();&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Seriously I know value is a value, it&#39;s a value for what?&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>I need to finish these books</title>
        <published>2014-05-08T00:00:00+00:00</published>
        <updated>2014-05-08T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/the-books-i-need-to-finish/"/>
        <id>https://notes.omerwazir.com/posts/the-books-i-need-to-finish/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/the-books-i-need-to-finish/">&lt;p&gt;It&#39;s easy to buy a book but it&#39;s much harder for me to remember to finish reading it. I used to spend time after work reading literature and non-fiction but I never spent time with technical material. That changed in the past year since I started learning Javascript. Now I&#39;ve acquired quite a few books on JS and a couple other interesting books. I&#39;ll stick with one book at a time and will take notes of what I&#39;ve learned.&lt;/p&gt;
&lt;p class=&quot;h3&quot;&gt;The Books I need to read&lt;/p&gt;
* Testable Javascript by Mark Ethan Trostler
* CSS3 For Web Designers by Dan Cederholm
* Javascript Allonge by Reginald Braithwaite
* Mobile First by Luke Wroblewski
* Responsive Web Design by Ethan Marcotte
* JavaScript Enlightenment by Cody Lindley
* Understanding Computation by Tom Stuart
* Data Structures and Algorithms with JavaScript by Michael McMillan
&lt;p&gt;I&#39;m eager to finish Testable Javascript first. Becoming better at writing testable and maintainable code is a major goal for me. Understanding Computation and Javascript Allonge are two books I really want to read, but those are the books I need to take my time with. I started Data Structures and Algorithms with JavaScript and found some errors in the code which turned me off from the book. I submitted some errata for the book and I guess I can continue with the book just to find more bugs.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>CSS Mistakes</title>
        <published>2014-04-10T00:00:00+00:00</published>
        <updated>2014-04-10T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/css-mistakes/"/>
        <id>https://notes.omerwazir.com/posts/css-mistakes/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/css-mistakes/">&lt;p&gt;&lt;a href=&quot;http://www.creativebloq.com/css3/avoid-css-mistakes-10135080&quot; title=&quot;10 CSS mistakes every web designer must avoid&quot;&gt;10 CSS mistakes every web designer must avoid&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The problem with some CSS is that you can tell that it&#39;s written in the top-down style. It mimics the HTML layout rather than abstracting the design elements, often using ids for context, such as #header, #content. This usually results in long selectors (how many times have you seen .menu ul li a {} ?), and the code is going to be really rough to debug and do maintenance on. To fix this CSS, you&#39;ll need to work on abstracting design components from the page, which will also help you remove redundancy in your code.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Each of the 10 tips are great because they talk about mistakes that are so easy to make.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Coding after work</title>
        <published>2014-04-01T00:00:00+00:00</published>
        <updated>2014-04-01T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/coding-after-work/"/>
        <id>https://notes.omerwazir.com/posts/coding-after-work/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/coding-after-work/">&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https://news.ycombinator.com/item?id=7475549&quot;&gt;My original answer&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You will probably have a higher chance of developing technical skills if you take some time to study and code during your free time. You shouldn&#39;t depend on your job to train you on new languages or frameworks. There are a lot of things you and I don&#39;t know and we won&#39;t have time to learn about them while at work.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Also being a developer isnt just purely coding. There&#39;s the ability to write legible code, write tests, know what to use when, know how to read code that you didnt write (or even in a language you arent a master of), find the cause of a bug in an efficient way. You need to be able to talk effectively to non-technical people to figure out why they think X is a bug or how Y is really supposed to work. Those type of skills kinda evolve during your work hours but you have to be aware about improving on them.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I think if you don&#39;t spend some extra time programming you very well might grow stale. Years will pass by and youll realize you want to get a new job but you dont really know that much beyond what you did at work.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The first part of my answer I bring up the point of not relying on your employer to train you. There are mulitple ways an employer can train you, they can pay for tuition/conferences, hire talent to come in for training sessions, pay for books. I&#39;ve come to believe that any of that is gravy and not something you are entitled to. Of course it benefits the employer to spend money training you but some places don&#39;t consider that factor at all. If you really want to get better at what you do then take the time to learn. Don&#39;t just sit around thinking:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;“I need to learn what Verb.js is but I need my boss to setup a training session on that.”&lt;/li&gt;
&lt;li&gt;“Nobody explained to me how to use Git. I won&#39;t use it until that really busy developer sits down and gives me a personal training session.”&lt;/li&gt;
&lt;li&gt;“Linux is so confusing I can&#39;t use it until someone trains me.”&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Assume a developer puts in about 40 hours a week. In most places those hours are spent fixing bugs in a legacy product. That&#39;s realistic because there is a ton of legacy code out there which works but needs some maintenance. If all you know are the patterns you&#39;ve seen in the legacy code and the approaches it takes to solving problems than you probably know only one way to solve those problems. There are other platforms/patterns/tools you can use but you won&#39;t know about them unless you program/learn during your free time. Being a great developer or just a good developer doesn&#39;t mean you refuse to work on legacy code, it can mean that you know how to improve it and you know why it&#39;s rotting. Being a smart developer means you know how to successfully migrate that legacy code out to something more stable/usable/modifiable.&lt;/p&gt;
&lt;p&gt;The second part of the question relates great development strictly to programming. Personally I think that development is more than just churning out lines of code. Not everyone can be the Michael Jordan of programming so you have to be a good teammate and make sure you work well with others. There&#39;s a kind of greatness that comes out of developers who can bring their whole team +1 a level.&lt;/p&gt;
&lt;p&gt;The final point I want to raise is that for many people being a developer means being an employed developer. You might have a great time working on something right now but will you be able to find a good job doing that same thing in another city, or for better pay, or for a better employer? It&#39;s risky to assume that you&#39;ll always be able to get a job for that one thing you&#39;re midly good at. You don&#39;t need to jump on the next newest language or framework but you should be learning what everyone else is doing in case you need to make a move.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>How to set your version of Visual Studio for npm</title>
        <published>2014-03-27T00:00:00+00:00</published>
        <updated>2014-03-27T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/setting-visual-studio-version-for-npm/"/>
        <id>https://notes.omerwazir.com/posts/setting-visual-studio-version-for-npm/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/setting-visual-studio-version-for-npm/">&lt;p&gt;When installing some npm modules on Windows an error may show up that says:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = &amp;#39;v100&amp;#39;) cannot be found.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What you can do is set your installed version of Visual Studio when running npm install.&lt;/p&gt;
&lt;p&gt;To do that simply run:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;npm install &amp;lt;module&amp;gt; -msvs_version=2013&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where &lt;code&gt;msvs_version&lt;/code&gt; is equal to the version of Visual Studio that you have.&lt;/p&gt;
&lt;p&gt;Yay!&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>The Git Cheat Sheet</title>
        <published>2014-03-04T00:00:00+00:00</published>
        <updated>2014-03-04T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://notes.omerwazir.com/posts/git-cheat-sheet/"/>
        <id>https://notes.omerwazir.com/posts/git-cheat-sheet/</id>
        
        <content type="html" xml:base="https://notes.omerwazir.com/posts/git-cheat-sheet/">&lt;p&gt;I initially found this at &lt;a rel=&quot;external&quot; href=&quot;https://help.github.com/articles/git-cheatsheet&quot;&gt;Github&lt;/a&gt; and it&#39;s identical to &lt;a rel=&quot;external&quot; href=&quot;http://cheat.errtheblog.com/s/git&quot;&gt;cheat.errtheblog&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;setup&quot;&gt;Setup&lt;/h3&gt;
&lt;p&gt;Clone the repository specified by &lt;code&gt;&amp;lt;repo&amp;gt;&lt;/code&gt; this is similar to “checkout” in some other version control systems such as Subversion and CVS:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git clone &amp;lt;repo&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Add colors to your ~/.gitconfig file:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[color]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ui = auto&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[color &amp;quot;branch&amp;quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  current = yellow reverse&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  local = yellow&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  remote = green&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[color &amp;quot;diff&amp;quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  meta = yellow bold&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  frag = magenta bold&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  old = red bold&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  new = green bold&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[color &amp;quot;status&amp;quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  added = yellow&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  changed = green&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  untracked = cyan&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Highlight whitespace in diffs:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[color]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ui = true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[color &amp;quot;diff&amp;quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  whitespace = red reverse&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[core]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add aliases to your ~/.gitconfig file:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[alias]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  st = status&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ci = commit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  br = branch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  co = checkout&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  df = diff&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  dc = diff --cached&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  lg = log -p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  lol = log --graph --decorate --pretty=oneline --abbrev-commit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  lola = log --graph --decorate --pretty=oneline --abbrev-commit --all&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ls = ls-files&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  # Show files ignored by git:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  ign = ls-files -o -i --exclude-standard&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;configuration&quot;&gt;Configuration&lt;/h3&gt;
&lt;p&gt;Edit the .git/config [or ~/.gitconfig] file in your $EDITOR:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config -e [--global]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sets your name and email for commit messages:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config --global user.name ’John Doe&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config --global user.email johndoe@example.com&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Tells &lt;code&gt;git branch&lt;/code&gt; and &lt;code&gt;git checkout&lt;/code&gt; to setup new branches so that &lt;code&gt;git pull&lt;/code&gt; will appropriately merge from that remote branch.  &lt;strong&gt;Recommended&lt;/strong&gt;. Without this you will have to add &lt;code&gt;--track&lt;/code&gt; to your branch command or manually merge remote tracking branches with &lt;code&gt;fetch&lt;/code&gt; and then &lt;code&gt;merge&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config branch.autosetupmerge true&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This tells git to convert the newlines to the system&#39;s standard when checking out files, and to LF newlines when committing in:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config core.autocrlf true&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To view all options:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config --list&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To ignore whitespace:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git config apply.whitespace nowarn&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can add &lt;code&gt;--global&lt;/code&gt; after &lt;code&gt;git config&lt;/code&gt; to any of these commands to make it apply to all git repos (writes to ~/.gitconfig).&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;info&quot;&gt;Info&lt;/h3&gt;
&lt;p&gt;Use this to recover from &lt;strong&gt;major&lt;/strong&gt; mess ups! It&#39;s basically a log of the last few actions and you might have luck and find old commits that have been lost by doing a complex merge:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reflog&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Show a diff of the changes made since your last commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git diff&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To diff against a particular file:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git diff -- &amp;lt;filename&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To show a diff between staging area and HEAD:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git diff --cached&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Show files added to the staging area, files with changes, and untracked files:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git status&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Show recent commits, most recent on top:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git log&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Useful options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--color&lt;/code&gt; with color&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--graph&lt;/code&gt; with an ASCII-art commit graph on the left&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--decorate&lt;/code&gt; with branch and tag names on appropriate commits&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--stat&lt;/code&gt;        with stats (files changed, insertions, and deletions)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-p&lt;/code&gt;            with full diffs&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--author=foo&lt;/code&gt;  only by a certain author&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--after=&quot;MMM DD YYYY&quot;&lt;/code&gt; ex. (&quot;Jun 20 2008&quot;) only commits after a certain date&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--before=&quot;MMM DD YYYY&quot;&lt;/code&gt; only commits that occur before a certain date&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--merge&lt;/code&gt;       only the commits involved in the current merge conflicts.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Show commits between the specified range:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git log &amp;lt;ref&amp;gt;..&amp;lt;ref&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Useful for seeing changes from remotes for example &lt;code&gt;git log HEAD..origin/master &lt;/code&gt; (after git remote update)&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Show the changeset (diff) of a commit specified by &lt;code&gt;&amp;lt;rev&amp;gt;&lt;/code&gt;, which can be any SHA1 commit ID, branch name, or tag (shows the last commit (HEAD) by default) also to show the contents of a file at a specific revision, use &lt;code&gt;git show &amp;lt;rev&amp;gt;:&amp;lt;filename&amp;gt;&lt;/code&gt; this is similar to cat-file but much simpler syntax:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git show &amp;lt;rev&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show only the names of the files that changed, no diff information:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git show --name-only &amp;lt;rev&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Show who authored each line in &lt;code&gt;&amp;lt;file&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git blame &amp;lt;file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show who authored each line in &lt;code&gt;&amp;lt;file&amp;gt;&lt;/code&gt; as of &lt;code&gt;&amp;lt;rev&amp;gt;&lt;/code&gt; (allows blame to go back in time):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git blame &amp;lt;file&amp;gt; &amp;lt;rev&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Really nice GUI interface to &lt;code&gt;git blame&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git gui blame&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Show only the commits which affected &lt;file&gt; listing the most recent first:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git whatchanged &amp;lt;file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;View all changes made to a file on a branch, this could be combined with &lt;code&gt;git remote show &amp;lt;remote&amp;gt;&lt;/code&gt; to find all changes on all branches to a particular file:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git whatchanged &amp;lt;branch&amp;gt; &amp;lt;file&amp;gt;  | grep commit | \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     colrm 1 7 | xargs -I % git show % &amp;lt;file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Show the diff between a file on the current branch and potentially another branch&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git diff &amp;lt;commit&amp;gt; head path/to/fubar&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Shows diff for staged (git-add&#39;ed) files (which includes uncommitted git cherry-pick&#39;ed files):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git diff --cached [&amp;lt;file&amp;gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;List all files in the index and under version control:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git ls-files&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show the current version on the remote repo. This can be used to check whether a local is required by comparing the local head revision:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git ls-remote &amp;lt;remote&amp;gt; [HEAD]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;adding-deleting&quot;&gt;Adding / Deleting&lt;/h3&gt;
&lt;p&gt;Add &lt;code&gt;&amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt;,&lt;/code&gt; etc... to the project&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add all files under directory &lt;code&gt;&amp;lt;dir&amp;gt;&lt;/code&gt; to the project, including subdirectories&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add &amp;lt;dir&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add all files under the current directory to the project &lt;strong&gt;WARNING&lt;/strong&gt; including untracked files:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Remove &lt;code&gt;&amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt;,&lt;/code&gt; etc... from the project&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git rm &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Remove all deleted files from the project&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git rm $(git ls-files --deleted)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Commits absence of &lt;code&gt;&amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt;,&lt;/code&gt; etc... from the project&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git rm --cached &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;ignoring&quot;&gt;Ignoring&lt;/h3&gt;
&lt;p&gt;####Option 1:&lt;/p&gt;
&lt;p&gt;Edit $GIT_DIR/.git/info/exclude. See Environment Variables below for explanation on $GIT_DIR.&lt;/p&gt;
&lt;p&gt;####Option 2:&lt;/p&gt;
&lt;p&gt;Add a file .gitignore to the root of your project. This file will be checked in.&lt;/p&gt;
&lt;p&gt;Either way you need to add patterns to exclude to these files.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;staging&quot;&gt;Staging&lt;/h3&gt;
&lt;p&gt;Add changes in &lt;code&gt;&amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt; ...&lt;/code&gt; to the staging area (to be included in the next commit):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Interactively walk through the current changes (hunks) in the working tree, and decide which changes to add to the staging area:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stage &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add -p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stage --patch&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Interactively add files/changes to the staging area. For a simpler mode (no menu), try &lt;code&gt;git add --patch&lt;/code&gt; (above)&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add -i&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stage --interactive&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;unstaging&quot;&gt;Unstaging&lt;/h3&gt;
&lt;p&gt;Remove the specified files from the next commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reset HEAD &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;committing&quot;&gt;Committing&lt;/h3&gt;
&lt;p&gt;Commit &lt;code&gt;&amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt;,&lt;/code&gt; etc..., optionally using commit message &lt;code&gt;&amp;lt;msg&amp;gt;&lt;/code&gt;, otherwise opening your editor to let you type a commit message&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ... [-m &amp;lt;msg&amp;gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Commit all files changed since your last commit (does not include new untracked files):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit -a&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Commit verbosely, i.e. includes the diff of the contents being committed in the commit message screen:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit -v&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Edit the commit message of the most recent commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit --amend&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Redo previous commit, including changes made to &lt;code&gt;&amp;lt;file1&amp;gt;, &amp;lt;file2&amp;gt;,&lt;/code&gt; etc...&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit --amend &amp;lt;file1&amp;gt; &amp;lt;file2&amp;gt; ...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;branching&quot;&gt;Branching&lt;/h3&gt;
&lt;p&gt;List all local branches:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;List all remote branches:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch -r&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;List all local and remote branches:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch -a&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a new branch named &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;, referencing the same point in history as the current branch&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;create a new branch named &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;, referencing &lt;code&gt;&amp;lt;start-point&amp;gt;&lt;/code&gt;, which may be specified any way you like, including using a branch name or a tag name:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch &amp;lt;branch&amp;gt; &amp;lt;start-point&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a new remote branch named &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;, referencing &lt;code&gt;&amp;lt;start-point&amp;gt;&lt;/code&gt; on the remote. Repo is the name of the remote.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    git push &amp;lt;repo&amp;gt; &amp;lt;start-point&amp;gt;:refs/heads/&amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin origin:refs/heads/branch-1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin origin/branch-1:refs/heads/branch-2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin branch-1 ## shortcut&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a tracking branch. Will push/pull changes to/from another repository.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch --track &amp;lt;branch&amp;gt; &amp;lt;remote-branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch --track experimental origin/experimental&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make an existing branch track a remote branch. (As of Git 1.7.0):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch --set-upstream &amp;lt;branch&amp;gt; &amp;lt;remote-branch&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch --set-upstream foo origin/foo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Delete the branch &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt; if the branch you are deleting points to a commit which is not reachable from the current branch, this command will fail with a warning:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch -d &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Delete a remote-tracking branch.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch -r -d &amp;lt;remote-branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch -r -d wycats/master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Even if the branch points to a commit not reachable from the current branch, you may know that that commit is still reachable from some other branch or tag. In that case it is safe to use this command to force git to delete the branch.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git branch -D &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make the current branch &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;, updating the working directory to reflect the version referenced by &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a new branch &lt;code&gt;&amp;lt;new&amp;gt;&lt;/code&gt; referencing &lt;code&gt;&amp;lt;start-point&amp;gt;&lt;/code&gt;, and check it out.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout -b &amp;lt;new&amp;gt; &amp;lt;start-point&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Removes a branch from a remote repository:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push &amp;lt;repository&amp;gt; :&amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin :old_branch_to_be_deleted&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Checkout a file from another branch and add it to this branch. File will still need to be added to the git branch, but it&#39;s present.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git co &amp;lt;branch&amp;gt; &amp;lt;path to new file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git co remote_at_origin__tick702_antifraud_blocking ..../...nt_elements_for_iframe_blocked_page.rb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show the contents of a file that was created on another branch and that does not exist on the current branch.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git show &amp;lt;branch&amp;gt; -- &amp;lt;path to file that does not exist&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git show remote_tick702 -- path/to/fubar.txt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show the contents of a file at the specific revision. Note: path has to be absolute within the repo:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git show &amp;lt;rev&amp;gt;:&amp;lt;repo path to file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;merging&quot;&gt;Merging&lt;/h3&gt;
&lt;p&gt;Merge branch &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt; into the current branch; this command is idempotent and can be run as many times as needed to keep the current branch up-to-date with changes in &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git merge &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Merge branch &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt; into the current branch, but do not autocommit the result; allows you to make further tweaks:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git merge &amp;lt;branch&amp;gt; --no-commit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Merge branch &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt; into the current branch, but drops any changes in &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt;, using the current tree as the new tree:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git merge &amp;lt;branch&amp;gt; -s ours&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;cherry-picking&quot;&gt;Cherry-Picking&lt;/h3&gt;
&lt;p&gt;Selectively merge a single commit from another local branch:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git cherry-pick [--edit] [-n] [-m parent-number] [-s] [-x] &amp;lt;commit&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git cherry-pick 7300a6130d9447e18a931e898b64eefedea19544&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Get the blob of some file whether it is in a repository or not:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git hash-object &amp;lt;file-path&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Find the commit in the repository that contains the file blob:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;obj_blob=&amp;quot;$1&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git log --pretty=format:&amp;#39;%T %h %s&amp;#39; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;| while read tree commit subject ; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    if git ls-tree -r $tree | grep -q &amp;quot;$obj_blob&amp;quot; ; then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        echo $commit &amp;quot;$subject&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    fi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;done&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;squashing&quot;&gt;Squashing&lt;/h3&gt;
&lt;h4 id=&quot;warning-git-rebase-changes-history-be-careful-google-it&quot;&gt;WARNING “git rebase” changes history. Be careful &amp;amp; Google it.&lt;/h4&gt;
&lt;p&gt;Change all but the first “pick” to “squash”. Squash the last 10 commits into one big commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git rebase --interactive HEAD~10&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;conflicts&quot;&gt;Conflicts&lt;/h3&gt;
&lt;p&gt;Work through conflicted files by opening them in your mergetool (opendiff, kdiff3, etc.) and choosing left/right chunks. The merged result is staged for commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git mergetool&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For binary files or if mergetool won&#39;t do, resolve the conflict(s) manually and then do:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git add &amp;lt;file1&amp;gt; [&amp;lt;file2&amp;gt; ...]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once all conflicts are resolved and staged, commit the pending merge with:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;sharing&quot;&gt;Sharing&lt;/h3&gt;
&lt;p&gt;Update the remote-tracking branches for &lt;code&gt;&amp;lt;remote&amp;gt;&lt;/code&gt; (defaults to “origin”). Does not initiate a merge into the current branch (see “git pull” below):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git fetch &amp;lt;remote&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fetch changes from the server, and merge them into the current branch. Note: .git/config must have a [branch &quot;some_name&quot;] section for the current branch, to know which remote-tracking branch to merge into the current branch.  Git 1.5.3 and above adds this automatically:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git pull&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Update the server with your commits across all branches that are &lt;strong&gt;COMMON&lt;/strong&gt; between your local copy and the server. Local branches that were never pushed to the server in the first place are not shared:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Update the server with your commits made to &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt; since your last push. This is always &lt;em&gt;required&lt;/em&gt; for new branches that you wish to share. After the first explicit push, &lt;code&gt;git push&lt;/code&gt; by itself is sufficient:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same as git push origin &lt;code&gt;&amp;lt;branch&amp;gt;&lt;/code&gt; but a little more obvious what is happening:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin &amp;lt;branch&amp;gt;:refs/heads/&amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin twitter-experiment:refs/heads/twitter-experiment&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;reverting&quot;&gt;Reverting&lt;/h3&gt;
&lt;p&gt;Reverse commit specified by &lt;code&gt;&amp;lt;rev&amp;gt;&lt;/code&gt; and commit the result. This does &lt;strong&gt;not&lt;/strong&gt; do the same thing as similarly named commands in other version control systems such as &lt;code&gt;svn revert&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git revert &amp;lt;rev&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Re-checkout &lt;code&gt;&amp;lt;file&amp;gt;&lt;/code&gt;, overwriting any local changes:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout &amp;lt;file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Re-checkout all files, overwriting any local changes. This is most similar to &lt;code&gt;svn revert&lt;/code&gt; if you are familiar with Subversion commands:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;fix-mistakes-undo&quot;&gt;Fix mistakes / Undo&lt;/h3&gt;
&lt;p&gt;Abandon everything since your last commit; this command can be &lt;strong&gt;DANGEROUS&lt;/strong&gt;. If merging has resulted in conflicts and you&#39;d like to just forget about the merge, this command will do that.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reset --hard&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Undo your most recent &lt;strong&gt;successful&lt;/strong&gt; merge &lt;strong&gt;and&lt;/strong&gt; any changes that occurred after. Useful for forgetting about the merge you just did. If there are conflicts (the merge was not successful), use &lt;code&gt;git reset --hard&lt;/code&gt; (above)
instead.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reset --hard ORIG_HEAD &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reset --hard origin/master &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Forgot something in your last commit? That&#39;s easy to fix. Undo your last commit, but keep the changes in the staging area for editing:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git reset --soft HEAD^&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Redo previous commit, including changes you&#39;ve staged in the meantime. Also used to edit commit message of previous commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit --amend&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;plumbing&quot;&gt;Plumbing&lt;/h3&gt;
&lt;p&gt;Determine if merging sha1-B into sha1-A is achievable as a fast forward; non-zero exit status is false:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;test &amp;lt;sha1-A&amp;gt; = $(git merge-base &amp;lt;sha1-A&amp;gt; &amp;lt;sha1-B&amp;gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;stashing&quot;&gt;Stashing&lt;/h3&gt;
&lt;p&gt;Save your local modifications to a new stash.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash save &amp;lt;optional-name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git svn rebase &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git pull&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restore the changes recorded in the stash on top of the current working tree state:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash apply&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restore the changes from the most recent stash, and remove it from the stack of stashed changes:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash pop&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;List all current stashes:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash list&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show the contents of a stash - accepts all diff args&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash show &amp;lt;stash-name&amp;gt; -p&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Delete the stash:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash drop [&amp;lt;stash-name&amp;gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Delete all current stashes:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git stash clear&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;remotes&quot;&gt;Remotes&lt;/h3&gt;
&lt;p&gt;Adds a remote repository to your git config.  Can be then fetched locally.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git remote add &amp;lt;remote&amp;gt; &amp;lt;remote_URL&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git remote add coreteam git://github.com/wycats/merb-plugins.git&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git fetch coreteam&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Delete a branch in a remote repository:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push &amp;lt;remote&amp;gt; :refs/heads/&amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a branch on a remote repository.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push &amp;lt;remote&amp;gt; &amp;lt;remote&amp;gt;:refs/heads/&amp;lt;remote_branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin origin:refs/heads/new_feature_name&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace a &lt;code&gt;&amp;lt;remote&amp;gt;&lt;/code&gt; branch with &lt;code&gt;&amp;lt;new_remote&amp;gt;&lt;/code&gt; think twice before do this.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push &amp;lt;repository&amp;gt; +&amp;lt;remote&amp;gt;:&amp;lt;new_remote&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push origin +master:my_branch&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Prune deleted remote-tracking branches from &lt;code&gt;git branch -r&lt;/code&gt; listing&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git remote prune &amp;lt;remote&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add a remote and track its master:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git remote add -t master -m master origin git://example.com/git.git/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Show information about the remote server:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git remote show &amp;lt;remote&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Track a remote branch as a local branch. It seems that somtimes an extra &#39;remotes/&#39; is required, to see the exact branch name, &lt;code&gt;git branch -a&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout -b &amp;lt;local branch&amp;gt; &amp;lt;remote&amp;gt;/&amp;lt;remote branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout -b myfeature origin/myfeature &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git checkout -b myfeature remotes/&amp;lt;remote&amp;gt;/&amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For branches that are remotely tracked (via git push) but that complain about non-fast forward commits when doing a &lt;code&gt;git push&lt;/code&gt;. The &lt;code&gt;git pull&lt;/code&gt; synchronizes local and remote, and if all goes well, the result is pushable.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git pull &amp;lt;remote&amp;gt; &amp;lt;branch&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git push&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Retrieves all branches from the remote repository. After this &lt;code&gt;git branch --track ...&lt;/code&gt; can be used to track a branch
from the new remote.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git fetch &amp;lt;remote&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;submodules&quot;&gt;Submodules&lt;/h3&gt;
&lt;p&gt;Add the given repository at the given path. The addition will be part of the next commit.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git submodule add &amp;lt;remote_repository&amp;gt; &amp;lt;path/to/submodule&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Update the registered submodules (clone missing submodules, and checkout the commit specified by the super-repo). &lt;code&gt;--init&lt;/code&gt; is needed the first time.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git submodule update [--init]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Executes the given command within each checked out submodule.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git submodule foreach &amp;lt;command&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;####Removing submodules:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Delete the relevant line from the .gitmodules file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Delete the relevant section from .git/config.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git rm --cached path_to_submodule&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;(no trailing slash).&lt;/p&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;Commit and delete the now untracked submodule files.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;####Updating submodules
To update a submodule to a new commit:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;update submodule:&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd &amp;lt;path to submodule&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git pull&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;commit the new version of submodule:&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd &amp;lt;path to toplevel&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git commit -m &amp;quot;update submodule version&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;check that the submodule has the correct version
&lt;code&gt;git submodule status&lt;/code&gt;
If the update in the submodule is not committed in the
main repository, it is lost and doing git submodule
update will revert to the previous version.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;patches&quot;&gt;Patches&lt;/h3&gt;
&lt;p&gt;Generate the last commit as a patch that can be applied on another clone (or branch) using &lt;code&gt;git am&lt;/code&gt;. Format patch can also generate a patch for all commits using &lt;code&gt;git format-patch HEAD^ HEAD&lt;/code&gt;. All page files will be enumerated with a prefix, e.g. 0001 is the first patch.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git format-patch HEAD^&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Generate a patch for a single commit. Revision does not need to be fully specified:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git format-patch &amp;lt;Revision&amp;gt;^..&amp;lt;Revision&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git format-patch d8efce43099^..d8efce43099&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Applies the patch file generated by format-patch.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git am &amp;lt;patch file&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Generates a patch file that can be applied using patch: &lt;code&gt;patch -p0 &amp;lt; patchfile&lt;/code&gt;. Useful for sharing changes without generating a git commit:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git diff --no-prefix &amp;gt; patchfile&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;tags&quot;&gt;Tags&lt;/h3&gt;
&lt;p&gt;Will list all tags defined in the repository.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git tag -l&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will checkout the code for a particular tag. After this you&#39;ll probably want to do &lt;code&gt;git co -b &amp;lt;some branch name&amp;gt;&lt;/code&gt; to define a branch. Any changes you now make can be committed to that branch and later merged.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git co &amp;lt;tag_name&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;archive&quot;&gt;Archive&lt;/h3&gt;
&lt;p&gt;Will export expanded tree as tar archive at given path:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git archive master | tar -x -C /somewhere/else&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will export archive as bz2:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git archive master | bzip2 &amp;gt; source-tree.tar.bz2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will export as zip:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git archive --format zip --output /full/path master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;git-instaweb&quot;&gt;Git Instaweb&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git instaweb --httpd=webrick [--start | --stop | --restart]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;environment-variables&quot;&gt;Environment Variables&lt;/h3&gt;
&lt;p&gt;Your full name to be recorded in any newly created commits.  Overrides user.name in .git/config&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GIT_AUTHOR_NAME, GIT_COMMITTER_NAME&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your email address to be recorded in any newly created commits.  Overrides user.email in .git/config&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GIT_AUTHOR_EMAIL, GIT_COMMITTER_EMAIL&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Location of the repository to use (for out of working directory repositories):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GIT_DIR&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Location of the Working Directory - use with GIT_DIR to specifiy the working directory root or to work without being in the working directory at all:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;GIT_WORKING_TREE&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;changing-history&quot;&gt;Changing history&lt;/h3&gt;
&lt;p&gt;Change author for all commits with given name&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #CDD6F4; background-color: #1E1E2E;&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;git filter-branch --commit-filter &amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        if [ &amp;quot;$GIT_COMMITTER_NAME&amp;quot; = &amp;quot;&amp;lt;Old Name&amp;gt;&amp;quot; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                GIT_COMMITTER_NAME=&amp;quot;&amp;lt;New Name&amp;gt;&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                GIT_AUTHOR_NAME=&amp;quot;&amp;lt;New Name&amp;gt;&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                GIT_COMMITTER_EMAIL=&amp;quot;&amp;lt;New Email&amp;gt;&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                GIT_AUTHOR_EMAIL=&amp;quot;&amp;lt;New Email&amp;gt;&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                git commit-tree &amp;quot;$@&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                git commit-tree &amp;quot;$@&amp;quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        fi&amp;#39; HEAD&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        
    </entry>
</feed>
