<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anny Gil on Medium]]></title>
        <description><![CDATA[Stories by Anny Gil on Medium]]></description>
        <link>https://medium.com/@anny.gil?source=rss-d8bd1e2d3e3a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GgbOguGZdnTS4XZtEmOyEw.png</url>
            <title>Stories by Anny Gil on Medium</title>
            <link>https://medium.com/@anny.gil?source=rss-d8bd1e2d3e3a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:44:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anny.gil/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Guide to Pointers in Go: Learning with Analogies for Beginners]]></title>
            <link>https://medium.com/rewrite-tech/a-guide-to-pointers-in-go-learning-with-analogies-for-beginners-83e64eb232b6?source=rss-d8bd1e2d3e3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/83e64eb232b6</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[pointers]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Anny Gil]]></dc:creator>
            <pubDate>Thu, 19 Sep 2024 13:48:20 GMT</pubDate>
            <atom:updated>2024-10-23T08:58:22.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zabPZKNp7I2jGWx1JAGq5g.png" /></figure><p>Hey there, Go developers! Are you ready to embark on a fun journey to understand pointers in Go? If you’re a beginner who loves analogies while learning, you’re in the right place. Let’s dive into the world of pointers.</p><h3>What Are Pointers?</h3><p>Imagine you have a magical map that always shows the location of your treasure. This map is like a pointer. Instead of holding the treasure itself, it shows you where the treasure is hidden.</p><h3>Why Are Pointers Important?</h3><ol><li><strong>Efficiency</strong>: Pointers let functions work with large treasures (data structures) without moving them around. Saves a lot of heavy lifting!</li><li><strong>Mutability</strong>: With pointers, you can change the treasure’s location without moving the treasure itself.</li><li><strong>Complex Data Structures</strong>: Pointers are essential for creating treasure maps (linked lists, trees) that lead to complex treasures.</li></ol><h3>Basics of Pointers in Go</h3><p>Let’s break down pointers in Go with a treasure map analogy.</p><h3>Declaring and Using Pointers</h3><p>To declare a pointer, use the * operator followed by the type. Here’s how to declare a pointer to an integer:</p><pre>var treasureMap *int</pre><p>Right now, treasureMap is just a blank map with no location marked on it. It’s initialized to nil.</p><h3>Assigning Addresses</h3><p>To mark a location on your treasure map, use the &amp; operator, which gives you the memory address of a variable. Let’s see this in action:</p><pre>package main<br>import &quot;fmt&quot;<br><br>func main() {<br>    var treasure int = 100<br>    var treasureMap *int<br>    treasureMap = &amp;treasure<br>    fmt.Println(&quot;Treasure value:&quot;, treasure) //Output: 100<br>    fmt.Println(&quot;Treasure location:&quot;, treasureMap) //Output: memory address of treasure<br>    fmt.Println(&quot;Value at treasure location:&quot;, *treasureMap) //Output: 100<br>}</pre><p>In this code:</p><ul><li>&amp;treasure retrieves the memory address where the treasure is stored, and treasureMap now holds that address, pointing to the location of the treasure.</li><li>*treasureMap dereferences the pointer, giving us the treasure value stored at that location.</li></ul><h3>Modifying Values Through Pointers</h3><p>Pointers let you change the value at the memory address they point to. Here’s an example:</p><pre>package main<br>import &quot;fmt&quot;<br><br>func main() {<br>    var treasure int = 100<br>    var treasureMap *int<br>    treasureMap = &amp;treasure<br>    fmt.Println(&quot;Initial treasure value:&quot;, treasure) a // Output: 100<br>    *treasureMap = 200 // Changing the treasure value through the map<br>    fmt.Println(&quot;Modified treasure value:&quot;, treasure) // Output: 200<br>}</pre><p>By changing the value at the address marked on treasureMap, we directly modify treasure.</p><h3>Pointers and Functions</h3><p>One of the best things about pointers is passing them to functions. This allows functions to modify the original treasure.</p><h3>Passing Pointers to Functions</h3><p>Let’s look at how you can pass pointers to a function:</p><pre>package main<br>import &quot;fmt&quot;<br><br>func doubleTreasure(value *int) {<br>    *value *= 2<br>}<br>func main() {<br>    treasure:= 50 // short hand declaration and initialization (:=)<br>    fmt.Println(&quot;Before doubling:&quot;, treasure) // Output: 50<br>    doubleTreasure(&amp;treasure) // Passing the address of treasure<br>    fmt.Println(&quot;After doubling:&quot;, treasure)  // Output: 100<br>}</pre><p>In this example:</p><ul><li>The doubleTreasure function takes a pointer to an integer.</li><li>Inside the function, we dereference value and double the treasure.</li></ul><h3>Common Pitfalls</h3><p>Pointers are powerful but come with some challenges:</p><ul><li><strong>Nil Pointers</strong>: A nil pointer is like a blank map with no location marked on it. Trying to find treasure on such a map causes a runtime panic.</li><li><strong>Pointer Arithmetic</strong>: Go doesn’t allow pointer arithmetic (no calculating distances on the map). Keeps things simple and avoids bugs.</li><li><strong>Memory Management</strong>: Go has garbage collection, so you don’t need to worry much about memory leaks, but understanding memory management helps.</li></ul><h3>Practical Example: Swapping Treasures</h3><p>Let’s use pointers to swap the values of two treasures.</p><pre>package main<br>import &quot;fmt&quot;<br><br>func swap(treasureA, treasureB *int) {<br>    temp := *treasureA<br>    *treasureA = *treasureB<br>    *treasureB = temp<br>}<br>func main() {<br>    treasure1, treasure2 := 5, 10 // Declaring multiple variables<br>    fmt.Println(&quot;Before swap:&quot;, treasure1, treasure2) // Output: 5 10<br>    swap(&amp;treasure1, &amp;treasure2) // Swapping the treasures<br>    fmt.Println(&quot;After swap:&quot;, treasure1, treasure2)  // Output: 10 5<br>}</pre><p>In this example:</p><ul><li>The swap function takes two pointers to integers.</li><li>By dereferencing the pointers, we swap the values of treasure1 and treasure2.</li></ul><h3>Conclusion</h3><p>Pointers might seem a bit tricky at first, but they are a powerful tool in your Go programming toolkit. They offer efficiency, flexibility, and the ability to handle complex data structures with ease. Think of pointers as your magical treasure maps, guiding you to the treasures (data) stored in memory.</p><p>Happy coding, and remember: learning is an adventure. Take your time, ask questions, and enjoy the journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83e64eb232b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rewrite-tech/a-guide-to-pointers-in-go-learning-with-analogies-for-beginners-83e64eb232b6">A Guide to Pointers in Go: Learning with Analogies for Beginners</a> was originally published in <a href="https://medium.com/rewrite-tech">REWRITE TECH by Diconium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Container Queries: A Friendly Guide for CSS Learners]]></title>
            <link>https://medium.com/rewrite-tech/exploring-container-queries-a-friendly-guide-for-css-learners-6f6af86aa09a?source=rss-d8bd1e2d3e3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f6af86aa09a</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[container-queries]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[responsive]]></category>
            <dc:creator><![CDATA[Anny Gil]]></dc:creator>
            <pubDate>Fri, 09 Aug 2024 08:47:55 GMT</pubDate>
            <atom:updated>2024-12-04T11:11:29.181Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-vwgX0JnCC7z5E6ep3D3g.png" /><figcaption>A modern web developer’s desk setup with a computer screen showing code</figcaption></figure><p>Hey there, fellow coding enthusiast!</p><p>If you’re on a self-taught journey and finding your way through the labyrinth of CSS, I’ve got some exciting news that will make your learning experience smoother and more enjoyable. CSS introduced a fantastic feature called <strong>Container Queries</strong>. This is a game-changer for creating responsive, adaptable web designs. Let’s dive into what Container Queries are, why they’re so important, and how you can start using them to make your websites look awesome.</p><h4>What Are Container Queries?</h4><p>Imagine you’re an artist with a collection of paintings. Each painting needs a frame that fits its size perfectly. Container Queries in CSS work similarly by allowing you to style elements based on the size of their specific container, just like choosing the right frame for each painting.</p><h4>The Scenario: Framing Paintings</h4><p>In this analogy, think of your CSS components as paintings and the containers they’re in as frames. Traditionally, with media queries, you would choose frames based on the size of the entire gallery wall (the viewport). But this doesn’t account for the different sizes of individual paintings. Container Queries, on the other hand, let you choose a frame for each painting that fits perfectly, ensuring everything looks great.</p><h4>Why Should You Care?</h4><ol><li><strong>Enhanced Flexibility</strong>: Your components adapt more precisely to their immediate layout context.</li><li><strong>Reusable Components</strong>: Create components that look great in any layout without needing extra CSS for each scenario.</li><li><strong>Cleaner Code</strong>: Reduce the need for multiple media queries, making your stylesheets simpler and more maintainable.</li></ol><h4>How to Use Container Queries</h4><p>Let’s create a simple, responsive text box that adjusts its layout based on the size of its parent container. This example will help you grasp the basics of Container Queries and see their practical benefits.</p><p>Step 1: Define the HTML Structure</p><p>Here’s a basic HTML structure for our text box:</p><pre>&lt;div class=&quot;text-box-container&quot;&gt;<br>  &lt;div class=&quot;text-box&quot;&gt;<br>    &lt;h2&gt;Responsive Text Box&lt;/h2&gt;<br>    &lt;p&gt;This text box adjusts its layout based on the size of its container (here: wide container, so styles applied within @container query get applied).&lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br><br>&lt;div class=&quot;small-parent-container&quot;&gt;<br>  &lt;div class=&quot;text-box-container&quot;&gt;<br>    &lt;div class=&quot;text-box&quot;&gt;<br>      &lt;h2&gt;Responsive small Text Box&lt;/h2&gt;<br>      &lt;p&gt;This small text box adjusts its layout based on the size of its small container (here: small container size, so styles within @container query do NOT get applied).&lt;/p&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Step 2: Set Up the Container</p><p>First, we need to define our container in CSS and tell the browser to treat the .text-box-container as a container for queries.</p><pre>.text-box-container {<br>  container-type: inline-size;<br>  background-color: #f9f9f9;<br>  border: 1px solid #ccc;<br>  border-radius: .6em;<br>  padding: 1em;<br>}</pre><p>Step 3: Apply Container Queries</p><p>Now, let’s write the CSS for our text box using Container Queries to adjust its layout based on the container’s size.</p><pre>/* Container for text boxes */<br>.text-box-container {<br>  container-type: inline-size;<br>  background-color: #f9f9f9;<br>  border: 1px solid #ccc;<br>  border-radius: .6em;<br>  padding: 1em;<br>}<br><br>/* Small parent container */<br>.small-parent-container{<br>  margin-top: 1rem;<br>  width: 25rem; <br>}<br><br>/* Default styles for the text box */<br>.text-box {<br>  background-color: #fff;<br>  border: 1px solid #ddd;<br>  border-radius: .6em;<br>  padding: 1em;<br>}<br><br>/* Container query for larger containers */<br>@container (min-width: 26rem) {<br>  .text-box {<br>    background-color: #e6f7ff;<br>    padding: 2em;<br>  }<br><br>  .text-box h2 {<br>    font-size: 2rem;<br>  }<br><br>  .text-box p {<br>    font-size: 1.5rem;<br>  }<br>}</pre><p>Step 4: Test and Observe</p><p>Place the .text-box-container in different contexts to see how the text box adapts:</p><ul><li><strong>Narrow Container</strong>: The text box uses the default padding and background color.</li><li><strong>Wide Container</strong>: When the container’s width is at least 26rem, the .text-box increases its padding, font sizes and changes its background color to provide a more spacious and enhanced look.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*0sm5aBeJbhR7Utk2kuL50A.png" /></figure><h4>Final Thoughts</h4><p>Container Queries are a fantastic addition to CSS, providing a more intuitive way to handle responsive design. This simple example shows how you can leverage this feature to create adaptable and reusable components. Start experimenting with Container Queries in your projects, and enjoy the newfound flexibility in your designs. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f6af86aa09a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rewrite-tech/exploring-container-queries-a-friendly-guide-for-css-learners-6f6af86aa09a">Exploring Container Queries: A Friendly Guide for CSS Learners</a> was originally published in <a href="https://medium.com/rewrite-tech">REWRITE TECH by Diconium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>