<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GDSC NIT Silchar Blog]]></title><description><![CDATA[GDSC NIT Silchar Blog]]></description><link>https://blog.gdscnits.in</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 14:37:49 GMT</lastBuildDate><atom:link href="https://blog.gdscnits.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Unleashing the power of Room Database with SQLite Mastery]]></title><description><![CDATA[INTRODUCTION

In modern Android app development, managing local data efficiently is critical for building any responsive and robust applications. The Room Database, a key component of Android Jetpack, provides a streamlined abstraction layer over SQL...]]></description><link>https://blog.gdscnits.in/unleashing-the-power-of-room-database-with-sqlite-mastery</link><guid isPermaLink="true">https://blog.gdscnits.in/unleashing-the-power-of-room-database-with-sqlite-mastery</guid><dc:creator><![CDATA[Parishmita Banik]]></dc:creator><pubDate>Sun, 23 Mar 2025 17:32:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736164320027/5ac6aed1-02f2-4382-9b0e-81467d56ef88.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">INTRODUCTION</h2>
<hr />
<p>In modern Android app development, managing local data efficiently is critical for building any responsive and robust applications. The Room Database, a key component of Android Jetpack, provides a streamlined abstraction layer over SQLite, enabling developers to interact with a database using less boilerplate code.</p>
<p>This blog explores the <strong>crud essentials</strong> of Room Database, breaking down its core components and design principles. We'll delve into the <strong>role of entities</strong> as the building blocks of your database schema and their intricate mapping to SQLite tables. Furthermore, we'll discuss the <strong>significance of abstract classes</strong>, which serve as the cornerstone of Room's DAO (Data Access Object) implementation, allowing developers to define database operations with precision.</p>
<h2 id="heading-understanding-crud-operations">UNDERSTANDING CRUD OPERATIONS</h2>
<hr />
<p><strong>RoomDatabase</strong> is a part of the Android Architecture Components and provides an abstraction layer over SQLite. It simplifies database work and allows for more robust database access while harnessing the full power of SQLite.</p>
<p><strong>CRUD</strong> is an acronym that <strong>stands for</strong> <strong>Create, Read, Update, and Delet</strong>e. These are the four fundamental operations performed on data in any database management system, including in Android development using SQLite and RoomDatabase.</p>
<p>Let’s break down each operation:</p>
<ol>
<li><p><strong>Create</strong>: This operation involves adding new data to the database. In the context of an app, it could be something like adding a new record (e.g., a new ‘wish’ in a wish-list app). In SQL terms, this is usually done using the <code>INSERT</code> statement.</p>
</li>
<li><p><strong>Read</strong>: This operation is used to retrieve data from the database. It can be a query for a specific item or a request for all records that meet certain criteria. In SQL, the <code>SELECT</code> statement is used for this purpose.</p>
</li>
<li><p><strong>Update</strong>: This operation involves modifying existing data in the database. It is used when the information in a database needs to be changed or updated. In SQL, this is done using the <code>UPDATE</code> statement.</p>
</li>
<li><p><strong>Delete</strong>: This operation removes data from the database. When an item is no longer needed or relevant, it can be deleted, which removes its corresponding row from the database table. In SQL, this is done using the <code>DELETE</code> statement.</p>
</li>
</ol>
<h3 id="heading-sqlite-with-room-entity-and-dao">SQLite with Room: Entity and DAO</h3>
<p>In Android development, particularly when using the Room Persistence Library, two key components come into play when interfacing with SQLite databases: <strong>Entity classes</strong> and <strong>Data Access Objects (DAOs)</strong>.</p>
<p>Here’s a detailed look at each:</p>
<ol>
<li><p><strong>Entity Class (@Entity)</strong>:</p>
<ul>
<li><p><strong>Purpose</strong>: An Entity class in Room represents a table within the SQLite database. Each instance of an entity corresponds to a row in the table.</p>
</li>
<li><p><strong>Structure</strong>:</p>
<ul>
<li><p><strong>Primary Key</strong>: Each entity must define at least one primary key. This is done using the <code>@PrimaryKey</code> annotation. For instance, <code>@PrimaryKey(autoGenerate = true)</code> can be used if you want the database to auto-generate the key.</p>
</li>
<li><p><strong>Columns</strong>: The fields in the entity represent the columns of the table. You can customize the column name using the <code>@ColumnInfo(name = "custom_name")</code> annotation. If not specified, the column name will be the same as the field name.</p>
</li>
</ul>
</li>
<li><p><strong>Example</strong>: In this example, <code>Wish</code> is an entity with a table name <code>wish_table</code>, containing two columns: <code>id</code> and <code>wish_desc</code>.</p>
</li>
</ul>
</li>
<li><p><strong>Data Access Object (DAO)</strong>:</p>
<ul>
<li><p><strong>Purpose</strong>: DAOs are interfaces or abstract classes where you define methods to access your database. In other words, DAOs are the main component for defining the logic of your database operations.</p>
</li>
<li><p><strong>Methods</strong>: Within a DAO, you define methods to perform your database operations (CRUD operations). Room translates these methods into SQLite queries.</p>
<ul>
<li><p><strong>Insert</strong>: Annotated with <code>@Insert</code>, used for adding records to the database.</p>
</li>
<li><p><strong>Query</strong>: Annotated with <code>@Query</code>, used for reading data. You can write SQLite queries inside the annotation.</p>
</li>
<li><p><strong>Update</strong>: Annotated with <code>@Update</code>, used to modify existing records.</p>
</li>
<li><p><strong>Delete</strong>: Annotated with <code>@Delete</code>, used to remove records.</p>
</li>
</ul>
</li>
<li><p><strong>Example</strong>: This DAO defines methods for adding, retrieving, updating, and deleting wishes in the <code>wish_table</code>.</p>
<pre><code class="lang-plaintext">  @Dao
  interface WishDao {
      @Insert
      fun addWish(wish: Wish)

      @Query("SELECT * FROM wish_table")
      fun getAllWishes(): List&lt;Wish&gt;

      @Update
      fun updateWish(wish: Wish)

      @Delete
      fun deleteWish(wish: Wish)
  }
</code></pre>
</li>
</ul>
</li>
</ol>
<h3 id="heading-setting-up-roomdatabase">Setting up RoomDatabase</h3>
<pre><code class="lang-plaintext">@Database(entities = [Wish::class], version = 1)
abstract class AppDatabase : RoomDatabase() {
    abstract fun wishDao(): WishDao
}
</code></pre>
<h2 id="heading-abstract-classes-in-kotlin">ABSTRACT CLASSES IN KOTLIN</h2>
<hr />
<p>In Kotlin, an <code>abstract</code> class is a type of class that <strong>cannot be instantiated directly</strong>, meaning you cannot create an object of an abstract class.</p>
<p>Instead, it is meant to be <strong>a base class that other classes extend from</strong>. The key characteristics of an abstract class in Kotlin are:</p>
<ol>
<li><p><strong>Abstract Methods</strong>: An abstract class can have abstract methods. These methods are declared without an implementation. The implementation of these methods must be provided by the subclasses that inherit the abstract class. This is useful for defining a common template for a group of subclasses.</p>
</li>
<li><p><strong>Non-Abstract Methods</strong>: Besides abstract methods, an abstract class can also have regular methods with implementations. This allows you to define shared behavior that subclasses can inherit or override.</p>
</li>
<li><p><strong>Instantiation</strong>: As mentioned, abstract classes cannot be instantiated on their own. They are designed to be subclassed, and their functionality is realized in their subclasses.</p>
</li>
<li><p><strong>Constructor</strong>: Like any other class, abstract classes can have constructors. These constructors are called when a subclass is instantiated.</p>
<p> In the context of using Room with Kotlin for Android development, the <code>abstract class</code> <strong>plays a crucial role, particularly when defining DAOs (Data Access Objects)</strong>.</p>
<p> Here’s how:</p>
<ul>
<li><p><strong>DAO as an Abstract Class</strong>: When you define a DAO in Room, you typically declare it as an <code>abstract class</code>. This is because the DAO is not meant to be instantiated directly. Instead, Room takes care of creating an implementation for you.</p>
</li>
<li><p><strong>Defining Database Operations</strong>: In your DAO, you define abstract methods for each database operation you want to perform (like adding, fetching, updating, or deleting data). Room generates the necessary code to perform these operations with SQLite.</p>
</li>
<li><p><strong>Example</strong>:</p>
<pre><code class="lang-plaintext">  @Dao
  abstract class WishDao {
      @Insert
      abstract fun addWish(wish: Wish)

      @Query("SELECT * FROM wish_table")
      abstract fun getAllWishes(): List&lt;Wish&gt;

      // Other CRUD operations...
  }
</code></pre>
</li>
</ul>
</li>
</ol>
<h2 id="heading-conclusion">CONCLUSION</h2>
<hr />
<p>This article provides an overview of the core of CRUD operations in RoomDatabase, the implementation of Entity and DAO, and the use of Kotlin’s abstract classes. These concepts are crucial for developing efficient, maintainable, and high-quality Android applications, setting a solid foundation for future development endeavors.</p>
]]></content:encoded></item><item><title><![CDATA[Procedural Generation : Where Math Meets Magic in Game Development]]></title><description><![CDATA[Ever stared at Minecraft’s endless landscapes or No Man’s Sky’s 18 quintillion planets and thought, “How the heck does this work?!” Buckle up—we’re diving into the secret sauce behind infinite worlds, smart algorithms, and why your GPU sometimes crie...]]></description><link>https://blog.gdscnits.in/procedural-generation-where-math-meets-magic-in-game-development</link><guid isPermaLink="true">https://blog.gdscnits.in/procedural-generation-where-math-meets-magic-in-game-development</guid><category><![CDATA[no man's sky]]></category><category><![CDATA[terraria]]></category><category><![CDATA[Games]]></category><category><![CDATA[procedural programming]]></category><category><![CDATA[Procedural Generation]]></category><category><![CDATA[minecraft]]></category><category><![CDATA[Video games]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[unity]]></category><category><![CDATA[Python]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[interactive]]></category><dc:creator><![CDATA[Mriganka Dey]]></dc:creator><pubDate>Wed, 19 Mar 2025 18:53:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1741939014415/1be24c47-8e92-4318-938c-b2de4fef25d4.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Ever stared at Minecraft’s endless landscapes or No Man’s Sky’s 18 quintillion planets and thought, “How the heck does this work?!” Buckle up—we’re diving into the secret sauce behind infinite worlds, smart algorithms, and why your GPU sometimes cries for mercy.</em></p>
<hr />
<h2 id="heading-why-procedural-generation-the-ultimate-developer-superpower">🚀 <strong>Why Procedural Generation? The Ultimate Developer Superpower</strong></h2>
<p>Imagine building a universe where <strong>every mountain, forest, and alien creature is unique</strong>—without hiring 10,000 artists. That’s procedural generation: <strong>teaching computers to “create” using math rules</strong>. It’s like giving a robot a paintbrush, but instead of colours, we use:</p>
<ul>
<li><p><strong>Noise algorithms</strong> (for natural-looking patterns)</p>
</li>
<li><p><strong>Fractals</strong> (for infinite self-similar detail)</p>
</li>
<li><p><strong>Seeds</strong> (tiny numbers that control randomness)</p>
</li>
</ul>
<p><em>Games use this to save storage space (Minecraft’s world files are shockingly small!) and create endless surprises. Let’s break it down.</em></p>
<hr />
<h2 id="heading-level-1-where-youve-seen-this-wizardry">🕹️ <strong>Level 1 : Where You’ve Seen This Wizardry</strong></h2>
<h2 id="heading-game-spotlight">🎮 <strong>Game Spotlight</strong></h2>
<ol>
<li><p><strong>Minecraft</strong> : Uses <strong>Perlin noise</strong> to generate terrain. Each block’s height is calculated via a math formula. Fun fact: A “seed” number (like “-4172144997902289642”) rebuilds the <em>exact same world</em> anywhere!</p>
</li>
<li><p><strong>No Man’s Sky</strong> : Planets are built from <strong>3D noise + rules</strong> (e.g., “If temperature &lt; 0, spawn ice”). Their secret? All 18 quintillion planets share just 6MB of code!</p>
</li>
<li><p><strong>Diablo 2</strong> : Dungeons use <strong>grammar-based generation</strong>—like LEGO blocks snapping together via rules (e.g., “Boss rooms must have 3 exits”).</p>
</li>
</ol>
<p><em>But how do these algorithms actually work? Let’s code!</em></p>
<hr />
<h2 id="heading-the-toolbox-4-core-techniques">🔨 <strong>The Toolbox : 4 Core Techniques</strong></h2>
<h2 id="heading-1-perlin-noise-the-og-terrain-builder">1️⃣ <strong>Perlin Noise : The OG Terrain Builder</strong></h2>
<p><strong>Theory Time!</strong> 🌟<br />Perlin noise works by creating a <em>gradient grid</em> of random directions (like tiny arrows). For any point (x,y), it calculates how "aligned" it is with nearby gradients, then blends these values smoothly. The result? Natural-looking patterns that games use for <strong>heightmaps</strong> (elevation data).</p>
<p><em>The grandfather of natural patterns. Used in Minecraft, Roblox, and even CGI movies.</em></p>
<p><strong>How it works</strong>:</p>
<ol>
<li><p>Create a grid of random gradients (arrows pointing in random directions).</p>
</li>
<li><p>For any point (x,y), calculate the dot product with nearby gradients.</p>
</li>
<li><p>Smoothly interpolate between values.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Generate 2D terrain with Python + noise library  </span>
<span class="hljs-keyword">import</span> noise  
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np  

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">generate_terrain</span>(<span class="hljs-params">width, height, scale=<span class="hljs-number">50.0</span>, octaves=<span class="hljs-number">6</span></span>):</span>  
    terrain = np.zeros((height, width))  
    <span class="hljs-keyword">for</span> y <span class="hljs-keyword">in</span> range(height):  
        <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> range(width):  
            terrain[y][x] = noise.pnoise2(  
                x/scale,   
                y/scale,  
                octaves=octaves,  <span class="hljs-comment"># Adds smaller details  </span>
                persistence=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># How much each octave matters  </span>
                lacunarity=<span class="hljs-number">2.0</span>    <span class="hljs-comment"># Frequency multiplier per octave  </span>
            )  
    <span class="hljs-keyword">return</span> terrain
</code></pre>
<p><em>Tip</em> : Add <code>octaves=6</code> to create realistic mountains with large ridges <strong>and</strong> small rocks!</p>
<p><em>Dive into the simple grid based Perlin Noise Generator and create your own stunning landscapes now!</em></p>
<iframe src="https://velgardey.github.io/perlin-noise/" width="100%" height="1100px" style="border:none;border-radius:8px;box-shadow:0 4px 8px rgba(0,0,0,0.1)">
</iframe>

<p><em>Another Perlin noise can be mapped to make hills and elevations of varying heights !</em></p>
<h2 id="heading-2-cellular-automata-the-digital-ant-colony"><strong>2️⃣ Cellular Automata: The Digital Ant Colony</strong></h2>
<p><strong>Theory Time!</strong> 🐜<br />Imagine a grid of tiny "ants" (cells) that follow simple social rules:</p>
<ul>
<li><p><em>Rule 1</em> : If 5+ neighbors are walls, stay a wall (safety in numbers!).</p>
</li>
<li><p><em>Rule 2</em> : If lonely (≤3 neighbors), become open space.</p>
</li>
</ul>
<p><strong>Why it’s genius</strong>: Just like real ants building colonies with no blueprint, these cells self-organize! Start with random noise (think TV static), apply the rules 5 times, and <em>poof</em>—chaos becomes connected caves.</p>
<p><em>Terraria uses this for its underground tunnels. Fewer iterations = jagged caves. More iterations = smooth corridors.</em></p>
<p><strong>Rules</strong>:</p>
<ul>
<li><p>Start with random walls (1) and empty space (0).</p>
</li>
<li><p>For each cell, count its 8 neighbors.</p>
</li>
<li><p>If ≥5 neighbors are walls, it becomes a wall. Repeat 5x.</p>
</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">generate_cave</span>(<span class="hljs-params">width=<span class="hljs-number">40</span>, height=<span class="hljs-number">40</span>, iterations=<span class="hljs-number">5</span></span>):</span>  
    <span class="hljs-comment"># Initialize random grid (45% walls)  </span>
    grid = [[<span class="hljs-number">1</span> <span class="hljs-keyword">if</span> np.random.random() &lt; <span class="hljs-number">0.45</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span> <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(width)]   
            <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(height)]  

    <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(iterations):  
        new_grid = []  
        <span class="hljs-keyword">for</span> y <span class="hljs-keyword">in</span> range(height):  
            new_row = []  
            <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> range(width):  
                <span class="hljs-comment"># Count neighbors (including self)  </span>
                neighbors = sum(  
                    grid[ny][nx]  
                    <span class="hljs-keyword">for</span> nx <span class="hljs-keyword">in</span> range(max(<span class="hljs-number">0</span>, x<span class="hljs-number">-1</span>), min(width, x+<span class="hljs-number">2</span>))  
                    <span class="hljs-keyword">for</span> ny <span class="hljs-keyword">in</span> range(max(<span class="hljs-number">0</span>, y<span class="hljs-number">-1</span>), min(height, y+<span class="hljs-number">2</span>))  
                )  
                <span class="hljs-comment"># Rule: Become wall if 5+ neighbors  </span>
                new_row.append(<span class="hljs-number">1</span> <span class="hljs-keyword">if</span> neighbors &gt;= <span class="hljs-number">5</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>)  
            new_grid.append(new_row)  
        grid = new_grid  
    <span class="hljs-keyword">return</span> grid
</code></pre>
<p><em>Run this 5 times—watch random blobs turn into connected caves!</em></p>
<p><em>Jump into the Automata Generator and watch as random blobs magically morph into connected caves !</em></p>
<iframe src="https://velgardey.github.io/cellular-automata/" style="width:100%;height:1000px;border:none;border-radius:8px;background:#1a1a1a">
</iframe>

<h2 id="heading-3-fractals-amp-l-systems-natures-ctrlc-ctrlv"><strong>3️⃣ Fractals &amp; L-Systems: Nature’s CTRL+C, CTRL+V</strong></h2>
<p><strong>Theory Time!</strong> 🌿<br />Fractals are <strong>infinitely repeating patterns</strong>—like a broccoli floret where every tiny branch looks like the whole veggie! Here’s how they work:</p>
<ol>
<li><p><strong>The Recipe</strong>: Start with a shape (e.g., a line).</p>
</li>
<li><p><strong>The Copy Machine</strong>: Replace parts of the shape with smaller copies of itself.</p>
</li>
<li><p><strong>Repeat Forever</strong>: Each iteration adds finer details.</p>
</li>
</ol>
<p><strong>L-Systems</strong> take this further with <em>grammar rules</em>:</p>
<ul>
<li><p>Start: <code>A</code> (a single branch)</p>
</li>
<li><p>Rule: Replace <code>A</code> → <code>A+B</code>, <code>B</code> → <code>A−B</code></p>
</li>
<li><p>After 3 iterations: <code>A+B+A−B+A+B−A−B</code> → a complex tree!</p>
</li>
</ul>
<p><em>Why gamers care</em> : Want 10,000 unique trees? Write 5 rules. Want a galaxy? Write 10. Fractals let you <em>clone complexity</em> from simplicity!</p>
<pre><code class="lang-python"><span class="hljs-comment"># Recursive tree generator using Turtle  </span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">draw_branch</span>(<span class="hljs-params">length, angle, depth</span>):</span>  
    <span class="hljs-keyword">if</span> depth == <span class="hljs-number">0</span>:  
        <span class="hljs-keyword">return</span>  
    turtle.forward(length)  
    turtle.left(angle)  
    draw_branch(length * <span class="hljs-number">0.7</span>, angle, depth<span class="hljs-number">-1</span>)  
    turtle.right(<span class="hljs-number">2</span> * angle)  
    draw_branch(length * <span class="hljs-number">0.7</span>, angle, depth<span class="hljs-number">-1</span>)  
    turtle.left(angle)  
    turtle.backward(length)  

turtle.speed(<span class="hljs-number">0</span>)  
turtle.left(<span class="hljs-number">90</span>)  
draw_branch(<span class="hljs-number">100</span>, <span class="hljs-number">30</span>, <span class="hljs-number">5</span>)  <span class="hljs-comment"># Try depth=7 for dense trees!</span>
</code></pre>
<p><em>Each branch splits into smaller copies—just like real plants!</em></p>
<p><em>Enter the Fractal Tree Generator and see your designs branch out into intricate patterns!</em></p>
<iframe src="https://velgardey.github.io/fractal-tree/" width="100%" height="970px" style="border-radius:8px;border:1px solid #404040"></iframe>

