<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on Sandra Ashipala</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/</link><description>Recent content in Posts on Sandra Ashipala</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 14 Mar 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://sandramsc-fun.sandraashipala.workers.dev/post/index.xml" rel="self" type="application/rss+xml"/><item><title>Demystifying Open Source</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/</link><pubDate>Thu, 14 Mar 2024 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/featured.jpg" alt="Featured image of post Demystifying Open Source" />&lt;p>Picture this: You&amp;rsquo;re honing your tech skills in silos (⌒_⌒;) and building projects for your GitHub and resume to impress the ever-inquisitive technical hiring manager who seeks the unique aspects in projects provided by potential candidates. Along your learning journey, you&amp;rsquo;ve encountered mentions of open source here and there, but never delved deeply into its realm. Additionally, you find yourself uncertain about where to begin. Does this sound familiar? Not long ago, I found myself in precisely this situation.&lt;/p>
&lt;p>However, with the right community and a sprinkle of courage (and chipping away at my own imposter syndrome), I found my footing and embarked on an exhilarating journey of growth and contribution.&lt;/p>
&lt;p>In this blog post, I&amp;rsquo;ll not only share my personal experiences and insights but also provide guidance based on my initial experience for those eager to dip their toes into the vast world of open-source contributions. So, grab a cup of your favourite beverage (latte macchiato☕ or bubble tea 🧋 for me), settle in, and let&amp;rsquo;s embark on an adventure filled with learning, growth, and community.&lt;/p>
&lt;h2 id="getting-started-choosing-a-project-to-contribute-to">Getting Started: Choosing a Project to Contribute To
&lt;/h2>&lt;p>Are you feeling overwhelmed (⋟﹏⋞) by the multitude of open-source projects available? Don&amp;rsquo;t fret; here are some tips to guide you in finding a project that aligns with your interests for your contributions (⌒‿⌒):&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Search GitHub for &amp;ldquo;good-first-issues&amp;rdquo;:&lt;/strong> GitHub is a treasure chest of open-source projects, and many of them tag beginner-friendly issues with labels like &lt;code>good-first-issue&lt;/code> or &lt;code>help-wanted&lt;/code>. Simply head to GitHub, use the search bar to look for these labels, and you&amp;rsquo;ll find a list of tasks waiting for eager contributors like yourself.&lt;/li>
&lt;li>&lt;strong>Explore Projects Related to Your Tech Stack:&lt;/strong> Leverage your expertise by searching GitHub for projects using keywords related to your tech stack. Utilizing the sort functionality you can filter through projects by &lt;em>Most stars&lt;/em>, &lt;em>Recently updated&lt;/em>, &lt;em>Best match&lt;/em>, etc. Whether it&amp;rsquo;s Python, C, or React.js, there&amp;rsquo;s a project out there waiting for your unique skill set.
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_0.png"
width="1920"
height="785"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_0_hu_97582887f0c87c8a.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_0_hu_301e0acb3769bd83.png 1024w"
loading="lazy"
alt="Open source contribution workflow diagram"
class="gallery-image"
data-flex-grow="244"
data-flex-basis="587px"
>&lt;/li>
&lt;li>&lt;strong>Websites with a List of Open Source Projects:&lt;/strong> Websites like &lt;a class="link" href="https://goodfirstissue.dev/" target="_blank" rel="noopener"
>Good First Issue&lt;/a> curate easy pickings from popular open-source projects, making it easier than ever to find your first contribution opportunity. Browse through their listings, pick a project that piques your interest, and dive in!&lt;/li>
&lt;/ol>
&lt;p>Another valuable approach involved searching LinkedIn for profiles of individuals possessing similar skills or expertise to mine. By examining the projects they were involved in and conducting further research, this method provided insights into relevant projects and served as a catalyst in discovering the Meshery project, which I will delve into further later on.
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_1.png"
width="612"
height="494"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_1_hu_9d3ea25fae07c3b1.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_1_hu_e3e04d4b6edc8bce.png 1024w"
loading="lazy"
alt="Open source contribution workflow diagram"
class="gallery-image"
data-flex-grow="123"
data-flex-basis="297px"
>&lt;/p>
&lt;h2 id="what-skills-do-i-need-to-get-started">What Skills Do I Need to Get Started?
&lt;/h2>&lt;p>The short answer? Whatever you bring to the table! Open source thrives on diversity, and contributions come in a variety of ways based on the contributor&amp;rsquo;s skill sets and their level. If you&amp;rsquo;re eager to learn and collaborate, you&amp;rsquo;re already halfway there. Start by exploring the repository, familiarise yourself with the tools used to build it, and don&amp;rsquo;t hesitate to ask for guidance along the way.
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_2.png"
width="690"
height="362"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_2_hu_c98dac007b55d884.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_2_hu_4217047ff6358f10.png 1024w"
loading="lazy"
alt="Open source contribution workflow diagram"
class="gallery-image"
data-flex-grow="190"
data-flex-basis="457px"
>
For example, &lt;a class="link" href="https://layer5.io/" target="_blank" rel="noopener"
>Layer5&lt;/a> is host to a vast variety of projects built and designed using different technologies and skill sets from people located all over the world (yay version control ┌(˘⌣˘)ʃ ). Keep in mind that contribution goes beyond code. Whether you&amp;rsquo;re a UX/UI designer, a technical writer, an SEO specialist, or a passionate blogger, there&amp;rsquo;s a place for you in the community. Explore the repositories, find where your skills align, and dive in.&lt;/p>
&lt;h2 id="my-open-source-journey-from-curiosity-to-contribution">My Open Source Journey: From Curiosity to Contribution
&lt;/h2>&lt;p>Let me rewind to the genesis of it all — during a Women Who Code Berlin webinar in April 2023, where a fellow attendee posed a question that the invited speaker graciously answered in detail during the Q&amp;amp;A session. As the speaker delved into the advantages of contributing to open-source projects, she highlighted the EddieHub Open Source community as an inclusive and welcoming environment — and Eddie, the founder, standing out as one of the most enthusiastic and supportive open-source leaders (a big shout out to Ellie King!), igniting my interest.&lt;/p>
&lt;p>Intrigued, I delved into the community (even before the webinar ended), joined their Discord, and found the BioDrop (formerly LinkFree) project, a shining example of a community-driven project, characterized by its meticulous organization and comprehensive documentation. I was pleasantly surprised by Eddie&amp;rsquo;s active involvement and encouragement to get started no matter the level of contribution (yes, I read the conversation history — &amp;ldquo;reading the room&amp;rdquo;).&lt;/p>
&lt;p>As my understanding of the open-source community deepened and my proficiency in Python programming and understanding of DevOps grew, I felt compelled to explore opportunities where my newly acquired skills could be put to meaningful use and provide avenues for continuous improvement. This pursuit ultimately led me to encounter &lt;a class="link" href="https://meshery.io/" target="_blank" rel="noopener"
>Meshery&lt;/a>, nestled within the Cloud Native Computing Foundation (CNCF) ecosystem.&lt;/p>
&lt;p>With Meshery, I didn&amp;rsquo;t just find another open-source project; I found a community, a platform for learning and growth, and the perfect avenue for channelling my newfound skills and passions into meaningful contributions. And so, my journey with Meshery under the Layer5 organization began, marking the dawn of an exciting chapter in my open-source journey.&lt;/p>
&lt;h2 id="how-to-get-started-with-meshery--making-your-first-contributions">How to Get Started with Meshery — Making Your First Contributions
&lt;/h2>&lt;p>Before we dive deeper, allow me to introduce Meshery. It serves as an open-source, cloud-native management platform, providing multi-cluster Kubernetes management functionalities. Notably, Meshery has been acknowledged as the 10th fastest-growing project out of over 200+ CNCF projects. It seamlessly integrates with all CNCF projects, alongside existing tools and Kubernetes clusters, enabling users to optimize their preferred monitoring, CI/CD, and security solutions with ease.&lt;/p>
&lt;p>Now that you&amp;rsquo;ve been introduced to Meshery, you might be wondering how you can get involved. Here are some steps to kickstart your journey with Meshery:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Explore the website:&lt;/strong> Start by visiting the &lt;a class="link" href="https://meshery.io/" target="_blank" rel="noopener"
>Meshery website&lt;/a> to gain a better understanding of its features and capabilities. You&amp;rsquo;ll find comprehensive documentation, tutorials, and resources to help you get started.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Join the community:&lt;/strong> Connect with fellow Meshery enthusiasts by joining the community forums, mailing lists, and social media channels. Engage in discussions in the &lt;code>#meshery&lt;/code> Slack channel, ask clarifying questions, and share your experiences with the community.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Contribute to the repository:&lt;/strong> Regardless of your experience level, there are numerous opportunities to make valuable contributions to the repository. Begin by familiarizing yourself with the &lt;code>CONTRIBUTING.md&lt;/code> guidelines. Don&amp;rsquo;t hesitate to ask questions for clarification and seek assistance from the community when needed (the discussion forum is a good place to do this too).
Start small by identifying issues labeled &lt;code>good-first-issues&lt;/code> or bugs marked as &lt;code>beginner-friendly&lt;/code>, and tailor your involvement within the project to align with your interests. As you explore the project and associated resources, and notice areas for improvement such as grammar adjustments, refining code segments, fixing a logo/banner, or enhancing installation steps based on your initial experience, don&amp;rsquo;t hesitate to raise an issue. Remember, every contribution, no matter how minor, has the potential to make a meaningful impact.&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_3.png"
width="1917"
height="1023"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_3_hu_70d14e45d29f5100.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_3_hu_b0492d69718b583e.png 1024w"
loading="lazy"
alt="Open source contribution workflow diagram"
class="gallery-image"
data-flex-grow="187"
data-flex-basis="449px"
>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Attend events:&lt;/strong> Keep an eye out for development meetings that happen online every week. These meets are a great way to learn from community members, network with like-minded individuals, and stay updated on the latest developments with projects in Layer5. If you&amp;rsquo;re new to the community, the Layer5 Newcomers&amp;rsquo; Meet (happening every Thursday — sync the community calendar to get a reminder in your local time) is a great place to get your first introductions to the community, meet other folks, and get introduced to the community and project flow!
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_4.png"
width="494"
height="593"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_4_hu_5d88d2c6cf1efd7e.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_4_hu_f722d1eed085e598.png 1024w"
loading="lazy"
alt="Open source contribution workflow diagram"
class="gallery-image"
data-flex-grow="83"
data-flex-basis="199px"
>&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>The steps described above were simply how I approached my first few weeks in the community. Initially, I spent the first few days quietly observing conversations in Slack, akin to &amp;ldquo;reading the room,&amp;rdquo; to understand the community&amp;rsquo;s communication style, how to start engaging in the conversations, and determine if it was a place where I could engage and thrive (if you haven&amp;rsquo;t guessed by now — it is and beyond).&lt;/p>
&lt;blockquote>
&lt;p>💡 In Layer5, I discovered more than just a collection of projects; it&amp;rsquo;s a supportive network of like-minded individuals with a shared mission to innovate and empower. The Layer5 community fosters an environment where contribution isn&amp;rsquo;t merely encouraged; it&amp;rsquo;s celebrated. If you find the Meshery project interesting, consider starring 🌟 the repository to show your support!
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_5.png"
width="1920"
height="246"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_5_hu_1b70309df96c7708.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/demystifying-open-source/image_5_hu_cf5335856f06e436.png 1024w"
loading="lazy"
alt="Open source contribution workflow diagram"
class="gallery-image"
data-flex-grow="780"
data-flex-basis="1873px"
>&lt;/p>&lt;/blockquote>
&lt;h2 id="reflections-on-personal-and-professional-growth">Reflections on Personal and Professional Growth
&lt;/h2>&lt;p>My journey into open source has been nothing short of transformative. From honing technical skills to cultivating soft skills like communication and collaboration, every contribution has been a stepping stone toward personal and professional growth. But the real challenge? It was transitioning from solitary learning and development to learning and building in public. Being part of welcoming and supportive open-source communities has been instrumental in overcoming that hurdle and taking those crucial first steps into learning and building in public — ultimately contributing to my growth as an engineer and developer.&lt;/p>
&lt;p>In a healthy open-source community, you&amp;rsquo;re not just a contributor; you&amp;rsquo;re part of something bigger. You collaborate with like-minded individuals, tackle real-world problems, and make a tangible impact on projects that transcend individual efforts. We get to forge new meaningful connections and share knowledge. So, whether you&amp;rsquo;re just starting out or looking to expand your horizons, remember this: the journey is yours to chart, so just get started. &lt;em>&amp;ldquo;jiāyóu&amp;rdquo;&lt;/em> 加油 !!&lt;/p>
&lt;p>Thank you for reading. Happy contributing!&lt;/p>
&lt;h3 id="useful-links">Useful Links
&lt;/h3>&lt;ul>
&lt;li>&lt;a class="link" href="https://www.eddiehub.org/" target="_blank" rel="noopener"
>EddieHub Community&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://slack.layer5.io/" target="_blank" rel="noopener"
>Layer5 Slack Community&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://github.com/meshery/meshery" target="_blank" rel="noopener"
>Meshery Repository&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Installing WSL on Windows 11 Home (Ubuntu)</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/</link><pubDate>Fri, 29 Dec 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/featured.jpg" alt="Featured image of post Installing WSL on Windows 11 Home (Ubuntu)" />&lt;p>Windows Subsystem for Linux (WSL) offers a powerful way to integrate Windows 11 Home with Linux. Having a growing interest in Linux and venturing into DevOps, I decided to find out how Ubuntu can be used on my new Windows machine—after previously trying to install Ubuntu on a bootable USB and realizing I mostly used the CLI rather than the bundled desktop apps.&lt;/p>
&lt;p>This article details how to install WSL with Ubuntu on Windows 11 Home, providing a practical approach to enhancing your development workflow.&lt;/p>
&lt;h2 id="why-wsl">Why WSL?
&lt;/h2>&lt;p>With WSL, you get direct access to Linux command-line tools without giving up Windows convenience or dual-booting.&lt;/p>
&lt;hr>
&lt;h2 id="installation-steps">Installation Steps
&lt;/h2>&lt;h3 id="step-1-enable-windows-subsystem-for-linux">Step 1: Enable Windows Subsystem for Linux
&lt;/h3>&lt;ol>
&lt;li>Click on the &lt;strong>Start&lt;/strong> menu.&lt;/li>
&lt;li>Search for &lt;strong>Turn Windows features on or off&lt;/strong> and open it.&lt;/li>
&lt;li>Scroll to the bottom and check the box for &lt;strong>Windows Subsystem for Linux&lt;/strong>.
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_0.png"
width="555"
height="491"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_0_hu_41566678db8f67c4.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_0_hu_a4822bbf7ae4ee59.png 1024w"
loading="lazy"
alt="Windows Features dialog with Windows Subsystem for Linux checked"
class="gallery-image"
data-flex-grow="113"
data-flex-basis="271px"
>&lt;/li>
&lt;li>Click &lt;strong>OK&lt;/strong>.&lt;/li>
&lt;li>Click &lt;strong>Restart now&lt;/strong> so the changes take effect.
&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_1.png"
width="757"
height="628"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_1_hu_8b817127d706e41c.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_1_hu_2a652ad088be4626.png 1024w"
loading="lazy"
alt="Windows Features confirmation or restart prompt"
class="gallery-image"
data-flex-grow="120"
data-flex-basis="289px"
>&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h3 id="step-2-install-wsl2">Step 2: Install WSL2
&lt;/h3>&lt;ol>
&lt;li>Launch &lt;strong>PowerShell&lt;/strong> as Administrator.&lt;/li>
&lt;li>To view available distributions verified for installation, run:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">wsl&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-list&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-online&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ol start="3">
&lt;li>To install the default Ubuntu distribution, run:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">wsl&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-install&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_2.png"
width="1100"
height="195"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_2_hu_7831d912bea547ff.png 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/installing-wsl-on-windows/image_2_hu_a969338795cf2ca2.png 1024w"
loading="lazy"
alt="Windows Features confirmation or restart prompt"
class="gallery-image"
data-flex-grow="564"
data-flex-basis="1353px"
>&lt;/p>
&lt;ol start="4">
&lt;li>To install a specific distribution, run:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">wsl&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-install&lt;/span> &lt;span class="n">-d&lt;/span> &lt;span class="nb">DISTRO-NAME&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>For example, running:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">wsl&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-install&lt;/span> &lt;span class="n">-d&lt;/span> &lt;span class="n">Ubuntu&lt;/span>&lt;span class="p">-&lt;/span>&lt;span class="mf">20.04&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>will install Ubuntu 20.04 LTS.&lt;/p>
&lt;ol start="5">
&lt;li>Restart your machine when prompted.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h3 id="step-3-set-up-ubuntu">Step 3: Set Up Ubuntu
&lt;/h3>&lt;ol>
&lt;li>Launch the installed &lt;strong>Ubuntu&lt;/strong> app from the &lt;strong>Start&lt;/strong> menu.&lt;/li>
&lt;li>Follow on-screen instructions to set up a user account and configure your Ubuntu environment.&lt;/li>
&lt;li>Upon completion, you&amp;rsquo;ll have a fully functional Ubuntu terminal ready for use.&lt;/li>
&lt;/ol>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/image_3.png"
loading="lazy"
alt="Windows Features confirmation or restart prompt"
>&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>Following these steps, you&amp;rsquo;ve successfully integrated Ubuntu into your Windows machine and can now navigate a Linux environment from your familiar Windows desktop.&lt;/p>
&lt;p>Thank you for reading. Happy Coding!&lt;/p></description></item><item><title>Unlocking the Power of Python [PART 1]: Understanding Loops, Indentation and Variables 🤓</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/</link><pubDate>Thu, 17 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/featured.jpg" alt="Featured image of post Unlocking the Power of Python [PART 1]: Understanding Loops, Indentation and Variables 🤓" />&lt;p>Developed by Guido van Rossum in 1991, Python has evolved into an extremely versatile and powerful programming language that is well-known to both beginners and seasoned developers alike. Its clean and elegant syntax makes coding a breeze, allowing us to focus on unleashing our creativity and problem-solving skills. From creating interactive games to automating daily tasks, Python provides a powerful platform for bringing ideas to life.&lt;/p>
&lt;p>This post will cover the initial fundamental requirements to get started with understanding and programming in Python, from loops, comments and variables and is part 1 of a two-part series on Unlocking the Power of Python. So, let’s embark on this thrilling journey together, where learning becomes an adventure, and every line of code we write opens up new possibilities.&lt;/p>
&lt;h2 id="why-indentation-is-important-in-python">Why indentation is important in Python
&lt;/h2>&lt;p>In Python, indentation is very important in determining the structure and flow of your code. Unlike other programming languages that use brackets or parentheses to denote code blocks, Python uses indentation. Proper indentation ensures that your code is clear, understandable and that the Python interpreter correctly interprets it.&lt;/p>
&lt;p>Take a look at the following code example:&lt;/p>
&lt;pre>&lt;code>if condition A:
print(&amp;quot;Condition A is TRUE.&amp;quot;)
print(&amp;quot;Executing code block.&amp;quot;)
else:
print(&amp;quot;Condition A is FALSE.&amp;quot;)
print(&amp;quot;Executing alternate code block.&amp;quot;)
&lt;/code>&lt;/pre>
&lt;p>The statements within the &lt;code>if&lt;/code> and &lt;code>else&lt;/code> blocks are indented by four spaces in this example. The indentation shows which statements belong to which blocks. The Python interpreter will raise an error if the indentation is wrong or inconsistent.&lt;/p>
&lt;p>Python increases code readability and maintainability by requiring correct indentation. It encourages developers to write clean and well-organized code.&lt;/p>
&lt;h2 id="how-to-use-the-if-if--else-statements">How to use the &lt;code>if&lt;/code>, &lt;code>if … else&lt;/code> statements
&lt;/h2>&lt;p>In Python, the &lt;code>if&lt;/code> statement allows you to execute a block of code conditionally based on the evaluation of a Boolean expression.&lt;/p>
&lt;p>Here is the syntax:&lt;/p>
&lt;pre>&lt;code>if condition:
# Code block to execute if condition is TRUE
else:
# Code block to execute if condition is FALSE
&lt;/code>&lt;/pre>
&lt;p>The condition is an expression that evaluates to either TRUE or FALSE. If the condition is TRUE, the code block indented under the &lt;code>if&lt;/code> statement is executed. If the condition is FALSE, the code block indented under the &lt;code>else&lt;/code> statement (if provided) is executed.&lt;/p>
&lt;p>The following example demonstrates the usage of &lt;code>if&lt;/code> and &lt;code>if … else&lt;/code> statements:&lt;/p>
&lt;pre>&lt;code>age = 25
if age &amp;gt;= 18:
print(&amp;quot;You are an adult.&amp;quot;)
else:
print(&amp;quot;You are not an adult yet.&amp;quot;)
&lt;/code>&lt;/pre>
&lt;p>In the above example, if the &lt;code>age&lt;/code> variable is greater than or equal to 18, the program will print “You are an adult“. Otherwise, it will print “You are not an adult yet.“&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_0.jpg"
width="730"
height="690"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_0_hu_9a868bb3c4b4c3d4.jpg 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_0_hu_a15de5a964d09328.jpg 1024w"
loading="lazy"
alt="Illustration"
class="gallery-image"
data-flex-grow="105"
data-flex-basis="253px"
>&lt;/p>
&lt;p>The image above is an illustration of the if and if … else statements.&lt;/p>
&lt;p>To test more than one condition, you can also chain multiple &lt;code>if&lt;/code> statements together using the &lt;code>elif&lt;/code> keyword:&lt;/p>
&lt;pre>&lt;code>grade = 80
if grade &amp;gt;= 90:
print(&amp;quot;Excellent!&amp;quot;)
elif grade &amp;gt;= 80:
print(&amp;quot;Good job!&amp;quot;)
elif grade &amp;gt;= 70:
print(&amp;quot;Fair&amp;quot;)
else:
print(&amp;quot;Not there yet.&amp;quot;)
&lt;/code>&lt;/pre>
&lt;p>This example uses a program to check the value of the &lt;code>grade&lt;/code> variable and prints different messages based on the grade range.&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_1.jpg"
width="2000"
height="731"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_1_hu_5377ee262fd42135.jpg 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_1_hu_dc7ae6c4b9afdcfe.jpg 1024w"
loading="lazy"
alt="Illustration"
class="gallery-image"
data-flex-grow="273"
data-flex-basis="656px"
>&lt;/p>
&lt;p>The image above is an illustration of the if … elif …else statements.&lt;/p>
&lt;h2 id="how-to-use-comments">How to use comments
&lt;/h2>&lt;p>Comments are very helpful in adding explanations to your code. They give context, explanations, or reminders about the purpose of code functionalities for yourself and other programmers who read it. The sign &lt;code>#&lt;/code> is used to add comments in Python. Anything on the same line that follows the &lt;code>#&lt;/code> sign is considered a comment and is disregarded by the Python interpreter when the code is run.&lt;/p>
&lt;p>Here is the syntax:&lt;/p>
&lt;pre>&lt;code># This is a comment
print(&amp;quot;Hello, World!&amp;quot;)
&lt;/code>&lt;/pre>
&lt;p>Comments can assist with documenting your code and make it easier to comprehend and maintain. They can also help you with temporarily disabling or excluding specific lines of code without completely deleting them.&lt;/p>
&lt;h2 id="how-to-assign-values-to-variables">How to assign values to variables
&lt;/h2>&lt;p>In Python, you can assign values to variables using the assignment operator &lt;code>=&lt;/code>. The variable of the left side of the operator receives the value on the right side.&lt;/p>
&lt;pre>&lt;code>name = &amp;quot;Spring&amp;quot;
age = 25
&lt;/code>&lt;/pre>
&lt;p>In the above example, the variable name is assigned the string value “Spring“ and the variable &lt;code>age&lt;/code> is assigned the integer value 25.&lt;/p>
&lt;p>Python is a dynamically typed language, which means that you don’t need to explicitly declare the type of variable. The type is inferred based on the value assigned to it.&lt;/p>
&lt;p>The value of one variable can also be assigned to another value:&lt;/p>
&lt;pre>&lt;code>x = 10
# Assignes the value of x = 10 to y
y = x
&lt;/code>&lt;/pre>
&lt;p>In the example above, the value of &lt;code>x&lt;/code> is assigned to &lt;code>y&lt;/code>, resulting in both variables having the same value (10).&lt;/p>
&lt;h2 id="how-to-use-the-while-and-for-loops">How to use the &lt;code>while&lt;/code> and &lt;code>for&lt;/code> loops
&lt;/h2>&lt;p>There are two types of loops that can be used in Python, namely the &lt;code>while&lt;/code> loop and the &lt;code>for&lt;/code> loop. The &lt;code>while&lt;/code> loop repeatedly executes a block of code as long as a specified condition remains TRUE. The loop will continue to execute the code block until the condition becomes FALSE. If the condition is initially FALSE, the code block will not execute at all.&lt;/p>
&lt;p>Here is the syntax for a &lt;code>while&lt;/code> loop:&lt;/p>
&lt;pre>&lt;code>while condition A:
# Code block to execute while condition A is TRUE
&lt;/code>&lt;/pre>
&lt;p>Here is an example that illustrates the usage of a &lt;code>while&lt;/code> loop:&lt;/p>
&lt;pre>&lt;code>count = 0
while count &amp;lt; 15:
print(&amp;quot;Count:&amp;quot;, count)
count += 1
&lt;/code>&lt;/pre>
&lt;p>The loop prints the current value of &lt;code>count&lt;/code> and increments it by 1 in each iteration. The loop is repeated until &lt;code>count&lt;/code> reaches 15.&lt;/p>
&lt;p>The &lt;code>for&lt;/code> loop, on the other hand, is used to iterate over a sequence (such as a list, tuple, or string) or any iterable object. It assigns each item from the sequence to a variable and executes a code block for each item.&lt;/p>
&lt;p>Here is the syntax for a &lt;code>for&lt;/code> loop:&lt;/p>
&lt;pre>&lt;code>for item in sequence:
# Code block to execute for each item
&lt;/code>&lt;/pre>
&lt;p>Here is an example that illustrates the usage of a &lt;code>for&lt;/code> loop:&lt;/p>
&lt;pre>&lt;code>fruits = [&amp;quot;apple&amp;quot;, &amp;quot;banana&amp;quot;, &amp;quot;cantaloupe&amp;quot;]
for fruit in fruits:
print(fruit)
# Returns:
# apple
# banana
# cantaloupe
&lt;/code>&lt;/pre>
&lt;p>In the above example, the loop iterates over the &lt;code>fruits&lt;/code> list and prints each item in the list.&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_0.jpg"
width="730"
height="690"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_0_hu_9a868bb3c4b4c3d4.jpg 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_1/image_0_hu_a15de5a964d09328.jpg 1024w"
loading="lazy"
alt="Illustration"
class="gallery-image"
data-flex-grow="105"
data-flex-basis="253px"
>&lt;/p>
&lt;p>The above image is an illustration of the while and for loop.&lt;/p>
&lt;p>Reminder (ᵔ◡ᵔ): As you embark on your learning journey, remember to practice regularly and challenge yourself with coding exercises.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>In conclusion, Python&amp;rsquo;s versatility and power make it a programming language that captivates beginners and experienced developers alike. Its clean syntax and emphasis on creativity and problem-solving make coding a delightful experience. This post covered essential elements such as loops, comments, variables, and conditional statements. Dive deeper into Python, and unlock a world of limitless possibilities.&lt;/p>
&lt;p>By grasping the above concepts, you&amp;rsquo;ve taken the first steps towards becoming a proficient programmer. However, this is just the beginning of your journey into the world of coding. There is so much more to explore and learn!&lt;/p>
&lt;p>In Part 2 of Unlocking the Power of Python, we will delve into functions and the range function.&lt;/p>
&lt;p>Stay curious, stay dedicated, and happy coding!&lt;/p></description></item><item><title>Maximising Efficiency with Node.js and NVM</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/maximising-efficiency/</link><pubDate>Tue, 15 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/maximising-efficiency/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/maximising-efficiency/featured.jpg" alt="Featured image of post Maximising Efficiency with Node.js and NVM" />&lt;p>&lt;strong>An all-inclusive intro guide&lt;/strong>&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>Node.js has revolutionized the way server-side applications are built. With its event-driven architecture and extensive module ecosystem, Node.js enables developers to create highly scalable and performant applications. However, managing several versions of Node.js can be challenging, making it difficult to get started. This is where Node Version Manager (NVM) comes into play, providing developers with a seamless solution for version control.&lt;/p>
&lt;p>This post will delve into the world of Node.js and NVM, exploring their functionalities, benefits, and how they work together to enhance the workflow of development projects.&lt;/p>
&lt;h2 id="overview-of-nodejs-and-nvm">Overview of Node.js and NVM
&lt;/h2>&lt;h3 id="what-is-nodejs">What is Node.js?
&lt;/h3>&lt;p>Node.js is an open-source, cross-platform JavaScript runtime environment built on Chrome&amp;rsquo;s V8 JavaScript engine. Unlike traditional server-side technologies, Node.js allows developers to execute JavaScript code on the server, bringing the language to the backend. By leveraging an event-driven, non-blocking I/O model, Node.js achieves exceptional scalability and efficiently handles concurrent requests. It has gained immense popularity in building real-time applications, APIs, microservices, as well as full-stack web applications.&lt;/p>
&lt;h3 id="key-features-and-benefits-of-nodejs">Key features and benefits of Node.js
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Vast Ecosystem:&lt;/strong> Node.js boasts a massive ecosystem of reusable modules known as npm (Node Package Manager). With over a million packages available, developers can easily integrate existing solutions into their projects, saving valuable development time.&lt;/li>
&lt;li>&lt;strong>Fast Execution:&lt;/strong> Node.js leverages the V8 JavaScript engine, renowned for its high-performance execution. This results in rapid code execution and optimized resource utilization.&lt;/li>
&lt;li>&lt;strong>Scalability:&lt;/strong> Node.js enables the creation of scalable applications, thanks to its ability to handle a large number of concurrent connections efficiently. This makes it well-suited for building applications with high traffic demands.&lt;/li>
&lt;/ul>
&lt;h3 id="what-is-node-version-manager-nvm">What is Node Version Manager (NVM)?
&lt;/h3>&lt;p>Managing multiple versions of Node.js on a single machine can be challenging, especially when different projects require different versions. Node Version Manager (NVM) provides a seamless solution to this problem. It is a command-line tool that allows developers to install, switch, and manage multiple Node.js versions effortlessly. NVM provides a consistent environment for development, ensuring that projects run on the required Node.js version without conflicts.&lt;/p>
&lt;h3 id="key-features-and-benefits-of-nvm">Key features and benefits of NVM
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Version Control:&lt;/strong> NVM allows developers to install and switch between multiple Node.js versions, ensuring compatibility with different projects. It provides flexibility without the need for manual installations and avoids conflicts between projects that rely on different Node.js versions.&lt;/li>
&lt;li>&lt;strong>Project Isolation:&lt;/strong> With NVM, each project can have its own isolated environment with a specific Node.js version and set of dependencies. This avoids clashes between project dependencies and ensures consistent behaviour across different projects.&lt;/li>
&lt;li>&lt;strong>Easy Installation and Upgrades:&lt;/strong> NVM simplifies the process of installing and upgrading Node.js versions. It provides a straightforward command-line interface to manage versions, making it easy to stay up-to-date with the latest releases.&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/maximising-efficiency/image_0.jpg"
width="1230"
height="320"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/maximising-efficiency/image_0_hu_2a61c8d544413534.jpg 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/maximising-efficiency/image_0_hu_17655cf27ebf7af6.jpg 1024w"
loading="lazy"
alt="Illustration"
class="gallery-image"
data-flex-grow="384"
data-flex-basis="922px"
>&lt;/p>
&lt;p>NVM usage illustration&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note ✍🏾:&lt;/strong> To switch between different versions of Node.js, navigate to your terminal and type &lt;code>nvm [node version number]&lt;/code>: i.e. &lt;code>nvm 16.17.1&lt;/code>&lt;/p>&lt;/blockquote>
&lt;p>Now that you&amp;rsquo;re familiar with Node.js and NVM, this next section will guide you through the step-by-step process of setting up Node.js and NVM on your local machine. Let&amp;rsquo;s get started!&lt;/p>
&lt;h2 id="installing-nodejs-and-nvm">Installing Node.js and NVM
&lt;/h2>&lt;h3 id="step-1-install-nvm">Step 1: Install NVM
&lt;/h3>&lt;p>1.1. Visit the NVM GitHub repository at &lt;a class="link" href="https://github.com/nvm-sh/nvm" target="_blank" rel="noopener"
>https://github.com/nvm-sh/nvm&lt;/a>.&lt;/p>
&lt;p>1.2. Look for the installation instructions in the README file. As of now, the recommended method is to use the installation script. You can find the script under the section &amp;ldquo;Install &amp;amp; Update Script.&amp;rdquo;&lt;/p>
&lt;p>1.3. Copy the installation script. It should look something like this:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl -o- &lt;span class="o">[&lt;/span>https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh&lt;span class="o">](&lt;/span>https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh&lt;span class="o">)&lt;/span> &lt;span class="p">|&lt;/span> bash
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><item><title>Unlocking the Power of Python [PART 2]: Understanding functions and range</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_0/</link><pubDate>Tue, 15 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_0/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_0/featured.jpg" alt="Featured image of post Unlocking the Power of Python [PART 2]: Understanding functions and range" />&lt;p>This post is part two of &lt;em>Unlocking the Power of Python&lt;/em>, covering functions to explore the idea of and how to use the &lt;code>range&lt;/code> function. So, let’s continue on this thrilling journey and unlock the power of Python.&lt;/p>
&lt;h2 id="what-is-a-function-and-how-do-you-use-functions">What is a function and how do you use functions
&lt;/h2>&lt;p>In Python, a function is a block of reusable code that performs a specific task. Functions allow you to organize code into logical units, promote code reuse, and improve the readability and maintainability of your code.&lt;/p>
&lt;p>Here is the syntax for defining and using a function:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">greet&lt;/span>&lt;span class="p">():&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;Hello, world!&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Call the function&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">greet&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>A function is defined using the &lt;code>def&lt;/code> keyword followed by the function name, parentheses, and a colon. The body of the function, where the code is written, is indented under the function definition.&lt;/p>
&lt;p>In the example above, the &lt;code>greet&lt;/code> function is defined without any parameters. It simply prints the greeting message when called. The function is called using its name followed by parentheses, triggering the execution of the code within the function.&lt;/p>
&lt;p>Functions can also accept parameters, allowing you to pass values into the function for processing. Here’s an example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">greet&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">name&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;Hello, &amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">name&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Call the function with an argument&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">greet&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;John&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In the above example, the &lt;code>greet&lt;/code> function accepts a single parameter called &lt;code>name&lt;/code>. When called with an argument, the value of the argument is passed to the &lt;code>name&lt;/code> parameter inside the function, and the function prints the greeting message with the provided name.&lt;/p>
&lt;p>Functions can also return values using the &lt;code>return&lt;/code> statement. The &lt;code>return&lt;/code> statement allows a function to compute a result and send it back to the caller.&lt;/p>
&lt;p>Here’s an example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">add_numbers&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">b&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">b&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Call the function and store the result&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">add_numbers&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;Sum: &amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">result&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In this example, the &lt;code>add_numbers&lt;/code> function takes two parameters, &lt;code>a&lt;/code> and &lt;code>b&lt;/code>, and returns their sum using the &lt;code>return&lt;/code> statement. The function is called with the arguments &lt;code>5&lt;/code> and &lt;code>2&lt;/code>, and the returned value is stored in the &lt;code>result&lt;/code> variable and printed.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note:&lt;/strong> Functions can have multiple parameters, perform complex computations, include control structures (&lt;code>if&lt;/code> and &lt;code>for&lt;/code> loops), and even call other functions. They provide a powerful mechanism for organizing and structuring code in Python.&lt;/p>&lt;/blockquote>
&lt;h2 id="what-does-a-function-return-if-it-does-not-use-a-return-statement">What does a function return if it does not use a &lt;code>return&lt;/code> statement
&lt;/h2>&lt;p>In Python, if a function does not use a &lt;code>return&lt;/code> statement, it implicitly returns &lt;code>None&lt;/code>. &lt;code>None&lt;/code> is a special object in Python that represents the absence of a value.&lt;/p>
&lt;p>Here’s an example of a function without a &lt;code>return&lt;/code> statement:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">say_heya&lt;/span>&lt;span class="p">():&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;Heya, world!&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">say_heya&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Output: None&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The &lt;code>say_heya&lt;/code> function prints the greeting message but does not have a &lt;code>return&lt;/code> statement. When the function is called, it executes the code within the function but does not explicitly return any value. As a result, the value assigned to &lt;code>result&lt;/code> is &lt;code>None&lt;/code>.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note:&lt;/strong> Even though a function may not have a &lt;code>return&lt;/code> statement, it can still have side effects, such as modifying global variables or printing output. The absence of a &lt;code>return&lt;/code> statement only means that the function does not explicitly produce a return value.&lt;/p>&lt;/blockquote>
&lt;h2 id="how-to-use-range">How to use &lt;code>range&lt;/code>
&lt;/h2>&lt;p>The &lt;code>range&lt;/code> function in Python generates a sequence of numbers within a specified range. It is commonly used for iterating over a sequence of numbers or controlling the number of loop iterations. The &lt;code>range&lt;/code> function can be called with one, two, or three arguments, representing the &lt;code>start&lt;/code>, &lt;code>stop&lt;/code>, and &lt;code>step&lt;/code> values of the range, respectively.&lt;/p>
&lt;p>Here are three examples that illustrate the usage of &lt;code>range&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Generate a sequence from 0 to 7&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="n">number&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">8&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">number&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Generate a sequence from 3 to 8 (inclusive) with a step of 3&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="n">number&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">9&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">3&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">number&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Generate a sequence in reverse from 15 to 5 (inclusive) with a step of -1&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="n">number&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">15&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">4&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="o">-&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">number&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In the first example, &lt;code>range(8)&lt;/code> generates a sequence of numbers from &lt;code>0&lt;/code> to &lt;code>7&lt;/code>. The loop iterates over this sequence, printing each number.&lt;/p>
&lt;p>In the second example, &lt;code>range(3, 9, 3)&lt;/code> generates a sequence of numbers from &lt;code>3&lt;/code> to &lt;code>8&lt;/code> (inclusive) with a step of &lt;code>3&lt;/code>. The loop iterates over this sequence, printing each number.&lt;/p>
&lt;p>In the third example, &lt;code>range(15, 4, -1)&lt;/code> generates a sequence of numbers in reverse from &lt;code>15&lt;/code> to &lt;code>5&lt;/code> (inclusive) with a step of &lt;code>-1&lt;/code>. The loop iterates over this sequence, printing each number in reverse order.&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_0/image_0.jpg"
width="1456"
height="1181"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_0/image_0_hu_729d9a1813cc82e1.jpg 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/python-fundamentals_0/image_0_hu_4afca1613d7dbdef.jpg 1024w"
loading="lazy"
alt="Illustration"
class="gallery-image"
data-flex-grow="123"
data-flex-basis="295px"
>&lt;/p>
&lt;p>The &lt;code>range&lt;/code> function is versatile and can be combined with loops and other Python constructs to control iteration and generate sequences of numbers efficiently.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>To summarise, functions are essential to organizing and reusing code in Python while enhancing readability and reusability. In addition to allowing you to create reusable blocks of code, they also provide the ability for parameters and returns to be passed. Additionally, the &lt;code>range&lt;/code> function can be used to efficiently generate sequences of numbers.&lt;/p>
&lt;p>Thank you for reading. Happy coding!&lt;/p></description></item><item><title>7 Key Concepts and Features of Version Control</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/version-control/</link><pubDate>Mon, 14 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/version-control/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/version-control/featured.jpg" alt="Featured image of post 7 Key Concepts and Features of Version Control" />&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>Version control is a practice that allows you to manage and track changes to files or a set of files over time. As a software development tool, it is commonly used for managing documents, spreadsheets, and multimedia files.&lt;/p>
&lt;p>Version Control Systems keep a history of changes made to files, enabling you to access previous versions, compare differences, and revert to earlier states if needed. As a result, they facilitate structured and organized collaboration, particularly when multiple individuals are working on the same set of documents at the same time. This post will highlight 7 key concepts and features that are most frequently associated with Version Control in the context of software development/engineering.&lt;/p>
&lt;h2 id="key-concepts-and-features">Key concepts and features
&lt;/h2>&lt;h3 id="repository">Repository
&lt;/h3>&lt;p>A repository is a central storage location where all versions and changes to files are stored; it also contains the project&amp;rsquo;s history.&lt;/p>
&lt;h3 id="commit">Commit
&lt;/h3>&lt;p>A commit is an entry in the file representing one particular change or a set of changes. Each commit is associated with a unique identifier and includes a message describing the changes.&lt;/p>
&lt;h3 id="branches">Branches
&lt;/h3>&lt;p>Branches can be created within a repository to separate lines of development. In this way, multiple users are able to work on different features or experiments simultaneously without interfering with one another&amp;rsquo;s work. Branches can be merged back together later.&lt;/p>
&lt;h3 id="merging">Merging
&lt;/h3>&lt;p>Merging is the process of combining changes from one branch to another. It allows you to integrate changes made in separate branches back into the main branch or other designated branches.&lt;/p>
&lt;h3 id="diffing">Diffing
&lt;/h3>&lt;p>Diffing refers to the ability to compare the differences between two versions of a file or between branches. It shows the additions, deletions, and modifications made to the content.&lt;/p>
&lt;h3 id="conflict-resolution">Conflict resolution
&lt;/h3>&lt;p>When multiple people make conflicting changes to the same file or code section, a conflict occurs. Version control systems provide tools to help resolve these conflicts, ensuring that changes are merged correctly.&lt;/p>
&lt;h3 id="history-and-annotations">History and annotations
&lt;/h3>&lt;p>Version control systems maintain a detailed history of all changes, including who made each change and when. Using annotations, you can identify who wrote specific lines or sections of a document.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>Commonly used version control systems include Subversion, Git and Mercurial. These systems offer powerful features for collaboration, code management, and project organization, making them essential tools for software development teams.&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/image_0.jpg"
loading="lazy"
alt="Illustration"
>&lt;/p>
&lt;p>Thanks for reading. Happy Coding!&lt;/p></description></item><item><title>Git Commands</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/git-commands/</link><pubDate>Mon, 14 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/git-commands/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/git-commands/featured.jpg" alt="Featured image of post Git Commands" />&lt;p>&lt;strong>A quick guide - to keep handy&lt;/strong>&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>Git is a powerful version control system that allows developers (and professionals who might benefit from the tool) to track changes, collaborate on projects, and manage code efficiently (you can learn more about version control here). In this post, we will cover a few of the most frequently used Git commands (at least the ones I use most often in development) and outline their basic functionalities.&lt;/p>
&lt;h2 id="list-of-git-commands">List of Git commands
&lt;/h2>&lt;h3 id="git-init">&lt;code>git init&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git init&lt;/code> command initializes a new Git repository in your current working directory. It creates a hidden “.git” folder that contains the necessary data for version control.&lt;/p>
&lt;h3 id="git-clone-repository_url">&lt;code>git clone [repository_url]&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git clone&lt;/code> command allows you to copy an existing Git repository from a remote source, such as GitHub. It downloads the entire repository, including its history, to your local machine.&lt;/p>
&lt;h3 id="git-add-files">&lt;code>git add [file(s)]&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git add&lt;/code> command stages file(s) for the next commit. You can specify individual files or directories. Use &lt;code>git add .&lt;/code> , to stage all modified files in the current director.&lt;/p>
&lt;h3 id="git-status">&lt;code>git status&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git status&lt;/code> command displays the current status of your repository. It shows which files have been modified, staged, or untracked. This command is helpful for understanding the state of your project.&lt;/p>
&lt;h3 id="git-log">&lt;code>git log&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git log&lt;/code> command shows a chronological list of commits in the repository. It displays information such as the commit hash, author, date, and commit message. Use &lt;code>git log --oneline&lt;/code> for a more concise view.&lt;/p>
&lt;h3 id="git-pull-remotebranch">&lt;code>git pull [remote][branch]&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git pull&lt;/code> command fetches and merges changes from a remote repository into your local branch. It is used to update your local branch with the latest changes made by others. Note that you’d need to specify the remote and branch to pull from.&lt;/p>
&lt;h3 id="git-branch">&lt;code>git branch&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git branch&lt;/code> command lists all branches in your repository. It also highlights the branch you are currently on. Use &lt;code>git branch [branch_name]&lt;/code> to create a new branch.&lt;/p>
&lt;h3 id="git-checkout-branch_name">&lt;code>git checkout [branch_name]&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git checkout&lt;/code> command combines changes from one branch into another. It integrates the changes from the specified branch into the current branch. This is useful when you want to incorporate features or bug fixes from one branch into another.&lt;/p>
&lt;h3 id="git-merge-branch">&lt;code>git merge [branch]&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git merge&lt;/code> command combines changes from one branch into another. It integrates the changes from the specified branch into the current branch. This is useful when you want to incorporate features or bug fixes from one branch into another.&lt;/p>
&lt;h3 id="git-remote">&lt;code>git remote&lt;/code>
&lt;/h3>&lt;p>The &lt;code>git remote&lt;/code> command lists the remote repositories associated with your local repository. It shows their names, URL’s and other information. You can add new remotes using &lt;code>git remote add [name][url]&lt;/code>.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>Having an understanding of these commands will greatly enhance your ability to manage and collaborate on projects effectively. It can also be convenient to have these in one place so as to access them with ease when you need to.&lt;/p>
&lt;p>Thanks for reading. Happy Coding!&lt;/p></description></item><item><title>Recursion</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/recursion/</link><pubDate>Mon, 14 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/recursion/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/recursion/featured.jpg" alt="Featured image of post Recursion" />&lt;p>&lt;strong>The Code that Calls Itself&amp;hellip;and Itself&amp;hellip;and Itself&amp;hellip;🌀&lt;/strong>&lt;/p>
&lt;p>Let’s say someone got you a gift and they handed you this huge wrapped-up box that required all your strength to hold. You then start to unwrap this gift and soon realise that inside this gift-wrapped box is another&amp;hellip;gift-wrapped box…you continue to unwrap this smaller box and once you’re done, you realise there’s another even smaller gift-wrapped box inside it. This goes on for three more boxes (getting smaller and smaller) until you finally reach the gift (imagine that ideal item you’ve been longing to have or own for ages). That’s recursion! You’re solving a bigger problem by breaking it down into smaller problems until you reach the simplest one.&lt;/p>
&lt;p>We just described the concept of recursion using a metaphor of unwrapping nested gift boxes. The initial large wrapped box represents the original problem. The act of unwrapping it to reveal another gift-wrapped box inside represents a recursive function calling itself to solve a smaller sub-problem. The process continues until a base case is reached, which is symbolised by the smaller gift box that contains the desired gift. In the context of C programming, it represents a recursive function that calls itself repeatedly until it reaches a base case.&lt;/p>
&lt;p>The image above depicts an illustration of Recursion.&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>Recursion is a fundamental concept in Computer Science and programming that allows a function or method to call itself within its own definition. In this post, we will explore what recursion is, how to implement it, and when it should and should not be used.&lt;/p>
&lt;h2 id="what-is-recursion">What is Recursion?
&lt;/h2>&lt;p>Recursion is a programming technique that involves a function or method calling itself within its own definition. The idea behind recursion is to break a problem down into smaller and smaller sub-problems until they are simple enough to solve. Each time the function is called, it works on a smaller and simpler version of the original problem until the base case is reached.&lt;/p>
&lt;p>The base case is the condition in which the function does not call itself again and returns a value. The base case is essential because, without it, the function would continue to call itself indefinitely, resulting in an infinite loop and eventually crashing the program.&lt;/p>
&lt;h2 id="how-to-implement-recursion">How to implement Recursion
&lt;/h2>&lt;p>To implement recursion in a program, you need to define a function or method that calls itself within its own definition. To gain a better understanding of recursion, suppose we wanted to calculate the factorial of a number using recursion.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note ✍🏼:&lt;/strong> The factorial of a number is the product of all positive integers less than or equal to that number.&lt;/p>&lt;/blockquote>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-c" data-lang="c">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#include&lt;/span> &lt;span class="cpf">&amp;lt;stdio.h&amp;gt;&lt;/span>&lt;span class="cp">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#include&lt;/span> &lt;span class="cpf">&amp;#34;main.h&amp;#34;&lt;/span>&lt;span class="cp">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">* main - Entry point of the program
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">*
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">* Description: Recursive function to calculate the factorial of a number
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">* Return: nothing
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">*/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kt">int&lt;/span> &lt;span class="nf">factorial&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">int&lt;/span> &lt;span class="n">n&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">int&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Base case: when n is 0 or 1, return 1*/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">0&lt;/span> &lt;span class="o">||&lt;/span> &lt;span class="n">n&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">else&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Recursive case: multiply n with factorial(n-1)*/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="nf">factorial&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">n&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">));&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kt">int&lt;/span> &lt;span class="nf">main&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">int&lt;/span> &lt;span class="n">num&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">int&lt;/span> &lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nf">factorial&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">num&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nf">printf&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;The factorial of %d is %d&lt;/span>&lt;span class="se">\n&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">num&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">result&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>What does all this mean? — Let&amp;rsquo;s walk through the above function step-by-step:&lt;/p>
&lt;ul>
&lt;li>First, include the standard libraries &lt;code>#include &amp;lt;stdio.h&amp;gt;&lt;/code> required to use built-in functions like &lt;code>printf&lt;/code>.&lt;/li>
&lt;li>Then we include the function description, stating the name and purpose of the function as well as any parameters in use.&lt;/li>
&lt;li>We declare a recursive function called &lt;code>factorial&lt;/code> that takes an integer &lt;code>n&lt;/code> as a parameter and returns an integer.&lt;/li>
&lt;li>Inside the &lt;code>factorial&lt;/code> function, we have the base case. If &lt;code>n&lt;/code> is 0 or 1, we return 1 because the factorial of 0 or 1 is 1.&lt;/li>
&lt;li>If &lt;code>n&lt;/code> is not 0 or 1, we have a recursive case. We then calculate the factorial by multiplying &lt;code>n&lt;/code> with the factorial of &lt;code>n-1&lt;/code>. To do this, we call the &lt;code>factorial&lt;/code> function again with the parameter &lt;code>n-1&lt;/code>.&lt;/li>
&lt;li>In the &lt;code>main&lt;/code> function, we initialise a variable &lt;code>num&lt;/code> to 5 (the number whose factorial we want to calculate).&lt;/li>
&lt;li>We call the &lt;code>factorial&lt;/code> function with &lt;code>num&lt;/code> as the argument and store the result in the variable &lt;code>result&lt;/code>.&lt;/li>
&lt;li>Finally, we use &lt;code>printf&lt;/code> to display the result.&lt;/li>
&lt;/ul>
&lt;p>When the program is run, it will (hopefully) calculate the factorial of 5 using recursion and print the result as “The factorial of 5 is 120“ (if not, then we need to keep calm and debug 🐞).&lt;/p>
&lt;h2 id="when-to-use-recursion">When to use Recursion
&lt;/h2>&lt;p>Recursion is an excellent tool for solving problems that can be broken down into smaller and simpler sub-problems. Here are some situations in which recursion can be helpful:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Sorting Algorithms:&lt;/strong> Some sorting algorithms such as quicksort and mergesort use recursion to divide the problem into smaller sub-problems.&lt;/li>
&lt;li>&lt;strong>Search Algorithms:&lt;/strong> Some search algorithms such as binary search and depth-first search use recursion to explore a problem space.&lt;/li>
&lt;li>&lt;strong>Mathematical Problems:&lt;/strong> Recursive solutions are often used in mathematical problems such as the Fibonacci sequence or calculating factorials.&lt;/li>
&lt;/ul>
&lt;h2 id="when-not-to-use-recursion">When not to use Recursion
&lt;/h2>&lt;p>Recursion as said previously can be a powerful tool, but it is not always the best solution to a problem. Here are some situations in which recursion should not be used:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Large Data Sets:&lt;/strong> Recursion can cause stack overflow errors if too many function calls are made. This can be a problem when dealing with large data sets.&lt;/li>
&lt;li>&lt;strong>Deeply Nested Recursion:&lt;/strong> Deeply nested recursion can be difficult to understand and debug, leading to errors and performance issues.&lt;/li>
&lt;li>&lt;strong>Overhead:&lt;/strong> As mentioned earlier, each function call requires additional memory, which can lead to performance issues when dealing with large data sets.&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>While recursion can be a powerful technique, it’s important to consider the problem’s characteristics, input size, language limitations, and performance requirements before deciding to use recursion or opt for an iterative approach. It’s important to have a base case that terminates the recursion. Otherwise, the function will keep calling itself indefinitely, leading to an infinite loop (which isn’t a bad thing if you love gifts&amp;hellip;but at some point, you’ll want to get to the base case sooner than later 🤭).&lt;/p>
&lt;p>Thanks for reading. Happy Coding!&lt;/p></description></item><item><title>Understanding malloc and free in C</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/malloc-free/</link><pubDate>Fri, 11 Aug 2023 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/malloc-free/</guid><description>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/malloc-free/featured.jpg" alt="Featured image of post Understanding malloc and free in C" />&lt;p>“Who in the world is malloc and where are they located and why do they need to be freed?”, was my first thought when the topic malloc &amp;amp; free was introduced in a c programming course I was “shadowing“. This post will delve into how malloc is indeed a function (not a who) and the need to free allocated memory after making use of it.&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>Effective programming necessitates proper memory allocation and management. This article focuses on dynamic memory allocation and introduces the C functions malloc and free. Additionally, it provides a detailed walkthrough of successfully implementing these concepts.&lt;/p>
&lt;h2 id="dynamic-memory-allocation-with-malloc-and-free">Dynamic Memory Allocation with malloc and free
&lt;/h2>&lt;p>Dynamic memory allocation allows us to allocate and deallocate memory during program execution.&lt;/p>
&lt;h3 id="the-malloc-function">The malloc function
&lt;/h3>&lt;p>The malloc function in C reserves a block of memory of a specified size and returns a pointer to the beginning of that block. Here’s an example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-c" data-lang="c">&lt;span class="line">&lt;span class="cl">&lt;span class="kt">int&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="n">dynamicArray&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">int&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nf">malloc&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">5&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="k">sizeof&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">int&lt;/span>&lt;span class="p">));&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In this code, malloc allocates memory for an array of 5 integers. The returned pointer is cast to an int* to match the data type.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Reminder (ᵔ◡ᵔ):&lt;/strong> always include the &lt;code>&amp;lt;stdlib.h&amp;gt;&lt;/code> header file for the malloc function.&lt;/p>&lt;/blockquote>
&lt;h3 id="the-free-function">The free function
&lt;/h3>&lt;p>The free function deallocates memory previously allocated using malloc. Here’s an example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-c" data-lang="c">&lt;span class="line">&lt;span class="cl">&lt;span class="nf">free&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">dynamicArray&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In this code, free releases the memory allocated for the dynamicArray. It’s essential to call free for every dynamically allocated memory block to prevent memory leaks.&lt;/p>
&lt;p>&lt;img src="https://sandramsc-fun.sandraashipala.workers.dev/post/malloc-free/image_0.jpg"
width="1456"
height="1717"
srcset="https://sandramsc-fun.sandraashipala.workers.dev/post/malloc-free/image_0_hu_ffa8b8c9f3eab689.jpg 480w, https://sandramsc-fun.sandraashipala.workers.dev/post/malloc-free/image_0_hu_da6222af443f97e8.jpg 1024w"
loading="lazy"
alt="Illustration"
class="gallery-image"
data-flex-grow="84"
data-flex-basis="203px"
>&lt;/p>
&lt;h2 id="benefits-of-dynamic-memory-allocation">Benefits of Dynamic Memory Allocation
&lt;/h2>&lt;p>Let’s understand why and when we should use dynamic memory allocation&lt;/p>
&lt;h3 id="unknown-data-size">Unknown Data Size
&lt;/h3>&lt;p>When the size of the data is unknown or varies during runtime, dynamic allocation becomes essential. For instance, when reading user input or data from a file, malloc enables us to allocate memory based on the input size.&lt;/p>
&lt;h3 id="resource-efficiency">Resource Efficiency
&lt;/h3>&lt;p>Allocating memory dynamically ensures efficient memory utilization. Instead of declaring multiple fixed-size variables, dynamic allocation lets us optimise memory usage by allocating memory as needed.&lt;/p>
&lt;p>Understanding dynamic memory allocation, malloc and free functions are fundamental skills in C programming. By applying these concepts and tools, we can efficiently manage memory resources, optimize program efficiency, and build robust and reliable applications. Here is a practical example of dynamic memory allocation:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-c" data-lang="c">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#include&lt;/span> &lt;span class="cpf">&amp;lt;stdio.h&amp;gt;&lt;/span>&lt;span class="cp">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#include&lt;/span> &lt;span class="cpf">&amp;lt;stdlib.h&amp;gt;&lt;/span>&lt;span class="cp">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#include&lt;/span> &lt;span class="cpf">&amp;#34;main.h&amp;#34;&lt;/span>&lt;span class="cp">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">/**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">* main - Entry
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">*
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">* Return: nothing
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">*/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kt">int&lt;/span> &lt;span class="nf">mai&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">int&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">int&lt;/span> &lt;span class="o">*&lt;/span>&lt;span class="n">dynamicArray&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Allocate memory for an array of 5 integers */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">dynamicAray&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kt">int&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nf">malloc&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">5&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="k">sizeof&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kt">int&lt;/span>&lt;span class="p">));&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Check if allocation was successful */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">dynamicArray&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="nb">NULL&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Assign values to the dynamic array */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="o">++&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">dynamicArray&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Print the array */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="o">++&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nf">printf&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;%d&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">dynamicArray&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nf">printf&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="se">\n&lt;/span>&lt;span class="s">&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="cm">/* Free the dynamically allocated memory */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nf">free&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">dynamicArray&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In this example, memory was allocated for an array of 5 integers using malloc. Values to the array were then assigned and printed. And in the final step, the dynamically allocated memory was freed using the free function.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Takeway (๑ᵔ⤙ᵔ๑):&lt;/strong>&lt;/p>
&lt;p>malloc allocates the requested number of bytes and returns a pointer to the first byte of the allocated space.
General format
&lt;code>ptr = (type *) malloc(byte_size);&lt;/code>&lt;/p>
&lt;p>free frees up previousely allocated space
General format
&lt;code>free(ptr);&lt;/code>&lt;/p>&lt;/blockquote>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>In programming, dynamic memory allocation is a powerful technique that enables programmers to allocate and deallocate memory during program execution. By using the malloc function, one can dynamically allocate memory, using the free function helps in releasing that memory when it is no longer needed. When dealing with unknown data sizes or creating dynamic data structures, this flexibility becomes especially valuable.&lt;/p>
&lt;p>Thank you for reading. Happy Coding!&lt;/p></description></item><item><title>Masters Thesis: Exploring Visualisations for Financial Statements in Virtual Reality</title><link>https://sandramsc-fun.sandraashipala.workers.dev/post/masters-thesis/</link><pubDate>Mon, 14 Dec 2020 00:00:00 +0000</pubDate><guid>https://sandramsc-fun.sandraashipala.workers.dev/post/masters-thesis/</guid><description>&lt;h1 id="exploring-visualisations-for-financial-statements-in-virtual-reality">Exploring Visualisations for Financial Statements in Virtual Reality
&lt;/h1>&lt;p>&lt;strong>Authors:&lt;/strong> Tanja Kojić, Sandra Ashipala, Sebastian Möller, Jan-Niklas Voigt-Antons&lt;br>
&lt;strong>Published in:&lt;/strong> 2020 IEEE International Conference on Artificial Intelligence and Virtual Reality (AIVR)&lt;br>
&lt;strong>Conference Date:&lt;/strong> 14–18 December 2020 (Utrecht, Netherlands)&lt;br>
&lt;strong>Publisher:&lt;/strong> IEEE&lt;br>
&lt;strong>DOI:&lt;/strong> &lt;a class="link" href="https://doi.org/10.1109/AIVR50618.2020.00018" target="_blank" rel="noopener"
>10.1109/AIVR50618.2020.00018&lt;/a>&lt;br>
&lt;strong>IEEE Xplore:&lt;/strong> &lt;a class="link" href="https://ieeexplore.ieee.org/document/9319099" target="_blank" rel="noopener"
>View Publication&lt;/a>&lt;/p>
&lt;h2 id="overview">Overview
&lt;/h2>&lt;p>Investigates how 3D Virtual Reality (VR) data visualizations affect user comprehension and engagement with personal financial statements compared to traditional 2D paper prototypes. In a controlled user study (N = 23), participants completed financial analysis tasks across both mediums. While 2D paper interaction felt more natural with lower perceived latency, task accuracy was comparably high in both conditions—demonstrating that VR is a viable medium for analyzing complex financial data.&lt;/p>
&lt;h2 id="citation-bibtex">Citation (BibTeX)
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;span class="lnt">9
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bibtex" data-lang="bibtex">&lt;span class="line">&lt;span class="cl">&lt;span class="nc">@inproceedings&lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="nl">kojic2020exploring&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">author&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{Koji{\&amp;#39;c}, Tanja and Ashipala, Sandra and M{\&amp;#34;o}ller, Sebastian and Voigt-Antons, Jan-Niklas}&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">title&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{Exploring Visualisations for Financial Statements in Virtual Reality}&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">booktitle&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{2020 IEEE International Conference on Artificial Intelligence and Virtual Reality (AIVR)}&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">year&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{2020}&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">pages&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{}&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">doi&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{10.1109/AIVR50618.2020.00018}&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">publisher&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="s">{IEEE}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item></channel></rss>