<?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>DEV Community: conjurer</title>
    <description>The latest articles on DEV Community by conjurer (@leg_end).</description>
    <link>https://dev.to/leg_end</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%2F1657188%2Fd34c79d1-02d7-4462-97a0-7b121a43d921.jpg</url>
      <title>DEV Community: conjurer</title>
      <link>https://dev.to/leg_end</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leg_end"/>
    <language>en</language>
    <item>
      <title>PGP decryption and signing</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Wed, 18 Feb 2026 06:16:34 +0000</pubDate>
      <link>https://dev.to/leg_end/pgp-decryption-and-signing-1l4c</link>
      <guid>https://dev.to/leg_end/pgp-decryption-and-signing-1l4c</guid>
      <description>&lt;p&gt;Here's what we skip sometimes: when you receive an encrypted + signed PGP message, you can't see the signature until you decrypt it.&lt;/p&gt;

&lt;p&gt;PGP &lt;strong&gt;signs first, then encrypts&lt;/strong&gt;. The signature is sealed inside.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's acTually insIde
&lt;/h2&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%2Fkgoza1dmmr6iuj9qg840.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%2Fkgoza1dmmr6iuj9qg840.png" alt="Pgp message structure" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The outer layer is encryption. Your private key unlocks it. Only then can you see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;who signed it (signer's key id)&lt;/li&gt;
&lt;li&gt;actual content&lt;/li&gt;
&lt;li&gt;the sign itself&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The 2 pHase floW
&lt;/h2&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%2Fxozr7ux7xfqwils16p73.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%2Fxozr7ux7xfqwils16p73.png" alt="flow diagram" width="800" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decrypt&lt;/strong&gt; -&amp;gt; reveals the signer's key id&lt;br&gt;
&lt;strong&gt;Verify&lt;/strong&gt; -&amp;gt; confirms the signature&lt;/p&gt;

&lt;h2&gt;
  
  
  The gotCha that cost me hoUrs
&lt;/h2&gt;

&lt;p&gt;After decrypting, I tried parsing the content- extract the parts, do some processing, pass to verification.&lt;/p&gt;

&lt;p&gt;Signature verification failed. Every time.&lt;/p&gt;

&lt;p&gt;Here's why:&lt;br&gt;
PGP libraries use &lt;strong&gt;streaming parsers&lt;/strong&gt;. When you parse a packet, you get the header, but the body is still in the stream- waiting to be read. If you serialize what you parsed, the body is missing.&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%2F6pqx22owkwe8284ol5vn.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%2F6pqx22owkwe8284ol5vn.png" alt="streaming parser issue" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix:&lt;br&gt;
&lt;strong&gt;Read raw bytes first&lt;/strong&gt;, before parsing. Those bytes are the complete signed message. Pass them directly to verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quik referEnce
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Encrypted Message
├── Session Key (encrypted for you)
└── Encrypted Blob
    └── [after decryption]
        ├── Signer's Key ID  ← now you know who!
        ├── Content
        └── Signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  FUrther reAding
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://datatracker.ietf.org/doc/html/rfc4880" rel="noopener noreferrer"&gt;RFC 4880&lt;/a&gt; — The OpenPGP spec&lt;br&gt;
&lt;code&gt;gpg --list-packets&lt;/code&gt; — See any PGP message's structure&lt;br&gt;
&lt;a href="https://docs.sequoia-pgp.org/" rel="noopener noreferrer"&gt;Sequoia PGP docs&lt;/a&gt; — If you're implementing in Rust&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>pgp</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Epoch time</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Mon, 16 Jun 2025 17:20:46 +0000</pubDate>
      <link>https://dev.to/leg_end/epoch-time-49pd</link>
      <guid>https://dev.to/leg_end/epoch-time-49pd</guid>
      <description>&lt;p&gt;&lt;strong&gt;Epoch time&lt;/strong&gt;, also known as &lt;strong&gt;Unix time&lt;/strong&gt; or &lt;strong&gt;POSIX time&lt;/strong&gt;, is just:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The number of seconds since &lt;strong&gt;1970-01-01 00:00:00 UTC&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