<h2 id="heading-4-wave-function-collapse-wfc-the-ai-artist">4️⃣ <strong>Wave Function Collapse (WFC): The AI Artist</strong></h2>
<p><strong>Theory Time!</strong> 🧩<br />WFC works like Sudoku. Each tile has <em>constraints</em> (e.g., "roads must connect"). The algorithm collapses possibilities one cell at a time, respecting neighbours. It’s <strong>constraint satisfaction</strong>—noise with rules!</p>
<p><em>Used in Townscaper and Bad North for coherent villages.</em></p>
<p><strong>How it works</strong>:</p>
<ol>
<li><p>Define tiles (e.g., “road”, “house”) and their compatible neighbours.</p>
</li>
<li><p>Start with a blank grid.</p>
</li>
<li><p>Collapse each cell’s possibilities based on neighbours.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Simplified WFC example  </span>
tiles = {  
    <span class="hljs-string">"water"</span>: {<span class="hljs-string">"up"</span>: [<span class="hljs-string">"water"</span>, <span class="hljs-string">"sand"</span>], <span class="hljs-string">"down"</span>: [<span class="hljs-string">"water"</span>]},  
    <span class="hljs-string">"sand"</span>: {<span class="hljs-string">"up"</span>: [<span class="hljs-string">"grass"</span>], <span class="hljs-string">"down"</span>: [<span class="hljs-string">"water"</span>]},  
    <span class="hljs-string">"grass"</span>: {<span class="hljs-string">"down"</span>: [<span class="hljs-string">"sand"</span>]}  
}  

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">collapse_cell</span>(<span class="hljs-params">grid, x, y</span>):</span>  
    possible_tiles = list(tiles.keys())  
    <span class="hljs-comment"># Check neighbors (left/top)  </span>
    <span class="hljs-keyword">if</span> x &gt; <span class="hljs-number">0</span>:  
        left_tile = grid[y][x<span class="hljs-number">-1</span>]  
        possible_tiles = [t <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> possible_tiles  
                          <span class="hljs-keyword">if</span> t <span class="hljs-keyword">in</span> tiles[left_tile][<span class="hljs-string">"right"</span>]]  
    <span class="hljs-keyword">if</span> y &gt; <span class="hljs-number">0</span>:  
        top_tile = grid[y<span class="hljs-number">-1</span>][x]  
        possible_tiles = [t <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> possible_tiles  
                          <span class="hljs-keyword">if</span> t <span class="hljs-keyword">in</span> tiles[top_tile][<span class="hljs-string">"down"</span>]]  
    <span class="hljs-comment"># Pick randomly from remaining options  </span>
    grid[y][x] = np.random.choice(possible_tiles)
</code></pre>
<p><em>WFC ensures beaches (sand) always sit between water and grass!</em></p>
<hr />
<h2 id="heading-the-dark-side-when-algorithms-rebel">💥 <strong>The Dark Side: When Algorithms Rebel</strong></h2>
<h2 id="heading-1-the-everything-looks-same-ish-problem">1️⃣ <strong>The “Everything Looks Same-ish” Problem</strong></h2>
<p><em>No Man’s Sky’s</em> 2016 launch taught us this: If all icy planets use the <em>same noise parameters</em>, players see repeating ice spikes. <strong>Why?</strong> Algorithms lack <em>context</em>—they don’t know a “cool mountain” from a “boring hill”.</p>
<p><em>Dev fix</em> : Mix multiple noise layers (e.g., Perlin for shape + Cellular algorithms for cracks) and sprinkle <strong>handcrafted landmarks</strong> (e.g., a giant alien skeleton every 10 planets).</p>
<h2 id="heading-2-your-gpu-hates-you"><strong>2️⃣</strong> <strong>Your GPU Hates You</strong></h2>
<p>Procedural generation <em>on-the-fly</em> can melt weaker hardware. Imagine generating <em>Elden Ring’s</em> entire map while players explore—your GPU would burst into flames!</p>
<p><em>Solutions</em> :</p>
<ul>
<li><p><strong>Chunking</strong>: Like Minecraft, generate the world in 16x16 blocks.</p>
</li>
<li><p><strong>Pre-baking</strong>: Generate textures/geometry during loading screens.</p>
</li>
<li><p><strong>Level of Detail (LOD)</strong>: Show low-poly mountains from afar, add details up close.</p>
</li>
</ul>
<h2 id="heading-3-storytellings-kryptonite"><strong>3️⃣</strong> <strong>Storytelling’s Kryptonite</strong></h2>
<p>Algorithms can’t write <em>The Last of Us</em>. Most procedural quests end up as:</p>
<pre><code class="lang-plaintext">1. Go to [RANDOM LOCATION]  
2. Kill [RANDOM NUMBER] [RANDOM ENEMY]  
3. Return to [RANDOM NPC]
</code></pre>
<p><em>Why?</em> Stories need <strong>intentionality</strong>—something RNG can’t provide.</p>
<p><em>Dev workaround</em> : Do what <em>Hades</em> did:</p>
<ul>
<li><p>Handwrite 1000+ dialogue lines</p>
</li>
<li><p>Use procedural <em>context</em> (e.g., “If player dies to lava, NPC mocks them”)</p>
</li>
</ul>
<h2 id="heading-4-the-oops-thats-impossible-glitch">4️⃣ <strong>The “Oops, That’s Impossible” Glitch</strong></h2>
<p>Procedural dungeons can accidentally create <strong>unbeatable rooms</strong> (e.g., a key behind a locked door). <em>Dwarf Fortress</em> once spawned whales on mountains—they suffocated immediately.</p>
<p><em>Debugging hell</em> : You can’t test every possible seed! Most devs use <strong>algorithmic safeguards</strong>:</p>
<pre><code class="lang-python"><span class="hljs-keyword">if</span> dungeon_room.has_key:  
    ensure_door_unlocked()
