<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wc="https://wilhelm.codes/ns/feed/1.0"><channel><title>Wilhelm Codes · Git</title><link>https://wilhelm.codes/tags/git/</link><description>Slinger of nibbles, bits and bytes. Over 25 years of professional experience as a software engineer. Love making glowing rectangles go "beep-boop".</description><generator>Hugo</generator><language>en-US</language><managingEditor>0xdeadbeef@devilmayco.de (Wilhelm Murdoch)</managingEditor><webMaster>0xdeadbeef@devilmayco.de (Wilhelm Murdoch)</webMaster><lastBuildDate>Thu, 04 Nov 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://wilhelm.codes/tags/git/index.xml" rel="self" type="application/rss+xml"/><item><title>Falsifying Github Participation Graphs for Fun &amp; Profit</title><link>https://wilhelm.codes/blog/falsifying-github-participation-graphs-for-fun-and-profit/</link><pubDate>Thu, 04 Nov 2021 00:00:00 +0000</pubDate><author>0xdeadbeef@devilmayco.de (Wilhelm Murdoch)</author><guid>https://wilhelm.codes/blog/falsifying-github-participation-graphs-for-fun-and-profit/</guid><category>bash</category><category>git</category><wc:kind>post</wc:kind><description>If you&amp;rsquo;ve spent any time job hunting in the tech industry, you&amp;rsquo;ve had to deal with recruiters. I like to joke around with my peers about how they&amp;rsquo;re a necessary evil, but in all seriousness, great recruiters are worth their weight in gold. However &amp;hellip;</description><content:encoded><![CDATA[<p>If you&rsquo;ve spent any time job hunting in the tech industry, you&rsquo;ve had to deal with recruiters. I like to joke around with my peers about how they&rsquo;re a necessary evil, but in all seriousness, great recruiters are worth their weight in gold. However &hellip;</p>
<p>But, good or bad, far too many of them will pass over your resume for the wildest reasons. We&rsquo;re not here to go over all of them. No, today we&rsquo;re going to address the somewhat recent trend of glancing at your public Github profile page and grading you based on how many green squares show up in your participation graph.</p>
<h2 id="whats-your-point">
  <a class="heading-link" href="#whats-your-point">What&rsquo;s your point?<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h2>
<p>Like basing your performance on LoC, using &ldquo;commits made&rdquo; as a recruiting metric is beyond useless. There can be any number of reasons why your graph isn&rsquo;t as populated as they&rsquo;d like:</p>
<ol>
<li>You work on private repositories and you haven&rsquo;t configured your profile to show anonymised private contributions.</li>
<li>You have an alternate account from your personal one to keep work and private life separate. Or, maybe it&rsquo;s just company policy.</li>
<li>You&rsquo;ve signed an NDA and can&rsquo;t publish your contributions publicly.</li>
<li>You set personal boundaries for your work-life balance and don&rsquo;t care to stare at glowing rectangles in your free time.</li>
<li>Or, maybe you&rsquo;ve just had a slow year? 🤷</li>
</ol>
<p>Personally, I have <em>thousands</em> of commits that will never see the light of day for some of the ☝️ points. If I&rsquo;m out job hunting, I would hate to be passed over because I don&rsquo;t tick some mundane box on an arbitrary checklist.</p>
<h2 id="what-to-do">
  <a class="heading-link" href="#what-to-do">What to do?<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h2>
<p>Well, we light up that graph like it&rsquo;s a switch board, of course. Make this information utterly useless. What do they care if your profile says you&rsquo;ve had <code>2,345</code> commits in the last week? Maybe you did. If it&rsquo;s 🟩 , they cross it off their checklist and move on to something else.</p>
<h2 id="ok-show-me">
  <a class="heading-link" href="#ok-show-me">Ok, show me.<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h2>