(ignoring leap seconds)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  🧠 Why use it?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Simple, universal way to represent time&lt;/li&gt;
&lt;li&gt;Great for timestamps, logs, caching, or versioning&lt;/li&gt;
&lt;li&gt;Timezone-neutral&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔢 Example:
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Human Time (UTC)&lt;/th&gt;
&lt;th&gt;Unix Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1970-01-01 00:00:00&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2000-01-01 00:00:00&lt;/td&gt;
&lt;td&gt;946684800&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2025-06-16 18:00:00&lt;/td&gt;
&lt;td&gt;1755405600&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  ⚙️ Get current Unix time:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;date +%s&lt;/code&gt; (Linux/macOS)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import time
print(int(time.time()))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>unix</category>
      <category>time</category>
      <category>programmers</category>
    </item>
    <item>
      <title>API Throttling 🏎️</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Fri, 30 May 2025 05:34:00 +0000</pubDate>
      <link>https://dev.to/leg_end/api-throttling-4dd9</link>
      <guid>https://dev.to/leg_end/api-throttling-4dd9</guid>
      <description>&lt;h2&gt;
  
  
  Throttle in a car
&lt;/h2&gt;

&lt;p&gt;The throttle (aka accelerator pedal) controls how much fuel enters the engine. &lt;br&gt;
More fuel → more power → more speed.&lt;/p&gt;

&lt;p&gt;Push the pedal, the car zooms. Release it, the car eases up.&lt;/p&gt;
&lt;h2&gt;
  
  
  API
&lt;/h2&gt;

&lt;p&gt;or Application Programming Interface&lt;br&gt;
is the middleman between user and application. Every tap, swipe, or click you make sends a request through an API.&lt;/p&gt;

&lt;p&gt;Now imagine millions of users doing that all at once. &lt;br&gt;
Boom 💥 — a flood of requests. Servers can get overwhelmed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Throttling&lt;/strong&gt; is how we control that flood. It sets limits on how many requests can be sent over a period — just like how a car throttle limits speed.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why throttling
&lt;/h3&gt;

&lt;p&gt;If an app has large user-base, users with blazing fast connection could hog all the server bandwidth.&lt;/p&gt;

&lt;p&gt;Slower users might be refrained from usage (talking legally haha).&lt;/p&gt;

&lt;p&gt;Heard of DDos attack right? The one where person &lt;em&gt;D&lt;/em&gt; sends tsunami of requests to crash the app.&lt;/p&gt;
&lt;h3&gt;
  
  
  How-to throttle
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Leaky bucket
&lt;/h4&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%2Fy88ha5v6fwuqfc7gupal.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%2Fy88ha5v6fwuqfc7gupal.png" alt="leaky bucket" width="567" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Requests filling a bucket at random speeds, but leaking (processing) at a fixed rate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if queue (bucket) is full
  "429 Too Many Requests";
else 
  queue.push(request);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Issue: starvation; newer requests get dumped if current processes are long-running tasks.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Fixed window
&lt;/h4&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%2Fik21l18itpqne7e16c3b.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%2Fik21l18itpqne7e16c3b.png" alt="fixed window" width="303" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Requests are counted in fixed intervals (like per second/minute).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (each interval) {
  process min (incoming_requests, requests_per_interval);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Issue: bursts; too many users at the start of the window can overwhelm the system before the second is up.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Sliding window
&lt;/h4&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%2Fqcee1e7yqrxuebno3aan.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%2Fqcee1e7yqrxuebno3aan.png" alt="sliding window" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Smarter cousin of fixed window. It smooths out request bursts by calculating usage over a rolling time window.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;On each request:
  if user_requests_in_last_x_seconds &amp;lt; limit
    process user_requests_in_last_x_seconds;
  else "429";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Like checking speed over the last interval instead of just the current one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Misc.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Retry strategy - don't keep honking, wait a little longer after each response failure&lt;/li&gt;
&lt;li&gt;Many APIs tell a user's closeness to rate limit, use them&lt;/li&gt;
&lt;li&gt;429 = server saying &lt;em&gt;Have a Break, Have a KitKat&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>api</category>
    </item>
    <item>
      <title>From Gnutella to DHT: Smarter Sharing</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Sun, 20 Apr 2025 11:50:57 +0000</pubDate>
      <link>https://dev.to/leg_end/from-gnutella-to-dht-smarter-sharing-40ji</link>
      <guid>https://dev.to/leg_end/from-gnutella-to-dht-smarter-sharing-40ji</guid>
      <description>&lt;p&gt;You click Download on a Linux ISO or that obscure open-source game, and somehow—bits of it start flowing in from all over the globe. Not from a single server, but from a swarm of strangers. Cool! But… how?&lt;/p&gt;