</code></pre>
<hr />
<h2 id="heading-beyond-games-real-world-sorcery">🌍 <strong>Beyond Games: Real-World Sorcery</strong></h2>
<h2 id="heading-movies-amp-cgi">🎥 <strong>Movies &amp; CGI</strong></h2>
<ul>
<li><p><strong>Avatar’s Pandora</strong>: Mixed procedural forests with hero trees painted by artists.</p>
</li>
<li><p><strong>Lord of the Rings’ Helm’s Deep Battle</strong>: Used <em>Massive Software</em> to simulate 10,000+ Uruk-hai with <strong>autonomous AI agents</strong>. Each orc had simple rules:</p>
<ul>
<li><p>“Find Allies”</p>
</li>
<li><p>“Attack Nearest Human”</p>
</li>
<li><p>“Flee if Surrounded”<br />  Result? A chaotic battle that <em>looked</em> hand-animated!</p>
</li>
</ul>
</li>
</ul>
<h2 id="heading-architecture">🏗️ <strong>Architecture</strong></h2>
<ul>
<li><p><strong>Procedural skyscrapers</strong>: Input “floor count, style, material” → get 100 variants.</p>
</li>
<li><p><strong>CityEngine</strong>: Software for generating entire cities for urban planning.</p>
</li>
</ul>
<h2 id="heading-ai-training">🧠 <strong>AI Training</strong></h2>
<ul>
<li>Generate infinite training data: <strong>random roads</strong> for self-driving cars, <strong>fake tumors</strong> for medical AI.</li>
</ul>
<hr />
<h2 id="heading-your-starter-kit">🛠️ <strong>Your Starter Kit</strong></h2>
<ol>
<li><p><strong>Noise Libraries</strong> : <code>FastNoiseLite</code> (C#/Unity), <code>noise</code> (Python)</p>
</li>
<li><p><strong>Engines</strong> : Try Unity’s <strong>Procedural Toolkit</strong> or Unreal’s <strong>PCG</strong> plugin.</p>
</li>
<li><p><strong>First Project</strong> : A “roguelike dungeon” with cellular automata (2D grid + ASCII art!).</p>
</li>
</ol>
<p><em>Remember: Start small. Your first planet can be a noisy sphere—no one’s judging!</em></p>
<hr />
<h2 id="heading-level-up-resources">📚 <strong>Level Up Resources</strong></h2>
<ul>
<li><p><strong>Book</strong>: <em>Procedural Generation in Game Design</em> by Tanya Short (for design philosophy)</p>
</li>
<li><p><strong>Tutorial</strong>: <a target="_blank" href="https://youtu.be/wbpMiKiSKm8">Procedural Landmass Generation</a> by Sebastian Lague</p>
</li>
<li><p><strong>Tool</strong>: <a target="_blank" href="https://github.com/mxgmn/WaveFunctionCollapse">Wave Function Collapse</a> GitHub</p>
</li>
</ul>
<p><em>Now go make something that’ll make Notch proud!</em> 🚀</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Defogging the basics of Fog Computing]]></title><description><![CDATA[In today's ever-evolving world, unlocking the true power of cloud technology is not merely an option but an essential strategy. A process called “fog computing” has been working behind the scenes to assist the cloud in exactly this task. As the fog d...]]></description><link>https://blog.gdscnits.in/defogging-the-basics-of-fog-computing</link><guid isPermaLink="true">https://blog.gdscnits.in/defogging-the-basics-of-fog-computing</guid><category><![CDATA[Fog Computing ]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[networking]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Shrish Lahiri]]></dc:creator><pubDate>Wed, 05 Feb 2025 21:04:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736263005090/253c95e5-4417-4540-a0f6-a5aefeacd9f0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In today's ever-evolving world, unlocking the true power of cloud technology is not merely an option but an essential strategy. A process called “fog computing” has been working behind the scenes to assist the cloud in exactly this task. As the fog descends on our homes this January, let's learn about fog computing and how it has helped shaped the diverse and complex system of high-speed networks that exist today.</p>
<p><img src="https://www.turningcloud.com/blog/wp-content/uploads/2021/09/what-is-fog-computing.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-exactly-is-fog-computing"><strong><em>What exactly is fog computing?</em></strong></h2>
<p>Coined by Cisco's product line manager Ginny Nichols in 2014, fog computing (or fogging), as the name implies, refers to a segregated computing infrastructure in which computing resources are located between a data source and the cloud (or) another data centre. In simple words, Fog is an extension of cloud computing that consists of multiple edge nodes directly connected to physical devices.</p>
<p>In nature, Fog is closer to Earth than clouds; In the tech world, it's the same; Fog is closer to end-users, bringing cloud capabilities to the ground.</p>
<p><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXehTg7sTAxAtDplnnql3w-fdWlv4QWnRTBRyA2-I5AcM8Tcp4XLldsFlLUju06Y8mP3C3fwjtuWvokqsnV3x_MosbcCV87HfozDWgOBmRewHyVHbLfwrLCt0BX2ymaEX2FLoNGr?key=US0TagL1e9zkxZ6KXYSBNkrW" alt /></p>
<h2 id="heading-what-are-the-benefits"><strong><em>What are the benefits?</em></strong></h2>
<ul>
<li><p>Fog computing brings the advantages and power of the cloud closer to where data is created and acted upon. This is often done to improve efficiency, bolster security and increase compatibility. </p>
</li>
<li><p>Fog networking complements cloud computing, enabling short-term analytics at the edge, while the cloud performs resource-intensive, longer-term analytics. Although edge devices and sensors are where data is generated and collected, they sometimes don't have the compute and storage resources to perform advanced analytics and machine learning tasks. Though cloud servers have the power to do this, they are often too far away to process the data and respond in a timely manner. </p>
</li>
<li><p>In addition, having all endpoints connecting to and sending raw data to the cloud over the internet can have privacy, security and legal implications, especially when dealing with sensitive data subject to regulations in different countries. </p>
</li>
<li><p>Fog computing helps by being much closer to devices than centralized data centres so that they can provide instant connections. The considerable processing power of edge nodes allows them to compute large amounts of data without sending them to distant servers.</p>
</li>
</ul>
<h2 id="heading-where-can-we-see-it-in-action">Where can we see it in action?</h2>
<ul>
<li><p>One increasingly common use case for fog computing is traffic control. Because sensors -- such as those used to detect traffic -- are often connected to cellular networks, cities sometimes deploy computing resources near the cell tower. These computing capabilities enable real-time analytics of traffic data, thereby enabling traffic signals to respond in real time to changing conditions.</p>
</li>
<li><p>This basic concept is also being extended to autonomous vehicles. Autonomous vehicles essentially function as edge devices because of their vast onboard computing power. These vehicles must be able to ingest data from a huge number of sensors, perform real-time data analytics and then respond accordingly.</p>
</li>
<li><p>Because an autonomous vehicle is designed to function without the need for cloud connectivity, it's tempting to think of autonomous vehicles as not being connected devices. Even though an autonomous vehicle must be able to drive safely in the total absence of cloud connectivity, it's still possible to use connectivity when available. Some cities are considering how an autonomous vehicle might operate with the same computing resources used to control traffic lights. </p>
</li>
<li><p>Such a vehicle might, for example, function as an edge device and use its own computing capabilities to relay real-time data to the system that ingests traffic data from other sources. The underlying computing platform can then use this data to operate traffic signals more effectively.</p>
</li>
<li><p>Few more applications are illustrated below:</p>
</li>
</ul>
<p><img src="https://pbs.twimg.com/media/DDgBp8YW0AAFNrl.jpg" alt class="image--center mx-auto" /></p>
<h2 id="heading-any-proscons"><strong><em>Any Pros/Cons?</em></strong></h2>
<p>Fog computing has its fair share of pros and cons as illustrated below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736263297728/c44e23e1-357e-4787-ad54-00480fb800d5.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-fact-checks-in-a-snap"><strong><em>Fact checks in a snap:</em></strong></h2>
<ul>
<li><h3 id="heading-fog-computing-vs-edge-computing">Fog computing vs. Edge computing:</h3>
</li>
</ul>
<p>According to the OpenFog Consortium started by Cisco, the key difference between edge and fog computing is where the intelligence and compute power are placed. In a strictly foggy environment, intelligence is at the local area network (LAN), and data is transmitted from endpoints to a fog gateway, where it's then transmitted to sources for processing and return transmission. In edge computing, intelligence and power can be in either the endpoint or a gateway.</p>
<ul>
<li><h3 id="heading-fog-computing-vs-cloud-computing">Fog Computing vs. Cloud Computing:</h3>
</li>
</ul>
<p>The main difference between fog computing and cloud computing is that Cloud is a centralized system, whereas Fog is a distributed decentralized infrastructure. It should be noted however that fog networking is not a separate architecture. It does not replace cloud computing but complements it by getting as close as possible to the source of information.</p>
<h2 id="heading-the-takeaway"><strong><em>The Takeaway:</em></strong></h2>
<p>As the demand for faster and efficient communication increases with the rise of smart technologies, Fog computing is likely only the first step to ensuring a smarter tomorrow. Let us appreciate the beauty of nature that continues to inspire bright minds across the globe; for a keen eye will easily notice that almost all innovations, large or small, originate from the infinite mysteries of Mother Earth.</p>
<p><img src="https://tse4.mm.bing.net/th?id=OIG2.u4onZpEIYyD.x6wUBryo&amp;pid=ImgGn" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[From Ancient Ciphers to Quantum Keys: A Journey Through Cryptography]]></title><description><![CDATA[Introduction
Cryptography is the practice and study of techniques for securing communication and data from adversaries. It ensures that information remains private, authentic, and untampered, even in the presence of malicious entities. Rooted in math...]]></description><link>https://blog.gdscnits.in/from-ancient-ciphers-to-quantum-keys-a-journey-through-cryptography</link><guid isPermaLink="true">https://blog.gdscnits.in/from-ancient-ciphers-to-quantum-keys-a-journey-through-cryptography</guid><dc:creator><![CDATA[Prachi]]></dc:creator><pubDate>Thu, 30 Jan 2025 07:18:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735127034264/6541f0e1-455e-4be4-9ac1-ce172ee0de8a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Cryptography is the practice and study of techniques for securing communication and data from adversaries. It ensures that information remains private, authentic, and untampered, even in the presence of malicious entities. Rooted in mathematics and computer science, cryptography plays a vital role in protecting digital systems and ensuring trust in the digital age.</p>
<h2 id="heading-how-this-all-began">How this all began?</h2>
<ul>
<li><p><strong>Ancient Cryptography</strong>:</p>
<ul>
<li><p><strong>Caesar Cipher</strong> : Julius Caesar used a simple substitution cipher to protect military messages.</p>
</li>
<li><p><strong>Al-Kindi</strong> : Introduced frequency analysis to break ciphers.</p>
</li>
<li><p><strong>Vigenère Cipher</strong>: A more complex cipher considered unbreakable at the time.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735078453695/d3afc721-16f4-4103-9796-960e2fc5d318.jpeg" alt class="image--center mx-auto" /></p>
</li>
</ul>
</li>
</ul>
<p><strong>Modern Cryptography</strong>:</p>
<ul>
<li><p><strong>Claude Shannon</strong> : Founded modern cryptographic theory.</p>
</li>
<li><p><strong>Symmetric Encryption</strong>: <strong>DES (1970s)</strong> became a widely used encryption standard.</p>
</li>
<li><p><strong>Public-Key Cryptography</strong>: Introduced by Diffie and Hellman in the 1970s, with <strong>RSA (1977)</strong> enabling secure communication without shared keys.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735078525361/205f4942-d444-46fc-a312-b3065c679f52.jpeg" alt class="image--center mx-auto" /></p>
</li>
</ul>
<h2 id="heading-diving-deep-in-cryptography">Diving deep in Cryptography:</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735125964258/1ab59cda-3ce0-4501-bfdb-5d7c789d89ef.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-1-symmetric-key-cryptography-secret-key-cryptography">1. <strong>Symmetric-Key Cryptography (Secret Key Cryptography)</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Both the sender and the receiver use the same key for both encryption and decryption.</p>
</li>
<li><p><strong>Examples</strong>:</p>
<ul>
<li><p><strong>AES (Advanced Encryption Standard)</strong>: A widely used encryption standard for securing data.</p>
</li>
<li><p><strong>DES (Data Encryption Standard)</strong>: An older encryption algorithm now considered insecure.</p>
</li>
<li><p><strong>RC4</strong>: A stream cipher that was widely used in protocols like SSL but is no longer considered secure.</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-2-asymmetric-key-cryptography-public-key-cryptography">2. <strong>Asymmetric-Key Cryptography (Public Key Cryptography)</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Uses a pair of keys—one public key for encryption and a private key for decryption.</p>
</li>
<li><p><strong>Examples</strong>:</p>
<ul>
<li><p><strong>RSA (Rivest–Shamir–Adleman)</strong>: A widely used asymmetric encryption algorithm.</p>
</li>
<li><p><strong>ECC (Elliptic Curve Cryptography)</strong>: More efficient than RSA for key sizes.</p>
</li>
<li><p><strong>DSA (Digital Signature Algorithm)</strong>: Used for creating digital signatures.</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-3-hash-functions">3. <strong>Hash Functions</strong></h3>
<ul>
<li><p><strong>Definition</strong>: A one-way function that takes an input and produces a fixed-length output (hash). The output is typically unique for each unique input. Used for verifying data integrity and creating digital signatures, not for encryption and decryption.</p>
</li>
<li><p><strong>Examples</strong>:</p>
<ul>
<li><p><strong>SHA (Secure Hash Algorithm)</strong>: A family of cryptographic hash functions, such as SHA-256.</p>
</li>
<li><p><strong>MD5 (Message Digest Algorithm 5)</strong>: An older hash function, now considered weak due to vulnerability to collision attacks.</p>
</li>
<li><p><strong>BLAKE2</strong>: A cryptographic hash function designed as an alternative to MD5 and SHA.</p>
</li>
</ul>
</li>
</ul>
<h2 id="heading-more-on-rsa">MORE ON → RSA</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735126285935/d7a46cb5-b131-43d2-9773-94f22f45c9ed.png" alt class="image--center mx-auto" /></p>
<p>RSA (Rivest-Shamir-Adleman) is one of the most widely used asymmetric cryptographic algorithms. It is based on the principle of public-key cryptography, where two keys are used: a <strong>public key</strong> for encryption and a <strong>private key</strong> for decryption.</p>
<h3 id="heading-steps-to-generate-rsa-keys"><strong>Steps to Generate RSA Keys</strong></h3>
<ol>
<li><p><strong>Choose two large prime numbers</strong> <code>p</code> and <code>q</code>.</p>
<ul>
<li>The larger the primes, the stronger the security.</li>
</ul>
</li>
<li><p><strong>Compute</strong> <code>n = p * q</code>.</p>
<ul>
<li>This value is used in both the public and private keys.</li>
</ul>
</li>
<li><p><strong>Calculate Euler’s Totient Function</strong> <code>φ(n) = (p - 1) * (q - 1)</code>.</p>
</li>
<li><p><strong>Choose a public exponent</strong> <code>e</code>.</p>
<ul>
<li>Typically, <code>e</code> is 65537, which is a commonly used prime number.</li>
</ul>
</li>
<li><p><strong>Calculate the private exponent</strong> <code>d</code>.</p>
<ul>
<li><code>d</code> is the modular inverse of <code>e</code> modulo <code>φ(n)</code>. This can be calculated using the Extended Euclidean Algorithm.</li>
</ul>
</li>
<li><p><strong>The public key is</strong> <code>(n, e)</code>.</p>
<ul>
<li>The private key is <code>(n, d)</code>.</li>
</ul>
</li>
</ol>
<p>AND…TAADAH! We can generate our own pair of public and private keys.</p>
<h2 id="heading-how-to-implement">How to implement?</h2>
<h3 id="heading-cpythonjava-libraries-for-cryptography"><strong>C++/Python/Java Libraries for Cryptography</strong></h3>
<ol>
<li><p><strong>OpenSSL:</strong> <a target="_blank" href="https://www.openssl.org/">https://www.openssl.org</a></p>
</li>
<li><p><strong>Crypto++:</strong> <a target="_blank" href="https://www.cryptopp.com/">https://www.cryptopp.com/</a></p>
</li>
<li><p>Botan: <a target="_blank" href="https://botan.randombit.net/">https://botan.randombit.net/</a></p>
</li>
<li><p>PyCryptodome:<a target="_blank" href="https://www.pycryptodome.org/">https://www.pycryptodome.org</a></p>
</li>
</ol>
<p>5.Bouncy Castle:<a target="_blank" href="https://www.bouncycastle.org/">https://www.bouncycastle.org/</a></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The field has evolved significantly, from ancient encryption methods like Caesar ciphers to modern techniques such as RSA, AES, and elliptic curve cryptography (ECC), each offering greater security and efficiency. Cryptography is foundational in various applications, including secure messaging, digital signatures, key exchange protocols, and blockchain technology.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding and Preventing SQL Injection Attacks]]></title><description><![CDATA[Introduction
In this article, you'll learn about an attack that targets a very common application vulnerability, an injection attack. I'll demonstrate such an attack and, most importantly, show you how you can protect yourself. An injection attack ha...]]></description><link>https://blog.gdscnits.in/understanding-and-preventing-sql-injection-attacks</link><guid isPermaLink="true">https://blog.gdscnits.in/understanding-and-preventing-sql-injection-attacks</guid><dc:creator><![CDATA[Abhinav Narayan Dev]]></dc:creator><pubDate>Sun, 26 Jan 2025 18:51:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736619208931/a06c32b9-e60e-4419-8fd7-422a09d8f130.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>In this article, you'll learn about an attack that targets a very common application vulnerability, an <strong>injection attack</strong>. I'll demonstrate such an attack and, most importantly, show you how you can protect yourself. An injection attack happens when an attacker tries to inject malicious code or commands into an application. This typically happens if the application doesn't validate user input before processing it. The injected code can then be executed, leading to a wide range of potential security issues.</p>
<p>One common type of injection attack is <strong>SQL injection</strong>. Using a SQL injection, an attacker can manipulate the SQL statements your application sends to a database, enabling them to perform unauthorized actions or access sensitive data. To demonstrate this, I will use the <a target="_blank" href="https://juice-shop.herokuapp.com/#/">OWASP Juice Shop</a>, an intentionally vulnerable web application designed to help users learn about various application security risks. The OWASP Juice Shop is available on <a target="_blank" href="https://github.com/juice-shop">GitHub</a>.</p>
<h2 id="heading-exploiting-a-sql-injection-vulnerability">Exploiting a SQL Injection vulnerability</h2>
<p>Users can log in to this shop using their email address and password. In this scenario, a typical injection attack would be to manipulate the input and try to log in as a different user.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736879929088/13e105fc-7b04-4484-8a05-2684f7eba4cb.png" alt class="image--center mx-auto" /></p>
<p>A website like this often uses a relational database like MySQL to manage its users, and if this is the case, the login page probably sends a select statement to that database to see if the email address exists and if the password is correct. These statements usually look similar to this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">users</span> <span class="hljs-keyword">WHERE</span> email = <span class="hljs-string">'email'</span> <span class="hljs-keyword">AND</span> <span class="hljs-keyword">password</span> = <span class="hljs-string">'password'</span>
</code></pre>
<p>Now, let's try logging in to an account (hopefully an admin account). The problem is, we don't know the email or password. To bypass this, we can modify the query so that it doesn't validate the email or password. One way to achieve this is by adding two dashes (--) to comment out the rest of the SQL query.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">users</span> <span class="hljs-keyword">WHERE</span> email = <span class="hljs-string">'email'</span> <span class="hljs-comment">-- AND password = 'password'</span>
</code></pre>
<p>Notice that after adding (--) to the query, everything following it is treated as a comment. This means the query will ignore the password check.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">users</span> <span class="hljs-keyword">WHERE</span> email = <span class="hljs-string">'email'</span> <span class="hljs-keyword">OR</span> <span class="hljs-number">1</span>=<span class="hljs-number">1</span> <span class="hljs-comment">-- AND password = 'password'</span>
</code></pre>
<p>Furthermore, by adding <code>OR 1=1</code>, the query will evaluate whether 1 equals 1, which is always true. As a result, it is not required to know the email address to log in.</p>
<p>But how can we modify the data we send so that it adds these dashes? If we just add them to the email address, it would look like this:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">users</span> <span class="hljs-keyword">WHERE</span> email = <span class="hljs-string">'email or 1=1 --'</span> <span class="hljs-keyword">AND</span> <span class="hljs-keyword">password</span> = <span class="hljs-string">'password'</span>
</code></pre>
<p>The dashes are inside the code, and the database will think it's part of the email address and not part of the query itself, so this doesn't work.</p>
<p>Now, how do we get the dashes outside of this code? We can achieve this by adding another single quote (<code>'</code>) as part of the email address we provide. For example: <code>email' OR 1=1 --</code>.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">users</span> <span class="hljs-keyword">WHERE</span> email = <span class="hljs-string">'email'</span> <span class="hljs-keyword">or</span> <span class="hljs-number">1</span>=<span class="hljs-number">1</span> <span class="hljs-comment">--' AND password = 'password'</span>
</code></pre>
<p>We've got a valid query that only looks for the email address and ignores the password. Let's try this in the app.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736882962014/eb335b2a-cc80-4dca-99a3-9a51864fbed3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736883114048/0aa875d9-2312-4a15-9e3b-d3a4fef84692.png" alt class="image--center mx-auto" /></p>
<p>We are, in fact, logged in as the admin and have access to all their data, including addresses, payment options, and a digital wallet.</p>
<h2 id="heading-fixing-a-sql-injection-vulnerability">Fixing a SQL injection vulnerability</h2>
<p>It actually looks like a serious security risk. Let's see how we can fix this. Here's the login function from this shop.</p>
<pre><code class="lang-typescript"><span class="hljs-built_in">module</span>.<span class="hljs-built_in">exports</span> = <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">login</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-function">(<span class="hljs-params">req: Request, res: Response</span>) =&gt;</span> {
        <span class="hljs-keyword">const</span> email = req.body.email;
        <span class="hljs-keyword">const</span> password = security.hash(req.body.password);

        <span class="hljs-keyword">const</span> query = <span class="hljs-string">`
            SELECT * FROM Users WHERE email = '<span class="hljs-subst">${email}</span>' AND password = '<span class="hljs-subst">${password}</span>'
        `</span>;

        models.sequelize.query(query, {
            model: UserModel,
            plain: <span class="hljs-literal">true</span>
        }).then(<span class="hljs-function">(<span class="hljs-params">authenticatedUser: { data: User }</span>) =&gt;</span> {
            <span class="hljs-keyword">const</span> user = utils.queryResultToJson(authenticatedUser);

            <span class="hljs-keyword">if</span> (user.data?.id) {
                returnSuccessfulLogin(res, user);
            } <span class="hljs-keyword">else</span> {
                returnUnauthorized(res, <span class="hljs-string">"Invalid email or password."</span>);
            }
        });
    };
};
</code></pre>
<p>As you can see, it takes the email and adds it to the query, and also the password, hashes it for security and adds it to the query too. Then, it sends the query using sequelize and transforms the result into a user model. If the user exists, they will be logged in. Otherwise, the app will return the message that we've already seen, "Invalid email or password."</p>
<p>We can fix this by not directly using the user input and using query parameters instead. Let's replace the email and the password with question marks and add them as parameters to the Sequelize query using the replacements attribute. This way, the query isn't just built from whatever the user enters into the fields. It is parameterized, and the database server makes sure that none of these replacements can be executed as part of the query.</p>
<pre><code class="lang-typescript"><span class="hljs-built_in">module</span>.<span class="hljs-built_in">exports</span> = <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">login</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-function">(<span class="hljs-params">req: Request, res: Response</span>) =&gt;</span> {
        <span class="hljs-keyword">const</span> email = req.body.email;
        <span class="hljs-keyword">const</span> password = security.hash(req.body.password);

        <span class="hljs-keyword">const</span> query = <span class="hljs-string">`
            SELECT * FROM Users WHERE email = ? AND password = ?
        `</span>;

        models.sequelize.query(query, {
            replacements:[email,password],
            model: UserModel,
            plain: <span class="hljs-literal">true</span>
        }).then(<span class="hljs-function">(<span class="hljs-params">authenticatedUser: { data: User }</span>) =&gt;</span> {
            <span class="hljs-keyword">const</span> user = utils.queryResultToJson(authenticatedUser);

            <span class="hljs-keyword">if</span> (user.data?.id) {
                returnSuccessfulLogin(res, user);
            } <span class="hljs-keyword">else</span> {
                returnUnauthorized(res, <span class="hljs-string">"Invalid email or password."</span>);
            }
        });
    };
};
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>This was a straightforward but classic example of an injection attack. I hope it effectively demonstrated the importance of never trusting user input and ensuring that nothing a user sends to your application is executed directly. To protect your application against such risks, <strong>always</strong> <strong>validate and sanitize all inputs</strong>, or leverage built-in mechanisms like query parameters, as shown in the demo.</p>
<h3 id="heading-online-resources-and-tutorials">Online resources and tutorials</h3>
<p>Here are some online resources you can refer to for more details about SQL injection and exploitation:</p>
<ol>
<li><p>OWASP SQL Injection Cheat Sheet : <a target="_blank" href="https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html">https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html</a></p>
</li>
<li><p>Wikipedia: <a target="_blank" href="https://en.wikipedia.org/wiki/SQL_injection">https://en.wikipedia.org/wiki/SQL_injection</a></p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Augmented Reality: A Game Changer for Mobile Apps]]></title><description><![CDATA[What is Augmented Reality (AR) ?
Augmented Reality (AR) is a technology that enhances the real-world environment by superimposing digital information, such as images, sounds, videos, or other sensory elements, onto it. Unlike Virtual Reality (VR), wh...]]></description><link>https://blog.gdscnits.in/augmented-reality-a-game-changer-for-mobile-apps</link><guid isPermaLink="true">https://blog.gdscnits.in/augmented-reality-a-game-changer-for-mobile-apps</guid><dc:creator><![CDATA[Draksha Chaudhary]]></dc:creator><pubDate>Mon, 06 Jan 2025 18:06:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736084006387/ffb8e133-083b-4c78-8ee4-765a83cc6313.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<h2 id="heading-what-is-augmented-reality-ar"><strong>What is Augmented Reality (AR) ?</strong></h2>
<p><strong>Augmented Reality (AR)</strong> is a technology that enhances the real-world environment by superimposing digital information, such as images, sounds, videos, or other sensory elements, onto it. Unlike <strong>Virtual Reality (VR)</strong>, which creates an entirely virtual environment, Augmented Reality (AR) enhances the real world with digital content, such as virtual objects, information, or effects, viewed through devices like smartphones, tablets, or AR glasses. Some examples of AR are Pokémon GO, IKEA Place, Google lens, Snapchat filters, etc.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736084506310/54da4d2d-fc0f-48eb-865f-0d42ddcc5777.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-key-technologies-behind-ar-in-mobile-apps"><strong>Key Technologies Behind AR in Mobile Apps</strong></h2>
<h3 id="heading-arkit-ios-and-arcore-android">ARKit (iOS) and ARCore (Android)</h3>
<p><strong>ARKit</strong> (iOS) and <strong>ARCore</strong> (Android) are platforms that enable developers to create AR experiences on mobile devices by utilizing the camera, sensors, and processing power. They provide features like surface detection, motion tracking, and light estimation.</p>
<h3 id="heading-slam-and-computer-vision">SLAM and Computer Vision</h3>
<p><strong>SLAM</strong> (Simultaneous Localization and Mapping) allows AR apps to map the environment and track the device’s position in real-time, ensuring accurate placement of virtual objects. <strong>Computer Vision</strong> helps the device recognize objects, detect surfaces, and interpret the environment through image analysis, enabling seamless integration of virtual content with the physical world for interactive experiences.</p>
<p>Together, <strong>SLAM</strong> and <strong>Computer Vision</strong> enable AR systems to perform real-time analysis and interaction with the physical world, making virtual content appear as if it is truly integrated into the environment, regardless of how the user moves or changes their viewpoint.</p>
<hr />
<h2 id="heading-why-is-ar-a-game-changer-for-mobile-apps"><strong>Why is AR a Game Changer for Mobile Apps?</strong></h2>
<p><strong>Augmented Reality (AR)</strong> is a game-changer for mobile apps by enhancing user experiences through the integration of digital content into the real world. AR blends the physical and virtual worlds, offering interactive, immersive, and engaging features like real-time interaction, object recognition, and environmental mapping. It works using a combination of camera sensors, SLAM (Simultaneous Localization and Mapping), and computer vision to track surroundings, identify objects, and place virtual content accurately.</p>
<p><strong>AR features</strong> include real-time environmental understanding, realistic 3D object overlays, navigation assistance, and gesture recognition, which create seamless and interactive experiences. AR works through devices’ cameras and sensors, allowing apps to map the environment, understand the user’s position, and render virtual objects accordingly.</p>
<p><strong>AR is used across various sectors</strong>:</p>
<ul>
<li><p><strong>Retail</strong>: Apps like <strong>IKEA Place</strong> help visualize furniture in homes.</p>
</li>
<li><p><strong>Gaming</strong>: Games like <strong>Pokémon GO</strong> use AR to place virtual characters in real environments.</p>
</li>
<li><p><strong>Education</strong>: AR enables interactive learning, like <strong>Google Expeditions</strong> for virtual field trips.</p>
</li>
<li><p><strong>Healthcare</strong>: <strong>Microsoft HoloLens</strong> overlays medical data for precise surgeries.</p>
</li>
<li><p><strong>Real Estate</strong>: Virtual property tours via AR apps.</p>
</li>
</ul>
<p><strong>Companies driving AR</strong> include <strong>Apple</strong> (ARKit), <strong>Google</strong> (ARCore), <strong>Microsoft</strong> (HoloLens), and <strong>Snapchat</strong> with AR filters. AR is transforming mobile apps, enhancing engagement, and creating new opportunities across industries.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736084079113/dce6adea-6128-4904-80a2-98c335121bf2.jpeg" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In conclusion, Augmented Reality (AR) is transforming mobile apps by combining the real world with digital content, creating interactive and immersive experiences. With tools like <strong>ARKit</strong> and <strong>ARCore</strong>, AR is used in various industries such as retail, gaming, education, healthcare, and real estate. Companies like <strong>Apple</strong>, <strong>Google</strong>, <strong>Microsoft</strong>, and <strong>Snapchat</strong> are leading the way in making AR more accessible and impactful. As AR continues to improve, it offers endless possibilities to enhance user engagement and revolutionize how we interact with technology in everyday life.</p>
<hr />
<p>For more ideas :<br /><a target="_blank" href="https://youtu.be/XPNUmcEOYW0?si=zmmsPpS_HIVfo7TF">Augmented Reality in 60sec</a></p>
<p><a target="_blank" href="https://www.youtube.com/watch?v=ut5V3TeTBqg">AR Invitation card</a></p>
<p><a target="_blank" href="https://www.instagram.com/reel/C4--h0PveJ8/?epik=dj0yJnU9cFVXeWZyand5dmRvRGRQUWJ0Y25lVlFFWXVHbXJHOHMmcD0wJm49aVh2SDFuTUlYVW9RMDdqemlpcWRIQSZ0PUFBQUFBR2Q2aTVj">AR Mirror</a></p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Inside Tor: The Network That Safeguards Privacy and Fuels the Dark Web]]></title><description><![CDATA[Introduction

Beneath the surface of the internet lies the dark web, a hidden realm accessible through tools like Tor. The Onion Router (Tor) is a free and open-source project that serves as the backbone of this concealed network, enabling anonymous ...]]></description><link>https://blog.gdscnits.in/inside-tor-the-network-that-safeguards-privacy-and-fuels-the-dark-web</link><guid isPermaLink="true">https://blog.gdscnits.in/inside-tor-the-network-that-safeguards-privacy-and-fuels-the-dark-web</guid><category><![CDATA[tor]]></category><dc:creator><![CDATA[Chanswarang Boro]]></dc:creator><pubDate>Thu, 19 Dec 2024 19:44:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734078356766/a12e413d-c514-4f0f-b04a-088cf864cbae.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<hr />
<p>Beneath the surface of the internet lies the dark web, a hidden realm accessible through tools like Tor. The Onion Router (Tor) is a free and open-source project that serves as the backbone of this concealed network, enabling anonymous communication and hosting private services. However, Tor is more than just a gateway to the dark web, it’s a powerful tool for safeguarding privacy and anonymity online. From protecting sensitive sources to bypassing censorship, Tor empowers user to reclaim control of their digital footprint.</p>
<h2 id="heading-what-is-tor">What is tor?</h2>
<hr />
<p>Tor network is a overlay network designed for anonymous communication over internet. Instead of direct user to website communication, data is routed through multiple random volunteer-operated <strong>relays</strong> or <strong>onion routers</strong> (computer running specialized tor software, 7000+ in total).</p>
<p>To join the Tor network, users can use the official Tor Browser or other browsers that support Tor connections. They also need to obtain a up-to-date ‘consensus‘, which is a type of document containing all the information about the relays and gives an overview of the whole network, managed by directory authorities.</p>
<h2 id="heading-the-principle-of-tor">The principle of Tor</h2>
<hr />
<p>The principle of Tor is <strong>onion routing</strong>. The client first form a circuit with multiple relays and sends the traffic through the circuit with multiple layers of encryption as many as the number of relay present in the circuit (usually three), thus forming an onion like shape. Each relay peels off one layer of encryption and sends it to the next node, exposing only the information needed to forward the data.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734190961392/88c18131-4938-4e32-b133-3c526dd84e39.jpeg" alt class="image--center mx-auto" /></p>
<p>This ensures: -</p>
<ul>
<li><p>No single relay knows both the user’s identity and their final destination.</p>
</li>
<li><p>The contents of the message remain hidden from the intermediate relays.</p>
</li>
</ul>
<h2 id="heading-more-about-the-circuit">More about the circuit</h2>
<p>When a user initiates a connection, their tor client constructs a circuit (a path) of three relays chosen randomly from the 7000+ relays described in the ‘consensus‘. The client establishes a unique symmetric key with each of the three relays. These relays are strategically chosen to ensure anonymity: -</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734251862389/fcffd470-4b9e-411c-9351-6ccc51f9e264.jpeg" alt class="image--center mx-auto" /></p>
<ul>
<li><p><strong>Guard relays:</strong> - This is the entry to the tor network. It knows the IP address of the user’s, but does not know the final destination of the traffic. Guard relays are chosen carefully for their reliability and stability.</p>
</li>
<li><p><strong>Middle relays:</strong> -  It acts as an intermediary, it connects the guard and the exit relay. It doesn’t know both the location of the user and the destination.</p>
</li>
<li><p><strong>Exit relay</strong>: - The final relay in the circuit, it sends the data to its intended destination, after decrypting the final layer. While it sees the unencrypted contented of traffic (if not HTTPS), it doesn’t know the identity of the traffic. It is the only relay that knows the final destination.</p>
</li>
</ul>
<blockquote>
<p>Relays decrypts data using their unique symmetric keys, which are intended only for them.</p>
</blockquote>
<p>After establishing the circuit, the client sends the three layer encrypted data to the guard node. By the time the data reaches its destination, all the encryption layer’s are removed, and the exit relay sends the raw request or traffic to the server. The server sees the request coming from the exit relay, not from the user.</p>
<h2 id="heading-what-are-onionhidden-services">What are onion/hidden services?</h2>
<hr />
<p>Onion services are anonymous network services (or websites) that are accessible exclusively through Tor network. These onion services are not indexed by standard search engines and are accessible only through tor using the <strong>onion addresses</strong>, which consist of a string of 56 random characters followed by ‘<code>.onion</code>'<strong>.</strong> Each onion service is identified by unique <code>.onion</code> address. <code>.onion</code> is a special type of TLD (Top-Level Domain) reserved only for Tor network. Unlike traditional domains that are resolved through the Domain Name System (DNS), <code>.onion</code> addresses are looked up by Distributed Hash Table(DHT), a mechanism used by Tor. At a high level, these <code>.onion</code> address are derived as a hash of the public key associated with the service.</p>
<h2 id="heading-how-onionhidden-services-work">How onion/hidden services work?</h2>
<hr />
<p>When a onion service comes to life, it will pick three random relays as their introduction point and establish circuits to them. It generates a hidden service descriptor containing its public key, IP address of each of the introduction points and other metadata. The hidden service signs the descriptor with its private key and uploads to six Hidden Service Directories (HSDirs), specialized relays chosen using a Distributed Hash Table (DHT).</p>
<p>How can client and hidden services talk to each other: -</p>
<blockquote>
<p><em>“To make the explanation more relatable, let us use Naruto (as the client) trying to order ramen from ichiraku shop (acting as the hidden service)”.</em></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734258841875/f67a5ad9-15b0-4626-af97-29f7b814ba7f.jpeg" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Naruto will fetch the hidden service descriptor from the HSDirs. With this information it knows how to reach the ichiraku shop and its introduction points.</p>
</li>
<li><p>Using the descriptor’s details, the Naruto picks randomly one of the introduction points and forms a circuit to it. At the same time, he will select a random relay and creates a circuit to it(we will refer this relay as <strong>rendezvous point</strong>). Then Naruto send a request to the introduction point, including:-</p>
<ul>
<li><p><strong>Rendezvous cookie</strong>: Randomly generated, one-time identifier for the session.</p>
</li>
<li><p>Information about the selected Rendezvous point (encrypted using hidden service public key).</p>
</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734250151117/6060da18-0237-4446-8e25-14aa8aa66d4f.jpeg" alt class="image--center mx-auto" /></p>
<blockquote>
<p><em>Each arrow describes a full tor circuit.</em></p>
</blockquote>
<ul>
<li><p>Introduction point forwards the client request to the onion service. Ichiraku shop decrypts the request and learns about:-</p>
<ul>
<li><p>The rendezvous point selected by the Naruto.</p>
</li>
<li><p>The rendezvous cookie, used to identify the session.</p>
</li>
</ul>
</li>
<li><p>The Ichiraku shop creates a circuit to the rendezvous point and sends the rendezvous cookie to confirm its identity. And Naruto also sends the rendezvous cookie to the rendezvous point.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734250197562/c4db1421-98d9-4a3e-833a-34518d65a13c.jpeg" alt class="image--center mx-auto" /></p>
<ul>
<li>Now both the Naruto and Ichiraku shop have a circuit to the rendezvous point. The rendezvous point verifies the rendezvous cookie from both parties to confirm they belong to the same session. Once verified, the rendezvous point connects the two circuits, effectively completing a single, end-to-end encrypted circuit (with six hops) between Naruto and Ichiraku shop. From this point onwards, the rendezvous point forwards encrypted communication between the two, ensuring their interactions remains within the Tor network. Dattebayo!!.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734251954026/8eb1c09b-e877-47ad-a076-4997c3c0c1fc.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<hr />
<p>This article provides an overview of Tor, the backbone of the dark web, and its role in ensuring online anonymity and privacy. While it only scratches the surface, the technology behind Tor is very vast. If this piqued your interest, check out the the detailed documentation linked below to dive deeper into its working.</p>
<p>Link:-</p>
<p><a target="_blank" href="https://spec.torproject.org/intro/index.html">Tor Specifications</a></p>
]]></content:encoded></item><item><title><![CDATA[EMBRACING BIOMIMICRY: App features inspired by nature]]></title><description><![CDATA[What is Biomimicry in design?
Nature provides many design inspirations, and its basic concepts may well be used in Android application development to enhance an application’s usability. In this article, we look at easy-to-implement swipe buttons and ...]]></description><link>https://blog.gdscnits.in/embracing-biomimicry-app-features-inspired-by-nature</link><guid isPermaLink="true">https://blog.gdscnits.in/embracing-biomimicry-app-features-inspired-by-nature</guid><category><![CDATA[Android]]></category><dc:creator><![CDATA[Sristi Dey]]></dc:creator><pubDate>Sun, 15 Dec 2024 08:56:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/G5eGxZ4-2Dw/upload/f651e4eeb8b8b9f69f988dbaec9dcdb8.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-biomimicry-in-design">What is Biomimicry in design?</h2>
<p><strong>Nature provides many design inspirations, and its basic concepts may well be used in Android application development to enhance an application’s usability. In this article, we look at easy-to-implement swipe buttons and other controls taken from biomimicry, which is the imitation of structures and functions by different structures and systems found in nature. Moreover, biomimicry provides nature’s solutions to address human challenges.</strong></p>
<h2 id="heading-some-of-its-applications-in-android-development">Some of its applications in Android Development:</h2>
<ol>
<li><h3 id="heading-swipe-buttons"><strong>Swipe Buttons</strong>:</h3>
<p> Swipe gestures reflect the smooth, continuous movement like water or wind. For instance, consider a swipe-to-unlock button. This mimics our natural, real-world action of sliding objects.</p>
<p> To get a quick understanding, follow these steps using Android Studio:</p>
<ul>
<li><p>Use a constraint layout as a base</p>
</li>
<li><p>Add a MotionLayout for defining the swipe path</p>
</li>
<li><p>Use onTouchEvent() with a GestureDetector for the swipe motion</p>
</li>
</ul>
</li>
</ol>
<ol start="2">
<li><h3 id="heading-expand-or-collapse">Expand or Collapse:</h3>
<p> The way flowers bloom can inspire creating expand/collapse effects on menus, dropdowns, etc. in applications.</p>
<p> Steps to follow to create this effect on a card view using Android Studio:</p>
<p> In the XML layout, after setting up a card view and a text view with collapsible content inside, here is the code snippet.</p>
</li>
</ol>
<pre><code class="lang-kotlin"><span class="hljs-keyword">val</span> cardView = findViewById&lt;CardView&gt;(R.id.cardView)
        <span class="hljs-keyword">val</span> collapsibleContent = findViewById&lt;TextView&gt;(R.id.collapsibleContent)

        (cardView.parent <span class="hljs-keyword">as</span> ViewGroup).layoutTransition = LayoutTransition()

        cardView.setOnClickListener {
            <span class="hljs-keyword">if</span> (collapsibleContent.visibility == View.GONE) {
                collapsibleContent.visibility = View.VISIBLE <span class="hljs-comment">// Expand</span>
            } <span class="hljs-keyword">else</span> {
                collapsibleContent.visibility = View.GONE <span class="hljs-comment">// Collapse</span>
            }
        }
