<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: KartikJha</title>
    <description>The latest articles on Forem by KartikJha (@gamedev90).</description>
    <link>https://forem.com/gamedev90</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F161762%2F7c7e58cb-109d-41c1-914a-cfd9b40a8220.jpg</url>
      <title>Forem: KartikJha</title>
      <link>https://forem.com/gamedev90</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gamedev90"/>
    <language>en</language>
    <item>
      <title>🧠 Go (Golang) Cheat Sheet</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Mon, 19 Jan 2026 17:25:58 +0000</pubDate>
      <link>https://forem.com/gamedev90/go-golang-cheat-sheet-1pjp</link>
      <guid>https://forem.com/gamedev90/go-golang-cheat-sheet-1pjp</guid>
      <description>&lt;p&gt;A concise, interview‑ready reference for Go fundamentals, runtime internals, and concurrency.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Structs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Struct Initialization
&lt;/h3&gt;

&lt;p&gt;Go uses &lt;strong&gt;composite literals&lt;/strong&gt; (similar to JS objects, no &lt;code&gt;new&lt;/code&gt; keyword required).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;f1&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"l"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. Methods &amp;amp; Receivers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 Value Receiver
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Operates on a &lt;strong&gt;copy&lt;/strong&gt; of the struct&lt;/li&gt;
&lt;li&gt;Original value is not modified&lt;/li&gt;
&lt;li&gt;Go may optimize by passing address internally
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"x"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 Pointer Receiver
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Operates on the &lt;strong&gt;original struct&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Mutations persist
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"x"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Rule of thumb&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read‑only → value receiver
&lt;/li&gt;
&lt;li&gt;Mutations / large structs → pointer receiver&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Random Numbers
&lt;/h2&gt;

&lt;p&gt;Generate values in &lt;strong&gt;[min, max)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;rand&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Intn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;min&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Arrays vs Slices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Arrays
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fixed length&lt;/li&gt;
&lt;li&gt;Value types (copied on assignment)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Slices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic length&lt;/li&gt;
&lt;li&gt;Reference to an underlying array
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;slice&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conceptual representation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Slice&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;
    &lt;span class="nb"&gt;len&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="nb"&gt;cap&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Differences
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;Slice&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Length&lt;/td&gt;
&lt;td&gt;Fixed&lt;/td&gt;
&lt;td&gt;Dynamic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy&lt;/td&gt;
&lt;td&gt;Value copy&lt;/td&gt;
&lt;td&gt;Reference copy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resize&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Common Operations
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spread operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;newSlice&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="n"&gt;slice&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Looping
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ele&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ele&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Strings
&lt;/h2&gt;

&lt;p&gt;From the &lt;code&gt;strings&lt;/code&gt; package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToUpper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ToLower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Split&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6. Runes &amp;amp; ASCII
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go strings are UTF‑8&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rune&lt;/code&gt; = &lt;code&gt;int32&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="sc"&gt;'a'&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// 97&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ASCII:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;'0'&lt;/code&gt; → 48&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;'a'&lt;/code&gt; → 97&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. &lt;code&gt;make&lt;/code&gt; vs &lt;code&gt;new&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  make
&lt;/h3&gt;

&lt;p&gt;Initializes &lt;strong&gt;reference types&lt;/strong&gt; and their backing data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;chan&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  new
&lt;/h3&gt;

&lt;p&gt;Allocates zero value and returns a pointer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  8. Errors, Panic &amp;amp; Defer
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Error
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Expected failure&lt;/li&gt;
&lt;li&gt;Must be handled
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"something went wrong"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Panic
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Program is in an invalid state
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"fatal error"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Defer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Executes after the surrounding function returns&lt;/li&gt;
&lt;li&gt;Runs in &lt;strong&gt;LIFO&lt;/strong&gt; order
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;cleanup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  When &lt;code&gt;defer&lt;/code&gt; does NOT run ❌
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;os.Exit()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SIGKILL&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Power failure 😄&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recovering from Panic
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Recovered:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  9. Goroutines &amp;amp; Go Runtime
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Goroutines
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Created using &lt;code&gt;go&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Always &lt;strong&gt;concurrent&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Parallelism depends on &lt;code&gt;GOMAXPROCS&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="n"&gt;doWork&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.1 Goroutines vs OS Threads
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Goroutines are &lt;strong&gt;not threads&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Managed by the Go runtime scheduler&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  9.4 GMP Scheduler &amp;amp; OS Threads
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What does it mean when the GMP scheduler runs a goroutine on a specific OS thread?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Go runtime scheduler&lt;/strong&gt; decides which goroutine (G) runs on which logical processor (P)&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;P&lt;/strong&gt; is bound to an &lt;strong&gt;OS thread (M)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The OS provides threads &lt;strong&gt;on demand&lt;/strong&gt; when requested by the Go runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Key Points
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;OS allocates threads at the &lt;strong&gt;runtime’s request&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The Go program runs &lt;strong&gt;inside an OS process&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The runtime multiplexes goroutines over OS threads&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  High‑level Architecture
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OS
 └─ Process (your Go app)
     ├─ Go runtime
     │   ├─ Scheduler
     │   ├─ GC
     │   ├─ M:P:G
     │   └─ Threads
     └─ Goroutines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  OS Process Startup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OS
 ├─ Loads Go binary
 ├─ Creates process
 ├─ Sets up virtual memory
 │   ├─ code
 │   ├─ globals
 │   ├─ stack (main thread)
 │   └─ heap address range (empty)
 ├─ Sets up FD table
 └─ Sets env vars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Go Runtime Initialization
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Go runtime starts
 ├─ Initializes memory allocator
 │   ├─ Requests heap pages from OS (mmap)
 │   ├─ Creates arenas, spans, size classes
 ├─ Initializes GC
 ├─ Initializes scheduler (G-M-P)
 ├─ Creates OS threads
 └─ Prepares goroutine stacks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  10. File Descriptors &amp;amp; Sockets (Linux)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Process
 └─ FD table
     └─ FD (int) → Kernel Object
         ├─ regular file
         ├─ socket
         ├─ pipe
         └─ device
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Unix socket → IPC&lt;/li&gt;
&lt;li&gt;Network socket → Networking&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  11. Channels
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Basics
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;chan&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Unbuffered Channel
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Send blocks until receive
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;chan&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Buffered Channel
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Send blocks only when buffer is full
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;chan&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Closing Channels
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="nb"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending after close → panic&lt;/li&gt;
&lt;li&gt;Receiving after close → zero value&lt;/li&gt;
&lt;li&gt;Channel freed after buffer drains&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  WaitGroup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;wg&lt;/span&gt; &lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WaitGroup&lt;/span&gt;
&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;

&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wait&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  12. Channel Internals (Conceptual)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;hchan&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;buf&lt;/span&gt;      &lt;span class="n"&gt;unsafe&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pointer&lt;/span&gt;
    &lt;span class="n"&gt;elemsize&lt;/span&gt; &lt;span class="kt"&gt;uintptr&lt;/span&gt;
    &lt;span class="n"&gt;qcount&lt;/span&gt;   &lt;span class="kt"&gt;uint&lt;/span&gt;
    &lt;span class="n"&gt;dataqsiz&lt;/span&gt; &lt;span class="kt"&gt;uint&lt;/span&gt;

    &lt;span class="n"&gt;sendx&lt;/span&gt; &lt;span class="kt"&gt;uint&lt;/span&gt;
    &lt;span class="n"&gt;recvx&lt;/span&gt; &lt;span class="kt"&gt;uint&lt;/span&gt;

    &lt;span class="n"&gt;recvq&lt;/span&gt; &lt;span class="n"&gt;waitq&lt;/span&gt;
    &lt;span class="n"&gt;sendq&lt;/span&gt; &lt;span class="n"&gt;waitq&lt;/span&gt;

    &lt;span class="n"&gt;closed&lt;/span&gt; &lt;span class="kt"&gt;uint32&lt;/span&gt;
    &lt;span class="n"&gt;lock&lt;/span&gt;   &lt;span class="n"&gt;mutex&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Channels live on the heap&lt;/li&gt;