&lt;h3&gt;
  
  
  🧩 Step 1: Not All P2P Is Structured Chaos
&lt;/h3&gt;

&lt;p&gt;Before we get to BitTorrent, let’s back up a bit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gnutella: A Swarm Without a Map
&lt;/h2&gt;

&lt;p&gt;Gnutella was one of the earliest P2P protocols. It didn’t care about structure. A node looking for a file would just yell into the void:&lt;br&gt;
&lt;em&gt;Hey, neighbors — got this file?&lt;/em&gt;&lt;br&gt;
If they didn’t, the request would ripple outward.&lt;/p&gt;

&lt;p&gt;It worked… kind of. But the inefficiency grew fast—lots of messages flying around, lots of nodes just forwarding them. &lt;br&gt;
Imagine finding a book in a giant library by just asking random people.&lt;/p&gt;


&lt;h3&gt;
  
  
  🧱 Step 2: Structure Comes In – Enter DHT
&lt;/h3&gt;

&lt;p&gt;Structured networks introduced Distributed Hash Tables (DHTs). These are like well-organized directories: instead of shouting into a crowd, you navigate through a small number of connections—like Six Degrees of Kevin Bacon, but with hex IDs.&lt;/p&gt;

&lt;p&gt;Each node is assigned a key (a long hex string), and each file is also hashed to a key. Nodes store file pointers close to that file’s hash.&lt;/p&gt;

&lt;p&gt;So how do nodes find each other?&lt;br&gt;
They maintain a routing table. It’s like a sparse map:&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%2Fcf6u0mlubk4smhdl0wuf.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%2Fcf6u0mlubk4smhdl0wuf.png" alt="routing table" width="305" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each row in this table corresponds to a longer prefix match with the node’s ID. Each column represents a possible hex digit at that position. Over time, it learns good "directions" for routing toward any key.&lt;/p&gt;

&lt;p&gt;So instead of broadcasting everywhere, you hop from node to node, getting closer and closer to the file’s hash.&lt;/p&gt;


&lt;h3&gt;
  
  
  🧪 Step 3: BitTorrent – Efficient Chaos
&lt;/h3&gt;

&lt;p&gt;Now—BitTorrent. It’s a peer-to-peer protocol, but it takes it further:&lt;br&gt;
Files are split into pieces.&lt;/p&gt;

&lt;p&gt;You can download different pieces from different peers simultaneously. Once you have a piece, you can serve it to others.&lt;/p&gt;

&lt;p&gt;Each group of people sharing a file is called a &lt;em&gt;swarm&lt;/em&gt;. A &lt;em&gt;tracker&lt;/em&gt; keeps track of peers in a swarm and who has what. But there’s a twist…&lt;/p&gt;
&lt;h3&gt;
  
  
  Trackerless Torrents (DHT-powered swarms)
&lt;/h3&gt;

&lt;p&gt;BitTorrent introduced a DHT-based approach for peer discovery. Instead of relying on a tracker (which can fail), nodes use DHT to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store: Hey, I have file X (hash: abcd...)—if anyone needs it, here’s my IP.&lt;/li&gt;
&lt;li&gt;Find: I’m looking for file X—who has it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the routing table magic we talked about? That’s what powers this.&lt;/p&gt;
&lt;h3&gt;
  
  
  🕸️ Finder Networks: Meta-Swarm Mechanics
&lt;/h3&gt;

&lt;p&gt;Sometimes, you don’t connect to a swarm directly. You connect to a peer finder. These finders form a kind of meta-overlay, a network where each node relays partial knowledge of finders to other finders connected to the swarm (reversing the swarm - finder role haha).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When you search for a file:

You ask your local finder node.

If it doesn’t know the answer, it forwards the request to a connected finder.

The search continues until a finder can:

Directly connect you to the swarm, or