</code></pre>
<ol start="3">
<li><h3 id="heading-adapt-dynamic-colors"><strong>Adapt Dynamic Colors</strong>:</h3>
<p> This is inspired by how colors in nature often balance or fit each other. Dynamic colors adapt to the user’s wallpaper and respond accordingly to the light and dark themes.</p>
<p> Refer to the online resource provided below for the implementation of dynamic colors using Android Studio.</p>
<p> MATERIAL 3 DESIGN: <a target="_blank" href="https://developer.android.com/develop/ui/views/theming/dynamic-colors">https://developer.android.com/develop/ui/views/theming/dynamic-colors</a></p>
</li>
<li><p><strong>Pull-to-Refresh:</strong></p>
<p> The pull-to-refresh interaction resembles nature’s elasticity of materials.</p>
<p> A Brief Overview:</p>
<ul>
<li>Add SwipeRefreshLayout dependency</li>
</ul>
</li>
</ol>
<p>    To use SwipeRefreshLayout in your app, add the following dependency to your build.gradle file:</p>
<pre><code class="lang-kotlin">    dependencies {
        implementation(<span class="hljs-string">"androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"</span>)
    }
</code></pre>
<ul>
<li>Add the SwipeRefreshLayout Widget</li>
</ul>
<p>    To add the swipe-to-refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView. SwipeRefreshLayout only supports a single ListView or GridView child.</p>
<p>    The following example demonstrates how to add the SwipeRefreshLayout widget to an existing layout file containing a ListView:</p>
<pre><code class="lang-xml">    <span class="hljs-tag">&lt;<span class="hljs-name">androidx.swiperefreshlayout.widget.SwipeRefreshLayout</span>
        <span class="hljs-attr">xmlns:android</span>=<span class="hljs-string">"http://schemas.android.com/apk/res/android"</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/swiperefresh"</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"match_parent"</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"match_parent"</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">ListView</span>
            <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@android:id/list"</span>
            <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"match_parent"</span>
            <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"match_parent"</span> /&gt;</span>

    <span class="hljs-tag">&lt;/<span class="hljs-name">androidx.swiperefreshlayout.widget.SwipeRefreshLayout</span>&gt;</span>
</code></pre>
<p>    Then, in MainActivity.kt,</p>
<pre><code class="lang-kotlin">    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainActivity</span> : <span class="hljs-type">AppCompatActivity</span></span>(), SwipeRefreshLayout.OnRefreshListener {
     <span class="hljs-keyword">lateinit</span> <span class="hljs-keyword">var</span> swipeRefreshLayout: SwipeRefreshLayout
     <span class="hljs-keyword">lateinit</span> <span class="hljs-keyword">var</span> listView: ListView

    <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">onCreate</span><span class="hljs-params">(savedInstanceState: <span class="hljs-type">Bundle</span>?)</span></span> {
     <span class="hljs-keyword">super</span>.onCreate(savedInstanceState)
     setContentView(R.layout.activity_main)
     listView = findViewById(R.id.list)
     swipeRefreshLayout = findViewById(R.id.swiperefresh)
     swipeRefreshLayout.setOnRefreshListener(<span class="hljs-keyword">this</span>)
    }
    <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">onRefresh</span><span class="hljs-params">()</span></span>{
     Handler(Looper.getMainLooper()).postDelayed({
     Toast.makeText( <span class="hljs-keyword">this</span> , <span class="hljs-string">"Refreshed"</span>, Toast.LENGTH_LONG).show()
     swipeRefreshLayout.isRefreshing = <span class="hljs-literal">false</span>
    }, <span class="hljs-number">300</span>)
    }