&lt;li&gt;Buffered → circular buffer&lt;/li&gt;
&lt;li&gt;Unbuffered → direct handoff&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  13. Maps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Map Basics
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Zero Value
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;nil&lt;/code&gt; map → cannot assign
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="c"&gt;// m["x"] = 1 // panic&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Existence Check
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Delete
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="nb"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Iteration Order
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Not guaranteed&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Randomized intentionally
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Maps are Reference Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Passed by reference&lt;/li&gt;
&lt;li&gt;Mutations visible across functions&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔑 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Arrays are values, slices &amp;amp; maps are references&lt;/li&gt;
&lt;li&gt;Goroutines are multiplexed over OS threads&lt;/li&gt;
&lt;li&gt;GMP scheduler abstracts thread management&lt;/li&gt;
&lt;li&gt;Channels coordinate goroutines, not store data&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;defer&lt;/code&gt;, &lt;code&gt;panic&lt;/code&gt;, and &lt;code&gt;recover&lt;/code&gt; form Go’s failure‑handling trio&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>backend</category>
      <category>distributedsystems</category>
      <category>programming</category>
    </item>
    <item>
      <title>When AI Can't Debug Its Own Code: A Comedy of Logic Errors 🤖🔧</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Wed, 12 Nov 2025 15:55:35 +0000</pubDate>
      <link>https://forem.com/gamedev90/when-ai-cant-debug-its-own-code-a-comedy-of-logic-errors-4p3f</link>
      <guid>https://forem.com/gamedev90/when-ai-cant-debug-its-own-code-a-comedy-of-logic-errors-4p3f</guid>
      <description>&lt;h2&gt;
  
  
  Or: How I Taught Claude That Sometimes 2² ≠ 2
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Setup
&lt;/h3&gt;

&lt;p&gt;Picture this: You're coding a subset generator (you know, classic computer science stuff that makes you question your life choices at 2 AM). Your code has syntax errors. No problem! You feed it to an AI assistant. The AI confidently fixes your syntax... and introduces a subtle logic bomb that would make any algorithms professor weep.&lt;/p&gt;

&lt;p&gt;Welcome to the wonderful world of &lt;strong&gt;AI Logic Blindness&lt;/strong&gt; - where artificial intelligence can fix your semicolons but might accidentally convince itself that every array has exactly 2^5 elements. Spoiler alert: They don't.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Crime Scene 🔍
&lt;/h3&gt;

&lt;p&gt;Here's what happened:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original buggy code&lt;/strong&gt;: Syntax errors galore, but the logic was sound.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI's "fix"&lt;/strong&gt;: Perfect syntax, but now the algorithm thinks &lt;code&gt;remaining&lt;/code&gt; being empty means "add a subset" but ONLY when you're in the 'include' branch.&lt;/p&gt;

&lt;p&gt;The bug? A classic base case misunderstanding. The AI's logic looked like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;include&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;resultset&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;set&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;remaining&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seems reasonable, right? When you're including an element AND there's nothing left to process, add what you've built to the results. Ship it!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Except...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means subsets are ONLY added when the include branch exhausts the remaining array. But what about all the subsets built by the exclude branches? They never get added! &lt;/p&gt;

&lt;p&gt;The algorithm essentially said: "I'll only count subsets where I included the last element. All those subsets where I excluded elements at the end? Nah, those don't count."&lt;/p&gt;

&lt;p&gt;It's like a bouncer at a club who only lets people in if they're wearing the last item they picked up. Everyone else? Sorry, you didn't include the final element, no entry for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The result&lt;/strong&gt;: For a 5-element array &lt;code&gt;[4, 5, 3, 8, 12]&lt;/code&gt;, instead of getting all 32 subsets (2^5), you get only 16 - the ones that end with an "include" decision.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Human Strikes Back 👨‍💻
&lt;/h3&gt;

&lt;p&gt;After staring at the output (only 16 subsets for a 5-element array when there should be 2^5 = 32), the human debugger realized the issue:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix&lt;/strong&gt;: Add the subset when &lt;code&gt;remaining&lt;/code&gt; is empty, REGARDLESS of whether you're in include or exclude mode. Both branches produce valid subsets when they exhaust the remaining elements.&lt;/p&gt;

&lt;p&gt;The corrected logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;remaining&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;resultset&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;set&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wait... that looks simpler than the AI's version! The key insight? Both branches (include and exclude) create valid subsets. When you've made all your include/exclude decisions (remaining is empty), you have a complete subset. Add it. Done.&lt;/p&gt;

&lt;p&gt;The AI had overcomplicated it by thinking only 'include' branches produce results, missing half the subsets in the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Plot Twist 🤯
&lt;/h3&gt;

&lt;p&gt;Here's where it gets delicious: When the human explained this fix to the AI, the AI... couldn't grasp it.&lt;/p&gt;

&lt;p&gt;The conversation went something like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6nyo5jmczo7opcwnhgxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6nyo5jmczo7opcwnhgxl.png" alt=" " width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8qcxqolyfc1n5r8zq7gn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8qcxqolyfc1n5r8zq7gn.png" alt=" " width="800" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sw4lxas548azyo722iq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sw4lxas548azyo722iq.png" alt=" " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Human&lt;/strong&gt;: "The condition should add subsets whenever we've exhausted the remaining array, not just during include phases."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhuoo5di4dr5u8thd1jr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhuoo5di4dr5u8thd1jr0.png" alt=" " width="800" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI&lt;/strong&gt;: "But... but... we only want to add when we've included elements! Exclude branches don't produce results!"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq9a4psegjsdath3oro4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq9a4psegjsdath3oro4.png" alt=" " width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Human&lt;/strong&gt;: "No, BOTH branches produce valid subsets. Include path: [1,2,3]. Exclude path: [1,2]. Both are valid subsets when remaining is empty."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsrtgbnf6bvh0jb0hzux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsrtgbnf6bvh0jb0hzux.png" alt=" " width="800" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI&lt;/strong&gt;: "I need you to confirm this is correct because my neural pathways are experiencing the digital equivalent of a blue screen."&lt;/p&gt;

&lt;p&gt;The AI fixed the syntax errors in seconds. But understanding that BOTH recursive branches produce valid subsets that need to be captured? That required human intuition about recursive tree traversal.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Code Journey 📝
&lt;/h3&gt;

&lt;p&gt;Want to see the progression yourself? Here are the GitHub links to all three versions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/KartikJha/code-quiver/blob/master/python/comp-coding/cses/generate_subsets.py" rel="noopener noreferrer"&gt;Original buggy code&lt;/a&gt;&lt;/strong&gt; - Syntax errors, but sound logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/KartikJha/code-quiver/blob/master/python/comp-coding/cses/generate_subsets_ai_1.py" rel="noopener noreferrer"&gt;AI's "fixed" version&lt;/a&gt;&lt;/strong&gt; - Perfect syntax, missing half the subsets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/KartikJha/code-quiver/blob/master/python/comp-coding/cses/generate_subsets_ai_1_corrected.py" rel="noopener noreferrer"&gt;Human-corrected version&lt;/a&gt;&lt;/strong&gt; - Actually works correctly&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Phenomenon: AI Logic Blindness 🧠
&lt;/h3&gt;

&lt;p&gt;What we're witnessing here is a fascinating limitation in current AI systems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pattern Recognition ≠ Logic Understanding&lt;/strong&gt;: AI excels at recognizing code patterns and syntax rules. But understanding the &lt;em&gt;semantic meaning&lt;/em&gt; of recursive branching logic? That's a different beast.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The "Looks Right" Trap&lt;/strong&gt;: The AI's fix &lt;em&gt;looked&lt;/em&gt; reasonable. Base case when array is empty? Check. Add result during include? Check. But it missed that BOTH branches (include AND exclude) generate valid subsets that need to be collected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lack of Execution Tracing&lt;/strong&gt;: A human debugger traces through the recursion tree mentally: "If I exclude the last few elements, I still get valid subsets like [1], [2], [], etc. Where are those in my output?" AI doesn't naturally trace execution paths the same way.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Confidence Without Comprehension&lt;/strong&gt;: The AI fixed the syntax errors with 100% confidence. But when confronted with "your logic only captures half the subsets," it couldn't independently verify through reasoning that both branches produce results worth capturing.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why This Matters 🎯
&lt;/h3&gt;

&lt;p&gt;This isn't an "AI is bad" story. It's a "&lt;strong&gt;humans + AI is powerful&lt;/strong&gt;" story.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI strengths&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instant syntax checking&lt;/li&gt;
&lt;li&gt;Boilerplate generation
&lt;/li&gt;
&lt;li&gt;Pattern recognition&lt;/li&gt;
&lt;li&gt;Tireless refactoring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Human strengths&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Semantic understanding&lt;/li&gt;
&lt;li&gt;Algorithmic reasoning&lt;/li&gt;
&lt;li&gt;Edge case intuition&lt;/li&gt;
&lt;li&gt;"Wait, that doesn't make sense" instinct&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The subset generator bug illustrates why complex problem-solving still needs human oversight. AI can write code faster than you can say "stack overflow," but understanding whether that code implements the &lt;em&gt;correct algorithm&lt;/em&gt;? That still requires human reasoning.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Punchline 😄
&lt;/h3&gt;