Connect to another finder who knows more.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each finder keeps a table of IDs and their approximate location in the overlay—so your request isn’t random, it’s guided by proximity in hash space.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>torrent</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Turn the Wi-Fi on!</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Sat, 05 Apr 2025 15:39:48 +0000</pubDate>
      <link>https://dev.to/leg_end/turn-the-wi-fi-on-2gie</link>
      <guid>https://dev.to/leg_end/turn-the-wi-fi-on-2gie</guid>
      <description>&lt;p&gt;Ever walked into your house, turned on the light switch, and nothing happened—only to realize the &lt;strong&gt;main power was off&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Booted up the Linux machine and Wi-Fi wasn’t working!&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 1: Check if the "Power Supply" (NetworkManager) is ON
&lt;/h3&gt;

&lt;p&gt;NetworkManager is like house's electrical panel—it manages which appliances (Wi-Fi, Ethernet, etc.) get power (internet).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemctl status NetworkManager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&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;Active: inactive (dead)
NetworkManager.service: Job NetworkManager.service/start failed with result 'dependency'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main switch was off.&lt;/p&gt;

&lt;h4&gt;
  
  
  Turn the Power Back On
&lt;/h4&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;systemctl restart NetworkManager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it showed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Active: active (running)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lights are back on! 💡 But wait…&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 2: Check if the Devices Are Plugged In
&lt;/h3&gt;

&lt;p&gt;Let’s see if the &lt;strong&gt;Wi-Fi adapter&lt;/strong&gt; is even recognized (like checking if the lamp is plugged in).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip &lt;span class="nb"&gt;link &lt;/span&gt;show
nmcli device
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looks good! The adapter was visible and marked &lt;strong&gt;connected&lt;/strong&gt;, but internet wasn’t quite there yet…&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 3: Check Device Connection
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;A proper IP address  (getting electricity at the socket). A quick:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ping &lt;span class="nt"&gt;-c&lt;/span&gt; 4 8.8.8.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returned successfully—so the &lt;strong&gt;raw connectivity&lt;/strong&gt; was fine!&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 4: DNS - the Culprit
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;aka, the Address Book Was Missing&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Even though the connection was up, websites still weren’t loading.&lt;/p&gt;

&lt;p&gt;Like &lt;strong&gt;having electricity&lt;/strong&gt;, but the smart speaker doesn’t know how to play music—because the &lt;strong&gt;Wi-Fi password is gone&lt;/strong&gt;, or here, the DNS resolver was missing.&lt;/p&gt;

&lt;p&gt;Fix it by adding Google's DNS 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;vi /etc/resolv.conf
nameserver 8.8.8.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 5: Restart Network Services
&lt;/h3&gt;

&lt;p&gt;Just like you'd reboot your Wi-Fi router when things get weird, restart the services:&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;systemctl restart NetworkManager
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart wpa_supplicant.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🎉 And finally—it worked. Back online!&lt;/p&gt;




&lt;h3&gt;
  
  
  TL;DR:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;NetworkManager = Power switch&lt;/li&gt;
&lt;li&gt;WiFi Adapter = Device plugged in&lt;/li&gt;
&lt;li&gt;IP Address = Electricity flow&lt;/li&gt;
&lt;li&gt;Restarting services = Rebooting the system&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ubuntu</category>
      <category>terminal</category>
      <category>programming</category>
    </item>
    <item>
      <title>Linux Package Management: A Gourmet Guide</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Mon, 16 Sep 2024 06:21:26 +0000</pubDate>
      <link>https://dev.to/leg_end/linux-package-management-a-gourmet-guide-40kc</link>
      <guid>https://dev.to/leg_end/linux-package-management-a-gourmet-guide-40kc</guid>
      <description>&lt;h2&gt;
  
  
  Restaurant Analogy
&lt;/h2&gt;

&lt;p&gt;Downloading and installing software on Linux ~ ordering a meal&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Aim: bring meal (software) to the table (computer)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are different ways to get a software, whether it's a package from the official repository or an external source (restro), or compiling from source (diy cooking).&lt;/p&gt;

&lt;p&gt;Let'see how this works!&lt;/p&gt;

&lt;h3&gt;
  
  
  The Menu: Repositories and Packages
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Choosing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different distributions (or restaurants) have their own repositories, just like how some restaurants serve Italian food while others serve sushi.&lt;br&gt;
For example, view the available packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Ordering&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;sudo apt install &amp;lt;package-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The waiter communicates with the kitchen (package manager).&lt;/p&gt;