</code></pre>
<ol start="5">
<li><h3 id="heading-ripple-effect">Ripple Effect:</h3>
<p> This effect can be easily implemented on a button. It is inspired by the natural ripples in water. This subtle animation gives users a natural feel and makes it visually appealing.</p>
<p> Here, the <em>?attr/selectableItemBackground</em> adds a ripple effect within the view's bounds.</p>
<p> To ensure the theme and ripple effects work well together, it is better to use app:background provided by the Material Components library or AppCompat.</p>
<p> Code Snippet:</p>
</li>
</ol>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">androidx.constraintlayout.widget.ConstraintLayout</span> <span class="hljs-attr">xmlns:android</span>=<span class="hljs-string">"http://schemas.android.com/apk/res/android"</span>
    <span class="hljs-attr">xmlns:app</span>=<span class="hljs-string">"http://schemas.android.com/apk/res-auto"</span>
    <span class="hljs-attr">xmlns:tools</span>=<span class="hljs-string">"http://schemas.android.com/tools"</span>
    <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/main"</span>
    <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"match_parent"</span>
    <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"match_parent"</span>
    <span class="hljs-attr">tools:context</span>=<span class="hljs-string">".MainActivity"</span>&gt;</span>


    <span class="hljs-tag">&lt;<span class="hljs-name">Button</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/button"</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"wrap_content"</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"wrap_content"</span>
        <span class="hljs-attr">android:text</span>=<span class="hljs-string">"Button"</span>
        <span class="hljs-attr">app:layout_constraintBottom_toBottomOf</span>=<span class="hljs-string">"parent"</span>
        <span class="hljs-attr">app:layout_constraintEnd_toEndOf</span>=<span class="hljs-string">"parent"</span>
        <span class="hljs-attr">app:layout_constraintStart_toStartOf</span>=<span class="hljs-string">"parent"</span>
        <span class="hljs-attr">app:layout_constraintTop_toTopOf</span>=<span class="hljs-string">"parent"</span>
        <span class="hljs-attr">app:background</span>=<span class="hljs-string">"?attr/selectableItemBackground"</span>
        <span class="hljs-attr">android:clickable</span>=<span class="hljs-string">"true"</span>
        <span class="hljs-attr">android:focusable</span>=<span class="hljs-string">"true"</span>/&gt;</span>
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Buffer Overflow Basics: A Simple Guide to Understanding Vulnerabilities]]></title><description><![CDATA[Introduction
Have you ever wondered how seemingly harmless input can compromise a program's security? Buffer overflows have become a notorious weapon in the hands of attackers, allowing them to manipulate memory and execute malicious code. In this bl...]]></description><link>https://blog.gdscnits.in/buffer-overflow-basics-a-simple-guide-to-understanding-vulnerabilities</link><guid isPermaLink="true">https://blog.gdscnits.in/buffer-overflow-basics-a-simple-guide-to-understanding-vulnerabilities</guid><category><![CDATA[Buffer Overfow]]></category><category><![CDATA[exploit]]></category><category><![CDATA[memory]]></category><category><![CDATA[C]]></category><category><![CDATA[vulnerabilities]]></category><dc:creator><![CDATA[Auth0x78]]></dc:creator><pubDate>Mon, 25 Nov 2024 18:19:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732557677589/e8a299a7-2c7a-4eb1-890a-fc5750180853.avif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">Introduction</h3>
<p>Have you ever wondered how seemingly harmless input can compromise a program's security? Buffer overflows have become a notorious weapon in the hands of attackers, allowing them to manipulate memory and execute malicious code. In this blog post, we will explore what a buffer overflow is, how it occurs, and why it poses such a significant threat in the world of cybersecurity.</p>
<ul>
<li><p><strong>Definition</strong>: Buffer overflow occurs when a program tries to write data into a buffer beyond the buffer’s allocated size causing it to overwrite adjacent memory.</p>
</li>
<li><p><strong>Importance</strong>: Understanding buffer overflows allows us to prevent people with malicious intent exploit your code and also makes you in general a better programmer.</p>
</li>
</ul>
<h3 id="heading-what-is-buffer-overflow">What is Buffer Overflow?</h3>
<ul>
<li><p><strong>Technical Definition</strong>: A buffer overflow happens when data written to a buffer overflows and alters the values in memory addresses next to the destination buffer because of inadequate bounds checking.</p>
</li>
<li><p><strong>Example</strong>: Consider a buffer of size 5 bytes. Now imagine you copied the string “USER12AB” into the buffer. As you can see the length of the string is 8 bytes, but the allocated capacity of buffer is just 5, so what happens is the first 5 bytes, i.e, “USER1” are copied into the buffer and the rest 3 bytes of the string are copied into the memory adjacent to buffer. (See figure below)</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728544813552/6e0b7566-b755-4c61-89f9-75877e763855.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>Memory Layout</strong>:</p>
<ul>
<li><p><strong>Stack</strong>: Used for function calls and local variables. Memory is automatically managed in a <strong>LIFO</strong> manner, making it faster but limited in size and scope.</p>
</li>
<li><p><strong>Heap</strong>: Used for dynamic memory allocation. Memory is manually managed with functions like <code>malloc()</code>/<code>free()</code>. It's slower but provides a larger, flexible storage space.</p>
</li>
<li><p><strong>Example</strong>:</p>
<p>  Stack: <code>int a = 10;</code></p>
<p>  Heap: <code>int* p = malloc(sizeof(int));</code></p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-common-causes-of-buffer-overflow">Common causes of Buffer Overflow</h3>
<ul>
<li><p><strong>Unsafe Functions</strong>: Common C/C++ functions (e.g., <code>strcpy</code>, <code>sprintf</code>) that lead to overflows.</p>
</li>
<li><p><strong>Lack of Bounds Checking</strong>: Proper input validation is crucial to ensure program stability and security. Without bounds checking, user inputs can exceed expected limits, causing buffer overflows, crashes, or vulnerabilities exploitable by attackers</p>
</li>
</ul>
<h3 id="heading-example-a-simple-vulnerable-program">Example: A Simple Vulnerable Program</h3>
<pre><code class="lang-c"><span class="hljs-comment">// FILE NAME: buffer.c</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string.h&gt;</span></span>

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">vulnerable_function</span><span class="hljs-params">(<span class="hljs-keyword">char</span>* input)</span> </span>{
    <span class="hljs-keyword">char</span> buffer[<span class="hljs-number">10</span>]; <span class="hljs-comment">// Create buffer of 10 characters</span>
    <span class="hljs-built_in">strcpy</span>(buffer, input); <span class="hljs-comment">// Vulnerable to overflow</span>
}

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">char</span>* argv[])</span> </span>{
    <span class="hljs-keyword">if</span>(argc &gt; <span class="hljs-number">1</span>) {
        vulnerable_function(argv[<span class="hljs-number">1</span>]);    
    }

    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<p>The output of the above code (compiled w/ GCC):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728548026688/b9b68cc1-7f9f-43c8-b5d7-a496a953e979.png" alt class="image--center mx-auto" /></p>
<p>The flaw in this program lies in the use of <code>strcpy</code>, which does not check the length of the input. If a user inputs more than 10 characters, it will overflow, leading to unexpected behavior or crashes.</p>
<p>If an attacker provides a long input string, it can overwrite adjacent memory, potentially crashing the program or allowing malicious actions to occur.</p>
<p>Fortunately, there is a thing called the Stack Smashing Protector (SSP) which is a security feature in many compilers including GCC that detects buffer overflows in programs. It adds extra checks to the code that can detect when a buffer overflow has happened and stop the program from running, which protects against attacks that try to exploit these vulnerabilities.</p>
<h3 id="heading-how-does-buffer-overflow-work-w-example">How does buffer overflow work w/ Example</h3>
<ol>
<li><p>Declaring a buffer</p>
<ul>
<li><p>In programming languages like C, you might declare an array with a fixed size. For instance:</p>
<pre><code class="lang-c">  <span class="hljs-keyword">char</span> buffer[<span class="hljs-number">10</span>]; <span class="hljs-comment">// An char array with size 10</span>
</code></pre>
</li>
</ul>
</li>
<li><p>Writing Data to the buffer</p>
<ul>
<li><p>When you write data to the buffer, using some vulnerable function, for eg: <code>strcpy</code>, the function assumes that the there is enough allocated space for the data given. Example:</p>
<p>  strcpy(buffer, “Hello!\0”); // This fits into the buffer</p>
</li>
</ul>
</li>
<li><p>Writing Data that exceeds the buffer’s fixed size</p>
<ul>
<li><p>If you try to write more data than the buffer can hold, like this:</p>
<pre><code class="lang-c">  <span class="hljs-built_in">strcpy</span>(buffer, <span class="hljs-string">"Hello this is a long string\0"</span>);
  <span class="hljs-comment">// The string being copied is larger than</span>
  <span class="hljs-comment">// the allocated size of the bufffer-</span>
</code></pre>
</li>
<li><p>The <code>strcpy</code> continues writing data beyond the end of the buffer, leading to a <strong>buffer overflow</strong>.</p>
</li>
<li><p>This extra data that doesn’t fit into the buffer starts overwriting adjacent memory locations. This can include other variables, function return addresses, or even critical data used by the program.</p>
</li>
</ul>
</li>
<li><p>What happens next?</p>
<ul>
<li><p>Overwriting critical data can lead to:</p>
<ol>
<li><p><strong>Unexpected behaviour</strong>: The program may crash or give incorrect results.</p>
</li>
<li><p><strong>Security vulnerabilities</strong>: An attacker may exploit the overflow to execute arbitrary code by overwriting the return address of a function.</p>
<p> Example: Consider a vulnerable program that contains a buffer overflow. An attacker might input a payload that looks like this:</p>
<pre><code class="lang-plaintext"> AAAAAAAA...AAAABBBBCCCC
</code></pre>
<ul>
<li><p>Here, "AAAAAAAA" fills the buffer, "BBBB" overwrites the return address, and "CCCC" represents the shellcode that will be executed.</p>
</li>
<li><p><strong>NOTE</strong>: This is a simplified explanation and not an accurate representation of how a <strong>Return Address Overwrite</strong> actually works</p>
</li>
</ul>
</li>
</ol>
</li>
</ul>
</li>
</ol>
<h3 id="heading-defenses-against-buffer-overflow-attacks">Defenses Against Buffer Overflow Attacks</h3>
<p>There many defenses one can use, some of them being:</p>
<ol>
<li><p>Stack Canaries: Compilers insert special values, called canaries into stack frames.</p>
<p> If the value of canary is modified, it suggest a buffer overflow has taken place.</p>
<p> <img src="https://media.springernature.com/lw685/springer-static/image/chp%3A10.1007%2F978-3-031-64064-3_13/MediaObjects/561472_1_En_13_Fig13_HTML.png" alt="PwnShield: An Automated Approach to Detect and Exploit Buffer Overflows and  Bypassing Modern Mitigation Techniques | SpringerLink" /></p>
</li>
<li><p>ASLR (Address Space Layout Randomization): Its a memory protection proccess that safeguards against buffer oveflows. It works by randomizing the memory location where executable are loaded into memory.</p>
<p> <img src="https://cdn.prod.website-files.com/5ff66329429d880392f6cba2/605caf49d3e9a45ebd7f4e32_12.1.jpg" alt="How to protect, prevent and mitigate buffer overflow attacks" /></p>
</li>
<li><p>Data Execution Prevention (DEP): Its a policy enforced by the operating system that prevents execution of code in memory area marked as non-executable, preventing attacker from executing thier payload.</p>
</li>
</ol>
<h3 id="heading-further-reading-and-resources">Further Reading and Resources</h3>
<p>Some online resources that you can refer for more details regarding buffer overflows and exploitation:</p>
<ol>
<li><p>CTF Handbook: <a target="_blank" href="https://ctf101.org/binary-exploitation/buffer-overflow/">https://ctf101.org/binary-exploitation/buffer-overflow/</a></p>
</li>
<li><p>Wikipedia: <a target="_blank" href="https://en.wikipedia.org/wiki/Buffer_overflow">https://en.wikipedia.org/wiki/Buffer_overflow</a></p>
</li>
<li><p>GeekForGeeks: <a target="_blank" href="https://www.geeksforgeeks.org/buffer-overflow-attack-with-example/">https://www.geeksforgeeks.org/buffer-overflow-attack-with-example/</a></p>
</li>
</ol>
<p>Books:</p>
<ol>
<li><p><em>The Shellcoder's Handbook</em> by Chris Anley et al.</p>
</li>
<li><p><em>Hacking: The Art of Exploitation</em> by Jon Erickson</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Brainf#ck - The Programming Language]]></title><description><![CDATA[“How minimalistic can a programming language be?”. Can it be as minimalistic as Brainfuck, an esoteric (mysterious, hard to understand) programming language created in 1993? Its creator Urban Muller set out for its creation to implement the smallest ...]]></description><link>https://blog.gdscnits.in/brainfck-the-programming-language</link><guid isPermaLink="true">https://blog.gdscnits.in/brainfck-the-programming-language</guid><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[Arindom]]></dc:creator><pubDate>Fri, 07 Jun 2024 12:01:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1717751852821/18e9eb2e-7c87-47b7-a5e0-7bce5583176d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>“How minimalistic can a programming language be?”. Can it be as minimalistic as <strong><em>Brainfuck</em></strong>, an <strong>esoteric</strong> (mysterious, hard to understand) programming language created in 1993? Its creator <em>Urban Muller</em> set out for its creation to implement the smallest possible compiler; he succeeded with a size of 296 bytes.</p>
<p>So, how does this esoteric programming language work?</p>
<p>Well, the language consists of 8 commands listed below:</p>
<p><img src="https://lh7-us.googleusercontent.com/-Cp7UQVaf_AYrM7qWirP-Yavb1_116DUZ0bNzC3KaGW-K-hjrJGfulGT75ZTDqYeGej8kKAvzETmBLsjKGfm8_PTxooaRGQYLGnvj_britrgDPBSQUdG2QgEfaoms7RF6a5xZRIzuh8S-_VxQkMho4E" alt /></p>
<p>The commands are executed sequentially; hence, the program is a sequence of these commands. The compiler or interpreter should disregard any character other than the eight specified above. Characters other than the eight operators should be considered comments. As the name implies, Brainfuck programs are sometimes tough to understand. It is essentially a Turing-complete language.</p>
<p>The idea behind Brainfuck is memory manipulation. Essentially, we are provided an array of 30,000 1-byte memory chunks. The array size is determined by the implementation used in the compiler or interpreter, although normal brainfuck is 30,000. Within this array, you may raise the memory pointer, the memory pointer's value, and so forth.</p>
<p>As <em>roachhd</em> mentions in his GitHub post: “When cavemen started scrawling shit on the walls, the first-ever picture drawn was a man waving at a picture of the planet Earth.” So why not look at “Hello World” through the eyes of Brainfuck :</p>
<p><strong>Hello World</strong></p>
<p>\&gt;++++++++[&lt;+++++++++&gt;-]&lt;.</p>
<p>--[-----&gt;+&lt;]&gt;-.</p>
<p>+++++++..</p>
<p>+++.</p>
<p>\&gt;&gt;++++++[&lt;+++++++&gt;-]&lt;++.</p>
<p>------------.</p>
<p>\&gt;++++++[&lt;+++++++++&gt;-]&lt;+.</p>
<p>&lt;.</p>
<p>+++.</p>
<p>------.</p>
<p>--------.</p>
<p>\&gt;&gt;&gt;++++[&lt;++++++++&gt;-]&lt;+.</p>
<p>I'm sure this made you go</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716051307045/4f85e8d8-2033-4601-9708-b1806e34f75b.jpeg?auto=compress,format&amp;format=webp" alt /></p>
<p>Here is a brief explanation:</p>
<p>The first line begins with a “&gt;” followed by 8 “+” which implies moving one cell to the right and incrementing that cell’s value eight times. This gives us—you guessed it—the value 8 in cell 1. Following this is a “[“, then a “&lt;” and a total of 9 “+” which is followed by a “&gt;”, a “-” and a closing “]”. Thus, we begin a loop( [ ) in which we move left (&lt;, back to cell 0), add nine (9+s) to that cell, move right again(&gt;), and remove one from the number in cell 1. Remember that the loop runs until the cell value reaches zero, thus this would be repeated eight times, each time adding nine to cell 0. So we can see that cell 0 has a value of 72, corresponding to the capital letter 'H' in the ASCII table. The line is concluded by a “.” corresponding to the character “H” output.</p>
<p>memory blocks</p>
<p>A memory block visualization yields:</p>
<p>-------------</p>
<p>[72][0][0][0][0][0]...</p>
<p>^</p>
<p>memory pointer</p>
<p>Similarly, in the second line, we added the ASCII value of 101, which represents “e”.</p>
<p>This way, we can interpret this language that is true to its name.</p>
<p>As can be understood, the language scores very low in its efficiency. However, it is still a cult classic among programmers of various age groups. Use at your own risk and get ready to be <em>“Brainf#ck”</em> -ed.</p>
]]></content:encoded></item><item><title><![CDATA[Unveiling the Power of Serverless Computing: A Dive into AWS Lambda]]></title><description><![CDATA[In the vast landscape of cloud computing, few innovations have sparked as much interest and excitement as serverless computing. One of the foremost platforms leading this revolution is Amazon Web Services (AWS) Lambda. This blog will take you on a jo...]]></description><link>https://blog.gdscnits.in/unveiling-the-power-of-serverless-computing-a-dive-into-aws-lambda</link><guid isPermaLink="true">https://blog.gdscnits.in/unveiling-the-power-of-serverless-computing-a-dive-into-aws-lambda</guid><category><![CDATA[AWS]]></category><category><![CDATA[serverless]]></category><category><![CDATA[aws lambda]]></category><dc:creator><![CDATA[Niraj kumar]]></dc:creator><pubDate>Mon, 29 Apr 2024 15:38:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1714325333860/6a0be35e-a928-4c12-bfdf-82b6aeff8094.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the vast landscape of cloud computing, few innovations have sparked as much interest and excitement as serverless computing. One of the foremost platforms leading this revolution is Amazon Web Services (AWS) Lambda. This blog will take you on a journey through the world of AWS Lambda, exploring its capabilities, recent advancements, and a fascinating project exemplifying its potential.</p>
<h3 id="heading-understanding-aws-lambda"><strong>Understanding AWS Lambda</strong></h3>
<p>AWS Lambda allows developers to run code without provisioning or managing servers. Instead, Lambda automatically scales your application by running code in response to triggers, such as changes in data, shifts in system state, or HTTP requests.</p>
<h4 id="heading-key-features-of-aws-lambda"><strong>Key Features of AWS Lambda:</strong></h4>
<ol>
<li><p><strong>Scalability</strong>: Lambda automatically scales your application by running code in response to each trigger.</p>
</li>
<li><p><strong>Pay-Per-Use</strong>: You pay only for the compute time you consume.</p>
</li>
<li><p><strong>Integration</strong>: Seamlessly integrates with other AWS services, allowing for powerful event-driven architectures.</p>
</li>
<li><p><strong>Flexibility</strong>: Supports multiple programming languages including Python, Node.js, Java, and more.</p>
</li>
</ol>
<ul>
<li><h3 id="heading-recent-advancements-in-aws-lambda"><strong>Recent Advancements in AWS Lambda</strong></h3>
<p>  AWS is continuously innovating to enhance the capabilities of Lambda. Some recent advancements include:</p>
<ol>
<li><p><strong>Lambda Extensions</strong>: Introduced to simplify the integration of monitoring, security, and other tools with Lambda functions.</p>
</li>
<li><p><strong>Provisioned Concurrency</strong>: Ensures that functions are initialized and ready to respond instantly, reducing latency for applications with varying workloads.</p>
</li>
<li><p><strong>Custom Runtimes</strong>: Allows developers to bring their own programming languages to Lambda, expanding its flexibility.</p>
</li>
<li><p><strong>Container Image Support</strong>: Enables packaging and deploying Lambda functions as container images, offering more control over dependencies and runtime environment.</p>
<h3 id="heading-exploring-a-real-world-project-image-processing-with-aws-lambda"><strong>Exploring a Real-world Project: Image Processing with AWS Lambda</strong></h3>
<p> Let's delve into a practical application of AWS Lambda: image processing. Imagine you have a web application where users can upload images, and you need to generate thumbnails for these images. Traditionally, you might set up a server to handle this task, but with Lambda, you can achieve this in a serverless manner.</p>
<h4 id="heading-project-overview"><strong>Project Overview:</strong></h4>
<ul>
<li><p><strong>Objective</strong>: Automatically generate thumbnails for uploaded images.</p>
</li>
<li><p><strong>Technologies Used</strong>: AWS Lambda, Amazon S3 (for storing images), Amazon API Gateway (for triggering Lambda function), Python (for image processing).</p>
</li>
<li><p><strong>Workflow</strong>:</p>
<ol>
<li><p>User uploads an image to Amazon S3 bucket.</p>
</li>
<li><p>S3 triggers a Lambda function.</p>
</li>
<li><p>Lambda function retrieves the uploaded image, processes it to generate a thumbnail, and stores the thumbnail back in S3.</p>
</li>
<li><p>User can now access the thumbnail image.</p>
</li>
</ol>
</li>
</ul>
</li>
</ol>
</li>
</ul>
<h4 id="heading-code-snippet-python"><strong>Code Snippet (Python):</strong></h4>
<pre><code class="lang-python">    pythonCopy codeimport os
    <span class="hljs-keyword">import</span> boto3
    <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

    s3 = boto3.client(<span class="hljs-string">'s3'</span>)

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">lambda_handler</span>(<span class="hljs-params">event, context</span>):</span>
        <span class="hljs-comment"># Retrieve bucket and key from event</span>
        bucket = event[<span class="hljs-string">'Records'</span>][<span class="hljs-number">0</span>][<span class="hljs-string">'s3'</span>][<span class="hljs-string">'bucket'</span>][<span class="hljs-string">'name'</span>]
        key = event[<span class="hljs-string">'Records'</span>][<span class="hljs-number">0</span>][<span class="hljs-string">'s3'</span>][<span class="hljs-string">'object'</span>][<span class="hljs-string">'key'</span>]

        <span class="hljs-comment"># Download image from S3</span>
        local_image_path = <span class="hljs-string">'/tmp/'</span> + os.path.basename(key)
        s3.download_file(bucket, key, local_image_path)

        <span class="hljs-comment"># Open image and generate thumbnail</span>
        <span class="hljs-keyword">with</span> Image.open(local_image_path) <span class="hljs-keyword">as</span> img:
            img.thumbnail((<span class="hljs-number">100</span>, <span class="hljs-number">100</span>))
            thumbnail_path = <span class="hljs-string">'/tmp/thumbnail_'</span> + os.path.basename(key)
            img.save(thumbnail_path)

        <span class="hljs-comment"># Upload thumbnail to S3</span>
        thumbnail_key = <span class="hljs-string">'thumbnails/'</span> + os.path.basename(key)
        s3.upload_file(thumbnail_path, bucket, thumbnail_key)

        <span class="hljs-keyword">return</span> {
            <span class="hljs-string">'statusCode'</span>: <span class="hljs-number">200</span>,
            <span class="hljs-string">'body'</span>: <span class="hljs-string">'Thumbnail generated successfully.'</span>
        }