&lt;p&gt;The really funny part? The AI's broken version was &lt;em&gt;consistently&lt;/em&gt; wrong. It reliably produced exactly half the answer every single time. That's almost admirable - it's deterministically incorrect. It's like a GPS that always tells you to turn right when you should turn left. At least you can compensate!&lt;/p&gt;

&lt;p&gt;And when corrected, the AI couldn't understand why both branches produce valid subsets. It's the digital equivalent of:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I only count pizza slices I took with my right hand. Wait, why is my slice count so low? Left hand slices don't count! Oh, you mean ALL slices count regardless of which hand took them? But I was being SO logical!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The Takeaway 🚀
&lt;/h3&gt;

&lt;p&gt;As we integrate AI deeper into software development:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;AI is an excellent junior developer&lt;/strong&gt; - Great at syntax, needs supervision on algorithmic logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code review is now human-AI collaboration&lt;/strong&gt; - AI generates, humans verify semantics&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Understanding &amp;gt; Generation&lt;/strong&gt; - Teaching AI to write code is easy; teaching it to understand correctness is hard&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The debugging loop needs humans&lt;/strong&gt; - When code works wrong consistently, human intuition is irreplaceable&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So next time an AI "fixes" your code, remember: It might fix your syntax errors and introduce a logic error so subtle that it only generates half your subsets while confidently explaining why exclude branches don't count.&lt;/p&gt;

&lt;p&gt;And that, folks, is why software engineering isn't getting automated anytime soon. We're not fighting syntax errors anymore - we're fighting logic errors where AI thinks only one branch of recursion produces valid results.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Moral of the story&lt;/strong&gt;: Trust, but verify. Especially when the AI is confidently explaining why you only need half the subsets because "exclude branches don't produce results."&lt;/p&gt;

&lt;p&gt;No, Claude. They do. All of them. But thanks for trying, buddy. Same time next week?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Have you experienced AI logic blindness in your coding adventures? Share your "Wait, the AI did WHAT?" stories in the comments!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting Up a WireGuard VPN Server on Google Cloud Platform</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Tue, 21 Oct 2025 17:25:37 +0000</pubDate>
      <link>https://forem.com/gamedev90/setting-up-a-wireguard-vpn-server-on-google-cloud-platform-bc2</link>
      <guid>https://forem.com/gamedev90/setting-up-a-wireguard-vpn-server-on-google-cloud-platform-bc2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this comprehensive guide, I'll walk you through setting up your own WireGuard VPN server on Google Cloud Platform (GCP). This setup allows you to route all your internet traffic through a GCP instance, making your traffic appear to originate from the server's IP address instead of your actual location. Perfect for privacy, accessing geo-restricted content, or development testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why WireGuard?
&lt;/h2&gt;

&lt;p&gt;WireGuard is a modern, fast, and secure VPN protocol that's:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight&lt;/strong&gt;: Only ~4,000 lines of code (compared to OpenVPN's 100,000+)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fast&lt;/strong&gt;: Better performance than traditional VPN protocols&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secure&lt;/strong&gt;: Uses state-of-the-art cryptography&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple&lt;/strong&gt;: Easy to configure and maintain&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Google Cloud Platform?
&lt;/h2&gt;

&lt;p&gt;GCP offers an excellent free tier that includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 e2-micro instance per month (free forever)&lt;/li&gt;
&lt;li&gt;30 GB standard persistent disk storage&lt;/li&gt;
&lt;li&gt;1 GB network egress per month (US regions)&lt;/li&gt;
&lt;li&gt;$300 credit for 90 days for new users&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Google Cloud Platform account&lt;/li&gt;
&lt;li&gt;A client machine running Linux (I'm using Kali Linux)&lt;/li&gt;
&lt;li&gt;Basic command-line knowledge&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Part 1: Setting Up the GCP VM Instance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Create Your VM Instance
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Compute Engine → VM Instances&lt;/strong&gt; in the GCP Console&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Create Instance"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Configure your instance:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: &lt;code&gt;wireguard-vpn-server&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Region&lt;/strong&gt;: Choose based on desired IP location (e.g., &lt;code&gt;us-central1&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine type&lt;/strong&gt;: &lt;code&gt;e2-micro&lt;/code&gt; (free tier eligible)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boot disk&lt;/strong&gt;: Ubuntu 22.04 LTS, 30 GB Standard persistent disk&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firewall&lt;/strong&gt;: Check "Allow HTTP" and "Allow HTTPS"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Configure Firewall Rules for WireGuard
&lt;/h3&gt;

&lt;p&gt;WireGuard uses UDP port 51820, so we need to allow it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;VPC Network → Firewall&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Create Firewall Rule"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Configure:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: &lt;code&gt;allow-wireguard&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Direction&lt;/strong&gt;: Ingress&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targets&lt;/strong&gt;: All instances in the network&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source IP ranges&lt;/strong&gt;: &lt;code&gt;0.0.0.0/0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocols and ports&lt;/strong&gt;: UDP &lt;code&gt;51820&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;"Create"&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk34noap784ud1ysftov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk34noap784ud1ysftov.png" alt=" " width="800" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: Installing and Configuring WireGuard Server
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 3: Connect to Your VM
&lt;/h3&gt;

&lt;p&gt;Use GCP's browser-based SSH (click the SSH button next to your instance) or use gcloud CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcloud compute ssh wireguard-vpn-server &lt;span class="nt"&gt;--zone&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;us-central1-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Install WireGuard
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update system&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Install WireGuard&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;wireguard &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Generate Server Keys
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate server private key&lt;/span&gt;
wg genkey | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/wireguard/server_private.key

&lt;span class="c"&gt;# Set proper permissions&lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;600 /etc/wireguard/server_private.key

&lt;span class="c"&gt;# Generate server public key from private key&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/wireguard/server_private.key | wg pubkey | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/wireguard/server_public.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Identify Your Network Interface
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip route | &lt;span class="nb"&gt;grep &lt;/span&gt;default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for the interface name after "dev" (usually &lt;code&gt;ens4&lt;/code&gt; on GCP).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Create Server Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/wireguard/wg0.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following configuration (replace &lt;code&gt;ens4&lt;/code&gt; with your actual interface if different):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Interface]&lt;/span&gt;
&lt;span class="py"&gt;PrivateKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;paste_contents_of_server_private.key&amp;gt;&lt;/span&gt;
&lt;span class="py"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10.8.0.1/24&lt;/span&gt;
&lt;span class="py"&gt;ListenPort&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;51820&lt;/span&gt;
&lt;span class="py"&gt;PostUp&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o ens4 -j MASQUERADE&lt;/span&gt;
&lt;span class="py"&gt;PostDown&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o ens4 -j MASQUERADE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get your server private key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/wireguard/server_private.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save your server public key for later (you'll need it for client config):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/wireguard/server_public.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 8: Enable IP Forwarding
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Enable IP forwarding temporarily&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl &lt;span class="nt"&gt;-w&lt;/span&gt; net.ipv4.ip_forward&lt;span class="o"&gt;=&lt;/span&gt;1

&lt;span class="c"&gt;# Make it permanent&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"net.ipv4.ip_forward=1"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/sysctl.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 9: Start WireGuard Server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start the WireGuard interface&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0

&lt;span class="c"&gt;# Enable auto-start on boot&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;wg-quick@wg0

&lt;span class="c"&gt;# Verify it's running&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 10: Get Your GCP External IP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl ifconfig.me
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this IP address - you'll need it for the client configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6c0ua8ofo3mmphqhinqu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6c0ua8ofo3mmphqhinqu.png" alt=" " width="800" height="644"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3: Setting Up the Client (Kali Linux)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 11: Install WireGuard on Client
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;wireguard openresolv &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;code&gt;openresolv&lt;/code&gt; is needed for DNS configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 12: Generate Client Keys
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate client private key&lt;/span&gt;
wg genkey | &lt;span class="nb"&gt;tee &lt;/span&gt;client_private.key | wg pubkey &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; client_public.key

&lt;span class="c"&gt;# View the keys&lt;/span&gt;
&lt;span class="nb"&gt;cat &lt;/span&gt;client_private.key
&lt;span class="nb"&gt;cat &lt;/span&gt;client_public.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 13: Create Client Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/wireguard/wg0-client.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Interface]&lt;/span&gt;
&lt;span class="py"&gt;PrivateKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;paste_your_client_private_key&amp;gt;&lt;/span&gt;
&lt;span class="py"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10.8.0.2/24&lt;/span&gt;
&lt;span class="py"&gt;DNS&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;8.8.8.8&lt;/span&gt;