&lt;p&gt;This process downloads the package, along with any dependencies needed to make sure the meal works perfectly.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Kitchen: Installing the Software
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Prep&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kitchen starts unpacking all the ingredients (the software files and dependencies). &lt;/p&gt;

&lt;p&gt;The package manager (chef) ensures everything is compatible and fits perfectly on the system. Missing dependencies are fetched and added.&lt;/p&gt;

&lt;p&gt;And done!&lt;br&gt;
(this was the external source installation)&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%2Fddeze2h28qx3pm3ug06t.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%2Fddeze2h28qx3pm3ug06t.png" alt="pkmg" width="800" height="186"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  DIY
&lt;/h2&gt;

&lt;p&gt;Instead of using pre-packaged ingredients, you’re starting with raw materials (grabbing the source code) and cooking it on your system using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./configure
make
sudo make install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;++ Can customize according to user needs!&lt;br&gt;
++ Made from scratch!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Redux: Town of Magical Order</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Sun, 15 Sep 2024 04:48:34 +0000</pubDate>
      <link>https://dev.to/leg_end/redux-town-of-magical-order-eg7</link>
      <guid>https://dev.to/leg_end/redux-town-of-magical-order-eg7</guid>
      <description>&lt;p&gt;An interesting approach!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Magical Town of "Redux" 🏰
&lt;/h2&gt;

&lt;p&gt;This town had one amazing feature: no matter what happened, everyone in town always knew the exact state of everything going on. No confusion, no chaos—everything was magically managed! How?!&lt;/p&gt;

&lt;p&gt;Let's see.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Requests (Actions) ✉️
&lt;/h3&gt;

&lt;p&gt;If someone wants something to happen in the town, they fill out a request form called an Action.&lt;/p&gt;

&lt;p&gt;An Action is a simple document that says:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;What&lt;/em&gt; you want to do (Adopt a dragon).&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Any extra details&lt;/em&gt; (Adopt a fire-breathing dragon).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example actions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Action Type: "ADOPT_DRAGON"&lt;/li&gt;
&lt;li&gt;Details: Fire-breathing dragon&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These requests are super important because they let the town make changes in a predictable way. No one can just go rogue!&lt;/p&gt;

&lt;h3&gt;
  
  
  The Messengers (Dispatch) 🏃‍♂️
&lt;/h3&gt;

&lt;p&gt;Now how do people submit their requests? They use messengers. The townspeople call this process Dispatching an Action.&lt;/p&gt;

&lt;p&gt;When a resident wants to make a change, they dispatch an Action (request) to the Mayor.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Mayor (Store) 👨‍💼
&lt;/h3&gt;

&lt;p&gt;In Redux, there’s a Mayor who keeps track of everything happening in the town. He knows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many houses are built.&lt;/li&gt;
&lt;li&gt;What’s in everyone’s fridge.&lt;/li&gt;
&lt;li&gt;How many unicorns are running around!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Magical Scroll (State) 📜
&lt;/h3&gt;

&lt;p&gt;This scroll holds the entire truth of the town. The scroll updates whenever something official happens, and every resident trusts the scroll.&lt;/p&gt;

&lt;p&gt;A reference:&lt;br&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%2Fhndwl9o2z8l35pnmctdi.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%2Fhndwl9o2z8l35pnmctdi.png" alt="reference" width="800" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Wizards (Reducers) 🧙‍♂️
&lt;/h3&gt;

&lt;p&gt;Now, who handles these dispatched requests? The Wizards in town! These Wizards are known as Reducers.&lt;/p&gt;

&lt;p&gt;Whenever the Mayor receives an Action (request), he sends it over to the Reducers, who are magical beings. Their job is to take the current State (the magical scroll) and the Action, then figure out what the new State should be.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
If the Action is to adopt a dragon, the Wizard makes sure there’s room for a dragon and updates the scroll.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rule: Wizards can’t change the scroll directly. They always make a copy of the current scroll, make the necessary changes on the copy, and send that back to the Mayor.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The Town Criers (Subscribers) 📢
&lt;/h3&gt;