<p>Crack your knuckles and get ready to do some coding. For this little project, we&rsquo;ll be doing some simple Bash scripting. I&rsquo;m currently working on MacOS, but this code should be fairly portable on other Linux-based distributions.</p>
<p>You will, naturally, need a Github account. Let&rsquo;s start there.</p>
<h3 id="configure-your-participation-graph">
  <a class="heading-link" href="#configure-your-participation-graph">Configure Your Participation Graph<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h3>
<p>Did you know you can configure your participation graph to display anonymised private commit statistics? Ensure that setting is ✅ and move on to the next step.</p>
<p><img
  src="https://wilhelm.codes/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-1_hu_a64e6216dfe1bb5e.webp"
  srcset="/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-1_hu_a64e6216dfe1bb5e.webp 736w"
  sizes="(max-width: 48rem) 100vw, 736px"
  width="736"
  height="198"
  alt=""
  
  loading="lazy"
  decoding="async"
/>
</p>
<h3 id="new-private-repository">
  <a class="heading-link" href="#new-private-repository">New Private Repository<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h3>
<p>Let&rsquo;s create a new <em>empty</em> repository entitled <code>graph-participation</code> and make sure it&rsquo;s private.</p>
<p><img
  src="https://wilhelm.codes/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-2_hu_b7f3ea1f8aabce13.webp"
  srcset="/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-2_hu_b7f3ea1f8aabce13.webp 736w, /blog/falsifying-github-participation-graphs-for-fun-and-profit/image-2_hu_415764d2f8820b54.webp 1104w"
  sizes="(max-width: 48rem) 100vw, 736px"
  width="736"
  height="78"
  alt=""
  
  loading="lazy"
  decoding="async"
/>
</p>
<h3 id="checkout-local-working-copy">
  <a class="heading-link" href="#checkout-local-working-copy">Checkout Local Working Copy<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h3>
<p>Follow the post-setup instructions Github gives you to check out a local working copy of your new 🔒 repository!</p>
<div class="code-block">
  <div class="code-head">
    <span class="code-file"></span>
    <span class="code-lang">Bash</span>
  </div>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s2">&#34;Let&#39;s goooooooo!&#34;</span> &gt;&gt; README.md
</span></span><span class="line"><span class="cl">git init
</span></span><span class="line"><span class="cl">git add README.md
</span></span><span class="line"><span class="cl">git commit -m <span class="s2">&#34;The first and final legitimate commit in this repository ...&#34;</span>
</span></span><span class="line"><span class="cl">git branch -M main
</span></span><span class="line"><span class="cl">git remote add origin git@github.com:&lt;account&gt;/github-participation.git
</span></span><span class="line"><span class="cl">git push -u origin main</span></span></code></pre></div>
</div>
<p>Of course, replace <code>&lt;account&gt;</code> with the name of your Github account.</p>
<h3 id="writing-some-code">
  <a class="heading-link" href="#writing-some-code">Writing Some Code<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h3>
<p>Here comes the best part! What, you didn&rsquo;t think you&rsquo;d walk away from this article without writing a bit of code, did you?</p>
<p>This script is super-simple. There&rsquo;s no need for elegance here as we&rsquo;re probably only ever going to run this code once or twice. I&rsquo;ll show you the full snippet and then walk you through the details.</p>
<div class="code-block">
  <div class="code-head">
    <span class="code-file"></span>
    <span class="code-lang">Bash</span>
  </div>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">start</span><span class="o">=</span>2021-05-01