</code></pre>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<p>    AWS Lambda empowers developers to build scalable, cost-effective, and resilient applications without worrying about infrastructure management. With recent advancements like Lambda Extensions, Provisioned Concurrency, and Container Image Support, Lambda continues to push the boundaries of serverless computing.</p>
<p>    As demonstrated through the image processing project, Lambda enables seamless integration with other AWS services to create powerful and efficient solutions. Whether you're a seasoned developer or just starting your journey into cloud computing, AWS Lambda offers a compelling platform to unleash your creativity and innovation.</p>
<p>    Stay tuned for more exciting developments in the world of cloud computing and serverless architecture!</p>
]]></content:encoded></item><item><title><![CDATA[A Framework for Intelligent App Development: Integrating Human Feedback and TFLite for Next-Gen Apps]]></title><description><![CDATA[Introduction
Developing next-generation apps requires a blend of cutting-edge technologies to provide intelligent and efficient user experiences. In this blog post, we'll explore a framework that combines the power of TensorFlow Lite (TFLite) for on-...]]></description><link>https://blog.gdscnits.in/a-framework-for-intelligent-app-development-integrating-human-feedback-and-tflite-for-next-gen-apps</link><guid isPermaLink="true">https://blog.gdscnits.in/a-framework-for-intelligent-app-development-integrating-human-feedback-and-tflite-for-next-gen-apps</guid><category><![CDATA[Machine Learning]]></category><category><![CDATA[AI]]></category><category><![CDATA[development]]></category><category><![CDATA[app development]]></category><category><![CDATA[Android]]></category><category><![CDATA[iOS]]></category><dc:creator><![CDATA[Gaurav Bhushan Kumar]]></dc:creator><pubDate>Tue, 19 Mar 2024 04:36:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1705822550056/6e904b9f-3850-460a-a3ff-54c105858acd.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<h1 id="heading-introduction">Introduction</h1>
<p>Developing next-generation apps requires a blend of cutting-edge technologies to provide intelligent and efficient user experiences. In this blog post, we'll explore a framework that combines the power of TensorFlow Lite (TFLite) for on-device machine learning with the invaluable input from human feedback. This approach not only enhances the capabilities of your applications but also ensures user-centric development.</p>
<p>As this is just an intro into this ever-growing field this blog will be focused on giving the head start into the world of on-device machine learning.</p>
<h1 id="heading-tensorflow-and-python-for-model-development">TensorFlow and Python for Model Development</h1>
<h2 id="heading-model-development">Model Development</h2>
<ul>
<li><p>Utilize the extensive capabilities of TensorFlow, a powerful open-source machine learning framework, for model development.</p>
</li>
<li><p>Leverage Python, a versatile and widely used programming language, for building and training machine learning models.</p>
</li>
</ul>
<p>Here, we will use the code to train a basic sentiment analysis model, detailed explanation link: <a target="_blank" href="https://www.tensorflow.org/tutorials/keras/text_classification">Basic text classification  |  TensorFlow Core</a></p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> shutil
<span class="hljs-keyword">import</span> string
<span class="hljs-keyword">import</span> re 

<span class="hljs-comment"># Getting the dataset</span>
url = <span class="hljs-string">"https://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz"</span>
dataset = tf.keras.utils.get_file(<span class="hljs-string">"aclImdb_v1"</span>, url, untar=<span class="hljs-literal">True</span>, cache_dir=<span class="hljs-string">'.'</span>, cache_subdir=<span class="hljs-string">''</span>)
dataset_dir = os.path.join(os.path.dirname(dataset), <span class="hljs-string">'aclImdb'</span>)

<span class="hljs-comment"># Removing the sup dir as we don't need that</span>
train_dir = os.path.join(dataset_dir, <span class="hljs-string">'train'</span>)
remove_dir = os.path.join(train_dir, <span class="hljs-string">'unsup'</span>)
shutil.rmtree(remove_dir)

batch_size = <span class="hljs-number">32</span>
seed = <span class="hljs-number">42</span>

raw_train_ds = tf.keras.utils.text_dataset_from_directory(
    <span class="hljs-string">'aclImdb/train'</span>, 
    batch_size=batch_size, 
    validation_split=<span class="hljs-number">0.2</span>, 
    subset=<span class="hljs-string">'training'</span>, 
    seed=seed)
raw_val_ds = tf.keras.utils.text_dataset_from_directory(
    <span class="hljs-string">'aclImdb/train'</span>, 
    batch_size=batch_size, 
    validation_split=<span class="hljs-number">0.2</span>, 
    subset=<span class="hljs-string">'validation'</span>, 
    seed=seed)
raw_test_ds = tf.keras.utils.text_dataset_from_directory(
    <span class="hljs-string">'aclImdb/test'</span>, 
    batch_size=batch_size)

<span class="hljs-comment"># To clean up the i/p data</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">custom_standardization</span>(<span class="hljs-params">input_data</span>):</span>
  lowercase = tf.strings.lower(input_data)
  stripped_html = tf.strings.regex_replace(lowercase, <span class="hljs-string">'&lt;br /&gt;'</span>, <span class="hljs-string">' '</span>)
  <span class="hljs-keyword">return</span> tf.strings.regex_replace(stripped_html,
                                  <span class="hljs-string">'[%s]'</span> % re.escape(string.punctuation),
                                  <span class="hljs-string">''</span>)

<span class="hljs-comment"># Vectorizing the i/p text</span>
max_features = <span class="hljs-number">10000</span>
sequence_length = <span class="hljs-number">250</span>

vectorize_layer = tf.keras.layers.TextVectorization(
    standardize=custom_standardization,
    max_tokens=max_features,
    output_mode=<span class="hljs-string">'int'</span>,
    output_sequence_length=sequence_length)

<span class="hljs-comment"># Make a text-only dataset (without labels), then call adapt</span>
train_text = raw_train_ds.map(<span class="hljs-keyword">lambda</span> x, y: x)
vectorize_layer.adapt(train_text)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">vectorize_text</span>(<span class="hljs-params">text, label</span>):</span>
  text = tf.expand_dims(text, <span class="hljs-number">-1</span>)
  <span class="hljs-keyword">return</span> vectorize_layer(text), label

<span class="hljs-comment"># retrieve a batch (of 32 reviews and labels) from the dataset</span>
text_batch, label_batch = next(iter(raw_train_ds))
first_review, first_label = text_batch[<span class="hljs-number">0</span>], label_batch[<span class="hljs-number">0</span>]
print(<span class="hljs-string">"Review"</span>, first_review)
print(<span class="hljs-string">"Label"</span>, raw_train_ds.class_names[first_label])
print(<span class="hljs-string">"Vectorized review"</span>, vectorize_text(first_review, first_label))

train_ds = raw_train_ds.map(vectorize_text)
val_ds = raw_val_ds.map(vectorize_text)
test_ds = raw_test_ds.map(vectorize_text)

<span class="hljs-comment"># To stop I/P Buffering </span>
AUTOTUNE = tf.data.AUTOTUNE

train_ds = train_ds.cache().prefetch(buffer_size=AUTOTUNE)
val_ds = val_ds.cache().prefetch(buffer_size=AUTOTUNE)
test_ds = test_ds.cache().prefetch(buffer_size=AUTOTUNE)

<span class="hljs-comment"># Creating the Model</span>
embedding_dim = <span class="hljs-number">16</span>

model = tf.keras.Sequential([
  tf.keras.layers.Embedding(max_features, embedding_dim),
  tf.keras.layers.Dropout(<span class="hljs-number">0.2</span>),
  tf.keras.layers.GlobalAveragePooling1D(),
  tf.keras.layers.Dropout(<span class="hljs-number">0.2</span>),
  tf.keras.layers.Dense(<span class="hljs-number">1</span>)])

model.summary()

model.compile(loss=tf.keras.losses.BinaryCrossentropy(from_logits=<span class="hljs-literal">True</span>),
              optimizer=<span class="hljs-string">'adam'</span>,
              metrics=tf.metrics.BinaryAccuracy(threshold=<span class="hljs-number">0.0</span>))

<span class="hljs-comment"># Training the model</span>
epochs = <span class="hljs-number">50</span>
history = model.fit(
  train_ds,
  validation_data=val_ds,
  epochs=epochs
)

<span class="hljs-comment"># Evaluating the Model</span>
loss, accuracy = model.evaluate(test_ds)

print(<span class="hljs-string">"Loss: "</span>, loss)
print(<span class="hljs-string">"Accuracy: "</span>, accuracy)

export_model = tf.keras.Sequential([
  vectorize_layer,
  model,
  tf.keras.layers.Activation(<span class="hljs-string">'sigmoid'</span>)
])

export_model.compile(
    loss=tf.keras.losses.BinaryCrossentropy(from_logits=<span class="hljs-literal">False</span>), optimizer=<span class="hljs-string">"adam"</span>, metrics=[<span class="hljs-string">'accuracy'</span>]
)

<span class="hljs-comment"># Test it with `raw_test_ds`, which yields raw strings</span>
loss, accuracy = export_model.evaluate(raw_test_ds)
print(accuracy)


examples = [
  <span class="hljs-string">"The movie was great!"</span>,
  <span class="hljs-string">"The movie was okay."</span>,
  <span class="hljs-string">"The movie was terrible..."</span>
]

export_model.predict(examples)
export_model.save(<span class="hljs-string">"model.keras"</span>, save_format=<span class="hljs-string">"keras"</span>)
</code></pre>
<h1 id="heading-tensorflow-lite">TensorFlow Lite</h1>
<h2 id="heading-overview">Overview</h2>
<ul>
<li><p>TensorFlow Lite is a lightweight machine learning framework developed by Google, specifically designed for mobile and embedded devices.</p>
</li>
<li><p>It enables developers to deploy models directly on user devices, making inference faster and more efficient.</p>
</li>
</ul>
<h2 id="heading-integrating-tensorflow-model-with-our-application">Integrating TensorFlow model with our application</h2>
<h3 id="heading-creating-tensorflow-lite-model">Creating TensorFlow Lite Model</h3>
<p>For that we need to convert our model into a TensorFlow Lite Format. This can be done with the help of this code snippet:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-comment"># Load your pre-trained TensorFlow model</span>
model = tf.keras.models.load_model(<span class="hljs-string">"model.keras"</span>)

<span class="hljs-comment"># Convert the model to TensorFlow Lite format</span>
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()

<span class="hljs-comment"># Save the converted model to a file</span>
<span class="hljs-keyword">with</span> open(<span class="hljs-string">"model.tflite"</span>, <span class="hljs-string">"wb"</span>) <span class="hljs-keyword">as</span> f:
    f.write(tflite_model)
</code></pre>
<p>This will create a model.tflite file that we will be using later in our application to inculcate Artificial Intelligence.</p>
<h3 id="heading-application-integration">Application Integration</h3>
<p><strong>Android Integration:</strong></p>
<p>For Android app integration, leverage the power of Kotlin or Java along with Android Studio:</p>
<ul>
<li><p>Load the TensorFlow Lite model in your Android app.</p>
</li>
<li><p>Implement an efficient inference pipeline using Android's native features.</p>
</li>
<li><p>Utilize the Android SDK for UI elements and seamless user interaction.</p>
</li>
</ul>
<p>Detailed Explanation Link: <a target="_blank" href="https://www.tensorflow.org/lite/android">TensorFlow Lite for Android</a></p>
<p><strong>iOS Integration:</strong></p>
<p>For iOS app integration, use Swift or Objective-C along with Xcode:</p>
<ul>
<li><p>Integrate the TensorFlow Lite model into your iOS app.</p>
</li>
<li><p>Leverage Core ML for efficient on-device machine learning.</p>
</li>
<li><p>Design a user-friendly interface using iOS SDK elements.</p>
</li>
</ul>
<p>Detailed Explanation Link: <a target="_blank" href="https://www.tensorflow.org/lite/guide/ios">iOS quickstart  |  TensorFlow Lite</a></p>
<p><strong>Backend Integration with Python | Web Integration:</strong></p>
<p>For backend logic and seamless communication with your app, Python plays a crucial role:</p>
<ul>
<li><p>Develop a Python-based backend to handle communication with the app.</p>
</li>
<li><p>Implement data processing, storage, and retrieval using Python.</p>
</li>
<li><p>Utilize Flask or Django for building robust API endpoints.</p>
</li>
</ul>
<p>Detailed Explanation Link: <a target="_blank" href="https://www.tensorflow.org/lite/guide/inference#load_and_run_a_model_in_python">TensorFlow Lite | Python</a></p>
<h3 id="heading-human-feedback-integration">Human Feedback Integration</h3>
<h4 id="heading-1-user-feedback-collection">1. User Feedback Collection</h4>
<p>Implement mechanisms to collect user feedback within your app using Python for backend integration. This could include:</p>
<ul>
<li><p>Ratings and reviews</p>
</li>
<li><p>In-app surveys</p>
</li>
<li><p>User analytics data</p>
</li>
</ul>
<p>Utilize tools like Firebase Analytics, Google Analytics, or custom Python-based solutions to gather meaningful insights into user interactions.</p>
<h4 id="heading-2-continuous-learning-and-model-improvement">2. Continuous Learning and Model Improvement</h4>
<p>Leverage human feedback to iteratively improve your TFLite model, adapting to changing user needs and preferences.</p>
<h1 id="heading-benefit-of-the-framework">Benefit of the Framework</h1>
<ol>
<li><p><strong>On-Device Intelligence:</strong></p>
<ul>
<li>TensorFlow Lite enables on-device machine learning, reducing latency and dependency on network connectivity.</li>
</ul>
</li>
<li><p><strong>User-Centric Development:</strong></p>
<ul>
<li>Human feedback ensures that your app evolves based on real user experiences, leading to increased user satisfaction.</li>
</ul>
</li>
<li><p><strong>Privacy and Security:</strong></p>
<ul>
<li>On-device processing with TFLite enhances user privacy by reducing the need for data to be sent to external servers.</li>
</ul>
</li>
<li><p><strong>Efficient Resource Utilization:</strong></p>
<ul>
<li>TensorFlow Lite models are optimized for mobile devices, ensuring efficient use of device resources.</li>
</ul>
</li>
</ol>
<h2 id="heading-real-world-applications">Real World Applications</h2>
<p>Explore real-world applications of this framework in various domains such as:</p>
<ul>
<li><p>Image and object recognition</p>
</li>
<li><p>Natural language processing</p>
</li>
<li><p>Gesture recognition</p>
</li>
<li><p>Personalized recommendations</p>
</li>
<li><p>and many more.</p>
</li>
</ul>
<h1 id="heading-conclusion">Conclusion</h1>
<p>By combining the capabilities of TensorFlow and Python for model development, TensorFlow Lite for on-device machine learning, and human feedback, your app development process becomes more adaptive and user-focused. This comprehensive framework empowers developers to create intelligent applications that continuously evolve to meet user expectations, setting the stage for the next generation of mobile experiences.</p>
]]></content:encoded></item><item><title><![CDATA[Apple Vision Pro : A New Era of UI UX Design]]></title><description><![CDATA[Apple has always been a pioneer in creating innovative and user-friendly products. Their latest venture, Apple Vision Pro, is no exception. Apple Vision Pro is a mixed-reality headset that combines virtual reality (VR) and augmented reality (AR) tech...]]></description><link>https://blog.gdscnits.in/apple-vision-pro-a-new-era-of-ui-ux-design</link><guid isPermaLink="true">https://blog.gdscnits.in/apple-vision-pro-a-new-era-of-ui-ux-design</guid><category><![CDATA[Apple Vision pro]]></category><category><![CDATA[UIUX]]></category><dc:creator><![CDATA[Kaustav Dev]]></dc:creator><pubDate>Tue, 19 Mar 2024 04:32:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707850557586/41bced88-a43a-4ab0-85da-cf9a63e3c204.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Apple has always been a pioneer in creating innovative and user-friendly products. Their latest venture, Apple Vision Pro, is no exception. Apple Vision Pro is a mixed-reality headset that combines virtual reality (VR) and augmented reality (AR) technologies to create immersive and interactive experiences for users. According to Apple, Apple Vision Pro will offer features such as an eye- and hand-tracking interface, 3D video, spatial audio, and spatial apps that will enable users to explore, create, and connect in new ways.</p>
<p>But what does Apple Vision Pro mean for the UI UX design industry? How will it affect the way designers create and deliver digital products and services? In this blog, we will explore how Apple Vision Pro will revolutionize the UI UX design industry by creating new challenges and opportunities for designers.</p>
<h3 id="heading-new-challenges-for-uiux-designers"><strong>New Challenges for UI/UX Designers</strong></h3>
<p>Apple Vision Pro will introduce new challenges for UI UX designers, as they will have to adapt to a new medium and paradigm of design. Some of these challenges are:</p>
<ul>
<li><p><strong>Designing for spatial interactions and 3D environments</strong>: Unlike traditional 2D interfaces, Apple Vision Pro will allow users to interact with 3D objects and environments in a spatial context. This means that designers will have to consider factors such as depth, scale, perspective, lighting, shadows, and physics when creating UI UX elements. Designers will also have to design for different types of interactions, such as gaze, gesture, voice, and touch, and ensure that they are intuitive and consistent across different scenarios.</p>
</li>
<li><p><strong>Adapting to different user preferences and contexts</strong>: Apple Vision Pro will enable users to customize their experiences according to their preferences and contexts. For example, users will be able to adjust the level of immersion, realism, and complexity of the content they see and interact with. Users will also be able to switch between different modes of Apple Vision Pro, such as VR, AR, or mixed reality, depending on their needs and situations. This means that designers will have to design for multiple user personas, scenarios, and environments, and ensure that the UI UX elements are adaptable and responsive to the user’s choices.</p>
</li>
<li><p><strong>Ensuring usability, accessibility, and comfort</strong>: Apple Vision Pro will pose new challenges for the usability, accessibility, and comfort of the UI UX design. For example, designers will have to consider the potential issues of motion sickness, eye strain, and fatigue that users may experience when using Apple Vision Pro. Designers will also have to ensure that the UI UX elements are accessible and inclusive for users with different abilities, backgrounds, and preferences. Designers will have to test and evaluate the UI UX design with real users and devices and apply the best practices and guidelines for VR and AR design.</p>
</li>
</ul>
<h3 id="heading-new-opportunities-for-ui-ux-designers"><strong>New Opportunities for UI UX Designers</strong></h3>
<p>Apple Vision Pro will also create new opportunities for UI UX designers, as they will be able to expand the scope and impact of their work across various industries and domains. Some of these opportunities are:</p>
<ul>
<li><p><strong>Expanding the scope and impact of UI UX design</strong>: Apple Vision Pro will open up new possibilities for UI UX design in various fields and sectors, such as education, entertainment, health, tourism, gaming, social, and more. Designers will be able to create and deliver innovative and engaging solutions that can enhance the user’s learning, enjoyment, well-being, exploration, and connection. Designers will also be able to leverage the power of spatial computing and data to create and visualize complex and dynamic information and systems</p>
</li>
<li><p><strong>Enhancing user engagement and satisfaction</strong>: Apple Vision Pro will enable designers to create immersive and personalized experiences for users that can increase their engagement and satisfaction. For example, designers will be able to use 3D video and spatial audio to create realistic and captivating content that can stimulate the user’s senses and emotions. Designers will also be able to use eye- and hand-tracking interfaces to create interactive and responsive content that can adapt to the user’s attention and intention.</p>
</li>
<li><p><strong>Innovating and collaborating with new tools and platforms</strong>: Apple Vision Pro will provide designers with new tools and platforms to create and share their UI UX design. For example, designers will be able to use Apple’s RealityKit and Reality Composer to create and edit 3D content and animations for Apple Vision Pro. Designers will also be able to use Apple’s Spatial App Store to discover and download spatial apps for Apple Vision Pro. Designers will also be able to collaborate with other designers and developers using Apple’s RealityKit Live Link and RealityKit Collaborative Sessions.</p>
</li>
</ul>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<p>Apple Vision Pro is a game-changer for the UI UX design industry, as it will create new challenges and opportunities for designers. Designers will have to adapt to a new medium and paradigm of design and consider factors such as spatial interactions, user preferences, usability, accessibility, and comfort. Designers will also be able to expand the scope and impact of their work and enhance user engagement and satisfaction. Designers will also be able to innovate and collaborate with new tools and platforms.</p>
]]></content:encoded></item><item><title><![CDATA[Deciphering Deepfakes: Navigating the Complex Landscape]]></title><description><![CDATA[https://youtu.be/gLoI9hAX9dw
 
Introduction:
In the ever-accelerating frontier of technological innovation, the term 'deepfake' has emerged as a focal point of discussion, transcending domains from entertainment to political discourse.
Deepfakes, a c...]]></description><link>https://blog.gdscnits.in/deciphering-deepfakes-navigating-the-complex-landscape</link><guid isPermaLink="true">https://blog.gdscnits.in/deciphering-deepfakes-navigating-the-complex-landscape</guid><category><![CDATA[Deepfake]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Nawadeep Atreya]]></dc:creator><pubDate>Tue, 19 Mar 2024 04:29:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1705211211547/4ad6df67-62d9-427c-b47f-da7308c19cd8.avif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/gLoI9hAX9dw">https://youtu.be/gLoI9hAX9dw</a></div>
<p> </p>
<h3 id="heading-introduction"><strong>Introduction:</strong></h3>
<p>In the ever-accelerating frontier of technological innovation, the term 'deepfake' has emerged as a focal point of discussion, transcending domains from entertainment to political discourse.</p>
<p>Deepfakes, a convergence of 'deep learning' and 'fake,' are AI-generated manipulations of video and audio content. The genesis lies in sophisticated algorithms, particularly generative adversarial networks (GANs), enabling the seamless substitution of one person's likeness or voice with another.</p>
<hr />
<h3 id="heading-the-mechanics"><strong>The Mechanics:</strong></h3>
<ul>
<li><strong>Algorithmic Precision:</strong> Deepfake technology's core lies in its ability to meticulously analyze extensive datasets. It learns intricate facial expressions, speech patterns, and gestures, subsequently creating synthetic content with unparalleled realism.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705212278275/11435eba-8a07-4322-a00b-aba58a681b74.jpeg" alt class="image--center mx-auto" /></p>
<ul>
<li><p><strong>Generative Adversarial Networks (GANs):</strong> Generative Adversarial Networks (GANs) drive the deepfake process with a dance between a generator and a discriminator.</p>
<ol>
<li><p><em>Generator:</em> Initiating the process, it crafts synthetic content, attempting to mimic a real scene or person.</p>
</li>
<li><p><em>Discriminator:</em> Simultaneously, it evaluates the authenticity of the generated content, discerning between the authentic and the fabricated.</p>
</li>
</ol>
</li>
</ul>
<p>    In an iterative loop, the generator refines its output to become increasingly indistinguishable from real life, while the discriminator adapts to discern more accurately. This dynamic interplay forms the core of deepfake evolution.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705212399773/2889a3e3-dbeb-407f-a9e2-61254906cc94.png" alt class="image--center mx-auto" /></p>
<hr />
<h3 id="heading-the-dual-edged-sword"><strong>The Dual-Edged Sword:</strong></h3>
<ul>
<li><p><strong>Technological Marvel:</strong> Recognizing the extraordinary capabilities of AI, deepfakes showcase the incredible strides technology has made in crafting convincing digital illusions. This technological marvel has pushed the boundaries of what was once deemed impossible.</p>
</li>
<li><p><strong>Threats and Concerns:</strong> Delving into the darker side, deepfakes pose inherent risks. From the erosion of trust due to misinformation to the potential harm caused by their malicious use, the technology forces us to confront the dual-edged nature of its capabilities.</p>
</li>
</ul>
<hr />
<h3 id="heading-ethical-considerations"><strong>Ethical Considerations:</strong></h3>
<ul>
<li><p><strong>Privacy Invasion:</strong> Examining the ethical dilemmas arising from the unauthorized use of individuals' likenesses. Individuals often find themselves thrust into fabricated scenarios without consent, raising profound questions about privacy and digital autonomy.</p>
</li>
<li><p><strong>Misuse for Malicious Content:</strong> Addressing the more nefarious applications, deepfakes can be misused to create explicit or compromising content, giving rise to serious moral and legal concerns regarding the boundaries of digital ethics.</p>
</li>
</ul>
<hr />
<h3 id="heading-combatting-deepfakes"><strong>Combatting Deepfakes:</strong></h3>
<ul>
<li><p><strong>Technological Solutions:</strong> Presenting ongoing efforts to develop advanced tools leveraging facial recognition, blinking pattern analysis, and audio forensics. These tools aim to detect and authenticate digital content, acting as a countermeasure to the deceptive potential of deepfake technology.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1705212851583/a69396cc-5d6e-4a3b-80da-982a99f401aa.jpeg" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>Legal Frameworks:</strong> Discuss legislative initiatives aimed at criminalizing the malicious use of deepfake technology. These legal frameworks aim to hold those responsible for consequential harm accountable, establishing a deterrent against nefarious applications.</p>
</li>
</ul>
<hr />
<h3 id="heading-the-future-landscape"><strong>The Future Landscape:</strong></h3>
<ul>
<li><p><strong>Technological Evolution:</strong> Reflecting on the ongoing advancements in deepfake technology and speculating on the potential trajectory of future developments. As technology evolves, so too must our strategies to navigate the challenges presented by deepfakes.</p>
</li>
<li><p><strong>Collaborative Vigilance:</strong> Emphasizing the need for a synchronized effort between technology, legislation, and public awareness. Only through collaborative vigilance can we effectively navigate the evolving landscape and ensure responsible use of deepfake technology.</p>
</li>
</ul>
<hr />
<h3 id="heading-conclusion">Conclusion:</h3>
<p>In the realm of entertainment, deepfakes have emerged as digital maestros, conducting symphonies of creativity that challenge the conventional boundaries of storytelling. Imagine a world where iconic actors from different eras seamlessly share the screen, blurring the lines between past and present. Deepfakes have the potential to breathe new life into cinema, offering a captivating dance between nostalgia and innovation.</p>
<p>Beyond the silver screen, deepfakes unveil the palette of creative expression. They become digital artisans, transforming mundane moments into extraordinary narratives. Through their lens, the ordinary can morph into the extraordinary, and the fantastical can become the tangible. In the hands of creators, deepfakes become instruments of imagination, inviting us to question not just what is real, but what could be.</p>
<p>As we traverse the landscape of deepfakes, we must embrace a nuanced perspective that recognizes both the shadows and the light they cast. It is in this delicate dance between risks and rewards that we unlock the full potential of this transformative technology, allowing it to shape a future where creativity knows no bounds.</p>
]]></content:encoded></item><item><title><![CDATA[A Comparative Analysis of SQL and MongoDB: Choosing the Right Database for Your Project]]></title><description><![CDATA[Introduction:
In the ever-evolving landscape of database management systems, the choice between SQL and NoSQL databases plays a crucial role in determining the success and efficiency of your application. SQL (Structured Query Language) and MongoDB (a...]]></description><link>https://blog.gdscnits.in/a-comparative-analysis-of-sql-and-mongodb-choosing-the-right-database-for-your-project</link><guid isPermaLink="true">https://blog.gdscnits.in/a-comparative-analysis-of-sql-and-mongodb-choosing-the-right-database-for-your-project</guid><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Rishi Raj Saha]]></dc:creator><pubDate>Tue, 09 Jan 2024 17:36:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1704820041713/84ad7d44-2070-4ba0-a4e0-40ec6a7bb3ed.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction:</h2>
<p>In the ever-evolving landscape of database management systems, the choice between SQL and NoSQL databases plays a crucial role in determining the success and efficiency of your application. SQL (Structured Query Language) and MongoDB (a NoSQL database) are two popular choices, each with its own strengths and weaknesses. In this blog post, we will delve into the characteristics, advantages, and considerations when deciding between SQL and MongoDB.</p>
<ol>
<li><p><strong>Data Model:</strong></p>
<ul>
<li><p><strong>SQL (Relational Databases):</strong></p>
<ul>
<li><p>SQL databases use a structured and tabular data model.</p>
</li>
<li><p>Data is organized into tables with predefined schemas, providing a clear and consistent structure.</p>
</li>
<li><p>Relationships between tables are established using foreign keys.</p>
</li>
</ul>
</li>
<li><p><strong>MongoDB (NoSQL Document-Oriented):</strong></p>
<ul>
<li><p>MongoDB employs a flexible, schema-less document-oriented data model.</p>
</li>
<li><p>Data is stored in BSON (Binary JSON) documents, allowing for a dynamic and hierarchical structure.</p>
</li>
<li><p>No predefined schema makes MongoDB adaptable to evolving data requirements.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Scalability:</strong></p>
<ul>
<li><p><strong>SQL:</strong></p>
<ul>
<li><p>Scaling vertically (adding more resources to a single server) is the traditional approach for SQL databases.</p>
</li>
<li><p>Some relational databases support horizontal scaling, but it may involve complex setups.</p>
</li>
</ul>
</li>
<li><p><strong>MongoDB:</strong></p>
<ul>
<li><p>NoSQL databases like MongoDB are designed for horizontal scalability.</p>
</li>
<li><p>Sharding allows for distributing data across multiple servers, facilitating efficient scalability.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Query Language:</strong></p>
<ul>
<li><p><strong>SQL:</strong></p>
<ul>
<li><p>SQL databases use a standardized query language (SQL) for data manipulation.</p>
</li>
<li><p>Well-established and widely adopted, SQL queries are powerful and expressive.</p>
</li>
</ul>
</li>
<li><p><strong>MongoDB:</strong></p>
<ul>
<li><p>MongoDB uses a JSON-like query language that supports complex queries and indexing.</p>
</li>
<li><p>Its query language is more flexible and resembles the structure of the data.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Schema Flexibility:</strong></p>
<ul>
<li><p><strong>SQL:</strong></p>
<ul>
<li><p>Rigorous schema enforcement ensures data consistency and integrity.</p>
</li>
<li><p>Changes to the schema may require altering existing data, which can be cumbersome.</p>
</li>
</ul>
</li>
<li><p><strong>MongoDB:</strong></p>
<ul>
<li><p>Schema-less design allows for easy adaptation to changing data requirements.</p>
</li>
<li><p>New fields can be added to documents without affecting existing data.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Use Cases:</strong></p>
<ul>
<li><p><strong>SQL:</strong></p>
<ul>
<li><p>Well-suited for applications with complex relationships and transactions, such as financial systems and traditional e-commerce platforms.</p>
</li>
<li><p>ACID compliance ensures data integrity.</p>
</li>
</ul>
</li>
<li><p><strong>MongoDB:</strong></p>
<ul>
<li><p>Ideal for projects with dynamic and evolving data, like content management systems, real-time analytics, and mobile applications.</p>
</li>
<li><p>Well-suited for scenarios where scalability and flexibility are critical.</p>
</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>Code examples to illustrate key concepts for both SQL and MongoDB.</p>
<h3 id="heading-sql-example-using-mysql-as-an-example"><strong>SQL Example (using MySQL as an example):</strong></h3>
<pre><code class="lang-sql"><span class="hljs-comment">-- Creating a table with a predefined schema</span>
<span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-keyword">users</span> (
    user_id <span class="hljs-built_in">INT</span> PRIMARY <span class="hljs-keyword">KEY</span>,
    username <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">50</span>) <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    email <span class="hljs-built_in">VARCHAR</span>(<span class="hljs-number">100</span>) <span class="hljs-keyword">UNIQUE</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
    birthdate <span class="hljs-built_in">DATE</span>
);