&lt;p&gt;Finally, Redux has this special group. These are creatures who like to stay updated with everything that happens. Whenever the State (magical scroll) changes, the Town Criers immediately announce the new State to everyone who cares to listen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Is Redux Awesome? 🎩
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Single Source of Truth: Everything about the town (the State) is written down in one place (the magical scroll).&lt;/li&gt;
&lt;li&gt;Predictability: The Reducers handle all changes in the town in a controlled, predictable way.&lt;/li&gt;
&lt;li&gt;Structure: No random changes, no chaos. Everything is handled through Actions, which ensures order.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>redux</category>
    </item>
    <item>
      <title>DNS: More Than Just a Web Directory</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Wed, 11 Sep 2024 06:04:59 +0000</pubDate>
      <link>https://dev.to/leg_end/dns-93p</link>
      <guid>https://dev.to/leg_end/dns-93p</guid>
      <description>&lt;p&gt;Domain Name System&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Laziness led to Domain = D here.&lt;/em&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%2Fxv6jf65sxed0w947b5ej.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%2Fxv6jf65sxed0w947b5ej.png" alt="Intro" width="632" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's not just 1 system that caches all the millions of sites, something deeper.&lt;br&gt;
It consists of 3 servers:&lt;br&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%2F7w6vo5iu94qb1efm0itk.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%2F7w6vo5iu94qb1efm0itk.png" alt="servers" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, the Auth servers (3rd) store the Ds with their IP addresses. The text instructions to determine the IP address for a specific D are &lt;em&gt;DNS records&lt;/em&gt; or &lt;em&gt;zone files&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let's see some!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A | AAAA : resolve D to IPv4 | IPv6&lt;/li&gt;
&lt;li&gt;PTR : reverse of 1, check email spams&lt;/li&gt;
&lt;li&gt;CNAME : aka another domain (when typing &lt;a href="http://www.instagram.com" rel="noopener noreferrer"&gt;www.instagram.com&lt;/a&gt;, it leads to instagram.com)&lt;/li&gt;
&lt;li&gt;MX : the server to send email to&lt;/li&gt;
&lt;li&gt;NS : name of auth server&lt;/li&gt;
&lt;li&gt;SRV : get service and port number&lt;/li&gt;
&lt;li&gt;TXT : text info about D&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>internet</category>
      <category>dns</category>
    </item>
    <item>
      <title>Web scraping- Interesting!</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Fri, 06 Sep 2024 04:20:12 +0000</pubDate>
      <link>https://dev.to/leg_end/web-scraping-interesting-17bn</link>
      <guid>https://dev.to/leg_end/web-scraping-interesting-17bn</guid>
      <description>&lt;p&gt;A cool term: &lt;br&gt;
&lt;em&gt;CRON = programming technique that schedules tasks automatically at specified intervals&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Web what?
&lt;/h3&gt;

&lt;p&gt;When researching projects etc., we usually write info from various sites- be it in a diary / excel / doc etc.&lt;br&gt;
We are &lt;em&gt;scraping&lt;/em&gt; the web and extracting data manually.&lt;/p&gt;

&lt;p&gt;Web scraping is automating this.&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%2F2u7xe1nnxttfxio820t5.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%2F2u7xe1nnxttfxio820t5.png" alt="intro" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;When googling say sneakers online, it shows a list of websites with products and prices. On the shopping tab is a more detailed record right?&lt;br&gt;
Google just scraped websites for you to show sneakers from different sites.&lt;br&gt;
This techinque is used by almost all big companies for their businesses since data has been increasing exponentially.&lt;/p&gt;

&lt;h3&gt;
  
  
  Web Crawler
&lt;/h3&gt;

&lt;p&gt;This is a technique that although fetches information but differs from scraping in the sense that it searches for the best websites and indexes them whereas scraping is done in a single website.&lt;/p&gt;

&lt;p&gt;It's used for &lt;em&gt;SEO analysis&lt;/em&gt; (scraping - gathering data).&lt;/p&gt;

&lt;p&gt;Famous web scraping technologies: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pptr.dev/" rel="noopener noreferrer"&gt;Puppeteer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="noopener noreferrer"&gt;BeautifulSoup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://brightdata.com/" rel="noopener noreferrer"&gt;BrightData&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Issues!
&lt;/h3&gt;

