<?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 Khanya Keswa on Medium]]></title>
        <description><![CDATA[Stories by Khanya Keswa on Medium]]></description>
        <link>https://medium.com/@khanya.keswa?source=rss-a552ff7bc3d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*9mhHcT3_lYtyGGHUZ4UzSg.jpeg</url>
            <title>Stories by Khanya Keswa on Medium</title>
            <link>https://medium.com/@khanya.keswa?source=rss-a552ff7bc3d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 07:08:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@khanya.keswa/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[Chopping Up Strings w/ Regex]]></title>
            <link>https://medium.com/@khanya.keswa/chopping-up-strings-w-regex-fbf51b3e92d7?source=rss-a552ff7bc3d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbf51b3e92d7</guid>
            <category><![CDATA[regular-expressions]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Khanya Keswa]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 17:45:58 GMT</pubDate>
            <atom:updated>2022-12-15T17:45:58.364Z</atom:updated>
            <content:encoded><![CDATA[<h3>Regular Expressions in JavaScript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*BZ7PNciyqWeYXjPAm7l1Ow.gif" /><figcaption>Chop up strings with regular expressions</figcaption></figure><p><strong>Regular Expressions (or regex for short)</strong> represent a sequence of characters used to define a search pattern. The two most common use cases where you would want to use regex are validating input and searching through text. Regex syntax can be intimidating, but learning the basics can help you understand much more complex patterns.</p><h4>Creating a Regex</h4><p>The first thing you need to learn is how to create a regular expression. In JavaScript, a regular expression can be created in two ways:</p><ol><li>Using forward slashes:</li></ol><pre>const regex = /expression/flags</pre><p>2. Using ​​the RegExp constructor:</p><pre>const regex = new RegExp(&#39;expression&#39;, &#39;flags&#39;)</pre><p>The first syntax is cleaner and can improve performance, but if your regex expression is dynamic, meaning it can change over time or depend on some user input, you need to use the second syntax. The flags part of the expression will be explained below.</p><h4>Writing a Regex</h4><p>You’ve just created a regular expression, but what can you write inside?</p><p>A regular expression is formed from regular characters or a combination of simple and special characters.</p><p>You can find an exact match using regular characters, but the full power of regex comes after learning special characters. There are many special characters, but the most common would be:</p><ul><li><strong>^</strong> start of a string</li><li><strong>$</strong> end of a string</li><li><strong>\s</strong> — white space</li><li><strong>\d</strong> — digit</li><li><strong>\w</strong> — word character</li><li><strong>\S</strong> — not a white space</li><li><strong>\D</strong> — not a digit</li><li><strong>\W</strong> — not a word character</li><li><strong>.</strong> — any character</li><li><strong>* </strong>— 0 or more preceding characters</li><li><strong>+ </strong>— 1 or more preceding characters</li><li><strong>? </strong>-0 or 1 preceding character</li><li><strong>{m,n}</strong> — at least m, at most n occurrences of the preceding character</li><li><strong>|</strong> — logical or</li><li><strong>[abc]</strong> — range (a or b or c) [^abc] not in range (not a and not b and not c)</li><li><strong>[a-z] </strong>— character range from a to z</li><li><strong>[0–9] </strong>— number range from 0 to 9</li></ul><p>If you want to use a special character like a regular character to find an exact match you can escape it using a backslash.</p><p>In addition to the actual expression, you can define flags that allow you to do advanced searching. For example, if you want to check for all matches and not only the first one you can use the <strong>g</strong> flag. If you want to use case-insensitive search use the <strong>i</strong> flag. If you want multi-line search use the <strong>m</strong> flag and so on. These flags can be used separately or together in any order.</p><p>Let’s see these in an example. Let’s say you’re building a web application and you have a registration form. The user first enters a username which you need to validate. You first want the username to be at least 3 characters so you write:</p><pre>/^.{3,}$/</pre><p><strong>^</strong> matches the beginning of the string. Then comes <strong>.{3,}</strong> that represents any character 3 or more times. Finally, <strong>$</strong> means the end of the string.</p><p>But you figure out that you don’t want users to have usernames with unlimited characters, let’s limit the number of characters to 16.</p><pre>/^.{3,16}$/</pre><p>Seems good, but then we have usernames that look like this 3.??,@= so you decide to limit the characters to lowercase letters, numbers, or dashes.</p><pre>/^[a-z0-9_-]{3,16}$/</pre><p>Finally, you’re okay with users using upper case characters so you add a case-insensitive <strong>i</strong> flag to the end.</p><pre>/^[a-z0-9_-]{3,16}$/i</pre><p>And now you have a compact regular expression you can use anywhere for username validation!</p><h4>Implementing Regex in JavaScript</h4><p>After you’ve learned how to create and build a regular expression it’s time to use it. Using a regex differs from language to language, but in JavaScript the three most common functions would be:</p><ol><li><strong>test ()</strong> — checks if a pattern is present in a string, returns true or false</li></ol><pre>/a|b/.test(&#39;car&#39;) // returns true</pre><p>2. <strong>match()</strong> — checks matches in a string, returns an array containing all matches or null if none are found</p><pre>&#39;Quick Brown Fox&#39;.match(/[A-Z]/g) // returns [&#39;Q&#39;, &#39;B&#39;, &#39;F&#39;]</pre><p>3.<strong> search ()</strong> — checks for a pattern match in a string, returns the index of the first match or -1 if not found</p><pre>&#39;Brown Fox&#39;.search(/o/) // returns 2</pre><p>These would be the basics of regular expressions and knowing them will be a great addition to your skills. If you want to learn more you can use tools like <a href="https://regexr.com/">regexr</a> which lets you interactively test your regular expressions and provide a detailed explanation of each regex element.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf51b3e92d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“O Dear”… Basics of Big O]]></title>
            <link>https://medium.com/@khanya.keswa/o-dear-basics-of-big-o-e00a2a22b4b?source=rss-a552ff7bc3d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e00a2a22b4b</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Khanya Keswa]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 17:48:20 GMT</pubDate>
            <atom:updated>2022-12-08T17:48:20.150Z</atom:updated>
            <content:encoded><![CDATA[<h3>Big O Notation (using Ruby)</h3><p>Big O Notation allows us to calculate the worst possible runtime of an algorithm, or how long it takes the algorithm to complete. In other words, it informs us of how much it will slow down based on the input size. It’s always good to know how fast an algorithm runs because we always to achieve the fastest time efficiently. Moreover, it’s an important concept to know when doing coding interviews as it really shows your understanding of problem solving and efficiency. There are multiple runtimes or time complexities that Big O covers, but in this one, I’ll be covering four main time complexities:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLjSsLSwtBbx56GY-7ToGQ.jpeg" /><figcaption>Graph displays 4 time complexities to visually understand runtimes</figcaption></figure><p>Constant Runtime: “<strong>O (1)</strong>”</p><pre>arr = [3, 1, 6, 9, 10, 2]<br>def print_all(arr)<br>   puts &quot;#{arr[0]}&quot; # prints out 3<br>   puts &quot;#{arr[1]}&quot; # prints out 1<br>end<br>print_all(arr)</pre><p>The runtime of this method is constant or <strong>O (1)</strong>. The reason being is no matter how big the array gets, the number of operations we perform never changes. It’s constant. We’re just printing out the first and second index of the array every time.</p><p>Linear Runtime: “<strong>O (n)</strong>”</p><pre>arr = [3, 1, 6, 9, 10, 2]<br>def print_all(arr)<br>   arr.each do |num|<br>      puts &quot;#{num}&quot;<br>   end<br>end<br>print_all(arr)</pre><p>The runtime of this method is linear or <strong>O (n)</strong>. As you can see, we have a loop inside the method this time which iterates over the entire array and prints out the element. However, the number of operations this loop performs will change, because depending on the amount of elements inside the array, the loop will have to make the correct number of iterations based on the input size. An array of size 5 will take only 5 iterations whereas an array of size 10 will take 10 iterations, which is twice as long. So as input size increases, runtime will also increase.</p><p>Exponential Runtime: “<strong>O (n²)</strong>”</p><pre>def print_all(arr)<br>   arr.each do |letter1|<br>      arr.each do |letter2|<br>         puts &quot;#{letter1}&quot; + &quot;#{letter2}&quot;<br>      end<br>   end<br>end<br>print_all([&quot;A&quot;, &quot;B&quot;, &quot;C&quot;]) # prints out 9 pairs<br>print_all([&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;]) # prints out 16 pairs</pre><p>The runtime of this method is exponential or <strong>O (n²)</strong>. In this case, we have a loop inside a loop. Depending on the size of the array, the outer loop will make its first iteration, and then the inner loop will iterate over the ENTIRE array before it goes back to the second iteration of the outer loop and it will continue on until the outer loop reaches the end of the array. This runtime is very inefficient. When you have a large array, it’s best to avoid using algorithms that utilize this runtime because it will take extremely long. In the method, an array size of 3 will pdrint out 9 pairs, and an array size of 4 will print out 16 pairs: the loop has to <strong>square</strong> the amount of iterations based on the input size, hence why it’s called exponential runtime. Something with an array size of 100 will take 10,000 iterations…. and nobody wants that.</p><p>Logarithmic Runtime: “<strong>O (log n)</strong>”</p><p>I will not show a method for this as it’s better to explain it. Logarithmic runtime is an extremely efficient runtime. If an array had a size of 4000 elements, it will probably take only 12 operations to find what you are looking for as opposed to iterating over the entire array. An example that always has logarithmic runtime is Binary Search. Binary search works like this: let’s say you’re given an array that is ordered numerically or alphabetically. In this case, we’ll do a numerically ordered array.</p><pre>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</pre><p>Our goal is to find a certain number in this array, let’s say 9. Well, your first guess is probably to make a loop and just start from the beginning of the array to get there, but it’ll take 9 iterations for you reach 9, which will just make it a linear runtime. If you had an ordered array with 1..1000 and you wanted to find 999, you would have to literally iterate 999 times to get the number. But of course, binary search makes this easier by starting at the middle of the array. There are two middle values here but we’ll choose 5 and start from there. Then we look at the left and right of 5. Is the value 9, that we’re searching for, to the left or right of 5? 9 is at the right of 5, so we ignore the left side of 5 and go start at the middle of the right half of 5.</p><pre>[5, 6, 7, 8, 9, 10]</pre><p>Now we’re searching through a shortened part of the array. And we just repeat the same process! Let’s look at the middle of this array, we’ll choose 8 for this one. Then, we look to the left and right of 8. 9 is at the right of 8, so we completely ignore the left side of 8 and now we’re searching through an even more shortened array.</p><pre>[8, 9, 10]</pre><p>Again, we start at the middle of the array, which is 9. But look, the middle of the array starts with 9, the value we’re looking for! So now we can just retrieve that value easily. This literally took 3 operations when the array had an input size of 10.</p><p><strong>Conclusion</strong></p><p>Knowing the runtimes of algorithms and how to improve them is why Big O Notation exists. Developing more efficient algorithms leads to faster runtimes and less code (space complexity). (I only went over the time complexity aspect of Big O, but there’s also space complexity which I may do in a future blog.) And like I said before, this doesn’t cover everything in Big O time complexity wise as I only covered the fundamentals and the most common ones so don’t take everything here as “<em>oh that’s it about Big O, now I’m set for coding interviews!</em>”. Just be sure to do some research on the other runtimes and how other algorithms exemplify that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e00a2a22b4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Key to Keyframes]]></title>
            <link>https://medium.com/@khanya.keswa/the-key-to-keyframes-fbfbb2959807?source=rss-a552ff7bc3d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbfbb2959807</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-design]]></category>
            <dc:creator><![CDATA[Khanya Keswa]]></dc:creator>
            <pubDate>Wed, 23 Nov 2022 17:20:20 GMT</pubDate>
            <atom:updated>2022-11-23T20:59:42.889Z</atom:updated>
            <content:encoded><![CDATA[<p>Pacing Animations in CSS: A Quick Guide</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*tDHzF_bdyUx3826ep3T8Bw.png" /></figure><p>A static webpage, in terms of design ingenuity and visual appeal, can only take you so far in terms of immersion of user experience. As humans we’re drawn to beauty in both aesthetic as well as movement, and so as developers constructing front-end experiences it’s up to us to capitalize on this tendency. CSS, and even further SCSS possesses a phenomenal range of tools and capabilities to breathe life into otherwise rigid user interfaces. One of those tools is the obvious: the “animation” property, which is shorthand for a full list of sub-properties crucial to customizing and personalizing the nature of how your DOM visually behaves. Animations do far more for an app experience than simply increasing complexity on the screen or establishing the perception of broad-stroke “activity”. Far more importantly, animations can be implemented to guide a user along a more intuitive and well thought-out user flow outside of simply following text-based instructions or adhering to crudely specified prompts. In addition, as a consequence of the inherent lack of dimensionality of a computer or phone screen, improving the perception of “tactility” or weight to the interactions to be found across the UI is immediately powerful and easy to pick up on as a new viewer.</p><p>As things stand, it certainly helps that a simple google search will yield countless references, examples, and generators online of CSS animations ranging from infinitely looping to interaction driven. A few excellent catalogue of CSS animations can be found through the following websites:</p><ul><li><a href="https://css-tricks.com/">CSS-Tricks</a></li><li><a href="https://www.webdesignerdepot.com/">Web Designer Depot</a></li><li><a href="https://animista.net/">Animista (A Personal Favorite)</a></li><li><a href="https://coolcssanimation.com/">Cool CSS Animation</a></li></ul><p>I thoroughly encourage hopping into a sandbox and implementing as wide a range as possible of these animations. From there I further encourage adjusting/recreating the more complex animation examples suit your fancy. Ultimately, I would follow the breadcrumbs along to the concept of keyframes, and how they are used to manipulate both the timing and direction of an animation’s progression.</p><figure><img alt="KEYFRAME DEFINITION What is a keyframe? A keyframe, also written as “key frame,” is something that defines the starting and/or ending point of any smooth transition. That something can be a drawing in animation or a particular frame of a shot when dealing with film or video. Any shot, animated or live-action, is broken down into individual frames." src="https://cdn-images-1.medium.com/max/1024/1*Bv-KDRzUn3Gv5eHTEfwnnA.png" /></figure><p>Keyframes are essentially what allow us to breakdown and map an animation into seperate, though continuous sequences that flow into one another by adjusting key visual attributes like transformation or visibility.</p><p>For example, we might use keyframes in the simplest interpretation possible, using the identifiers “from” and “to”, to define the beginning and end of an animation cycle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UiOBL8dWKj4H0fGgYSy7fA.png" /></figure><p>Essentially, we’re linking the animation to an element of class “.box” and defining the keyframes of “from” and “to” using the “opacity” property. Ultimately, this should toggle the visibility of the element depending on the timing function, duration, and repetition we further define in the “animation” property above.</p><p>Keyframes however allow far more precision than just the beginning and end of an animation cycle. Shown below is an example of how we might distribute the opacity changes over multiple keyframes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ci0P3InJTGRUZLfec3EuJA.png" /></figure><p>In a single animation cycle, in the above you’re able to alternate its opacity between several intermediate keyframes to create a more intricate visual. What’s important to consider and what may make the biggest difference between a frantic, aimless transition and a smooth, appealing one is first clearly visualizing the “steps” you envision that particularly element progressing through before setting the “pace” of the property changes between keyframes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbfbb2959807" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Illustration as a Conversation:]]></title>
            <link>https://medium.com/@khanya.keswa/illustration-as-a-conversation-b470f3608418?source=rss-a552ff7bc3d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b470f3608418</guid>
            <category><![CDATA[wireframing]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Khanya Keswa]]></dc:creator>
            <pubDate>Mon, 14 Nov 2022 16:34:59 GMT</pubDate>
            <atom:updated>2022-11-17T17:07:57.391Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wireframing as a Tool to Code Collaboratively</h3><h4>Wireframing is Web Development 101: What More Am I Missing?</h4><p>Wireframing can have a broad connotation and a similarly broad assessment of importance to the the process of collaboration, especially for software development. Speaking from the standpoint of someone with an extensive background in hardware design, I can think of numerous occasions in which wireframing user experiences embedded in the product uncovered profound and immediately transmissible insights related to the overall physical design. Admittedly, and at risk of stating the obvious, wireframing is an already widely utilized tool meant to kickstart the visual development of a product. However, what I feel may be occasionally overlooked is the potential of basic wireframing as a vessel in which to conversationally conduct product planning, especially when it boils down to the user flow through an app experience.</p><p>The benefit of wireframing to prototype software experience is self-evident. It’s an instant visualization of a product that maintains a necessary degree of malleability so as not to inhibit organic evolution towards said product’s final iteration. In addition to it being an accessible and demonstrative medium through which to cultivate team cohesion, it serves as an excellent promotional tool for drawing attention and commitment from those involved.</p><p>Nevertheless, wireframe prototyping can quickly snowball into a higher fidelity example of a user experience to the detriment of higher-level team coordination. This is often the case due to the pressures of timeline and meeting the routine benchmarks of an MVP for the sake of attaining a modest sensation of “productivity”. The intent is often easily obfuscated when this task becomes a singular one reserved for a UX designer as an isolated deliverable. So understanding this tendency, wireframing in a group setting/workshop should yield a sufficiently conceptual and less technical result from this exercise. Instead of a documented reference of a project’s intent/layout, a wireframe could serve as an especially engaging fabric for discussion and a suitable starting point for collaboration around a project’s future goals.</p><p>There exists a verifiable glut of tools and apps already accessible to the layman that are easy enough to adapt to and understand for the sake workshopping. Among them are platforms like Anima, Figma, and Miro, which though geared towards further specialization of product prototyping provide a seamless suite of tools to begin the “spitballing” process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KCKK6uSJ-K6QBWaLeduNBg.png" /><figcaption>Anima has built-in live collaborative tools</figcaption></figure><p>In addition to Anima, in favor of a more live-collaboration wireframing experience there’s Miro, a prototyping tool with albeit very simplistic creative capabilities is excellent for getting a number of eyes and ears in a room to talk shop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yJqpcjFBxxiXoeO2m8zq2A.gif" /><figcaption>Miro is immensely helpful when conductions larger workshops.</figcaption></figure><p>Ultimately, what these wireframing tools and others present as a discernible benefit over other ways of setting a unified vision for a project is visualizing the thoughts and goals of all parties involved, and in a way that is seamless to reference back to later outside of your typical meeting notes or recordings.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b470f3608418" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>