<span class="hljs-comment">-- Inserting data into the table</span>
<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> <span class="hljs-keyword">users</span> (user_id, username, email, birthdate)
<span class="hljs-keyword">VALUES</span> (<span class="hljs-number">1</span>, <span class="hljs-string">'xyz'</span>, <span class="hljs-string">'xyz@example.com'</span>, <span class="hljs-string">'03/01/1999'</span>);

<span class="hljs-comment">-- Querying data with SQL</span>
<span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">users</span> <span class="hljs-keyword">WHERE</span> username = <span class="hljs-string">'xyz'</span>;
</code></pre>
<h3 id="heading-mongodb-example-using-the-official-mongodb-nodejs-driver"><strong>MongoDB Example (using the official MongoDB Node.js driver):</strong></h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> { MongoClient } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongodb'</span>);

<span class="hljs-comment">// Connection URL and database name</span>
<span class="hljs-keyword">const</span> url = <span class="hljs-string">'mongodb://localhost:3000'</span>;
<span class="hljs-keyword">const</span> dbName = <span class="hljs-string">'mydatabase'</span>;

<span class="hljs-comment">// Creating a MongoDB client</span>
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> MongoClient(url, { <span class="hljs-attr">useNewUrlParser</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">useUnifiedTopology</span>: <span class="hljs-literal">true</span> });

<span class="hljs-comment">// Connect to the server</span>
client.connect(<span class="hljs-keyword">async</span> (err) =&gt; {
    <span class="hljs-keyword">if</span> (err) <span class="hljs-keyword">throw</span> err;

    <span class="hljs-comment">// Accessing a database</span>
    <span class="hljs-keyword">const</span> db = client.db(dbName);

    <span class="hljs-comment">// Inserting data into a collection (no predefined schema)</span>
    <span class="hljs-keyword">await</span> db.collection(<span class="hljs-string">'users'</span>).insertOne({
        <span class="hljs-attr">user_id</span>: <span class="hljs-number">1</span>,
        <span class="hljs-attr">username</span>: <span class="hljs-string">'xyz'</span>,
        <span class="hljs-attr">email</span>: <span class="hljs-string">'xyz@example.com'</span>,
        <span class="hljs-attr">birthdate</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(<span class="hljs-string">'03/01/1999'</span>),
    });

    <span class="hljs-comment">// Querying data with MongoDB</span>
    <span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> db.collection(<span class="hljs-string">'users'</span>).findOne({ <span class="hljs-attr">username</span>: <span class="hljs-string">'xyz'</span> });
    <span class="hljs-built_in">console</span>.log(result);

    <span class="hljs-comment">// Close the connection</span>
    client.close();
});
</code></pre>
<p>Conclusion:</p>
<p>The choice between SQL and MongoDB depends on the specific requirements and characteristics of your project. SQL databases offer a structured and ACID-compliant environment, while MongoDB provides flexibility and scalability in a dynamic, schema-less model. Understanding the nature of your data, scalability needs, and development preferences will guide you towards the most suitable database solution for your application. Ultimately, both SQL and MongoDB have their strengths, and the decision should align with the goals and demands of your project.</p>
]]></content:encoded></item><item><title><![CDATA[Navigating the Dynamic Landscape of UI/UX Development: Trends, Demands, and the Current Scenario]]></title><description><![CDATA[In the ever-evolving realm of UI/UX development, staying abreast of the latest trends and understanding the current demands is crucial for professionals and businesses alike. In this blog post, we'll delve into the key trends shaping UI/UX design, th...]]></description><link>https://blog.gdscnits.in/navigating-the-dynamic-landscape-of-uiux-development-trends-demands-and-the-current-scenario</link><guid isPermaLink="true">https://blog.gdscnits.in/navigating-the-dynamic-landscape-of-uiux-development-trends-demands-and-the-current-scenario</guid><category><![CDATA[UI]]></category><category><![CDATA[UX]]></category><category><![CDATA[Ui/Ux Design]]></category><category><![CDATA[trends]]></category><dc:creator><![CDATA[gracie ruth]]></dc:creator><pubDate>Tue, 09 Jan 2024 17:35:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1703953716793/d1f57cd5-b1e2-42f1-85a6-9528ddf9c256.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the ever-evolving realm of UI/UX development, staying abreast of the latest trends and understanding the current demands is crucial for professionals and businesses alike. In this blog post, we'll delve into the key trends shaping UI/UX design, the demands in the job market, and the current landscape of this dynamic field. As we approach 2024, let’s explore the trends shaping the industry and understand the demands for skilled designers.</p>
<p><strong>UX Trends for 2024</strong></p>
<p><strong>1. Dark Mode Dominance</strong></p>
<p>Dark mode has become more than just a trend; it’s now a user expectation. With the rise of OLED and AMOLED screens, dark themes offer benefits such as reduced eye strain, improved battery life, and enhanced readability. Designers are embracing dark mode across platforms, creating sleek and visually appealing interfaces.</p>
<p><strong>2. Neumorphism (Soft UI)</strong></p>
<p>Neumorphism combines flat design with subtle skeuomorphic elements. Buttons, cards, and other UI components appear slightly raised or pressed into the surface, mimicking physical interactions. This trend adds depth and realism to digital interfaces, making them more engaging.</p>
<p><strong>3. Oversized Typography</strong></p>
<p>Typography isn’t just about conveying information; it’s a powerful visual element. Large headlines, expressive fonts, and creative type treatments capture attention and set the tone for the user experience. Expect to see more bold and impactful typography in 2024.</p>
<p><strong>4. Generative AI and the UX Process</strong></p>
<p>Artificial intelligence (AI) is revolutionizing design workflows. Generative AI assists designers by automating repetitive tasks, suggesting design variations, and enhancing creativity. As AI tools become more accessible, designers can focus on strategic decisions and problem-solving.</p>
<p><strong>5. Growth Design and Hyper-Personalization</strong></p>
<p>Growth-focused design emphasizes iterative improvements based on data-driven insights. Hyper-personalization tailors experiences to individual users, enhancing engagement. Designers will need to balance scalability with personalized interactions.</p>
<p><strong>6. Ethical Design Considerations</strong></p>
<p>User well-being, privacy, and inclusivity are at the forefront of ethical design. Designers must navigate complex ethical dilemmas, ensuring that their creations benefit users without causing harm. Responsible design practices are essential.</p>
<p><strong>7. Inclusivity as a Mindset</strong></p>
<p>Inclusive design goes beyond accessibility compliance. It considers diverse abilities, cultures, and backgrounds. Designers should prioritize empathy, actively seeking perspectives from underrepresented groups. Inclusivity leads to better products and a more equitable digital world.</p>
<h2 id="heading-the-current-scenario-in-uiux-development"><strong>The Current Scenario in UI/UX Development</strong></h2>
<p>Against the backdrop of a tech landscape in constant flux, UI/UX designers are witnessing a paradigm shift. The rise of remote work has prompted professionals to adapt to virtual collaboration while companies are increasingly investing in creating exceptional user experiences to maintain a competitive edge.</p>
<p><strong>Demand for UI/UX Designers in 2024</strong></p>
<p>The demand for UI/UX designers continues to grow. According to projections, employment rates for web developers and digital designers (including UX designers) will increase by 23% from 2021 to 2031. However, entry-level roles may become more competitive as the field expands.</p>
<p>In conclusion, UI/UX designers play a pivotal role in shaping digital experiences. By staying informed, embracing trends, and championing ethical design, they contribute to a user-centric and visually delightful digital landscape.</p>
<p>Remember, as a designer, you’re not just creating interfaces; you’re crafting meaningful interactions that impact users worldwide. Happy designing!</p>
]]></content:encoded></item><item><title><![CDATA[Understanding the Golden Ratio in Website Design: Aesthetic Harmony and Functional Balance]]></title><description><![CDATA[When it comes to website design, having a visually pleasing and well-balanced layout is essential to drawing visitors in and efficiently delivering content. The golden ratio is one of the rules that designers frequently use to accomplish this balance...]]></description><link>https://blog.gdscnits.in/understanding-the-golden-ratio-in-website-design-aesthetic-harmony-and-functional-balance</link><guid isPermaLink="true">https://blog.gdscnits.in/understanding-the-golden-ratio-in-website-design-aesthetic-harmony-and-functional-balance</guid><category><![CDATA[UIUX]]></category><category><![CDATA[Web Design]]></category><category><![CDATA[golden ratio]]></category><dc:creator><![CDATA[Partha Sarathi Phukon]]></dc:creator><pubDate>Sat, 23 Dec 2023 16:18:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702102813857/8db95566-43ea-415d-a352-8d8dfd8c2d6d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When it comes to website design, having a visually pleasing and well-balanced layout is essential to drawing visitors in and efficiently delivering content. The golden ratio is one of the rules that designers frequently use to accomplish this balance. The Greek letter phi (Φ), which is commonly used to symbolize the golden ratio, is a mathematical proportion that is thought to produce aesthetically beautiful patterns in nature, art, and architecture.</p>
<h3 id="heading-what-is-the-golden-ratio">What is the Golden Ratio?</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702103525823/42267798-3ac8-4757-841c-87fe0d5b49c0.jpeg" alt class="image--center mx-auto" /></p>
<p>A mathematical ratio known as the "golden ratio" is about equal to 1.618. It happens when a line is cut in half such that the length of the line divided by the longer half equals the length of the line divided by the smaller part. Because of its widespread occurrence in nature and its aesthetically pleasing appearance, this percentage has captivated mathematicians, artists, and designers for centuries.</p>
<h3 id="heading-applying-the-golden-ratio-in-website-design">Applying the Golden Ratio in Website Design</h3>
<p><strong>1. Layout and Grid System</strong>s</p>
<p>In website design, the golden ratio can be applied to create balanced and visually appealing layouts. Designers often use grid systems based on the golden ratio to structure content and elements on a web page. For instance, a grid with proportions following the golden ratio can help in determining the placement and sizing of elements such as text blocks, images, and navigation menus.</p>
<p><strong>2. Typography and Text Layout</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702104268683/00a8d793-615c-4c25-bc6d-3e12aeca6289.jpeg" alt class="image--center mx-auto" /></p>
<p>Typography plays a crucial role in web design, influencing readability and user experience. Applying the golden ratio to typography involves determining ideal font sizes and line heights to achieve a harmonious balance between text and white space. This can enhance readability and make the content more visually appealing.</p>
<p><strong>3. Image and Element Placement</strong></p>
<p>The aesthetic appeal of a website is greatly enhanced by the use of images and other visual elements. Designers can choose the location and size of pictures or elements, including buttons, banners, and icons, by utilizing the golden ratio. This aids in producing an aesthetically beautiful arrangement that captures the user's eye while preserving the design's harmony.</p>
<p><strong>4. Logo and Icon Design</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702104846821/f04f5d7f-e68c-4bf3-8454-2e017352e3d1.png" alt class="image--center mx-auto" /></p>
<p>Logos and icons are often the visual representations of a brand or website. Designing these elements with proportions derived from the golden ratio can result in visually appealing and well-balanced logos that resonate with the audience and convey the desired message effectively.</p>
<p><strong>5. Responsive Design and Scalability</strong></p>
<p>The need for responsive design has grown as more people visit websites through a variety of devices. Another way to use the golden ratio is to design responsive layouts that adapt smoothly to various screen sizes. It is ensured that the design is aesthetically pleasant regardless of the device used by maintaining proportionate relationships between parts.</p>
<h3 id="heading-beyond-aesthetics-psychology-and-user-experience">Beyond Aesthetics: Psychology and User Experience</h3>
<p>Although the Golden Ratio undoubtedly enhances a website's aesthetic appeal, its significance goes beyond visual appeal. Its utilization can create in consumers a subliminal sense of beauty and order, which enhances the user experience. Users frequently connect intuitively with the harmony and balance this proportion creates, which enhances the perception of a website's legitimacy and dependability.</p>
<h3 id="heading-finding-a-balance">Finding a Balance</h3>
<p>The Golden Ratio can improve a website's design, but it's important to keep in mind that design principles are guidelines rather than hard and fast rules. It is crucial to strike a balance between design flexibility to meet functionality and user needs and strict adherence to the ratio.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>The golden ratio is a useful guideline that can help designers create visually beautiful and balanced layouts, even though it's not a hard and fast rule for web design. It's crucial to keep in mind, though, that design principles should also take the target audience's particular needs, usability, and functionality into account. When used with other design ideas, the golden ratio may create a visually appealing and captivating website that draws visitors in and improves their surfing experience.</p>
]]></content:encoded></item><item><title><![CDATA[Y2K38: The Looming Digital Quagmire]]></title><description><![CDATA[Introduction
As the digital world hurtles forward, a distant, yet looming issue has been quietly building—a potential echo of the Y2K bug that once stirred widespread concern. The year 2038, much like Y2K, holds the promise of chaos for unprepared sy...]]></description><link>https://blog.gdscnits.in/y2k38-the-looming-digital-quagmire</link><guid isPermaLink="true">https://blog.gdscnits.in/y2k38-the-looming-digital-quagmire</guid><category><![CDATA[Bugs and Errors]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Saptarshi Adhikari]]></dc:creator><pubDate>Sat, 23 Dec 2023 16:17:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1703024921571/9bfa8948-fb66-473b-9522-01e4b64cac5a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>As the digital world hurtles forward, a distant, yet looming issue has been quietly building—a potential echo of the Y2K bug that once stirred widespread concern. The year 2038, much like Y2K, holds the promise of chaos for unprepared systems raising the specter of the Y2K38 problem. Let us understand what was the Y2K bug and what is the forthcoming Year 2038 problem.</p>
<h2 id="heading-history-of-the-millennium-bug">History of the <strong>Millennium Bug</strong></h2>
<p>The <em>Millennium</em> Bug, also known as the Y2K problem, was a potential issue that stemmed from the way early computer systems stored dates. In many older systems, dates were recorded using only the last two digits to represent the year, assuming that the first two digits (19) would always remain constant. For instance, the year 1998 was represented as '98'. This was done as in those days memory storage was not as cheap as it is today, so storing the extra two digits '19' of the year would cost a good fortune.</p>
<p>As the year 2000 approached, there was concern that these systems would interpret the year 2000 as '00', potentially causing errors. Since '00' could be interpreted as 1900 instead of 2000, this raised the possibility of significant issues in various computer programs and systems that relied on accurate date calculations.</p>
<p>The fear was that financial systems, databases, industrial processes, and other critical infrastructure might malfunction or crash when the year changed from 1999 to 2000, leading to widespread disruptions. The concern wasn’t just about computer failures but also about potential safety hazards and economic disturbances.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703025640951/dddd986a-995e-4638-9c77-e325c910d0d8.jpeg" alt class="image--center mx-auto" /></p>
<p>To address this issue, organizations worldwide undertook massive efforts to update, test, and fix the software, ensuring that systems would accurately handle the change from 1999 to 2000. Fortunately, extensive preparation and remediation prevented major global disruptions when the new millennium arrived.</p>
<h2 id="heading-unix-time">Unix Time</h2>
<p>Unix time, also known as <strong>POSIX</strong> time, is a system for tracking time in computing systems. It represents time as the number of non-leap seconds that have passed since <strong>January 1, 1970, at 00:00:00 UTC</strong> (Coordinated Universal Time), the <strong>Unix epoch</strong> time.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">A non-leap second refers to any second not part of a leap second adjustment in timekeeping. Leap seconds are occasionally added to Coordinated Universal Time (UTC) to account for variations in the Earth's rotation speed and maintain synchronization with atomic time standards.</div>
</div>

<p>It originated as the system time of Unix operating systems but has come to be widely used in other computer operating systems, file systems, programming languages, and databases.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Interesting fact:</strong> The C standard library uses Unix time for all date and time functions, and Unix time is sometimes referred to as <strong>time_t</strong>, the name of the data type used for timestamps in C and C++.</div>
</div>

<h2 id="heading-understanding-y2k38"><em>Understanding Y2K38</em></h2>
<p>The UNIX time is currently stored in a signed 32-bit integer where the positive numbers denote time after 1970 and the negative denote time before 1970. When UNIX time was devised no one thought that there would be a time when the 32-bit would not be enough to store time. This gives rise to a big problem that is going to affect all computing systems unless it is fixed. On <strong>Wednesday, January 19, 2038</strong>, at <strong>03:14:07 UTC</strong> the last 32-bit signed positive integer (i.e. 2<sup>31-1</sup> )will be counted after that it will overflow to -2<sup>31</sup> sending every computer back to the past ( precisely <strong>Friday, December 13, 1901, at 20:45:52 UTC</strong> ).</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Interesting fact</strong>: The number 2<sup>31-1</sup> =2147483647 is a double Mersenne number. There are only four known double Mersenne numbers.</div>
</div>