&lt;p&gt;Notice it's not a user making requests to get the info from site, it's the code written! If the websites know this task is automated, they will quickly block the IP address.&lt;br&gt;
And this check has given rise to &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Captchas&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Dynamic content&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Goal: simulate how humans work!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bright data&lt;/em&gt; automates the job. It even rotates IPs to make the user unknown and unblocks sites (paid version!) for the user.&lt;/p&gt;

&lt;p&gt;Shoutout to &lt;a href="https://www.youtube.com/watch?v=lh9XVGv6BHs&amp;amp;list=WL&amp;amp;index=37" rel="noopener noreferrer"&gt;JSM&lt;/a&gt; for the wonderful explanation.&lt;br&gt;
Ps:&lt;br&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%2F86dgpbio4w2hkf13hqm3.jpg" 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%2F86dgpbio4w2hkf13hqm3.jpg" alt="captcha" width="409" height="294"&gt;&lt;/a&gt;&lt;br&gt;
Lol!&lt;/p&gt;

</description>
      <category>webscraping</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Geometric art | C++</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Wed, 04 Sep 2024 14:42:44 +0000</pubDate>
      <link>https://dev.to/leg_end/geometric-art-c-15ce</link>
      <guid>https://dev.to/leg_end/geometric-art-c-15ce</guid>
      <description>&lt;p&gt;Some geometric art today!&lt;br&gt;
Just some clicks and voila! A great pattern!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Libraries&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SDL2&lt;/li&gt;
&lt;li&gt;iostream&lt;/li&gt;
&lt;li&gt;vector&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  int main()
&lt;/h3&gt;

&lt;p&gt;User can choose between 2 modes, hence &lt;code&gt;type&lt;/code&gt;.&lt;br&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%2F7yz8xa09of38poeho8s9.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%2F7yz8xa09of38poeho8s9.png" alt="sdl init" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  main while(1)
&lt;/h3&gt;

&lt;p&gt;Detect if user wants to quit and exit;&lt;/p&gt;

&lt;p&gt;Detect a left click on the screen to add edges in the vector, and hence on the screen. Event handler sets the coordinates &lt;code&gt;(x, y)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Mouse movements are tracked on screen for location pointers.&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%2Fg3g1261p3dfnoizvh0qn.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%2Fg3g1261p3dfnoizvh0qn.png" alt="user events" width="800" height="995"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;On keypress:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;c : clear&lt;/li&gt;
&lt;li&gt;m : connect 2 most recent clicks (type 1)&lt;/li&gt;
&lt;li&gt;l : connect every point to every other point in vector (type 0)&lt;/li&gt;
&lt;li&gt;u : undo the last line(s)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Types of connections
&lt;/h3&gt;

&lt;p&gt;Set bg, drawing colors.&lt;br&gt;
Decide pattern according to type.&lt;br&gt;
Update the screen on render.&lt;br&gt;
Wait 1s before returning.&lt;br&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%2Fkm69c3l71qkpfucckbyh.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%2Fkm69c3l71qkpfucckbyh.png" alt="art render" width="800" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Output
&lt;/h3&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%2Fehzd3eh1x7islxfki5zx.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%2Fehzd3eh1x7islxfki5zx.png" alt="output" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=_q6fhu4DVe8" rel="noopener noreferrer"&gt;The Builder&lt;/a&gt; rocks it!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Rotating cube | C++</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Mon, 02 Sep 2024 13:20:37 +0000</pubDate>
      <link>https://dev.to/leg_end/rotating-cube-36kp</link>
      <guid>https://dev.to/leg_end/rotating-cube-36kp</guid>
      <description>&lt;p&gt;A quick and cool code!&lt;br&gt;
SDL2 is a library designed to provide low level access to audio, graphics hardware etc.&lt;br&gt;
Supports C++, lessgoo!&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup - screen.h
&lt;/h3&gt;

&lt;p&gt;Initialised the event handler, window and render pointers, and basic data members.&lt;/p&gt;

&lt;h4&gt;
  
  
  Requirements
&lt;/h4&gt;

&lt;p&gt;Show pixels on screen&lt;br&gt;
Clear the screen&lt;br&gt;
Check if &lt;em&gt;quit&lt;/em&gt; activity detected by user&lt;/p&gt;

&lt;h4&gt;
  
  
  Solution