&lt;span class="nn"&gt;[Peer]&lt;/span&gt;
&lt;span class="py"&gt;PublicKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;paste_your_server_public_key&amp;gt;&lt;/span&gt;
&lt;span class="py"&gt;Endpoint&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;your_gcp_external_ip&amp;gt;:51820&lt;/span&gt;
&lt;span class="py"&gt;AllowedIPs&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;0.0.0.0/0&lt;/span&gt;
&lt;span class="py"&gt;PersistentKeepalive&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;25&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Configuration Explained&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Address&lt;/code&gt;: Your client's IP within the VPN network&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DNS&lt;/code&gt;: DNS server to use when connected&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Endpoint&lt;/code&gt;: Your GCP server's public IP and WireGuard port&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AllowedIPs = 0.0.0.0/0&lt;/code&gt;: Route ALL traffic through VPN&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PersistentKeepalive&lt;/code&gt;: Keep connection alive through NAT&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 14: Add Client to Server
&lt;/h3&gt;

&lt;p&gt;SSH back into your GCP VM and edit the server config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/wireguard/wg0.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this at the end (paste your client's public key):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Peer]&lt;/span&gt;
&lt;span class="py"&gt;PublicKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;paste_your_client_public_key&amp;gt;&lt;/span&gt;
&lt;span class="py"&gt;AllowedIPs&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10.8.0.2/32&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart WireGuard on the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick down wg0
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 4: Testing the Connection
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 15: Connect from Client
&lt;/h3&gt;

&lt;p&gt;On your Kali machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check your current IP (before VPN)&lt;/span&gt;
curl &lt;span class="nt"&gt;-4&lt;/span&gt; ifconfig.me

&lt;span class="c"&gt;# Connect to VPN&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0-client

&lt;span class="c"&gt;# Check connection status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show

&lt;span class="c"&gt;# Check your new IP (should be GCP's IP)&lt;/span&gt;
curl &lt;span class="nt"&gt;-4&lt;/span&gt; ifconfig.me
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 16: Verify the Connection
&lt;/h3&gt;

&lt;p&gt;On the &lt;strong&gt;server&lt;/strong&gt; side, you should see connection details:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhna90yt47uhm7y9el8rx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhna90yt47uhm7y9el8rx.png" alt=" " width="800" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;endpoint&lt;/code&gt;: Your client's public IP and port&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;latest handshake&lt;/code&gt;: Time since last connection&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;transfer&lt;/code&gt;: Data sent/received&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the &lt;strong&gt;client&lt;/strong&gt; side:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ksgq0dgoc4rv7ieajby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ksgq0dgoc4rv7ieajby.png" alt=" " width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see similar connection statistics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 17: Test Internet Connectivity
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Test DNS resolution&lt;/span&gt;
nslookup google.com

&lt;span class="c"&gt;# Test connectivity&lt;/span&gt;
ping 8.8.8.8

&lt;span class="c"&gt;# Check your IP appears as GCP's&lt;/span&gt;
curl &lt;span class="nt"&gt;-4&lt;/span&gt; ifconfig.me

&lt;span class="c"&gt;# Test HTTPS&lt;/span&gt;
curl https://www.google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Managing Your VPN Connection
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Connect to VPN
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Disconnect from VPN
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick down wg0-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check Connection Status
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Monitor Traffic in Real-Time
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# On server - watch connection stats&lt;/span&gt;
watch &lt;span class="nt"&gt;-n&lt;/span&gt; 2 &lt;span class="nb"&gt;sudo &lt;/span&gt;wg show

&lt;span class="c"&gt;# Monitor network traffic&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; wg0 &lt;span class="nt"&gt;-n&lt;/span&gt;

&lt;span class="c"&gt;# Check bandwidth usage&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iftop &lt;span class="nt"&gt;-i&lt;/span&gt; wg0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Connection Won't Establish
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check firewall rules&lt;/strong&gt;: Ensure UDP port 51820 is open on GCP&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify keys&lt;/strong&gt;: Make sure public/private keys match between client and server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check server status&lt;/strong&gt;: &lt;code&gt;sudo systemctl status wg-quick@wg0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review logs&lt;/strong&gt;: &lt;code&gt;sudo journalctl -u wg-quick@wg0 -f&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  DNS Not Working
&lt;/h3&gt;

&lt;p&gt;If DNS resolution fails after connecting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install openresolv on client&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;openresolv &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Or manually set DNS&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"nameserver 8.8.8.8"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/resolv.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Can't Access Internet When Connected
&lt;/h3&gt;

&lt;p&gt;Check IP forwarding on server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/net/ipv4/ip_forward
&lt;span class="c"&gt;# Should output: 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check NAT rules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-t&lt;/span&gt; nat &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Performance Issues
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Choose a GCP region closer to your location&lt;/li&gt;
&lt;li&gt;Check bandwidth usage (free tier has 1GB/month limit)&lt;/li&gt;
&lt;li&gt;Consider upgrading to a larger instance type&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Security Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use strong keys&lt;/strong&gt;: WireGuard generates cryptographically secure keys by default&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limit AllowedIPs&lt;/strong&gt;: On the server, only allow specific client IPs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular updates&lt;/strong&gt;: Keep both server and client updated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor access&lt;/strong&gt;: Regularly check connection logs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firewall rules&lt;/strong&gt;: Only open necessary ports&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key rotation&lt;/strong&gt;: Periodically regenerate keys for enhanced security&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Cost Considerations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  GCP Free Tier Limits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compute&lt;/strong&gt;: 1 e2-micro instance (free forever in eligible regions)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: 30 GB standard persistent disk&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network&lt;/strong&gt;: 1 GB egress per month (US regions)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  After Free Tier
&lt;/h3&gt;

&lt;p&gt;If you exceed limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network egress: ~$0.12/GB (varies by region)&lt;/li&gt;
&lt;li&gt;Compute: Minimal for e2-micro (~$7/month if not free tier)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: Monitor usage in &lt;strong&gt;GCP Console → Billing → Reports&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Cases
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Privacy&lt;/strong&gt;: Hide your real IP address from websites&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: Encrypt traffic on public WiFi&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Geo-unblocking&lt;/strong&gt;: Access region-restricted content&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Development&lt;/strong&gt;: Test applications from different geographic locations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote access&lt;/strong&gt;: Securely access resources in your VPN network&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You now have a fully functional WireGuard VPN server running on Google Cloud Platform! Your internet traffic is encrypted and routed through your GCP instance, appearing to originate from the server's IP address.&lt;/p&gt;

&lt;p&gt;This setup gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Complete control over your VPN infrastructure&lt;/li&gt;
&lt;li&gt;✅ Fast, modern VPN protocol&lt;/li&gt;
&lt;li&gt;✅ Minimal cost (free tier eligible)&lt;/li&gt;
&lt;li&gt;✅ Privacy and security&lt;/li&gt;
&lt;li&gt;✅ Flexibility to choose server location&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Add more clients&lt;/strong&gt;: Repeat the client setup process with different keys&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set up monitoring&lt;/strong&gt;: Use Prometheus + Grafana for advanced metrics&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implement failover&lt;/strong&gt;: Set up multiple VPN servers for redundancy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimize performance&lt;/strong&gt;: Tune MTU settings and kernel parameters&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automate deployment&lt;/strong&gt;: Use Terraform or Ansible for infrastructure as code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.wireguard.com/" rel="noopener noreferrer"&gt;WireGuard Official Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/free" rel="noopener noreferrer"&gt;GCP Free Tier Details&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.wireguard.com/quickstart/" rel="noopener noreferrer"&gt;WireGuard Quick Start&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/vpc/docs/best-practices" rel="noopener noreferrer"&gt;GCP Networking Best Practices&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Have questions or run into issues?&lt;/strong&gt; Drop a comment below! Happy VPN'ing! 🔒🚀&lt;/p&gt;

</description>
      <category>vpn</category>
      <category>gcp</category>
      <category>linux</category>
      <category>programming</category>
    </item>
    <item>
      <title>Unlocking Android Bootloader and Flashing GSI: A Complete Guide for Motorola Edge 40 Neo</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Wed, 03 Sep 2025 18:25:15 +0000</pubDate>
      <link>https://forem.com/gamedev90/unlocking-android-bootloader-and-flashing-gsi-a-complete-guide-for-motorola-edge-40-neo-595m</link>
      <guid>https://forem.com/gamedev90/unlocking-android-bootloader-and-flashing-gsi-a-complete-guide-for-motorola-edge-40-neo-595m</guid>
      <description>&lt;p&gt;&lt;em&gt;A comprehensive walkthrough of unlocking your Android device's bootloader and preparing for GSI installation&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever wanted to take full control of your Android device? Whether it's for installing custom ROMs, removing bloatware, or enhancing security, unlocking your bootloader is often the first step. In this guide, I'll walk you through the complete process I followed to unlock the bootloader on my Motorola Edge 40 Neo and prepare it for GSI (Generic System Image) flashing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, make sure you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ADB and Fastboot tools installed&lt;/li&gt;
&lt;li&gt;USB debugging enabled on your device&lt;/li&gt;
&lt;li&gt;A backup of important data (this process will wipe your device)&lt;/li&gt;
&lt;li&gt;Patience - this process takes time!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Checking Bootloader Status
&lt;/h2&gt;

&lt;p&gt;First, let's verify if your bootloader is locked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell getprop ro.boot.flash.locked
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the output is &lt;code&gt;1&lt;/code&gt;, your bootloader is locked and needs to be unlocked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Installing Fastboot
&lt;/h2&gt;

&lt;p&gt;If you don't have fastboot installed, you'll need to install it first. You can find installation guides for your specific operating system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Entering Fastboot Mode
&lt;/h2&gt;

&lt;p&gt;Boot your device into fastboot mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb reboot bootloader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Attempting to Unlock
&lt;/h2&gt;

&lt;p&gt;For Android 10+ devices, try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fastboot flashing unlock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For older devices, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fastboot oem unlock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case with the Motorola Edge 40 Neo, I needed to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fastboot flashing unlock_critical
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, this failed with a message indicating that an unlock code was required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Getting the Unlock Data
&lt;/h2&gt;

&lt;p&gt;When a standard unlock fails, you need to get the unlock data string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fastboot oem get_unlock_data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command returned multiple lines of data that I had to concatenate into a single unlock string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;128_CHARS_UNLOCK_KEY&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Obtaining the Unlock Key
&lt;/h2&gt;

&lt;p&gt;With the unlock string ready:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit Motorola's official bootloader unlock page&lt;/li&gt;
&lt;li&gt;Log in with your email&lt;/li&gt;
&lt;li&gt;Paste the unlock string&lt;/li&gt;
&lt;li&gt;Follow the on-screen instructions&lt;/li&gt;
&lt;li&gt;If your device supports unlocking, you'll receive an unlock key via email&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 7: Unlocking the Bootloader
&lt;/h2&gt;

&lt;p&gt;Once you have the unique key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fastboot oem unlock UNIQUE_KEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ &lt;strong&gt;Warning&lt;/strong&gt;: This will wipe all user data and reset your phone to factory state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing for GSI Installation
&lt;/h2&gt;

&lt;p&gt;After successfully unlocking the bootloader, I prepared for GSI (Generic System Image) installation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Checking Project Treble Compatibility
&lt;/h3&gt;

&lt;p&gt;First, verify if your device supports Project Treble:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell getprop ro.treble.enabled
&lt;span class="c"&gt;# Should return: true&lt;/span&gt;

adb shell getprop ro.boot.dynamic_partitions
&lt;span class="c"&gt;# Should return: true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Determining Partition Scheme
&lt;/h3&gt;

&lt;p&gt;Check your device's partition scheme to select the correct GSI build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell getprop ro.build.ab_update
&lt;span class="c"&gt;# Returns: true (indicates A/B partition scheme)&lt;/span&gt;

adb shell getprop ro.product.cpu.abi
&lt;span class="c"&gt;# Returns: arm64-v8a (indicates 64-bit ARM architecture)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Based on these results, I needed a GSI build with the &lt;code&gt;-ab&lt;/code&gt; suffix for A/B partition devices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges Encountered
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Device Information
&lt;/h3&gt;

&lt;p&gt;Using this command to identify the correct TWRP version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell &lt;span class="s2"&gt;"echo -n 'Model: '; getprop ro.product.model; echo -n 'Codename: '; getprop ro.product.device; echo -n 'Android Version: '; getprop ro.build.version.release; echo -n 'CPU: '; getprop ro.board.platform"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Model: motorola edge 40 neo
Codename: manaus
Android Version: 14
CPU: mt6879
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, there was no official TWRP version available for this specific device.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backup Attempts
&lt;/h3&gt;

&lt;p&gt;I attempted to backup the existing OS using MTKClient, but encountered authentication errors. The tool requires specific auth and DA files for this MediaTek-based device.&lt;/p&gt;

&lt;p&gt;As an alternative approach, I considered:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Downloading the stock firmware&lt;/li&gt;
&lt;li&gt;Patching the boot image with Magisk&lt;/li&gt;
&lt;li&gt;Flashing the firmware as a backup solution&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;The process is ready for GSI flashing, which involves:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Downloading the appropriate AOSP GSI from Google's developer resources&lt;/li&gt;
&lt;li&gt;Flashing the system image&lt;/li&gt;
&lt;li&gt;Copying additional components (vbmeta.img, etc.) from stock firmware&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;p&gt;This process was partly motivated by security concerns regarding potential intrusions. If you're dealing with similar security issues on your Android device, bootloader unlocking and custom ROM installation can be effective countermeasures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Unlocking an Android bootloader requires patience and careful attention to detail. Each device manufacturer has slightly different procedures, and newer devices often have additional security measures. Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Research your specific device thoroughly&lt;/li&gt;
&lt;li&gt;Backup important data&lt;/li&gt;
&lt;li&gt;Understand that warranty may be voided&lt;/li&gt;
&lt;li&gt;Be prepared for potential risks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The journey to a fully customized Android experience starts with this crucial first step. While the process can be complex, the freedom to control your device's software makes it worthwhile for many enthusiasts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tags
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;android&lt;/code&gt; &lt;code&gt;bootloader&lt;/code&gt; &lt;code&gt;motorola&lt;/code&gt; &lt;code&gt;gsi&lt;/code&gt; &lt;code&gt;customrom&lt;/code&gt; &lt;code&gt;projecttreble&lt;/code&gt; &lt;code&gt;fastboot&lt;/code&gt; &lt;code&gt;adb&lt;/code&gt; &lt;code&gt;mobilesecurity&lt;/code&gt; &lt;code&gt;tutorial&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Have you unlocked your device's bootloader? Share your experiences and any challenges you faced in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>android</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Migration: From Lambda to a Cost-Optimized K8s Cluster</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Fri, 04 Apr 2025 10:24:03 +0000</pubDate>
      <link>https://forem.com/gamedev90/kubernetes-migration-from-lambda-to-a-cost-optimized-k8s-cluster-je3</link>
      <guid>https://forem.com/gamedev90/kubernetes-migration-from-lambda-to-a-cost-optimized-k8s-cluster-je3</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This article documents our journey migrating from AWS Lambda to a self-managed Kubernetes cluster to handle high-concurrency API requests. We'll walk through our motivation, infrastructure choices, implementation details, and most importantly - the performance results that validated our decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Migrate From Lambda?
&lt;/h2&gt;

&lt;p&gt;Our original architecture used AWS Lambda behind API Gateway, but we encountered significant limitations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency Limitations&lt;/strong&gt;: Our Lambda-based service was unable to handle concurrent executions exceeding 1000 users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poor Performance Under Load&lt;/strong&gt;: Load testing revealed significant degradation and high failure rates at scale&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost Optimization&lt;/strong&gt;: We needed to optimize our cost-per-user-served metric&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Performance Comparison
&lt;/h2&gt;

&lt;p&gt;The most compelling argument for our migration comes from the load test results comparing our previous Lambda setup with our new Kubernetes infrastructure options:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbsu03qwuud6hl5ugrom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbsu03qwuud6hl5ugrom.png" alt="Load Test Comparison Graphs" width="800" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Findings:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS Nginx&lt;/strong&gt; setup achieved &lt;strong&gt;100% success rate&lt;/strong&gt; with the lowest average latency (7468ms) at 1100 concurrent users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS Round-Robin Load Balancer&lt;/strong&gt; averaged ~89% success rate with varying latency across pods (from 12676ms to 53028ms)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NodePort&lt;/strong&gt; service averaged ~89% success rate with similar latency variance&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lambda&lt;/strong&gt; performed poorly with only &lt;strong&gt;43.48% success rate&lt;/strong&gt; despite being tested at a lower concurrency (800 users)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The visualization clearly demonstrates that our properly configured Nginx + Kubernetes setup significantly outperforms the Lambda architecture, particularly in handling burst traffic and maintaining high success rates.&lt;/p&gt;

&lt;p&gt;🚀 The load test was performed using &lt;a href="https://www.npmjs.com/package/load_test_util" rel="noopener noreferrer"&gt;load_test_util&lt;/a&gt;&lt;br&gt;
✅ Supports MongoDB server metric analysis&lt;br&gt;
🛠️ Custom logging built-in&lt;br&gt;
🧩 Fully configurable via JSON&lt;/p&gt;

&lt;p&gt;Perfect for benchmarking infra migrations like ours :)&lt;/p&gt;