<h2 id="heading-implications-of-y2k38">Implications of Y2K38</h2>
<ol>
<li><p><strong>Software Glitches and Malfunctions:</strong> Systems relying on 32-bit time representations may experience errors or crashes post-2038.</p>
</li>
<li><p><strong>Security Vulnerabilities:</strong> Unpatched systems might become susceptible to security breaches due to incorrect time handling.</p>
</li>
<li><p><strong>Infrastructure and Legacy Systems:</strong> Industries heavily reliant on legacy systems could face significant disruptions if not adequately addressed.</p>
</li>
<li><p><strong>Global Impact:</strong> Embedded systems, financial records, and critical infrastructure might be affected, posing a threat to daily operations</p>
</li>
</ol>
<h2 id="heading-addressing-the-looming-crisis">Addressing the Looming Crisis</h2>
<ol>
<li><p><strong>System Updates and Patches:</strong> Software developers and system administrators need to ensure that affected systems are updated to use 64-bit time representations.</p>
</li>
<li><p><strong>Migration Strategies:</strong> Encouraging migration to newer systems or adopting solutions that handle time more robustly.</p>
</li>
<li><p><strong>Testing and Validation:</strong> Rigorous testing and validation of systems to identify and rectify potential vulnerabilities.</p>
</li>
<li><p><strong>Awareness and Education:</strong> Raising awareness among businesses and organizations to tackle the issue before its arrival.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>While the Y2K38 problem may seem distant, its implications could be far-reaching if ignored. By acknowledging and addressing this issue now, industries and individuals can navigate the impending digital quagmire, ensuring a smoother transition into the future.</p>
<p>The looming Y2K38 issue shares similarities with the <strong>IPv4 to IPv6 shift</strong>, stressing the need for proactive system upgrades to prevent potential disruptions. Both scenarios highlight the necessity of adapting to technological limitations and evolving towards future-proof solutions for seamless digital infrastructure progression.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Interesting fact</strong>: Unix enthusiasts have a history of holding "<em>time_t</em> parties" (pronounced "time tea parties") to celebrate significant values of the Unix time number.<sup> </sup>These are directly analogous to the new year celebrations that occur at the change of year in many calendars.</div>
</div>

<h2 id="heading-resources-to-read-further">Resources to read further</h2>
<ul>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Year_2038_problem">Year 2038 problem (Wikipedia)</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Year_2000_problem">Year 2000 problem (Wikipedia)</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Unix_time">Unix Time (Wikipedia)</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Leap_second">Leap second (Wikipedia)</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Double_Mersenne_number">Double Mersenne number (Wikipedia)</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Mersenne_prime">Mersenne prime number (Wikipedia)</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/POSIX">POSIX (Wikipedia)</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Unveiling SASS: Elevating the Power of Stylesheets]]></title><description><![CDATA[In the realm of web development, the evolution of styling languages has paved the way for more efficient and maintainable code. One such standout is SASS (Syntactically Awesome Stylesheets), a CSS preprocessor that brings a wealth of features to the ...]]></description><link>https://blog.gdscnits.in/unveiling-sass-elevating-the-power-of-stylesheets</link><guid isPermaLink="true">https://blog.gdscnits.in/unveiling-sass-elevating-the-power-of-stylesheets</guid><category><![CDATA[CSS]]></category><category><![CDATA[Sass]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Bhargab Bora]]></dc:creator><pubDate>Wed, 20 Dec 2023 08:58:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702736093140/f8eefd50-7368-4726-8456-7a7676dad441.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the realm of web development, the evolution of styling languages has paved the way for more efficient and maintainable code. One such standout is SASS (Syntactically Awesome Stylesheets), a CSS preprocessor that brings a wealth of features to the table.</p>
<h3 id="heading-what-is-sass"><strong>What is SASS?</strong></h3>
<p>SASS is a CSS preprocessor scripting language that acts as a superset of CSS. Its primary objective is to simplify and enhance the process of writing stylesheets. By introducing features not present in traditional CSS, SASS provides developers with a more robust and flexible tool for styling web applications.</p>
<h3 id="heading-how-sass-differs-from-regular-css"><strong>How SASS Differs from Regular CSS</strong></h3>
<p>1. Variables</p>
<p>CSS:</p>
<pre><code class="lang-css"><span class="hljs-selector-pseudo">:root</span> {
  <span class="hljs-attribute">--primary-color</span>: <span class="hljs-number">#3498db</span>;
}

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-built_in">var</span>(--primary-color);
}
</code></pre>
<p>SASS:</p>
<pre><code class="lang-scss"><span class="hljs-variable">$primary-color</span>: <span class="hljs-number">#3498db</span>;

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-variable">$primary-color</span>;
}
</code></pre>
<p><strong>2. Nesting</strong></p>
<p>CSS:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">ul</span> {
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">list-style</span>: none;
}

<span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span> {
  <span class="hljs-attribute">display</span>: inline-block;
  <span class="hljs-attribute">margin-right</span>: <span class="hljs-number">10px</span>;
}

<span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span> <span class="hljs-selector-tag">a</span> {
  <span class="hljs-attribute">text-decoration</span>: none;
}
</code></pre>
<p>SASS:</p>
<pre><code class="lang-scss"><span class="hljs-selector-tag">nav</span> {
  <span class="hljs-selector-tag">ul</span> {
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">list-style</span>: none;

    <span class="hljs-selector-tag">li</span> {
      <span class="hljs-attribute">display</span>: inline-block;
      <span class="hljs-attribute">margin-right</span>: <span class="hljs-number">10px</span>;

      <span class="hljs-selector-tag">a</span> {
        <span class="hljs-attribute">text-decoration</span>: none;
      }
    }
  }
}
</code></pre>
<p><strong>3. Mixins</strong></p>
<p>CSS:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* No equivalent in plain CSS */</span>
</code></pre>
<p>SASS:</p>
<pre><code class="lang-scss"><span class="hljs-keyword">@mixin</span> flex-container(<span class="hljs-variable">$direction</span>: row, <span class="hljs-variable">$justify</span>: center, <span class="hljs-variable">$align</span>: center) {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">flex-direction</span>: <span class="hljs-variable">$direction</span>;
  <span class="hljs-attribute">justify-content</span>: <span class="hljs-variable">$justify</span>;
  <span class="hljs-attribute">align-items</span>: <span class="hljs-variable">$align</span>;
}

<span class="hljs-selector-class">.container</span> {
  <span class="hljs-keyword">@include</span> flex-container(column, space-between, center);
}
</code></pre>
<p><strong>4. Partials and Import</strong></p>
<p>CSS:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* No equivalent in plain CSS */</span>
</code></pre>
<p>SASS:</p>
<pre><code class="lang-scss"><span class="hljs-keyword">@import</span> <span class="hljs-string">'buttons'</span>;
<span class="hljs-keyword">@import</span> <span class="hljs-string">'forms'</span>;
</code></pre>
<h2 id="heading-why-sass-is-better-than-regular-css"><strong>Why SASS is Better Than Regular CSS</strong></h2>
<h3 id="heading-1-maintainability"><strong>1. Maintainability</strong></h3>
<p>With features like variables and mixins, SASS reduces redundancy and promotes code consistency, making stylesheets easier to maintain and update.</p>
<h3 id="heading-2-readability"><strong>2. Readability</strong></h3>
<p>The nested structure in SASS mirrors the HTML structure, resulting in more readable and intuitive code compared to traditional CSS.</p>
<h3 id="heading-3-reusability"><strong>3. Reusability</strong></h3>
<p>Mixins and variables in SASS promote the reuse of styles, enabling developers to create a library of consistent and easily applicable design patterns.</p>
<h3 id="heading-4-modularity"><strong>4. Modularity:</strong></h3>
<p>SASS supports the creation of modular styles through partials and import, allowing developers to work on specific components or sections independently.</p>
<h3 id="heading-5-enhanced-functionality"><strong>5. Enhanced Functionality</strong></h3>
<p>SASS introduces advanced functionalities like control directives, mathematical operations, and functions, providing developers with powerful tools for crafting intricate styles.</p>
<h2 id="heading-key-features-of-sass"><strong>Key Features of SASS</strong></h2>
<p><strong>1. Variables</strong></p>
<pre><code class="lang-scss"><span class="hljs-variable">$primary-color</span>: <span class="hljs-number">#3498db</span>;

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-variable">$primary-color</span>;
}
</code></pre>
<p><strong>2. Nesting</strong></p>
<pre><code class="lang-scss"><span class="hljs-selector-tag">nav</span> {
  <span class="hljs-selector-tag">ul</span> {
    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
    <span class="hljs-attribute">list-style</span>: none;

    <span class="hljs-selector-tag">li</span> {
      <span class="hljs-attribute">display</span>: inline-block;
      <span class="hljs-attribute">margin-right</span>: <span class="hljs-number">10px</span>;

      <span class="hljs-selector-tag">a</span> {
        <span class="hljs-attribute">text-decoration</span>: none;
      }
    }
  }
}
</code></pre>
<p><strong>3. Mixins</strong></p>
<pre><code class="lang-scss"><span class="hljs-keyword">@mixin</span> flex-container(<span class="hljs-variable">$direction</span>: row, <span class="hljs-variable">$justify</span>: center, <span class="hljs-variable">$align</span>: center) {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">flex-direction</span>: <span class="hljs-variable">$direction</span>;
  <span class="hljs-attribute">justify-content</span>: <span class="hljs-variable">$justify</span>;
  <span class="hljs-attribute">align-items</span>: <span class="hljs-variable">$align</span>;
}

<span class="hljs-selector-class">.container</span> {
  <span class="hljs-keyword">@include</span> flex-container(column, space-between, center);
}
</code></pre>
<p><strong>4. Partials and Import</strong></p>
<pre><code class="lang-scss"><span class="hljs-comment">// _buttons.scss</span>
<span class="hljs-selector-class">.button</span> {
  <span class="hljs-comment">// Button styles</span>
}

<span class="hljs-comment">// styles.scss</span>
<span class="hljs-keyword">@import</span> <span class="hljs-string">'buttons'</span>;

<span class="hljs-selector-class">.container</span> {
  <span class="hljs-comment">// Container styles</span>
}
</code></pre>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>SASS isn't just a preprocessor; it's a revolution in how we approach styling in web development. Its rich feature set, including variables, nesting, mixins, and modularity, elevates the efficiency and maintainability of stylesheets. As you integrate SASS into your workflow, you'll discover a new realm of possibilities for creating clean, modular, and powerful styles. Embrace the future of styling with SASS and watch your web projects flourish.</p>
]]></content:encoded></item><item><title><![CDATA[MASTERING MVVM - Delving Into
Modern Software Architecture]]></title><description><![CDATA[In the ever-evolving landscape of software development, mastering architectural patterns is key to building scalable, maintainable, and efficient applications. One such paradigm that has gained widespread adoption is the Model-View-ViewModel (MVVM) a...]]></description><link>https://blog.gdscnits.in/mastering-mvvm-delving-into-modern-software-architecture</link><guid isPermaLink="true">https://blog.gdscnits.in/mastering-mvvm-delving-into-modern-software-architecture</guid><category><![CDATA[MVVM]]></category><category><![CDATA[Android]]></category><dc:creator><![CDATA[ANKIT KUMAR BARNWAL]]></dc:creator><pubDate>Wed, 13 Dec 2023 18:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702563796706/6b44684c-9025-4852-b175-90e596caf345.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the ever-evolving landscape of software development, mastering architectural patterns is key to building scalable, maintainable, and efficient applications. One such paradigm that has gained widespread adoption is the Model-View-ViewModel (MVVM) architecture. In this blog, we'll delve into the core concepts of MVVM and explore how it empowers developers to create robust and modular applications.</p>
<h2 id="heading-intro-to-mvvm">Intro to MVVM</h2>
<p>MVVM is an architectural pattern that focuses mainly on separating the GUI (Graphical User Interface) from the main back-end logic or business logic(Data Model). The View Model in MVVM represents an abstraction of the View, which contains a View's state and behavior.</p>
<hr />
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702654507706/4f95b9c4-73ad-49dd-b095-c597cb3a6552.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-understanding-the-components-of-mvvm">Understanding the Components of MVVM</h2>
<h3 id="heading-model">Model</h3>
<p>At the heart of MVVM lies the Model, representing the application's data and business logic. This encapsulation ensures that changes in the underlying data are independent of the user interface, promoting a clear separation of concerns.</p>
<h3 id="heading-view">View</h3>
<p>The View, responsible for the user interface, focuses solely on presenting data and capturing user interactions. It remains agnostic to the underlying data source, enhancing the flexibility to adapt to changing requirements.</p>
<h3 id="heading-view-model">View-Model</h3>
<p>The ViewModel acts as the bridge between the Model and the View. It transforms raw data from the Model into a format suitable for the View and handles user input, ensuring a seamless interaction between the user interface and the application logic.</p>
<hr />
<h2 id="heading-key-benefits-of-mvvm"><strong>Key Benefits of MVVM:</strong></h2>
<h3 id="heading-modularity"><strong>Modularity:</strong></h3>
<p>MVVM promotes a modular design, allowing developers to work on different components independently. This modularity enhances code maintainability and facilitates easier testing of individual modules.</p>
<h3 id="heading-testability"><strong>Testability:</strong></h3>
<p>The separation of concerns in MVVM makes it highly testable. With distinct components handling data, UI, and application logic, unit testing becomes more straightforward, ensuring the reliability of each module.</p>
<h3 id="heading-enhanced-collaboration"><strong>Enhanced Collaboration:</strong></h3>
<p>The clear division between the UI and business logic in MVVM fosters collaboration between designers and developers. Designers can focus on crafting intuitive user interfaces, while developers work on the underlying functionality without disrupting the UI design.</p>
<h2 id="heading-mvvm-in-action"><strong>MVVM In Action:</strong></h2>
<h3 id="heading-add-dependencies">Add Dependencies</h3>
<p>In your <code>build. gradle</code> file (Module: app), add the necessary dependencies for implementing MVVM:</p>
<pre><code class="lang-kotlin"><span class="hljs-comment">// ViewModel and LiveData</span>
implementation <span class="hljs-string">"androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"</span>
implementation <span class="hljs-string">"androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"</span>

<span class="hljs-comment">// Retrofit for networking</span>
implementation <span class="hljs-string">"com.squareup.retrofit2:retrofit:2.9.0"</span>
implementation <span class="hljs-string">"com.squareup.retrofit2:converter-gson:2.9.0"</span>

<span class="hljs-comment">// Coroutines for asynchronous programming</span>
implementation <span class="hljs-string">"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"</span>
</code></pre>
<h3 id="heading-create-the-model"><strong>Create the Model</strong></h3>
<pre><code class="lang-kotlin"><span class="hljs-keyword">data</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">User</span></span>(<span class="hljs-keyword">val</span> id: <span class="hljs-built_in">Int</span>, <span class="hljs-keyword">val</span> name: String, <span class="hljs-keyword">val</span> email: String)
</code></pre>
<h3 id="heading-implement-the-viewmodel">Implement the ViewModel</h3>
<p>Create a ViewModel class that interacts with your data model and prepares data for the UI. For instance:</p>
<pre><code class="lang-kotlin"><span class="hljs-keyword">import</span> androidx.lifecycle.LiveData
<span class="hljs-keyword">import</span> androidx.lifecycle.MutableLiveData
<span class="hljs-keyword">import</span> androidx.lifecycle.ViewModel
<span class="hljs-keyword">import</span> androidx.lifecycle.viewModelScope
<span class="hljs-keyword">import</span> kotlinx.coroutines.launch

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserViewModel</span> : <span class="hljs-type">ViewModel</span></span>() {

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">val</span> userRepository = UserRepository() <span class="hljs-comment">// Assume you have a repository class</span>

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">val</span> _userList = MutableLiveData&lt;List&lt;User&gt;&gt;()
    <span class="hljs-keyword">val</span> userList: LiveData&lt;List&lt;User&gt;&gt; <span class="hljs-keyword">get</span>() = _userList
</code></pre>
<pre><code class="lang-kotlin">    <span class="hljs-keyword">init</span> {
        <span class="hljs-comment">// Fetch data from the repository and update the LiveData</span>
        viewModelScope.launch {
            _userList.value = userRepository.getUsers()
        }
    }
}
</code></pre>
<h3 id="heading-create-the-repository"><strong>Create the Repository</strong></h3>
<p>Build a repository class that acts as a single source of truth for your app's data. In this case, it interacts with a remote data source (e.g., a web API using Retrofit). For example:</p>
<pre><code class="lang-kotlin"><span class="hljs-keyword">import</span> retrofit2.Retrofit
<span class="hljs-keyword">import</span> retrofit2.converter.gson.GsonConverterFactory

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserRepository</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">val</span> userService: UserService

    <span class="hljs-keyword">init</span> {
        <span class="hljs-keyword">val</span> retrofit = Retrofit.Builder()
            .baseUrl(<span class="hljs-string">"https://api.example.com/"</span>)
            .addConverterFactory(GsonConverterFactory.create())
            .build()

        userService = retrofit.create(UserService::<span class="hljs-keyword">class</span>.java)
    }

    <span class="hljs-keyword">suspend</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">getUsers</span><span class="hljs-params">()</span></span>: List&lt;User&gt; {
        <span class="hljs-keyword">return</span> userService.getUsers()
    }
}
</code></pre>
<h3 id="heading-set-up-retrofit-interface"><strong>Set Up Retrofit Interface</strong></h3>
<p>Define an interface for your Retrofit service:</p>
<pre><code class="lang-kotlin"><span class="hljs-keyword">import</span> retrofit2.http.GET

<span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">UserService</span> </span>{

    <span class="hljs-meta">@GET(<span class="hljs-meta-string">"users"</span>)</span>
    <span class="hljs-keyword">suspend</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">getUsers</span><span class="hljs-params">()</span></span>: List&lt;User&gt;
}
</code></pre>
<h3 id="heading-create-the-view"><strong>Create the View</strong></h3>
<p>Design your user interface in your XML layout files. For example, a simple RecyclerView to display the list of users.</p>
<h3 id="heading-observe-viewmodel-in-the-view"><strong>Observe ViewModel in the View</strong></h3>
<p>In your activity or fragment, initialize the ViewModel and observe the LiveData to update the UI when the data changes:</p>
<pre><code class="lang-kotlin"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainActivity</span> : <span class="hljs-type">AppCompatActivity</span></span>() {

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">lateinit</span> <span class="hljs-keyword">var</span> userViewModel: UserViewModel

    <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">onCreate</span><span class="hljs-params">(savedInstanceState: <span class="hljs-type">Bundle</span>?)</span></span> {
        <span class="hljs-keyword">super</span>.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        userViewModel = ViewModelProvider(<span class="hljs-keyword">this</span>).<span class="hljs-keyword">get</span>(UserViewModel::<span class="hljs-keyword">class</span>.java)

        userViewModel.userList.observe(<span class="hljs-keyword">this</span>, { userList -&gt;
            <span class="hljs-comment">// Update UI with the new data</span>
            <span class="hljs-comment">// For example, update the RecyclerView adapter</span>
        })
    }
}
</code></pre>
<h3 id="heading-reference">Reference:</h3>
<p>You may refer to this video for a more detailed explanation.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/PU0ua391_u0?si=ldh_8Iu-80ERcoY8">https://youtu.be/PU0ua391_u0?si=ldh_8Iu-80ERcoY8</a></div>
<p> </p>
<h2 id="heading-conclusion">CONCLUSION</h2>
<p>Implementing the Model-View-ViewModel (MVVM) architecture elevates code quality and developer productivity, offering a distinct separation of concerns, heightened maintainability, and improved testability. This pattern excels in applications with intricate user interfaces, fostering cleaner, more sustainable code. Its prowess becomes evident when logic needs reuse across diverse application segments or platforms. Despite MVVM's merits, it isn't universally optimal. For simpler projects with minimal complexity, its overhead may outweigh the benefits. Recognizing MVVM's strengths and weaknesses is crucial, allowing developers to make informed architectural decisions aligned with project requirements and ensuring an optimal balance between efficiency and code structure.</p>
]]></content:encoded></item></channel></rss>