</span></span><span class="line"><span class="cl"><span class="nv">stop</span><span class="o">=</span>2021-05-09
</span></span><span class="line"><span class="cl"><span class="nv">max</span><span class="o">=</span><span class="m">20</span>
</span></span><span class="line"><span class="cl"><span class="k">while</span> <span class="o">[[</span> <span class="s2">&#34;</span><span class="si">${</span><span class="nv">start</span><span class="si">}</span><span class="s2">&#34;</span> !<span class="o">=</span> <span class="s2">&#34;</span><span class="si">${</span><span class="nv">stop</span><span class="si">}</span><span class="s2">&#34;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">do</span> 
</span></span><span class="line"><span class="cl">  <span class="nv">start</span><span class="o">=</span><span class="k">$(</span>gdate -I -d <span class="s2">&#34;</span><span class="si">${</span><span class="nv">start</span><span class="si">}</span><span class="s2"> + 1 day&#34;</span><span class="k">)</span>
</span></span><span class="line"><span class="cl">  <span class="k">for</span> <span class="o">((</span><span class="nv">run</span><span class="o">=</span>1<span class="p">;</span> run &lt;<span class="o">=</span> <span class="k">$((</span>RANDOM <span class="o">%</span> max <span class="o">+</span> <span class="m">1</span><span class="k">))</span><span class="p">;</span> run++<span class="o">))</span><span class="p">;</span> <span class="k">do</span>
</span></span><span class="line"><span class="cl">    openssl rand -hex <span class="m">32</span> &gt; touch.txt
</span></span><span class="line"><span class="cl">    git add -A
</span></span><span class="line"><span class="cl">    <span class="nb">export</span> <span class="nv">GIT_AUTHOR_DATE</span><span class="o">=</span><span class="s2">&#34;</span><span class="si">${</span><span class="nv">start</span><span class="si">}</span><span class="s2">T00:01&#34;</span>
</span></span><span class="line"><span class="cl">    <span class="nb">export</span> <span class="nv">GIT_COMMITTER_DATE</span><span class="o">=</span><span class="s2">&#34;</span><span class="si">${</span><span class="nv">GIT_AUTHOR_DATE</span><span class="si">}</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">    git commit -m <span class="s2">&#34;Touch #</span><span class="si">${</span><span class="nv">run</span><span class="si">}</span><span class="s2"> for </span><span class="si">${</span><span class="nv">GIT_AUTHOR_DATE</span><span class="si">}</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="k">done</span>
</span></span><span class="line"><span class="cl"><span class="k">done</span></span></span></code></pre></div>
</div>
<p>First things first, we only need to know three things to get started:</p>
<ol>
<li><code>start</code>: The day of our first &ldquo;commit&rdquo; in the format of <code>YYYY-MM-DD</code>.</li>
<li><code>stop</code>: The day of our last &ldquo;commit&rdquo; in the format of <code>YYYY-MM-DD</code>.</li>
<li><code>max</code>: We don&rsquo;t want a single commit per day. Otherwise, the graph will be all one colour and not at all random enough to look legitimate. So, to account for this, we randomly create between <code>1</code> and <code>20</code> commits per day.</li>
</ol>
<p>We start a <code>while</code> loop that keeps going until our <code>start</code> and <code>stop</code> strings are no longer different. With each iteration, we add <code>1</code> day to our <code>start</code> variable. Eventually, this date will increment until both <code>start</code> and <code>stop</code> strings are equal, thus ending the loop.</p>
<p>For each day iteration, we create another loop that randomly-iterates anywhere between <code>1</code> and <code>max</code> times. Within each nested iteration we replace the content of the file named <code>touch.txt</code> with a random value making it a unique commit.</p>
<p>We then stage this change and assign a date value to both the <code>GIT_AUTHOR_DATE</code> and <code>GIT_COMMITTER_DATE</code> environmental variables. These are what allow you to easily back date a commit.</p>
<p>Finally, we commit this unique change locally. This keeps happening for every day until the script stops.</p>
<p>Write this to an executable file, or just paste it into your terminal of choice and hit <code>enter</code>. If you see the following kind of log output, you know you&rsquo;re doing the right thing:</p>
<div class="code-block">
  <div class="code-head">
    <span class="code-file"></span>
    <span class="code-lang">Bash</span>
  </div>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="o">[</span>main 2ebb5b9<span class="o">]</span> Touch <span class="c1">#1 2021-05-07T00:01</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span> file changed, <span class="m">1</span> insertion<span class="o">(</span>+<span class="o">)</span>, <span class="m">1</span> deletion<span class="o">(</span>-<span class="o">)</span>
</span></span><span class="line"><span class="cl"><span class="o">[</span>main e104b0a<span class="o">]</span> Touch <span class="c1">#2 2021-05-07T00:01</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span> file changed, <span class="m">1</span> insertion<span class="o">(</span>+<span class="o">)</span>, <span class="m">1</span> deletion<span class="o">(</span>-<span class="o">)</span>
</span></span><span class="line"><span class="cl"><span class="o">[</span>main 873fa39<span class="o">]</span> Touch <span class="c1">#3 2021-05-07T00:01</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span> file changed, <span class="m">1</span> insertion<span class="o">(</span>+<span class="o">)</span>, <span class="m">1</span> deletion<span class="o">(</span>-<span class="o">)</span>
</span></span><span class="line"><span class="cl"><span class="o">[</span>main 9def564<span class="o">]</span> Touch <span class="c1">#4 2021-05-07T00:01</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span> file changed, <span class="m">1</span> insertion<span class="o">(</span>+<span class="o">)</span>, <span class="m">1</span> deletion<span class="o">(</span>-<span class="o">)</span>
</span></span><span class="line"><span class="cl"><span class="o">[</span>main 1b83187<span class="o">]</span> Touch <span class="c1">#1 2021-05-08T00:01</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span> file changed, <span class="m">1</span> insertion<span class="o">(</span>+<span class="o">)</span>, <span class="m">1</span> deletion<span class="o">(</span>-<span class="o">)</span>
</span></span><span class="line"><span class="cl"><span class="o">[</span>main b9f00db<span class="o">]</span> Touch <span class="c1">#2 2021-05-08T00:01</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span> file changed, <span class="m">1</span> insertion<span class="o">(</span>+<span class="o">)</span>, <span class="m">1</span> deletion<span class="o">(</span>-<span class="o">)</span></span></span></code></pre></div>
</div>
<p>Now, you simply have to push all your changes up to your repository on Github!</p>
<div class="code-block">
  <div class="code-head">
    <span class="code-file"></span>
    <span class="code-lang">Bash</span>
  </div>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git push origin main</span></span></code></pre></div>
</div>
<p>All you now have to do is sit back and wait for everything to update.</p>
<p>We&rsquo;ve gone from barren landscape:</p>
<p><img
  src="https://wilhelm.codes/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-3_hu_57ee498a4822644c.webp"
  srcset="/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-3_hu_57ee498a4822644c.webp 736w"
  sizes="(max-width: 48rem) 100vw, 736px"
  width="736"
  height="185"
  alt=""
  
  loading="lazy"
  decoding="async"
/>
</p>
<p>To a verdant garden paradise:</p>
<p><img
  src="https://wilhelm.codes/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-4_hu_86315f66da62beba.webp"
  srcset="/blog/falsifying-github-participation-graphs-for-fun-and-profit/image-4_hu_86315f66da62beba.webp 736w"
  sizes="(max-width: 48rem) 100vw, 736px"
  width="736"
  height="184"
  alt=""
  
  loading="lazy"
  decoding="async"
/>
</p>
<p>And that&rsquo;s it! 🎉</p>
<p>If you&rsquo;ve made a mistake, simply delete your private repository and try again with a fresh one.</p>
<h2 id="any-final-thoughts">
  <a class="heading-link" href="#any-final-thoughts">Any final thoughts?<span class="heading-anchor" aria-hidden="true">#</span>
  </a>
</h2>
<p>Job hunting is hard enough. Especially with more and more companies becoming increasingly risk-averse in their interviewing and recruiting processes. It&rsquo;s my hope that this little bit of harmless mischief will make things a bit easier for you!</p>]]></content:encoded></item></channel></rss>