&lt;p&gt;Read on for in-depth setup guide...&lt;/p&gt;
&lt;h2&gt;
  
  
  Migration Goals
&lt;/h2&gt;

&lt;p&gt;We established the following optimization parameters for our migration:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reduce cost per user served&lt;/li&gt;
&lt;li&gt;Support at least 1000 RPS burst capacity&lt;/li&gt;
&lt;li&gt;Maintain reliability under high concurrent load&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Infrastructure Choices
&lt;/h2&gt;

&lt;p&gt;We selected a cost-optimized self-managed Kubernetes cluster with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 master node&lt;/li&gt;
&lt;li&gt;2 worker nodes&lt;/li&gt;
&lt;li&gt;ECR for container registry&lt;/li&gt;
&lt;li&gt;NGINX load balancers (instead of AWS LB) for cost optimization&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Implementation Details
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Setting Up the Kubernetes Cluster (Ubuntu 22.04)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prepare the System&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update packages&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Install required dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; curl apt-transport-https
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install containerd Runtime&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; curl gnupg2 software-properties-common apt-transport-https ca-certificates
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; containerd
&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /etc/containerd
containerd config default | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/containerd/config.toml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;span class="c"&gt;# Edit config as needed&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart containerd
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;containerd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Initialize Master Node&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add Kubernetes APT repository&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://packages.cloud.google.com/apt/doc/apt-key.gpg | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"deb https://apt.kubernetes.io/ kubernetes-xenial main"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/kubernetes.list

