<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jamal Guyo on Medium]]></title>
        <description><![CDATA[Stories by Jamal Guyo on Medium]]></description>
        <link>https://medium.com/@jamalguyo08?source=rss-d2b09afe496d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WCpSHTHa3sXojlxYX2gByg.jpeg</url>
            <title>Stories by Jamal Guyo on Medium</title>
            <link>https://medium.com/@jamalguyo08?source=rss-d2b09afe496d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 23:32:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jamalguyo08/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Part 2: Stacking Context and Containing Block]]></title>
            <link>https://medium.com/@jamalguyo08/part-2-stacking-context-and-containing-block-ab0c6d2bffa0?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab0c6d2bffa0</guid>
            <category><![CDATA[stacking-context]]></category>
            <category><![CDATA[html-fundamental]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Tue, 12 Aug 2025 15:59:54 GMT</pubDate>
            <atom:updated>2025-08-12T15:59:54.787Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ORpaPYP6JiUkw8L-" /><figcaption>Photo by <a href="https://unsplash.com/@blenderdesigner?utm_source=medium&amp;utm_medium=referral">Sufyan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://medium.com/@jamalguyo08/why-developers-struggle-with-css-and-why-its-not-css-s-fault-31094e2b744f">Part 1</a>, we looked at the <strong>box model</strong> (what the element <em>is</em>) and <strong>formatting contexts</strong> (how elements <em>flow</em> in relation to each other).</p><p>But there’s still a missing piece to understanding why things don’t always look like you expect on screen:</p><ul><li><strong>What happens when elements overlap?</strong></li><li><strong>Relative to what does CSS actually position elements?</strong></li></ul><p>These are where <strong>stacking context</strong> and <strong>containing block</strong> come into play.</p><h3>Stacking Context: The “Layers” of the Web</h3><p>If formatting contexts decide <em>where</em> things sit in the page flow, <strong>stacking context</strong> decides <em>which one appears on top when they overlap</em>.</p><p>Think of stacking context as Photoshop layers — except in CSS, layers aren’t just one big global pile. Every stacking context is its own little “mini-layer system” with rules for which elements appear in front or behind.</p><blockquote><strong>The first stacking context</strong> is created by the &lt;html&gt; element.</blockquote><h4>The Default Positioning &amp; Layering Model</h4><p>When a page first loads, the &lt;html&gt; element creates the first stacking context — this is like a single, flat surface where all elements live.</p><p>By default:</p><ul><li><strong>Block-level elements</strong> (like &lt;div&gt;, &lt;p&gt;, &lt;h1&gt;) are placed one after another vertically.</li><li><strong>Inline elements</strong> (like &lt;span&gt;, text) flow next to each other horizontally inside a line.</li></ul><p>In this flat environment, nothing is “above” or “below” unless elements overlap.</p><p>When they <em>do</em> overlap:</p><ul><li><strong>HTML order</strong> — If both elements are unpositioned (position: static), the one that comes <strong>later in the HTML</strong> will appear on top.</li><li><strong>Positioned elements</strong> — If an element has a position other than static (relative, absolute, fixed, sticky), it <strong>immediately jumps above all non-positioned elements</strong>, no matter where it appears in the HTML. <em>(This happens even without adding a </em><em>z-index.)</em></li></ul><blockquote>This is the <strong>baseline behavior</strong> — everything starts in the same layer, and the only things that change the stacking order are: HTML source order and Being a positioned element</blockquote><h4>Z-Index in the Default Stacking Context</h4><p>When you give an element a z-index, you’re telling the browser how to layer it <strong>relative to other elements in the same stacking context</strong>.</p><p>But here’s the key:</p><ul><li>For <strong>most</strong> elements, z-index has no effect unless the element is <strong>positioned</strong> (relative, absolute, fixed, or sticky).</li><li><strong>Exception:</strong> If the element is a <strong>flex item</strong> (child of a flex container) or a <strong>grid item</strong> (child of a grid container), z-index will work even without position being set.</li></ul><p>How it plays out in the default stacking context:</p><ul><li>If both elements have z-index set and are in the same stacking context, the one with the <strong>higher value</strong> is drawn on top.</li><li>If z-index is the same or not set, HTML source order + positioning rules determine which is on top.</li></ul><h4>Creating a New Stacking Context</h4><p>Up to now, we’ve been talking about layering in a single, shared stacking context. But in reality, CSS can create <em>multiple</em> stacking contexts on top of the default stacking context.</p><p>When this happens:</p><ul><li>The new stacking context acts as <strong>its own private layer system</strong>.</li><li>Elements inside it are layered relative to <em>each other</em>, <strong>not</strong> relative to elements outside it.</li><li>No matter how big their z-index is, they can’t “break out” and overlap elements in other stacking contexts.</li></ul><p>Think of it like opening a folder in Photoshop:<br>You can reorder layers inside the folder, but nothing inside it can jump on top of layers outside.</p><p><strong>How to Create a New Stacking Context</strong><br> You create a new stacking context when you apply certain CSS properties to an element, for example:</p><ol><li>The &lt;html&gt; element (root stacking context, always present)</li><li>Any element with a position other than static <strong>and</strong> a z-index value <strong>other than </strong><strong>auto</strong></li><li>Elements with certain properties, even without position or z-index:</li></ol><ul><li>opacity &lt; 1</li><li>transform (any value other than none)</li><li>filter</li><li>perspective</li><li>clip-path</li><li>mask / mask-image / mask-border</li><li>will-change with certain properties</li><li>contain: paint</li></ul><h3>Containing Block: The Positioning Reference</h3><p>If stacking context answers “Who’s on top?”, containing block answers “Relative to what position do we place this thing?”</p><p><strong>By default:</strong><br> An element’s containing block is its <strong>nearest ancestor block-level element</strong> — usually its parent — in the normal document flow.</p><p>The containing block defines the coordinate system for layout:</p><ul><li>If you say top: 20px, it’s 20px from the top edge of the containing block.</li><li>If you say left: 0, it’s aligned with the containing block’s left edge.</li></ul><p>The containing block changes when you apply:</p><ul><li><strong>position: absolute</strong> → the containing block becomes the nearest ancestor with position set to relative, absolute, fixed, or sticky.</li><li><strong>position: fixed</strong> → the containing block is the viewport (unless a parent has a transform or similar property, see below).</li><li><strong>Special cases</strong>: Certain properties force an element to establish a containing block for its descendants, even if they aren’t positioned: transform, perspective, filter, contain: paint</li></ul><p><em>Next we’ll look at the cascade</em></p><blockquote>Note: I reread and revise these articles over time so they get simpler and clearer for my future self to understand as well.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab0c6d2bffa0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Developers Struggle with CSS (And Why It’s Not CSS’s Fault)]]></title>
            <link>https://medium.com/@jamalguyo08/why-developers-struggle-with-css-and-why-its-not-css-s-fault-31094e2b744f?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/31094e2b744f</guid>
            <category><![CDATA[html-css]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[block-formatting-context]]></category>
            <category><![CDATA[html-layouts]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 18:13:35 GMT</pubDate>
            <atom:updated>2025-08-13T13:41:11.187Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PZF4HmmjEA2K6Ws1" /><figcaption>Photo by <a href="https://unsplash.com/@kaimantha?utm_source=medium&amp;utm_medium=referral">Claudia Wolff</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Part 1 : Why Developers Struggle with CSS (And Why It’s Not CSS’s Fault)</h3><h3>The Hard Truth About CSS Knowledge Gaps</h3><p>After years of working with CSS, and debugging layout issues, I’ve noticed a universal pattern:</p><blockquote><em>Most developers blame CSS for being “unpredictable” or “broken” when, in reality, they simply don’t understand how it fundamentally works. </em>This is an observation about how CSS is taught (or rather, <em>not</em> taught).</blockquote><p>The core fundamentals we’ll look at in this series are:</p><ol><li><strong>box-model</strong></li><li><strong>formatting context</strong></li><li><strong>stacking context</strong></li><li><strong>containing block</strong></li><li><strong>the cascade</strong></li></ol><h3>Part 1 : Box-model and Formatting Context</h3><h3>Box Model</h3><p>In CSS, <strong>everything is a box</strong>.</p><p>Whether it’s a &lt;div&gt;, &lt;span&gt;, &lt;p&gt;, or even a text node — every element on your page is treated as a <strong>box</strong>.</p><p>The structure of these boxes are defined by the <strong>CSS box model</strong>, it describes the four invisible edges that control an element’s size and spacing:</p><ul><li><strong>Content</strong>: The actual text or image inside the element.</li><li><strong>Padding</strong>: Space around the content — it pushes the content inward.</li><li><strong>Border</strong>: A line (visible or not) that wraps the padding and content.</li><li><strong>Margin</strong>: Space outside the border — it pushes the element away from other elements.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*NnKmaODB-V9TpHhq3BG0HA.png" /><figcaption>box-model</figcaption></figure><h3>Formatting Context</h3><p><strong><em>Every box must participate in a formatting context.</em></strong></p><p>A <strong>formatting context</strong> is simply a <strong>set of layout rules</strong> that governs how boxes (elements) behave — both:</p><ul><li>In relation to their <strong>parent container</strong></li><li>And alongside <strong>their sibling elements</strong></li></ul><p>When a webpage loads, the &lt;html&gt; element automatically creates the first formatting context called <strong>Block Formatting Context (BFC)</strong>.</p><p>This root BFC:</p><ul><li>Governs all <strong>block-level elements</strong></li><li>Controls how those blocks stack vertically</li><li>Applies base layout rules across the page</li></ul><h4>What About Inline Elements?</h4><p>We said every element must participate in a<strong> </strong>formatting context. But the root BFC is only concerned with <strong>block-level elements</strong>. So where do <strong>inline elements</strong> like &lt;span&gt; and text fit in?</p><p>This is where the <strong>Inline Formatting Context (IFC)</strong> comes in.</p><p>Whenever a block-level element (like a &lt;div&gt; or &lt;p&gt;) contains <strong>only inline content</strong>, it creates an <strong>Inline Formatting Context</strong> inside itself.</p><p>The IFC handles:</p><ul><li>Horizontal layout of inline boxes (like text and spans)</li><li>Line breaking</li><li>Vertical alignment within a line</li></ul><blockquote>The <strong>root BFC</strong> handles <strong>vertical stacking. </strong>The <strong>IFC</strong> handles <strong>horizontal flow</strong></blockquote><p>Together, the BFC and IFC form the foundation of what’s called the <strong>Flow Layout</strong> — the default layout system in CSS.</p><ul><li>The &lt;html&gt; element creates a <strong>single root BFC</strong>.</li><li>Every block element on the page participates in this BFC.</li><li>Inside those block elements, if there’s only inline content, <strong>a new IFC is created</strong>.</li></ul><blockquote><em>This means </em><strong><em>the BFC is shared</em></strong><em> across many block elements,<br> but </em><strong><em>each IFC is created locally</em></strong><em> for every block element that needs it.</em></blockquote><pre>&lt;h1&gt;A Title&lt;/h1&gt;<br>&lt;div&gt;<br> &lt;span&gt;A paragraph&lt;/span&gt; of text inside a div tag<br>&lt;/div&gt;<br>The &lt;html&gt; element creates the root BFC</pre><blockquote>&lt;h1&gt; and &lt;div&gt; are block elements → they stack vertically because they participate in the root BFC</blockquote><blockquote>Inside &lt;div&gt;, you have inline content (&lt;span&gt; and text) → this triggers an Inline Formatting Context to handle horizontal flow</blockquote><blockquote>Together, the vertical stacking of blocks (BFC) and the horizontal flow of text (IFC) give us the flow layout — the default behavior you see on every web page.</blockquote><h4>Creating New Formatting Contexts (Mini Layouts)</h4><p>The root BFC provides the default layout — but we can create <strong>new formatting contexts</strong> (mini-layouts) inside it by using certain CSS properties.</p><p>These <strong>new BFCs</strong> behave like <strong>independent layout </strong>with their own modified rules. When you create a new BFC, it:</p><ul><li>Still lives inside the root BFC</li><li>But doesn’t follow all the rules</li><li>Can isolate layout issues</li></ul><p><strong>Common ways to create a new BFC:</strong></p><ul><li>display: flow-root</li><li>overflow: hidden | auto | scroll</li><li>float: left | right</li><li>display: flex | grid</li><li>position: absolute | fixed</li></ul><h4>Specialized BFCs: Flex and Grid</h4><p>New BFCs can share the base rules of the root BFC — but <strong>add additional behaviors</strong>, depending on how they’re created.</p><ul><li>A BFC created with display: flex becomes a <strong>Flex Formatting Context</strong>, with its own flex rules.</li><li>A BFC created with display: grid becomes a <strong>Grid Formatting Context</strong>, governed by grid-specific alignment and sizing.</li></ul><p>Other types of BFCs (e.g. created with position: absolute) follow different rules — for example:</p><ul><li>They don’t participate in margin collapsing</li><li>They are taken out of the normal document flow</li></ul><h4>The Role of display</h4><p>The display property does more than switch between block and inline. It defines which formatting context applies—either context-sensitive or rule-enforcing:</p><h4>Context-Sensitive display values:</h4><p>These elements do <strong>not</strong> create new formatting contexts (like BFC or FFC) by themselves. Instead, they <strong>participate</strong> in the formatting context of their parent, and internally they determine how their children are laid out.</p><ul><li>display: block<br> → Participates in the <strong>current BFC</strong>.<br> → If it contains only inline children, it internally creates an <strong>Inline Formatting Context (IFC)</strong> to lay them out.<br> → If it contains block-level children, it continues using the parent BFC&#39;s rules — <strong>no new BFC is created</strong> unless extra conditions are met (like overflow: hidden, float, etc.).</li><li>display: inline<br> → Participates in the <strong>Inline Formatting Context (IFC)</strong> of its parent (if one exists).<br> → If it contains block-level children (which is invalid in HTML and causes quirks), browsers often force a fix-up by wrapping them in anonymous block boxes — but <strong>no new BFC is created</strong>.</li></ul><h4>Rule-Enforcing display values:</h4><ul><li>display: flex → creates a <strong>Flex Formatting Context (FFC)</strong></li><li>display: grid → creates a <strong>Grid Formatting Context (GFC)</strong></li></ul><p>These special contexts isolate layout — new BFC is created with some specific rules and enforce their own layout system for children.</p><h3>Let’s Bring It All Together</h3><p>Here’s a complete example that demonstrates how these formatting contexts work in practice:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;!--<br>    &lt;html&gt; - Creates the initial BFC<br>           - All block Elements in the page participate in the rules of the<br>            root BFC initiated by the &lt;html&gt;<br>           - Block elements with only Inline elements will create a local<br>             IFC for the children<br>  --&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>  &lt;title&gt;Formatting Context Example&lt;/title&gt;<br>  &lt;style&gt;<br>    /* Just to visualize element boundaries */<br>    div, p, span, body {<br>      border: 1px solid #ccc;<br>      margin: 6px;<br>      padding: 6px;<br>    }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;!--<br>    &lt;body&gt; display is block<br>    - participates in root BFC<br>    - Inner part (context sensitive) determines formatting context for children:<br>      since body contains block elements that are not creating new BFC,<br>      it enforces the root BFC to its children<br>  --&gt;<br>  &lt;div style=&quot;display: block;&quot;&gt;<br>    &lt;!--<br>      &lt;div&gt; display:block<br>      - participates in root BFC<br>      - Inner part (context sensitive) defines formatting context for its children:<br>        contains block &lt;p&gt; and inline &lt;span&gt; children, and<br>        the block child element is not creating a new BFC, hence it enforces the <br>        root BFC to its children<br>    --&gt;<br>    &lt;p style=&quot;display: block;&quot;&gt;<br>      &lt;!--<br>        &lt;p&gt; display:block<br>        - participates in root BFC<br>        - Inner part (context sensitive) determines formatting context for children:<br>          contains inline text and &lt;span&gt; which is inline, <br>          so inner box creates a new local Inline Formatting Context (IFC)<br>      --&gt;<br>      This is a paragraph with some<br>      &lt;span style=&quot;display: inline;&quot;&gt;<br>        &lt;!--<br>          &lt;span&gt; display:inline<br>          - participates in &lt;p&gt;&#39;s IFC<br>          - Inner part (context sensitive) contains only text (inline), so <br>            it creates a new local Inline Formatting Context (IFC)<br>        --&gt;<br>        inline text.<br>      &lt;/span&gt;<br>    &lt;/p&gt;<br>    &lt;span style=&quot;display: inline;&quot;&gt;<br>      &lt;!--<br>          &lt;span&gt; display:inline<br>          - participates in root BFC<br>          - Inner part (context sensitive) contains only text (inline), so<br>           it creates a new local Inline Formatting Context (IFC)<br>        --&gt;<br>      inline text<br>    &lt;/span&gt;<br>  &lt;div&gt;<br>  &lt;div style=&quot;display:flex&quot;&gt;<br>     &lt;!--<br>        &lt;p&gt; display:flex<br>        - participates in root BFC<br>        - Inner part (Strict/enforces) creates a new BFC (mini-layout) that<br>          lives inside the root BFC.<br>        - Children become flex items and layout controlled by flex rules<br>      --&gt;<br>    &lt;div&gt;flex item&lt;/div&gt;<br>    &lt;div&gt;flex item&lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Coming Next: Stacking context and containing blocks</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31094e2b744f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux — managing permissions]]></title>
            <link>https://medium.com/@jamalguyo08/managing-permissions-in-linux-part-1-307919a8beb2?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/307919a8beb2</guid>
            <category><![CDATA[linux-user-group]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[linux-permission]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Sun, 09 Oct 2022 18:28:14 GMT</pubDate>
            <atom:updated>2022-10-16T21:00:01.159Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux — managing permissions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3JWfqHofheKK0_uZ" /><figcaption>Photo by <a href="https://unsplash.com/@qwitka?utm_source=medium&amp;utm_medium=referral">Maksym Kaharlytskyi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is a continuation of <a href="https://medium.com/@jamalguyo08/understanding-linux-permissions-f73117e7cf25">Linux - understanding permissions</a>.</p><p>To change the permission of a file or directory we use the command chmod .The command takes two arguments. The first is the permission you want to give and the second is the file or directory to apply the permission to i.e chmod &lt;permissions&gt; &lt;file/directory name&gt;</p><p>The first argument can be written in two ways:</p><h4>1. using the absolute method.</h4><p>This method involves the use of 3 digits to represent the permissions of the user, group, and others. This method is also called the <em>octal notation method.</em></p><p>The following numbers correspond to the respective permission:</p><ul><li>4 — stands for the <em>read(r) </em>permission</li><li>2 — stands for the <em>write(w) </em>permission</li><li>1 — stands for the <em>execute(x) permission</em></li></ul><p>The following is an example of how to represent permissions of the user, group, and others in octal notation</p><ul><li>rwxrwxrwx — 777<br>- the first rwx(4+2+1=7), the second rwx(4+2+1=7), and the third rwx(4+2+1=7)</li><li>rwxr-xr-x — 755<br>- the first rwx(4+2+1=7), the second r-x(4+1=5) and the third r-x(4+1=5)</li></ul><pre>jamal@jamal-hp:~$ ls -l<br>-rw-rw-r-- 1 jamal jamal 0 oct 2 15:38 demo.txt</pre><p>Therefore to change the permission of my <em>demo.txt </em>file above to full permissions for user, group and others we’ll type chmod 777 demo.txt:</p><pre>jamal@jamal-hp:~$ chmod 777 demo.txt<br>jamal@jamal-hp:~$ ls -l<br>-rwxrwxrwx 1 jamal jamal 0 oct 2 15:38 demo.txt</pre><p>Changing the permission of a directory is the same exact command.</p><h4>2. using the symbolic method</h4><p>Unlike the above method, the permissions in this method are represented using 3 letters, and the users, groups, and others are also represented using a letter each.</p><p>The letters corresponding to owners, groups, and others are as follows:</p><ul><li>u — represents owner/user</li><li>g — represents a group</li><li>o — represents others</li></ul><p>The letters corresponding to the respective permissions are as follows. This is the default way shown in the terminal when you run ls -l</p><ul><li>r — represents <em>read</em></li><li>w — represents <em>write</em></li><li>x — represents <em>execute</em></li></ul><p>To change the permissions we use the following mathematical expressions:</p><ul><li>+ — used to add permission e.g u+x adds execute permission to the user</li><li>- — used to remove a permission e.g g-x removes execute permission from the group</li><li>= — used to set permission if it doesn’t exist and override existing permission e.g o = w gives write permission to other users and removes all the other permissions.</li></ul><pre>jamal@jamal-hp:~$ ls -l<br>-rwxrwxrwx 1 jamal jamal 0 oct 2 15:38 demo.txt<br>jamal@jamal-hp:~$ <strong>chmod g=x demo.txt</strong><br>jamal@jamal-hp:~$ ls -l<br>-rwxrwx--x 1 jamal jamal 0 oct 2 15:38 demo.txt</pre><p>lastly…</p><p>To finish up on articles on Linux permissions we’ll cover two important commands <strong>chown</strong> and <strong>chrgp</strong>. So far from our example, our <strong>demo.txt </strong>file belongs to a group called <em>jamal </em>and owner called <em>jamal </em>as shown below</p><pre>jamal@jamal-hp:~$ ls -l<br>-rwxrwx--x 1 jamal jamal 0 oct 2 15:38 demo.txt</pre><p>To change the owner of the file to a different user on your machine we use the following commands:<br>- <strong>sudo chown &lt;new owner&gt; &lt;file&gt;<br>- sudo chown -R &lt;new owner&gt; &lt;directory&gt; — </strong>we use the -R on directories so that the subdirectories and files are changed to the new owner recursively.</p><p>To change the group owners of a file or directory we will substitute chown for chgrp .</p><pre>jamal@jamal-hp:~$ ls -l<br>-rwxrwxrwx 1 <strong>jamal</strong> <strong>jamal</strong> 0 oct 2 15:38 demo.txt<br>jamal@jamal-hp:~$ <strong>sudo chown peter demo.txt</strong><br>jamal@jamal-hp:~$ ls -l<br>-rwxrwx--x 1 <strong>peter jamal</strong> 0 oct 2 15:38 demo.txt</pre><p>From the example above you’ll notice that the <strong>owner</strong> of the file <em>demo.txt </em>has been changed to <em>peter</em></p><pre>jamal@jamal-hp:~$ ls -l<br>-rwxrwxrwx 1 <strong>jamal</strong> <strong>jamal</strong> 0 oct 2 15:38 demo.txt<br>jamal@jamal-hp:~$ <strong>sudo chown peter demo.txt</strong><br>jamal@jamal-hp:~$ ls -l<br>-rwxrwx--x 1 <strong>peter peter </strong>0 oct 2 15:38 demo.txt</pre><p>From the example above you’ll notice that the <strong>group</strong> of the file <em>demo.txt </em>has also been changed to <em>peter.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=307919a8beb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux — understanding permissions]]></title>
            <link>https://medium.com/@jamalguyo08/understanding-linux-permissions-f73117e7cf25?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f73117e7cf25</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-commands]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[linux-permission]]></category>
            <category><![CDATA[linux-user-group]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Sun, 02 Oct 2022 17:35:15 GMT</pubDate>
            <atom:updated>2022-10-16T12:40:35.324Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_jQwArMgtJ8FMQFR" /><figcaption>Photo by <a href="https://unsplash.com/@drice22?utm_source=medium&amp;utm_medium=referral">Danielle Rice</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>This is a continuation of my article on </em><a href="https://medium.com/@jamalguyo08/linux-users-and-groups-16ff5b3c0fe0"><em>Linux -users, and Groups</em></a><em>.</em></p><p>The multi-user functionality of Linux is made possible by:<br>- creating users <em>(covered in prev article)</em><br>- creating groups for the users <em>(covered in prev article)</em><br>- creating permissions on files and directories.</p><p>Let&#39;s look at an example before diving into how to create and remove permissions. If we list the contents of my home directory using the ls command <em>(we covered this command in the </em><a href="https://medium.com/@jamalguyo08/basic-linux-unix-navigations-cbbd6d28889f"><em>Linux -basic Navigation</em></a><em> article)</em> we will get the following output:</p><pre>jamal@jamal-hp:~$ ls -l<br>drwxrwxr-x 16 jamal jamal 4096 Jun 29 19:38 Desktop<br>-rw-rw-r-- 1  jamal jamal 0    Oct 2  15:38 demo.txt</pre><p>This is what they mean:</p><ol><li><strong>d</strong> — stands for a directory, in the case of a file you&#39;ll get a dash(-) instead. in the output above we can confirm that indeed <em>Desktop </em>is a directory and <em>demo.txt </em>is a file.</li><li><strong>rwx</strong> — the first set of three letters are <strong><em>Read, Write, Execute</em></strong> permissions relating to the user (the owner of that file/directory).<br>- r — stands for read permission. The user can read the file/directory.<br>- w — stands for write permission. The user can write to the file or directory.<br>-x — stands for execute permission. The user can execute the file or the directory.<br><em>if the user doesn&#39;t have the permission listed above, it is replaced with a dash(-).</em></li><li><strong>rwx — </strong>the second set of Read, Write, Execute permissions belong to the group the file or directory belongs to.</li><li><strong>rwx — </strong>the third set of Read, Write, Execute permissions belong to the other people who are neither the owners nor the group owning the file or directory.</li><li><strong>16 — </strong>this is the number of links.</li><li><strong>jamal</strong> — this is the owner of the file/directory.</li><li><strong>jamal — </strong>this is the group of owners to which the file/directory belongs.</li><li><strong>4096</strong> — this is the size of the file/directory</li><li><strong>Jun 29 19:38</strong> — this is the date and time the file/directory was created.</li><li><strong>Desktop</strong> — this is the name of the file/directory.</li></ol><p><em>from the example, <br>- the </em><strong><em>owner</em></strong><em> and the </em><strong><em>group</em></strong><em> of the directory </em><strong><em>desktop </em></strong><em>have the Read, Write and Execute permissions (rwxrwx)but the </em><strong><em>others</em></strong><em> only have Read and Execute permission(r-x) hence in full we have </em><strong><em>drwxrwxr-x (</em></strong><em>the </em><strong><em>d</em></strong><em> means this is a directory). <br>- the </em><strong><em>owner </em></strong><em>and the </em><strong><em>group </em></strong><em>of the file </em><strong><em>demo.txt </em></strong><em>have the Read and write permissions(rw-rw-) but the </em><strong><em>others </em></strong><em>only have the Read permission (r- -) hence in full we have </em><strong><em>-rw-rw-r- -(</em></strong><em>the first dash (— )means this is a file not a directory).</em></p><p><strong>NEXT → </strong><a href="https://medium.com/@jamalguyo08/managing-permissions-in-linux-part-1-307919a8beb2"><em>managing permissions in linux</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f73117e7cf25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux — users and groups]]></title>
            <link>https://medium.com/@jamalguyo08/linux-users-and-groups-16ff5b3c0fe0?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/16ff5b3c0fe0</guid>
            <category><![CDATA[linux-user-group]]></category>
            <category><![CDATA[linux-permission]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[sudo]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Sun, 25 Sep 2022 18:06:33 GMT</pubDate>
            <atom:updated>2022-10-16T12:25:55.892Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mIx_fZfY71zt3RtN" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The Unix operating system like Ubuntu supports multiuser, i.e we can have several users use the same machine. This however creates a challenge whereby <em>any user can modify the contents on the machine e.g delete a document or file needed by another user</em>. A practical way of separating different users was devised to solve this problem. To understand the solution to this problem we need to understand:</p><ul><li>how users and groups work (covered in this article)</li><li>how file and directory permissions work (covered in the next article)</li></ul><p>In this guide we’ll look at:</p><ol><li>How to create create, modify and delete a user</li><li>How to create, modify and delete a group</li></ol><h4>How to create, modify and delete a user</h4><p>Before we create a user, let&#39;s find out the name of the user on our local machine. Type whoami on your terminal to check the name of the user you are logged in as. <em>e.g in my case I am logged in as user -&gt; jamal</em></p><pre>jamal@jamal-hp:/$ whoami<br>jamal</pre><p>The list of all users on your Linux system can be found in /etc/passwd.You can use a text editor to view the contents of the file as shown below.</p><pre>jamal@jamal-hp:/$ vim /etc/passwd</pre><p>The output of the /etc/passwd will be of this format</p><p>jamal:x:1000:1000:Jamal,,,:/home/jamal:/bin/bash</p><ul><li><em>jamal</em> — is the username</li><li><em>x</em> — means your password is stored in a hidden file called shadow. The path to the file is <em>/etc/shadow</em></li><li><em>1000</em> — is the user id.</li><li><em>1000</em> — is the user group id. By default, you are added to a new user group with the same name as your username.</li><li><em>jamal/,,,</em> — is the information on the user.</li><li><em>/home/jamal</em> — is the home directory of the user.</li><li><em>/bin/bash </em>— is the default shell you are given to interact with the O.S.</li></ul><ol><li><strong>To modify the user information</strong> — we use the usermod command. e.g<br>- sudo usermod jamal --shell /bin/sh — to change the shell to <em>/bin/sh</em><br>- sudo usermod -l jayjay jamal — to change the username to <em>jayjay</em></li><li><strong>To check the id of the user — </strong>type id -u &lt;username&gt; .</li><li><strong>To view a list of all users — </strong>just type:<br>- getent passwd or <br>- access the <em>/etc/passwd </em>file.</li><li><strong>To create a new user</strong> — To create a new user simply type the command:<br>- sudo adduser &lt;username&gt; : The command will prompt you to create the new user&#39;s password, and additional information such as the full name<em>, phone number …</em><br>- sudo useradd &lt;username&gt; : This is a lazy version of the previous command. It’ll create a new user without a password and additional information. It won’t create a home directory as well. add the flag -m to create a home directory for the user. You can also create a password for the user using the next step below.</li><li><strong>To change the password of the user — </strong>to change the password of the user you created simply type sudo passwd &lt;username&gt;</li><li><strong>To switch to the new user — </strong>to switch to the user we just created you can use:<br>- su &lt;username&gt; — this will require you to input the password of the user you want to switch to.<br>- sudo su &lt;username&gt; — this will require the root user&#39;s password. <br><strong><em>NOTE</em></strong>: <em>not all users can have the sudo privilege. To access the file that manages the users who can do the sudo command type</em><em>sudo visudo .</em></li><li><strong>delete a user — </strong>to delete a user simply type sudo userdel &lt;username&gt;</li></ol><h4>How to create, modify and delete a group</h4><p>To understand the need for groups let’s take a scenario where a system admin is changing file or directory permissions for students and teachers. Without grouping, he/she will have to change the permissions of each and every user manually. Groups make it easier to change the permissions of a number of users very quickly.</p><p><em>By default, when we create a new user, a new group is automatically created with the same name and the user is added to that group. e.g user </em><em>jamal will be added to a group called </em><em>jamal</em></p><p>The information of all the groups on your machine will be found in the path /etc/group . To access it simply open it using a text editor of your choice for example vim /etc/group</p><ol><li><strong>To view the list of groups</strong> — just type:<br>- groups on your terminal. or <br>- getent group or<br>- access <em>/etc/group </em>file</li><li><strong>to create a new group— </strong>type sudo groupadd &lt;groupname&gt; e.g <em>sudo groupadd marketing.</em></li><li><strong>To add a user to a group — </strong>type:<br>- sudo adduser &lt;username&gt; &lt;groupname&gt; e.g <em>sudo adduser jamal marketing </em>or<br>- sudo usermod -aG &lt;groupname&gt; &lt;username&gt; e.g <em>sudo usermod -aG marketing jamal</em></li><li><strong>To delete a user from a group — </strong>type sudo deluser &lt;username&gt; &lt;groupname&gt; e.g <em>sudo deluser jamal marketing</em></li><li><strong>To delete a group — </strong>type sudo groupdel &lt;groupname&gt; e.g <em>sudo groupdel marketing</em></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16ff5b3c0fe0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux — basic navigations]]></title>
            <link>https://medium.com/@jamalguyo08/basic-linux-unix-navigations-cbbd6d28889f?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbbd6d28889f</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[navigation]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Sun, 07 Aug 2022 13:03:46 GMT</pubDate>
            <atom:updated>2022-10-16T12:31:38.400Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we get to the nitty gritty of navigation in Linux, It is important to point out how the files and folders are organized.</p><p>Linux files and folders are in hierarchical order, this is, they are arranged in a tree-like structure. The first directory in this hierarchical order is called a root directory. Every other files and folder originate from here. The root folder is usually denoted with a single forward slash ( <strong>/ ). </strong>Below is an example of a Linux file system.</p><figure><img alt="example of Linux file system" src="https://cdn-images-1.medium.com/max/414/1*bCtMtfZZgPmgRjQyTT0-Ow.png" /></figure><h4><strong>Navigation</strong></h4><p>To navigate the Linux file system, we’ll cover <strong>pwd</strong>, <strong>cd</strong> and <strong>ls</strong> commands on your terminal.</p><ol><li><strong>pwd</strong> — stands for print working directory. It is used to show where you are on the file system. The example below shows where I’m on the file system. The folders above it are: <em>jamal(my user folder)</em>, <em>home</em> folder and finally the <em>root folder</em>(shown as / ).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*W0v_xo_SA-NaOm0VA5VZBw.png" /></figure><p>2. <strong>cd</strong> — stands for change directory. It is used to navigate from one directory to another. To change your directory to the previous folder we use <strong>cd .. (the two dots are used to go back up a directory).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*QhcOSYglv_uzyu_Ho-OzSw.png" /></figure><p>To navigate to the next directory on the tree we use <strong>cd &lt;nameofdirectory&gt;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*qza03o8GekdJbfW9Pe9IqQ.png" /></figure><p>You can navigate to the root folder in one step as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*GkI0jymKlErwN0A-N-z9Vw.png" /></figure><p>3. <strong>ls </strong>— stands for list. It is used to list files or folders that are available in your working directory. It has some options/flags: to view details of the files or folders use the flag <strong>-L</strong>, to view hidden files use <strong>-a, </strong>or you can combine the two flags<strong> -la.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ss5bOvoajZra3TAOvNnDNA.png" /></figure><h4><strong>Looking Around</strong></h4><p>To look around we’ll use <strong>cat, less, file, head </strong>and <strong>tail </strong>commands.</p><ol><li><strong>cat</strong> — used to view the contents of a file. This command will show all the contents of a file selected. To use it just type <strong>cat &lt;filename&gt; </strong>as shown below:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0WAbG8ZsB6ayFesfOPyIBQ.png" /></figure><p>2. <strong>less — </strong>used to view the contents of a file one screen at a time. To use it just type <strong>less &lt;filename&gt;. </strong>To control less use :</p><ul><li><strong>PageUp/b — </strong>to scroll one page up</li><li><strong>PageDown/space — </strong>to scroll one page down</li><li><strong>q — </strong>to quit</li></ul><p>3. <strong>file — </strong>used to check the file type. To use it just type <strong>file &lt;filetype&gt;.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*aOfhAf9AT4KqlY43BYGzYg.png" /></figure><p>4. <strong>head — </strong>used to show the first 10 lines of the file by default. You can use it to read from a single file (<em>head &lt;filename&gt;), </em>or from multiple files (<em>head &lt;filename1&gt; &lt;filename2&gt;). </em>There are flags used to manipulate the behavior of the <strong>head. </strong>These are:</p><ul><li><strong>-n — </strong>used to change the number of lines to show e.g <em>-n 20(to show the first 20 lines of the file’s content)</em></li><li><strong>-c — </strong>used to change the number of bytes to show e.g <em>-c 32(to show the first 32bytes of the file’s content)</em></li><li><strong>-q — </strong>used to suppress the header information when reading from multiple files.</li></ul><p>5. <strong>tail — </strong>works just like a <em>head </em>command. The difference is that <em>tail </em>is used to read from the bottom of a file. By default, it shows the last 10 lines of a file. The flags mentioned in the <em>head </em>all apply to it as well.</p><h4><strong>Manipulating Files</strong></h4><p>To manipulate files we’ll use the commands <strong>cp, mv, rm, mkdir, rmdir </strong>and <strong>touch.</strong></p><ol><li><strong>cp — </strong>used to copy files and directories.</li></ol><ul><li>to copy file1 into file2 use the command <em>cp file1 file2. </em>if <em>file2 </em>doesn’t exist it will be created for you.</li><li>to copy a file to a folder use the command <em>cp &lt;filename&gt; &lt;directorypath&gt;</em></li><li>to copy several files use the command <em>cp &lt;wildcard-selection&gt; &lt;destination&gt; e.g cp *.txt &lt;destination&gt;( this will copy all files that end with .txt)</em></li><li>to copy a folder use the command <em>cp -r &lt;foldername&gt; &lt;destination&gt;</em>. The <em>-r </em>is used to recursively select all the contents of the folder.</li></ul><p>2. <strong>mv — </strong>used to move files and directories, and rename files and directories.</p><ul><li>to move a file or directory use <em>mv &lt;filename&gt; &lt;destination-path&gt; </em>and <em>mv -r &lt;directory&gt; &lt;destination-path&gt;.</em></li><li>to rename a file or folder simply move them to the same directory they are in e.g <em>mv demo.txt ./test.txt, mv -r directory ./directory2</em></li></ul><p><strong>Note: </strong><em>mv file1 file2</em><strong><em> — in this scenario file1 will be renamed to file2 if file2 doesn’t exist. If file2 exists then the contents of file1 will replace the contents of file2.</em></strong></p><p>3. <strong>rm — </strong>used to remove a file or directory.</p><ul><li>to remove a file using the command <em>rm &lt;filename&gt;</em></li><li>to remove a directory use the command <em>rm -r &lt;foldername&gt;</em></li></ul><p>4. <strong>mkdir — </strong>used to create a new directory. to use it simply type <em>mkdir &lt;directory name&gt;</em></p><p>5. <strong>rmdir — </strong>used to delete an empty directory. to use it simply type <em>rmdir &lt;directory name&gt;. </em>To delete a non empty directory use <em>rm -r &lt;directory name&gt;.</em></p><p>6. <strong>touch — </strong>used to create a new file. to use it simply type <em>touch &lt;filename&gt;. e.g touch demo.txt</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbbd6d28889f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript — imports and exports]]></title>
            <link>https://medium.com/@jamalguyo08/javascript-imports-and-exports-625842eb7c17?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/625842eb7c17</guid>
            <category><![CDATA[exports-and-imports]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es2015]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 13:31:21 GMT</pubDate>
            <atom:updated>2022-10-16T12:56:17.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NT8OkABivCnkEx0N" /><figcaption>Photo by <a href="https://unsplash.com/@lunarts?utm_source=medium&amp;utm_medium=referral">Volodymyr Hryshchenko</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>To appreciate import and export features in javascript, I’ll take you through how everything was before it.</p><p><strong>Before…</strong></p><p>If they wanted to organize their javascript code, developers created different Javascript files and added all the files they created into the html using the script tag as shown below.</p><pre>&lt;!DOCTYPE html&gt;</pre><pre>&lt;html lang=”en”&gt;<br>&lt;head&gt;<br>&lt;meta charset=”UTF-8&quot; /&gt;<br>&lt;meta http-equiv=”X-UA-Compatible” content=”IE=edge” /&gt;<br>&lt;meta name=”viewport” content=”width=device-width, initial-scale=1.0&quot;/&gt;<br>&lt;title&gt;Demo&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;</pre><pre>&lt;!-- LIST OF JAVASCRIPT FILES LOADED INTO THE APP --&gt;<br>&lt;script src=”./a.js”&gt;&lt;/script&gt;<br>&lt;script src=”./b.js”&gt;&lt;/script&gt;<br>&lt;script src=”./c.js”&gt;&lt;/script&gt;<br>&lt;script src=”./d.js”&gt;&lt;/script&gt;</pre><pre>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The disadvantages of this approach are:</p><ol><li>All the files are polluting the global namespace — Even though the code is separated into different files for organizational purposes, all the code are written to the global window object. Variables in one file can overwrite or conflict with variables in another file.The only way to make variables private was using a function to create a local scope.</li><li>The order in which javascript files are added is important — This is because all the files in the html are read as one javascript files with the end of the code in the first js file leading to the beginning of the second line and so on till the last file.</li></ol><p>prior to javascript implementing its own module system, developers used the following approaches to solve the problems above</p><ol><li>using Immediately Invoked Function Expressions(<strong>IIFEs</strong>) — did not solve the problem entirely since the code cannot be modularised and shared.</li><li>use of <a href="https://en.wikipedia.org/wiki/CommonJS"><strong>commonJs</strong></a> in nodejs — one of the solutions on modularisation. It meant code can be shared as packages and reused (e.g using js packages from npm). commonJs can be indentified with the use of require() and module.exports</li><li>tools like <strong>webpack </strong>and<strong> Babel</strong> — made it possible to use third party solutions by <em>transpiling</em> modules back to js code and <em>bundling</em> them.</li></ol><p><strong>After…</strong></p><p>Javacript modules were introduced in Ecmascript 2015(Es2015).</p><p>The keywords used are</p><ol><li>export — to export objects, functions, or primitives to a given file or module</li><li>import — to get code from other modules</li></ol><p>You can export and import a code from a file using two ways</p><ol><li><strong>Named export</strong> — as the name suggests, you are exporting something with a specific name.</li></ol><pre>export const name = &quot;John Doe&quot;<br>export function getName(){ <br>                return &quot;Jane Doe&quot;<br>}<br>export const person = {<br>name: &#39;Job Doe&#39;<br>}</pre><p>you can import the named exports as shown</p><pre><strong>import {name, getName, person} from &#39;./&lt;replacewithfilename&gt;&#39;;</strong> <br><em>// this imports indivual items,you can choose what to import.</em></pre><pre>or</pre><pre><strong>import {getName as giveMeTheNameNow} from &#39;./&lt;replacewithfilename&#39;</strong><br><em>// use name alias when importing.</em></pre><pre>or</pre><pre><strong>import * as fromLib from &#39;./&lt;replacewithfilename&gt;&#39; ;</strong><br><em>// this imports everything (e.g fromLib.name)</em></pre><p>2. <strong>Default export</strong> — used once in a file unlike named exports.</p><p>usually when you are exporting one value from a file or to create a fallback export.</p><pre>class HelloWorld{<br>....<br>}<br>export default HelloWorld</pre><p>to import the export defaults. <em>note: you don’t need the curly braces {}</em></p><pre>import HellowWorld from &#39;./&lt;replacewithfilename&gt;&#39;</pre><p><strong>finally…</strong></p><p>to add your modules to the html is as simple as adding a type to your script tag</p><pre>&lt;script type=&quot;module&quot; src=&quot;./a.js&quot;&gt;&lt;/script&gt;<br>&lt;script type=&quot;module&quot; src=&quot;./b.js&quot;&gt;&lt;/script&gt;</pre><p><strong>Bonus resource…</strong></p><p>To get a better understanding of module system in javascript.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FqJWALEoGge4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqJWALEoGge4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqJWALEoGge4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/62b4c8bf7306334599e8929fce11d0e4/href">https://medium.com/media/62b4c8bf7306334599e8929fce11d0e4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=625842eb7c17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python — setting up Django App]]></title>
            <link>https://medium.com/@jamalguyo08/setting-up-django-app-9c8845dfb413?source=rss-d2b09afe496d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c8845dfb413</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[pythondjangotutorial]]></category>
            <category><![CDATA[pipenv]]></category>
            <category><![CDATA[django-framework]]></category>
            <category><![CDATA[virtualenv]]></category>
            <dc:creator><![CDATA[Jamal Guyo]]></dc:creator>
            <pubDate>Sun, 02 Jan 2022 01:47:23 GMT</pubDate>
            <atom:updated>2022-10-16T12:58:53.540Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9WXJW0VDdQze37vg3tJcw.jpeg" /></figure><p>The following guide is on how to get started with Django for beginners.</p><h4>pre-requisite</h4><p>Make sure that you have python installed on your machine. Installation instructions for the latest python version can be found <a href="https://www.python.org/downloads/">here</a>.</p><p>The following instruction will show you how to get started with django using three different methods:</p><ol><li>using virtualenv</li><li>using pipenv</li><li>using poetry</li></ol><h4>Before we proceed…</h4><p>you need to understand what a virtual environment is and why we need it.</p><p>When you install python packages/modules they are stored globally by default. Every project you create with python will therefore reference the same global directory to retrieve the packages. This is all good and all but, what if you want to have different packages for different projects? what if you want to create a private package directory for each project so that they don’t conflict? This is where the virtual environment comes in.</p><p>A virtual environment is private/local environment separate from the global environment. The virtual environment will manage all the packages/modules privately for your specific project.</p><h3>1. using virtualenv</h3><p><em>By default, python comes with virtualenv to manage the packages for different environment. There is no need for installing it.</em></p><p>open your terminal and navigate to where you want to create your Django project</p><pre>cd &lt;project-folder&gt;</pre><p>Create a new virtual environment for the project. The virtual environment gives you an independent environment separate from the host operating systems environment. You will receive the message created virtual environment .... <em>don&#39;t forget the period sign at the end</em></p><pre>virtualenv -p python . | python3 -m venv &lt;nameofyourvirtualenv&gt;</pre><p>Activate the virtual environment we just created</p><pre>source bin/activate | source &lt;nameofyourvirtualenv&gt;/bin/activate</pre><p>and install Django using the pip command. pip is a package manager for python.</p><pre>pip install django</pre><p>Create a new Django project. <em>Again, don’t forget the period else an extra folder will be created for you</em>.</p><pre>django-admin startproject <em>&lt;name-of-your-project&gt;</em> .</pre><p>Finally, run your Django project</p><pre>python manage.py runserver</pre><h3>2. using pipenv</h3><p><em>Pipenv is a combination of PIP — python installer for python and virtualenv, hence the name “pip-env”. It handles the creation of a new virtual environment and the installation of packages for you. Just like yarn or npm in javascript, pipenv will create a lockfile and a file to manage the dependencies/packages/modules.</em></p><p>install pipenv — (on Linux)</p><pre>sudo apt install pipenv</pre><p>navigate to your project folder</p><pre>cd &lt;project-folder&gt;</pre><p>Install Django using pipenv. Pipenv will create the virtual environment for you and also install Django.</p><pre>pipenv install django</pre><p>start the created virtual environment</p><pre>pipenv shell</pre><p>Create your django project</p><pre>django-admin startproject <em>&lt;name-of-your-project&gt;</em>.</pre><p>run your project</p><pre>python manage.py runserver</pre><h3>3. using poetry</h3><p><em>poetry is a package manager for python. Poetry is to python as npm or yarn is to javascript.</em></p><p>install poetry on your machine using the poetry official docs <a href="https://python-poetry.org/docs/">here</a>.</p><p>navigate to your project folder</p><pre>cd &lt;project-folder&gt;</pre><p>Initialize poetry using the command below. This will create pyproject.toml a file that will have details about our project and its dependencies.</p><pre>poetry init</pre><p>start the created virtual environment</p><pre>poetry shell</pre><p>and install Django. Poetry will also create the virtual environment and start it for you and installs Django</p><pre>poetry add django</pre><p>create your Django project</p><pre>poetry run django-admin startproject <em>&lt;name-of-your-project&gt;</em>.</pre><p>Finally, run your project</p><pre>python manage.py runserver</pre><p><em>NOTE: to deactivate the virtual environment irrespective of the method you’ve used to create your django project type the following:</em></p><pre> deactivate</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c8845dfb413" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>