&lt;/h4&gt;

&lt;p&gt;A vector that stores all points to be rendered on screen. Looped to render them. Cleared the vector to clear the screen.&lt;br&gt;
Quit if user wants to exit.&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%2Foosfe4cyld6boyjlf41c.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%2Foosfe4cyld6boyjlf41c.png" alt="functions" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Cube
&lt;/h3&gt;

&lt;p&gt;Some structs and functions for 3d geometry&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%2Ftdpexokukvxsxofwmzkq.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%2Ftdpexokukvxsxofwmzkq.png" alt="cube parts" width="800" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  On the screen | int main()
&lt;/h3&gt;

&lt;p&gt;Initialised the cube with vertices and edges, and a centroid for easy translations&lt;br&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%2Fzh33d2is9nho5vbwjc0u.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%2Fzh33d2is9nho5vbwjc0u.png" alt="main func" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Brought each point to the origin, rotated it along the axes, translated it back.&lt;br&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%2Fq04xvvgtuozg0e3629yv.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%2Fq04xvvgtuozg0e3629yv.png" alt="while loop" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Show time!&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%2F56vhn7i2dfpl76r6yljd.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%2F56vhn7i2dfpl76r6yljd.png" alt="Rendered" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="https://www.youtube.com/watch?v=kdRJgYO1BJM&amp;amp;list=PLYmIsLVSssdJZT2xID8XKqDId11yvlQnh" rel="noopener noreferrer"&gt;The Builder&lt;/a&gt; for sharing the amazing tutorial!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>sdl2</category>
    </item>
    <item>
      <title>Deadlock | Valorant</title>
      <dc:creator>conjurer</dc:creator>
      <pubDate>Sun, 01 Sep 2024 05:50:44 +0000</pubDate>
      <link>https://dev.to/leg_end/deadlock-valorant-3hh9</link>
      <guid>https://dev.to/leg_end/deadlock-valorant-3hh9</guid>
      <description>&lt;h3&gt;
  
  
  Program | Process
&lt;/h3&gt;

&lt;p&gt;Program = some instructions a computer follows to execute / perform a task. It's stored in the secondary memory (eg. disk) and can have many processes.&lt;br&gt;
Process = an instance of a program, or a file under execution.&lt;br&gt;
(Yes running the &lt;code&gt;.exe&lt;/code&gt; after compiling a &lt;code&gt;.cpp&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;A program becomes a process when loaded into RAM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deadlock
&lt;/h3&gt;

&lt;p&gt;Like when two or more processes in a computer are waiting for each other to make a move, and no one’s budging. &lt;/p&gt;

&lt;p&gt;Imagine two processes are holding onto resources the other needs, but neither can proceed without the other letting go first. It’s the ultimate stalemate, and nothing moves forward.&lt;br&gt;
&lt;em&gt;Like 2 programmers waiting for each other's code to merge first.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deadlock’s Barrier Mesh
&lt;/h2&gt;

&lt;p&gt;If you’ve played Deadlock in Valorant, you know her Barrier Mesh (e) ability throws out a net that creates four interconnected nodes.&lt;br&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%2Fsxq16mu76129v8iihf4c.jpg" 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%2Fsxq16mu76129v8iihf4c.jpg" alt="Bind site a" width="300" height="168"&gt;&lt;/a&gt;Now, picture this: each of those four nodes represents a process dependent on each other. The dependence can be seen by the fifth central node. &lt;br&gt;
That’s what happens in a computer science deadlock: multiple processes are trapped, stuck in a loop of dependencies where each one waits for the other to release its hold of the requested resource.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaking the Barrier: Resolving the Deadlock
&lt;/h2&gt;

&lt;p&gt;A few options in Valorant: destroy the nodes or wait it out. &lt;br&gt;
Similarly, in programming, breaking a deadlock means forcing one process to release its hold or finding a workaround.&lt;br&gt;
Timeouts, resource ordering, or other techniques can be used to force a process to back down, freeing up the system. &lt;/p&gt;

&lt;p&gt;Whether it’s a game or a server, breaking the deadlock takes action and strategy — but once it happens, everything flows smoothly again.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks to the Valo devs for the easter egg!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>valorant</category>
      <category>os</category>
    </item>
  </channel>
</rss>