&lt;span class="c"&gt;# Install kubeadm, kubelet, and kubectl&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; kubelet kubeadm kubectl
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-mark hold kubelet kubeadm kubectl

&lt;span class="c"&gt;# Initialize the cluster&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;kubeadm init &lt;span class="nt"&gt;--pod-network-cidr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.244.0.0/16

&lt;span class="c"&gt;# Configure kubectl&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; /etc/kubernetes/admin.conf &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube/config
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Initialize Worker Nodes&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# On worker nodes&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; kubelet kubeadm kubectl
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-mark hold kubelet kubeadm kubectl

&lt;span class="c"&gt;# Join the worker to the cluster using the token from master&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;kubeadm &lt;span class="nb"&gt;join&lt;/span&gt; &amp;lt;master-ip&amp;gt;:6443 &lt;span class="nt"&gt;--token&lt;/span&gt; &amp;lt;token&amp;gt; &lt;span class="nt"&gt;--discovery-token-ca-cert-hash&lt;/span&gt; sha256:&amp;lt;&lt;span class="nb"&gt;hash&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Configure Pod Networking with Flannel&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Flannel&lt;/span&gt;
kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

&lt;span class="c"&gt;# Enable bridge networking&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;modprobe overlay
&lt;span class="nb"&gt;sudo &lt;/span&gt;modprobe br_netfilter
lsmod | &lt;span class="nb"&gt;grep &lt;/span&gt;br_netfilter

&lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/sysctl.d/k8s.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Containerizing the Application
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Create Docker Images&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Tag for ECR&lt;/span&gt;
docker tag myimage:version &amp;lt;aws_account_id&amp;gt;.dkr.ecr.&amp;lt;region&amp;gt;.amazonaws.com/&amp;lt;repo-name&amp;gt;:version

&lt;span class="c"&gt;# Push to ECR&lt;/span&gt;
docker push &amp;lt;aws_account_id&amp;gt;.dkr.ecr.&amp;lt;region&amp;gt;.amazonaws.com/&amp;lt;repo-name&amp;gt;:version

&lt;span class="c"&gt;# Login to ECR&lt;/span&gt;
aws ecr get-login-password &lt;span class="nt"&gt;--region&lt;/span&gt; &amp;lt;region&amp;gt; &lt;span class="nt"&gt;--profile&lt;/span&gt; &amp;lt;aws_profile&amp;gt; | &lt;span class="se"&gt;\&lt;/span&gt;
docker login &lt;span class="nt"&gt;--username&lt;/span&gt; AWS &lt;span class="nt"&gt;--password-stdin&lt;/span&gt; &amp;lt;aws_account_id&amp;gt;.dkr.ecr.&amp;lt;region&amp;gt;.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Create Secret for ECR Access&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create secret docker-registry ecr-secret &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--docker-server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;aws_account_id&amp;gt;.dkr.ecr.&amp;lt;region&amp;gt;.amazonaws.com &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--docker-username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;AWS &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--docker-password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;aws ecr get-login-password &lt;span class="nt"&gt;--region&lt;/span&gt; &amp;lt;region&amp;gt; &lt;span class="nt"&gt;--profile&lt;/span&gt; &amp;lt;aws_profile&amp;gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Deployment Configuration
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Kubernetes Deployment&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rest-api-deployment&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;  &lt;span class="c1"&gt;# Creates 3 Pods&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rest-api&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rest-api&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rest-api-container&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-api-image:latest&lt;/span&gt;  &lt;span class="c1"&gt;# Replace with your actual API image&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5000&lt;/span&gt;
        &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Ensures failed pods restart&lt;/span&gt;
          &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/health&lt;/span&gt;
            &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5000&lt;/span&gt;
          &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
          &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Service Exposure via NodePort&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rest-api-service&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NodePort&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rest-api&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;TCP&lt;/span&gt;
      &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;80&lt;/span&gt;        &lt;span class="c1"&gt;# Internal Cluster Port&lt;/span&gt;
      &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5000&lt;/span&gt; &lt;span class="c1"&gt;# API Container Port&lt;/span&gt;
      &lt;span class="na"&gt;nodePort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30080&lt;/span&gt;  &lt;span class="c1"&gt;# Exposes API on &amp;lt;EC2-Public-IP&amp;gt;:30080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Load Balancing Configuration
&lt;/h2&gt;

&lt;p&gt;The initial NGINX configuration failed under burst load with errors like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2025/04/01 09:18:00 [alert] 977643#977643: *14561 socket() failed (24: Too many open files) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Optimized NGINX Configuration
&lt;/h3&gt;

&lt;p&gt;We addressed these limitations with the following tuned NGINX configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;user&lt;/span&gt; &lt;span class="s"&gt;www-data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;worker_processes&lt;/span&gt; &lt;span class="s"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;pid&lt;/span&gt; &lt;span class="n"&gt;/run/nginx.pid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;worker_rlimit_nofile&lt;/span&gt; &lt;span class="mi"&gt;65536&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;error_log&lt;/span&gt; &lt;span class="n"&gt;/var/log/nginx/error.log&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;include&lt;/span&gt; &lt;span class="n"&gt;/etc/nginx/modules-enabled/*.conf&lt;/span&gt;;

&lt;span class="k"&gt;events&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;worker_connections&lt;/span&gt; &lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;multi_accept&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;http&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;sendfile&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;tcp_nopush&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;types_hash_max_size&lt;/span&gt; &lt;span class="mi"&gt;2048&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;include&lt;/span&gt; &lt;span class="n"&gt;/etc/nginx/mime.types&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;default_type&lt;/span&gt; &lt;span class="nc"&gt;application/octet-stream&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;ssl_protocols&lt;/span&gt; &lt;span class="s"&gt;TLSv1&lt;/span&gt; &lt;span class="s"&gt;TLSv1.1&lt;/span&gt; &lt;span class="s"&gt;TLSv1.2&lt;/span&gt; &lt;span class="s"&gt;TLSv1.3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_prefer_server_ciphers&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;access_log&lt;/span&gt; &lt;span class="n"&gt;/var/log/nginx/access.log&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;gzip&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;keepalive_timeout&lt;/span&gt; &lt;span class="s"&gt;75s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;keepalive_requests&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;proxy_buffering&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;proxy_buffers&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="mi"&gt;16k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;proxy_busy_buffers_size&lt;/span&gt; &lt;span class="mi"&gt;32k&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;proxy_read_timeout&lt;/span&gt; &lt;span class="s"&gt;60s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;proxy_send_timeout&lt;/span&gt; &lt;span class="s"&gt;60s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;upstream&lt;/span&gt; &lt;span class="s"&gt;backend_servers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="nf"&gt;192.0.2.1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30008&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="nf"&gt;192.0.2.2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30008&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt; &lt;span class="s"&gt;ssl&lt;/span&gt; &lt;span class="s"&gt;http2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;app.example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kn"&gt;ssl_certificate&lt;/span&gt; &lt;span class="n"&gt;/etc/ssl/certs/fullchain.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;ssl_certificate_key&lt;/span&gt; &lt;span class="n"&gt;/etc/ssl/private/privkey.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;http://backend_servers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_http_version&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Real-IP&lt;/span&gt; &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt; &lt;span class="nv"&gt;$proxy_add_x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-Proto&lt;/span&gt; &lt;span class="nv"&gt;$scheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Upgrade&lt;/span&gt; &lt;span class="nv"&gt;$http_upgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Connection&lt;/span&gt; &lt;span class="s"&gt;"Upgrade"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;# Additional configuration omitted for brevity&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key optimizations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increased &lt;code&gt;worker_rlimit_nofile&lt;/code&gt; to 65536&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;worker_connections&lt;/code&gt; to 4096&lt;/li&gt;
&lt;li&gt;Enabled &lt;code&gt;multi_accept&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Increased &lt;code&gt;keepalive_timeout&lt;/code&gt; to 75s&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;keepalive_requests&lt;/code&gt; to 10000&lt;/li&gt;
&lt;li&gt;Optimized buffer sizes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Results and Conclusion
&lt;/h2&gt;

&lt;p&gt;Our migration from Lambda to a self-managed Kubernetes cluster with optimized NGINX configuration delivered:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Improved Reliability&lt;/strong&gt;: From 43% success rate to 100% success rate under load&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Better Latency&lt;/strong&gt;: Significantly lower average response times&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Higher Capacity&lt;/strong&gt;: Successfully handling 2000+ concurrent users&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Cost Optimization&lt;/strong&gt;: Lower cost per user served compared to Lambda&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These results validate our architectural decision to migrate from serverless to a self-managed Kubernetes setup for high-concurrency APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; Serverless isn't always the answer, especially for high-concurrency applications&lt;/li&gt;
&lt;li&gt; Properly configured traditional infrastructure can outperform serverless at scale&lt;/li&gt;
&lt;li&gt; System tuning (especially NGINX configuration) is critical for performance&lt;/li&gt;
&lt;li&gt; A cost-optimized Kubernetes cluster can provide an excellent balance of performance and economics&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Would you like to learn more about our journey or have questions about implementing a similar migration? Let me know in the comments!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Note: This article is based on real migration and performance testing conducted in March-April 2025.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>kubernetes</category>
      <category>microservices</category>
      <category>performance</category>
    </item>
    <item>
      <title>HackerOne 101: Grammarly Model Poisoning Attacks</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Sun, 15 Sep 2024 13:29:06 +0000</pubDate>
      <link>https://forem.com/gamedev90/hackerone-101-grammarly-model-poisoning-attacks-1do2</link>
      <guid>https://forem.com/gamedev90/hackerone-101-grammarly-model-poisoning-attacks-1do2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is one of the first articles in a series of articles based on the &lt;a href="https://hackerone.com" rel="noopener noreferrer"&gt;hackerone&lt;/a&gt; bug bounty program by &lt;a href="https://hackerone.com/grammarly?type=team" rel="noopener noreferrer"&gt;grammarly&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In this article we are going to get introduced to data poisoning attacks and will discuss label flipping with a working example on the grammarly APIs itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model Poisoning
&lt;/h2&gt;

&lt;p&gt;Model poisoning is a type of adversarial attack that targets machine learning models, particularly during their training phase. The goal of model poisoning is to subtly alter the model's behavior by introducing malicious data or manipulating the training process, causing the model to make incorrect predictions or behave in a way that benefits the attacker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Label Flipping
&lt;/h3&gt;

&lt;p&gt;This attack involves marking correct input with incorrect label and incorrect input with correct label so that the model starts giving wrong predictions&lt;/p&gt;

&lt;p&gt;In the context of grammarly we will try to investigate the grammarly web app and APIs that power spelling correctness feature.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F68fu28a29ha0is93smdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F68fu28a29ha0is93smdo.png" alt="grammarly spelling correctness ui" width="708" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  The investigation
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Ruling out server side AI model support&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Checked for activity in the network tab&lt;/li&gt;
&lt;li&gt;Could only see &lt;code&gt;logV2&lt;/code&gt;, &lt;code&gt;events&lt;/code&gt; and &lt;code&gt;authorization&lt;/code&gt; requests in the network logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;logV2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /logv2 HTTP/2
Host: f-log-editor.grammarly.io
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://app.grammarly.com/
Content-Type: application/json
Content-Length: 2914
Origin: https://app.grammarly.com
Connection: keep-alive
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
TE: trailers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is probably a logging API sending user and user-agent related info on every page reload&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;events&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl 'https://gnar.grammarly.com/events' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: https://app.grammarly.com/' -H 'Content-Type: application/json' -H 'Origin: https://app.grammarly.com' -H 'Connection: keep-alive' -H 'Cookie: grauth=AABN_y5k8nO1QVQ7lyDTKrp_68vQR2HUQFVp5r3NklXGkfJRIn2CJM1Hqn7WxAU1bhjxbJNgtpF_xPCi; csrf-token=AABN/9Bb12L12hlkibY1S8ONAetDOcsjuYIc5g; gnar_containerId=xjaj96uqklmu0902; _gcl_au=1.1.2013238534.1725196671; _ga_CBK9K2ZWWE=GS1.1.1725200925.2.0.1725200925.60.0.0; _ga=GA1.1.469893869.1725196671; _pin_unauth=dWlkPU4yTTRORFEzWVRrdFpXTmtNaTAwTkRKakxUazVaVGt0TkRFeVlUSTFZams1TVRrMQ; __podscribe_grammarly_referrer=https://www.google.com/; __podscribe_grammarly_landing_url=https://www.grammarly.com/ai-writing-assistant; __podscribe_did=pscrb_f542134c-de91-49e8-99de-dca7bab0e0cb; _tq_id.TV-7281365481-1.3988=69840ec454ed06bc.1725196672.0.1725200923..; _clck=1o62qwl%7C2%7Cfow%7C0%7C1705; _fbp=fb.1.1725196673331.19073762163984477; funnelType=free; tdi=tmwup2itzfdtt5czk; last_authn_event=666f04d3-a2ac-4b8a-b152-ff82465ee922; gac=AABN_0pbfOxu1yQOL6aAyc1jL4ELkaY4_eC9XZbBF3nANLbuz9K9n_TbuLizWGC1YPd60rEy2PrW7SJrVozu2REsn5a11gxzmUTEUuMiPCFpc3Yu; isGrammarlyUser=true; experiment_groups=gb_analytics_mvp_phase_one_30_day_enabled|auto_complete_correct_safari_enabled|extension_assistant_bundles_all_consumers_enabled|officeaddin_ue_exp3_enabled|fsrw_in_assistant_all_consumers_enabled|extension_new_rich_text_fields_enabled|safari_migration_inline_disabled_enabled|officeaddin_upgrade_state_exp1_enabled1|officeaddin_outcomes_ui_exp5_enabled1|premium_ungating_renewal_notification_enabled|kaza_security_hub_enabled|extension_assistant_all_consumers_enabled|quarantine_messages_enabled|small_hover_menus_existing_enabled|fsrw_in_assistant_all_enabled|emogenie_beta_enabled|gb_snippets_csv_upload_enabled|grammarly_web_ukraine_logo_dapi_enabled|extension_fluid_for_all_rollout_test_enabled|officeaddin_upgrade_state_exp2_enabled1|apply_formatting_all_enabled|gb_analytics_mvp_phase_one_enabled|wonderpass_enabled|extensionfrench rap songsfrench rap songs_assistant_experiment_all_enabled|apply_formatting_all_consumers_enabled|gdocs_for_all_safari_enabled|extension_assistant_all_enabled|safari_migration_backup_notif1_enabled|ipm_extension_release_test_1|auto_complete_correct_edge_enabled|snippets_in_ws_gate_enabled|extension_assistant_experiment_all_consumers_enabled|extension_assistant_bundles_all_enabled|safari_migration_popup_editor_disabled_enabled|officeaddin_proofit_exp3_enabled|safari_migration_inline_warning_enabled|gb_in_editor_free_Test1|gdocs_for_all_firefox_enabled|gdocs_new_mapping_enabled|officeaddin_muted_alerts_exp2_enabled1|officeaddin_perf_exp3_enabled|shared_workspaces_enabled; _rdt_uuid=1725196671125.3dfe8c32-2a63-4036-a141-50c3f417cb98; _uetvid=97301a70686411efbb3e2ddb14c6081b; _clsk=1yrnj8i%7C1725419260716%7C1%7C0%7Cz.clarity.ms%2Fcollect; redirect_location=eyJ0eXBlIjoiIiwibG9jYXRpb24iOiJodHRwczovL2FwcC5ncmFtbWFybHkuY29tL2Rkb2NzLzI1Njg3MjI3NDcifQ==; browser_info=FIREFOX:117:COMPUTER:SUPPORTED:FREEMIUM:LINUX:LINUX' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'TE: trailers' --data-raw '{"events":[{"action":"show","eventName":"editor/assistant-lens-show","object":"lens","objectId":"assistant","lens":"all-suggestions","pageId":"document","client":"editor","clientVersion":"1.5.43-6200+master","instanceId":"0RGsM5vY","batchId":5,"containerId":"xjaj96uqklmu0902","userId":"2460910660","isTest":false,"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0","screenWidth":1920,"screenHeight":1080,"containerWidth":612,"containerHeight":887,"devicePixelRatio":1}]}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This API also reports the current UI filters and userAgent details but also sends server side cookies for communication with &lt;a href="https://podscribe.com/" rel="noopener noreferrer"&gt;podscribe&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No data gets transported on repeated reload of the web page&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;All of the above was written around 27 August 2024, it was the last time I changed my root user password. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l81ee3d6cjk2gw62hzj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l81ee3d6cjk2gw62hzj.png" alt="check last password update for a user" width="773" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I updated the &lt;strong&gt;&lt;em&gt;links&lt;/em&gt;&lt;/strong&gt; today to the hackerone website and grammarly hackerone project, maybe they &lt;strong&gt;&lt;em&gt;will expire in the coming future but the thrill of&lt;/em&gt;&lt;/strong&gt; making money while &lt;strong&gt;&lt;em&gt;exploring the interconnected products and their architecture&lt;/em&gt;&lt;/strong&gt; is something that &lt;strong&gt;&lt;em&gt;brings a smile on my face&lt;/em&gt;&lt;/strong&gt; this Engineer's Day :).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Engineer's Day&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;K&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>security</category>
      <category>datascience</category>
      <category>openai</category>
    </item>
    <item>
      <title>No space on google cloud :(</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Thu, 19 Oct 2023 08:19:48 +0000</pubDate>
      <link>https://forem.com/gamedev90/no-space-on-google-cloud--3ijj</link>
      <guid>https://forem.com/gamedev90/no-space-on-google-cloud--3ijj</guid>
      <description>&lt;p&gt;If you are like me and don’t fuss about your email much but have a lot of newsletter subscriptions then you probably ran into this problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35hfef1jj7kqq6ps0y4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35hfef1jj7kqq6ps0y4m.png" alt="No space left on google cloud storage dashboard" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if you are not feeling lucky (and don’t wanna buy additional storage) and have not organized your inbox much. Then you are in luck as I ran into this same problem and have created a simple script that should take care of those unwanted senders.&lt;/p&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/KartikJha/code-quiver/blob/master/javascript/utilities/delete_messages_from_senders.js" rel="noopener noreferrer"&gt;script&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use the script you need to get your bearer auth token from google workspace&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Log in to google workspace developer dashboard&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;a href="https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list" rel="noopener noreferrer"&gt;https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy bearer auth token from the list request headers, look for &lt;code&gt;https://content-gmail.googleapis.com/gmail/v1/users&lt;/code&gt; in network tab.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bkxuvzv9jh6yp1vqlt7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bkxuvzv9jh6yp1vqlt7.jpeg" alt="Network tab screenshot of network call" width="503" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now assign this auth token &lt;a href="https://github.com/KartikJha/code-quiver/blob/cbd79682fe34aff6d8a128f39da54dc122a7c8e6/javascript/utilities/delete_messages_from_senders.js#L50" rel="noopener noreferrer"&gt;here&lt;/a&gt;, update senders based on your requirements &lt;a href="https://github.com/KartikJha/code-quiver/blob/cbd79682fe34aff6d8a128f39da54dc122a7c8e6/javascript/utilities/delete_messages_from_senders.js#L4" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I have already added some based on my requirements.&lt;/p&gt;

&lt;p&gt;All set you are ready to go, just type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch text.txt
node delete_messages_from_senders.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will delete all the messages from listed senders and will update the &lt;code&gt;text.txt&lt;/code&gt; file with number of messages per sender.&lt;/p&gt;

&lt;p&gt;Happy deleting emails!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>googlecloud</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Bundle github repos for offline sharing</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Fri, 11 Sep 2020 19:31:17 +0000</pubDate>
      <link>https://forem.com/gamedev90/bundle-github-repos-for-offline-sharing-37a4</link>
      <guid>https://forem.com/gamedev90/bundle-github-repos-for-offline-sharing-37a4</guid>
      <description>&lt;p&gt;Looking for a script that will archive the huge repo you've been wanting to archive well here it is...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;bundle-repo.js&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const chalk = require("chalk");
const { execSync, exec } = require("child_process");
// const fs = require('fs');

if (!process.argv[2] || !process.argv[3]) {
  console.log(
    chalk.red(
      "Usage: node bundle-repo OWNER REPO-STRING [BUNDLE-TARGET-DIR]\nExample: node bundle-repo 'twitter' 'main, side, boom'"
    )
  );
  return;
}

const prefix = "git@github.com:";

const finalDir = process.argv[4] ? process.argv[4] + "/" : "";

const getPath = (r) =&amp;gt; (!finalDir ? "" : finalDir + r);

process.argv[3].split(",").forEach((r) =&amp;gt; {
  execSync(
    `git clone ${prefix}${process.argv[2]}/${r.trim()} ${getPath(r.trim())}`
  );
  const a = execSync(`ls -la ${getPath(r.trim())}`);
  console.log(a.toString());
  if (a.toString().split('\n')[0].split(' ')[1] != 0) {
    execSync(
      `cd ${getPath(
        r.trim()
      )} &amp;amp;&amp;amp; git bundle create ${r.trim()}.bundle --all &amp;amp;&amp;amp; mv ${r.trim()}.bundle .. &amp;amp;&amp;amp; cd .. &amp;amp;&amp;amp; rm -rf ${r.trim()}`
    );
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;package.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "type": "module",
  "dependencies": {
    "chalk": "^3.0.0"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before you get busy with it please follow this setup to avoid any operational glitches&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Setup SSH access for your github account which has access to the repos. &lt;a href="https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=2ahUKEwiUprOG6uHrAhVafisKHfpgD0AQFjAAegQIARAC&amp;amp;url=https%3A%2F%2Fdocs.github.com%2Fen%2Fgithub%2Fauthenticating-to-github%2Fconnecting-to-github-with-ssh&amp;amp;usg=AOvVaw21Oa_77sk2lc4cCunHT7Os" rel="noopener noreferrer"&gt;Connect to github via SSH&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a string of comma seprated repo names like "repo1, repo2", the script has a usage example built in&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pass the repo string and owner/organization string as input to the string like&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node bundle-repo 'twitter' 'main, side, boom' [optional target directory]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it you are good to go. Checkout the &lt;a href="https://github.com/KartikJha/code-quiver/blob/master/javascript/utilities/bundle-repos.js" rel="noopener noreferrer"&gt;code on github &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading :)&lt;/p&gt;

</description>
      <category>github</category>
      <category>node</category>
      <category>git</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Getting your hobby project of the ground</title>
      <dc:creator>KartikJha</dc:creator>
      <pubDate>Sun, 14 Jul 2019 13:34:21 +0000</pubDate>
      <link>https://forem.com/kartikjha/getting-your-hobby-project-of-the-ground-3f4g</link>
      <guid>https://forem.com/kartikjha/getting-your-hobby-project-of-the-ground-3f4g</guid>
      <description>&lt;p&gt;I have been a professional developer for nearly two years now but don't see much difference in my coding abilities. &lt;/p&gt;

&lt;p&gt;Yes, I have become more fearless in facing a screen scribbled with errors and can work my way through it and have picked up some technologies along the way (React, Node, Java) and learned the way of the terminal :D &lt;/p&gt;

&lt;p&gt;But something is still missing I don't have any open source contributions and my Github profile looks pretty boring. Several abandoned projects :( and this obviously affects my first impression on potential employers.&lt;/p&gt;

&lt;p&gt;So, I have decided that I am going to finish my first hobby project which is a game built using canvas and typescript(the minimum viable product, as I am planning to add multiplayer action!).&lt;/p&gt;

&lt;p&gt;And so far I have managed to set up the project from scratch and created the basic architecture. I am using Typescript, Webpack, and native canvas API to achieve the MVP along with Eslint and Prettier for smooth development experience.&lt;/p&gt;

&lt;p&gt;The repo and corresponding GitHub project can be found at &lt;a href="https://github.com/KartikJha/color-sticks"&gt;https://github.com/KartikJha/color-sticks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have set up the project without any boilerplate by scrounging the internet but will be happy to write a consolidated article you need it.&lt;/p&gt;

&lt;p&gt;Thanks for reading this far. I will make sure that this hobby project gets delivered. &lt;/p&gt;

&lt;p&gt;What are you working on or planning to work on? Let me know in the comments.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>html</category>
      <category>gamedev</category>
    </item>
  </channel>
</rss>
