<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: lizardkinglk</title>
    <description>The latest articles on Forem by lizardkinglk (@lizardkinglk).</description>
    <link>https://forem.com/lizardkinglk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F484530%2F16b7e32f-1eb0-47c6-87f5-cef320638f0d.jpeg</url>
      <title>Forem: lizardkinglk</title>
      <link>https://forem.com/lizardkinglk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/lizardkinglk"/>
    <language>en</language>
    <item>
      <title>Custom JSON Validator</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Thu, 12 Jun 2025 14:24:45 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/custom-json-validator-5e86</link>
      <guid>https://forem.com/lizardkinglk/custom-json-validator-5e86</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;As a developer I want to make cool apps and learn the insides of systems and know how they behave. The goal is to become a better dev. So I found this coding challenges newsletter. It has many build your own challenges with references linked to resources. Step by step approach with, in each step describing the goals need to have or achieve in the solution.&lt;/p&gt;

&lt;p&gt;Building your own json parser is one of them. So I tried it and could achieve the goals.&lt;/p&gt;

&lt;p&gt;Below is the link for the challenge so you can check it out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codingchallenges.fyi/challenges/challenge-json-parser/" rel="noopener noreferrer"&gt;Build Your Own JSON Parser&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This challenge has the final target of validating JSON also known as syntactical analyzing AKA parsing.&lt;/p&gt;
&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;p&gt;There are many resources provided in the challenge page. For validating a syntactically correct JSON is that the JSON should follow the correct JSON grammar. These JSON grammar is provided in the challenge page with resource linked to below page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.json.org/json-en.html" rel="noopener noreferrer"&gt;Introducing JSON&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is another resource that points to a book called 'Dragon Book'. This dragon book describes everything about compilers. This parsing is an area or an early step of compiling a language.&lt;/p&gt;

&lt;p&gt;Also the challenge has provided some official test data I call them. You can access them in the challenge page.&lt;/p&gt;
&lt;h1&gt;
  
  
  Approach
&lt;/h1&gt;

&lt;p&gt;My approach to implementing the solution is using the test data given in each step and overcome the goal for that with TDD (Test Driven Development) approach.&lt;/p&gt;

&lt;p&gt;Started as a console app and increment the functionality in each step.&lt;/p&gt;

&lt;p&gt;Besides the official test data, each step has test data that is not enough for me and I thought I should add more tests. So I added custom test data as well.&lt;/p&gt;
&lt;h1&gt;
  
  
  How to do?
&lt;/h1&gt;

&lt;p&gt;To put it simply figuring how to is an incremental process and my tests failed with each change and debugging helped a lot. As an example I thought I can simply &lt;code&gt;trim&lt;/code&gt; the json string and use &lt;code&gt;split&lt;/code&gt; with commas to divide them and do the validation with the content in the splitted array.&lt;/p&gt;

&lt;p&gt;But it raised questions like whenever I split them it could be spliting them from the characters which might be inside a string literal. So I had to refigure. This took couple of iterations of figuring outs and I finally came up with a solution. &lt;/p&gt;

&lt;p&gt;That is if I started from first index and read every byte to the last index then I can choose which is valid json and which are not. If any byte contains invalid JSON then I stop the process and return failed error message to the user regarding the invalid json found. If not it is valid JSON and program ends with success.&lt;/p&gt;
&lt;h1&gt;
  
  
  Summarize steps
&lt;/h1&gt;

&lt;p&gt;To achieve the challenge I'm following these steps below.&lt;/p&gt;
&lt;h3&gt;
  
  
  1 Read the user's arguments from the Command Line
&lt;/h3&gt;

&lt;p&gt;These commands contain only the file path argument (so far) which points&lt;br&gt;
   to a text or json (preferably) file path.&lt;/p&gt;
&lt;h3&gt;
  
  
  2 Validate the path and read all of the content then put it to a Character array
&lt;/h3&gt;

&lt;p&gt;This JSON String acts as read-only variable throughout the execution.&lt;/p&gt;

&lt;p&gt;I put the content to a character array because if I simply used&lt;br&gt;
   the json string (which I previously did) I realised it&lt;br&gt;
   using more memory as I'm passing the string &lt;code&gt;jsonString&lt;/code&gt;&lt;br&gt;
   argument to many functions in the solution.&lt;/p&gt;

&lt;p&gt;The reason behind this is, strings acting as value types allocating more&lt;br&gt;
   memory for the copy of variable inside the function that gets passed to.&lt;br&gt;
   To avoid this, using a character array to store the JSON String was&lt;br&gt;
   an option because it behaves as reference types saving memory, avoiding&lt;br&gt;
   the overhead of copy operation.&lt;/p&gt;

&lt;p&gt;Another reason to use a character array is the ease of using indexes or&lt;br&gt;
   simply direct memory access.&lt;/p&gt;

&lt;p&gt;But there must be a caveat here as the size limitation for character array&lt;br&gt;
   could only be too much.&lt;/p&gt;

&lt;p&gt;I should handle it with a message to the user&lt;br&gt;
   or find a solution like separate it to different arrays to&lt;br&gt;
   validate as subtasks for bigger files.&lt;/p&gt;
&lt;h3&gt;
  
  
  3 Validate the starting character
&lt;/h3&gt;

&lt;p&gt;Then from the start, as the starting character there could be either,&lt;/p&gt;

&lt;p&gt;curly brace - '{'&lt;br&gt;
   square brace - '['&lt;br&gt;
   or a bunch of whitespace characters as the starting character.&lt;/p&gt;

&lt;p&gt;So my solution has a function named &lt;code&gt;ValidateNextCharacter&lt;/code&gt;&lt;br&gt;
   that goes to target character reading from a given index&lt;br&gt;
   of the array excluding the whitespace characters.&lt;/p&gt;

&lt;p&gt;All of the whitespace are ignored until the target character.&lt;br&gt;
   And there can be special characters including&lt;br&gt;
   backslash - '\'&lt;br&gt;
   alphabetical - a-z&lt;br&gt;
   symbols - '[!@#$%^*.]' etc.&lt;/p&gt;

&lt;p&gt;If any of it contain above non-whitespace characters&lt;br&gt;
   then validate it as invalid json as the target character&lt;br&gt;
   only could be either curly or square brace.&lt;br&gt;
   (Even in vscode the value literal itself could be valid json, &lt;br&gt;
   the challenge and json standard does not comply with that)&lt;/p&gt;
&lt;h3&gt;
  
  
  4 Validate JSON Object
&lt;/h3&gt;

&lt;p&gt;Let's assume the starting character is for a JSON Object&lt;/p&gt;

&lt;p&gt;scenario1&lt;br&gt;
   &lt;code&gt;{ "key1": "value1", "key2": "value2" }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As you can see, it contains key value pairs separated by commas&lt;br&gt;
   and should end with clossing curly brace.&lt;br&gt;
   (Don't forget the whitespaces)&lt;/p&gt;

&lt;p&gt;If it contains none of that then the json object should be like below.&lt;/p&gt;

&lt;p&gt;scenario2&lt;br&gt;
   &lt;code&gt;{}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So let's say the starting index is like below,&lt;/p&gt;

&lt;p&gt;current starting index being 2&lt;br&gt;
   This is for the first scenario with two key value pairs.&lt;br&gt;
   Character at this starting index is double quotes - '"'&lt;/p&gt;

&lt;p&gt;current starting index being 1&lt;br&gt;
   This is for the second scenario with no key values and no whitespaces.&lt;br&gt;
   Character at this starting index is close curly braces - '}'&lt;/p&gt;

&lt;p&gt;So we need to figure out which scenario path we should go.&lt;br&gt;
   In my soultion there is a function called &lt;code&gt;ValidateFirstOccuringCharacter&lt;/code&gt;&lt;br&gt;
   to check what character comes first between a character set&lt;br&gt;
   and another character.&lt;/p&gt;

&lt;p&gt;As an example for this scenario we need to call our method like below.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ValidateFirstOccuringCharacter(ref startIndex, [Quotes], CloseCurlyBrace)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In here, startIndex argument is passed by ref for modify it in a single place&lt;br&gt;
   in memory and the second arguemnt for parameter is the character set&lt;br&gt;
   as array that contains only quotes.&lt;br&gt;
   The last argument being the Close Curly Brace&lt;br&gt;
   which is expected as the second character.&lt;/p&gt;

&lt;p&gt;What we achieve by doing this is figuring out if&lt;br&gt;
   either the JSON Object contains key values&lt;br&gt;
   (if that is the case then our solution knows it by returning 0)&lt;br&gt;
   or &lt;br&gt;
   it returns 1 if there were no key value pairs found.&lt;/p&gt;

&lt;p&gt;Furthermore,&lt;br&gt;
   This validates whitespace characters&lt;br&gt;
   and returns -1 if illegal characters were found.&lt;/p&gt;

&lt;p&gt;If it returns 1 which means that is the&lt;br&gt;
   scenario2 - '{}'&lt;/p&gt;

&lt;p&gt;Then we can think the JSON is valid and the result is handled&lt;br&gt;
   to the user with the success message.&lt;br&gt;
   But what if there was a scenario3 which is an extension to scenario2.&lt;br&gt;
   What if the JSON object would look like this below?&lt;/p&gt;

&lt;p&gt;scenario3 - ' { } '&lt;br&gt;
   Not a problem. Validate whitespace and reach curly brace open.&lt;br&gt;
   Check for first occuring character to be either Quotes - '"' or&lt;br&gt;
   Close Curly Brace - '}'&lt;/p&gt;

&lt;p&gt;Can close as valid JSON but can we actually?&lt;br&gt;
   Without validating until the end of the file we can't be certian.&lt;br&gt;
   See the scenario4 below&lt;/p&gt;

&lt;p&gt;scenario4 - ' { } what? '&lt;br&gt;
   The word 'what?' is invalid json as we concluded the JSON Object as&lt;br&gt;
   valid and it cannot contain values outside of whitespaces.&lt;br&gt;
   So in my solution there is a function named&lt;br&gt;
   &lt;code&gt;ValidateLegalTrailing&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This validates if the last set of characters to be contain only whitespace.&lt;br&gt;
   So if 'what?' or any other illegal characters were found then&lt;br&gt;
   the solution handles as invalid.&lt;/p&gt;

&lt;p&gt;We can see that empty arrays - '[]' can also be validated or even&lt;br&gt;
   spacious arrays - ' [   ] ' using these functions implemented.&lt;br&gt;
   Let's look into arrays with values later.&lt;/p&gt;
&lt;h3&gt;
  
  
  5 Validating Keys
&lt;/h3&gt;

&lt;p&gt;In the previous JSON Object if keys were found then it should start with&lt;br&gt;
   double quotes everytime. We should iterate the key value pairs until&lt;br&gt;
   end of object that is Close Curly Braces - '}' were found. &lt;/p&gt;

&lt;p&gt;Each key value pair are validated. To validate the key,&lt;br&gt;
   the procedure is below.&lt;br&gt;
   Starting from the first character of the key until the end&lt;br&gt;
   of the key content iterate the characters for illegal characters.&lt;br&gt;
   In here starting index is the index of quotes + 1 and last being&lt;br&gt;
   closing quotes - 1. See below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       start index
       v
      "key1"
          ^
          end index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The invalid characters for the keys are &lt;br&gt;
   line breaks - '\n' and tab spaces - '\t'&lt;/p&gt;

&lt;p&gt;So if any of these were found then the key is invalid.&lt;br&gt;
   Also if someone used any special characters which start from backslash&lt;br&gt;
   then these characters should escaped which means they should be followed&lt;br&gt;
   by character set mentioned in JSON reference provided in the challenge.&lt;br&gt;
   See below.&lt;/p&gt;

&lt;p&gt;valid example but why put "\n" inside a key?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      "ke\ny1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(this is interpreted by backslash - '\' followed by a &lt;br&gt;
   line character - 'n') I use a simple regex to match every and all of the&lt;br&gt;
   whitespace characters, escape sequences &amp;amp; special unicode characters&lt;br&gt;
   which exist within a JSON key. See below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ^(\\[\\""/bfnrt]{1}|(\\u[0-9aA-fF]{4}))$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See an invalid example below.&lt;/p&gt;

&lt;p&gt;invalid example because of line breaks '\n'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      "ke &amp;lt;-- line break here
       y1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see another example&lt;/p&gt;

&lt;p&gt;invalid example because '\y' is not a valid escape character&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      "ke\y1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(this is interpreted as - '\y' character. But since '\y' is&lt;br&gt;
   not in the given set of special characters in the&lt;br&gt;
   the JSON reference so this is a invalid JSON key scenario.&lt;/p&gt;

&lt;p&gt;Same goes for tabspaces as well. Instead of line breaks this acts&lt;br&gt;
   as tabspaces. See below.&lt;/p&gt;

&lt;p&gt;invalid example because of tab spaces '\t'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      "ke   y1"
         ^
         actual tabspace here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that validating values for string literals in&lt;br&gt;
   the value validation these rules goes the same.&lt;br&gt;
   Let's look into that later.&lt;/p&gt;
&lt;h3&gt;
  
  
  6 Validating Values
&lt;/h3&gt;

&lt;p&gt;When it comes to JSON values that are used by not only JSON Objects&lt;br&gt;
   but also by JSON Arrays. They are validated by a common function that calls&lt;br&gt;
   separate and specific child functions in my solution.&lt;br&gt;
   These values starts with any of the below characters (or tokens)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Negative        '-' for number values
   CharZero        '0' for number values
   CharOne         '1' for number values
   CharTwo         '2' for number values
   CharThree       '3' for number values
   CharFour        '4' for number values
   CharFive        '5' for number values
   CharSix         '6' for number values
   CharSeven       '7' for number values
   CharEight       '8' for number values
   CharNine        '9' for number values
   Quotes          '"' for string values
   OpenCurlyBrace  '{' for object values
   OpenSquareBrace '[' for array values
   CharNullStart   'n' for null as value
   CharTrueStart   't' for true as value
   CharFalseStart  'f' for false as value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So our &lt;code&gt;ValidateNextCharacter&lt;/code&gt; should expect for a value within this array.&lt;/p&gt;

&lt;p&gt;The solution checks for exact match for values of &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;true&lt;/code&gt; &amp;amp; &lt;code&gt;false&lt;/code&gt;&lt;br&gt;
   by using a two pointers method that implemented in the function &lt;br&gt;
   &lt;code&gt;ValidateJsonValueForNullOrBool&lt;/code&gt;&lt;br&gt;
   These values must end with a Comma - ',' character&lt;br&gt;
   or a Close Curly Brace - '}' thus indicating no more key-value pairs.&lt;/p&gt;

&lt;p&gt;For string values as mentioned previously it uses the same function&lt;br&gt;
   implemented for key validation as well. String values must end&lt;br&gt;
   with a Quote - '"' character.&lt;/p&gt;

&lt;p&gt;For JSON Objects and JSON Arrays that appear as values they are validated&lt;br&gt;
   separately with functions and they use a recursion logic for validating &lt;br&gt;
   their children. More on that later.&lt;br&gt;
   Just like one above,&lt;br&gt;
   the termination character being either Comma - ','&lt;br&gt;
   or a Close Curly Brace - '}' for value found as JSON Object,&lt;br&gt;
   and either Comma - ','&lt;br&gt;
   or a Close Square Brace - ']' for value found as JSON Array.&lt;/p&gt;

&lt;p&gt;For validating numbers I read the content until the termination character&lt;br&gt;
   which are any values &lt;code&gt;',', '}', ']'&lt;/code&gt; or any whitespace character.&lt;br&gt;
   So the numeric value itself can be validated regardless of what being &lt;br&gt;
   the termination character. (Termination character and whatever after&lt;br&gt;
   is validated by the called parent).&lt;br&gt;
   Collected numerical content is then validated by a regular expression.&lt;br&gt;
   The number could be simple or a scientific one. All numbers&lt;br&gt;
   should follow decimal representation as the JSON reference does not allow&lt;br&gt;
   0b - binary or 0x - hexadecimal values. There is a&lt;br&gt;
   caveat here as when the number is too long it might cause performance&lt;br&gt;
   issue. So it should be handled. The regular expression is below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ^[-]{0,1}(0|([1-9]{1})([0-9]{0,}))(\.[0-9]{1,}){0,1}([eE][-+]{0,1}[0-9]{1,}){0,1}$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below are two great sources I use to practice and become&lt;br&gt;
   somewhat bearable at regex&lt;/p&gt;

&lt;p&gt;&lt;a href="https://regexone.com/" rel="noopener noreferrer"&gt;RegexOne&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://regexr.com/" rel="noopener noreferrer"&gt;RegExr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This regex matches for negative values and if not present&lt;br&gt;
   then its a positive.&lt;br&gt;
   i.e.&lt;br&gt;
   "-" as value is invalid. empty value (zero-length) for a value is invalid.&lt;/p&gt;

&lt;p&gt;Then checks for other characters which is any digit either 0 to 9&lt;br&gt;
   i.e.&lt;br&gt;
   "-0" as value is invalid. "0" is valid&lt;/p&gt;

&lt;p&gt;Then checks for multiple digits.&lt;br&gt;
   "-01" this is invalid as non-rational numbers in JSON cannot start with 0.&lt;br&gt;
   "-11" is valid. So is "12"&lt;/p&gt;

&lt;p&gt;Then checks if rational number. If not then checks if scientific part was&lt;br&gt;
   included. If a rational number then it must start with a Dot - '.'&lt;br&gt;
   If it has a sceintific part then it should follow a Letter E - 'e' both &lt;br&gt;
   cases included. Then it must follow one or many positive or negative number.&lt;br&gt;
   "0.1" is valid. "12.01" is valid.&lt;br&gt;
   "-1.1E" is invalid. "1.12e2" is valid.&lt;br&gt;
   "1.12e+1" is valid. "-12.01E-1" is valid.&lt;/p&gt;

&lt;p&gt;That concludes value validation logic.&lt;/p&gt;
&lt;h3&gt;
  
  
  7 Validate JSON Array
&lt;/h3&gt;

&lt;p&gt;To validate JSON string that is also a JSON Array is bit easier but not&lt;br&gt;
   as performant as validating objects since it checks for containment of &lt;br&gt;
   any character included in the value prefix array which has many&lt;br&gt;
   comparrison hits to take.&lt;/p&gt;

&lt;p&gt;So I need to start from reading empty whitespaces and then check&lt;br&gt;
   if an array  literal was found (Open Square Brace - '['). If found&lt;br&gt;
   then it should start the array validation logic.&lt;/p&gt;

&lt;p&gt;Simply following the above steps it validates each and every value reside&lt;br&gt;
   inside the array until a Close Square Brace - ']' was found.&lt;/p&gt;

&lt;p&gt;Also as mentioned above if Object or Array literal was found as&lt;br&gt;
   the value then it takes a function call to validate their children.&lt;br&gt;
   To make it further nested let's take below examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   {
     "key1": {
       "key1a": true,
       "key1b": {
         "key1ba": [
           1,
           null
         ]
       },
       "key1c": [
         true,
         false
       ]
     }
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In here "key1" has a JSON Object found as the value for its "key1a" key.&lt;br&gt;
   So "key1a" calls the function to validate its children just like their&lt;br&gt;
   parent ("key1") expected. And reports the result to called parent.&lt;br&gt;
   This uses self calls (recursion) inside child object to invoke&lt;br&gt;
   grandchildren to validate these results.&lt;br&gt;
   Also the start index continues from the ended position of child so it does&lt;br&gt;
   not need to travel back to the position where the parent of its child&lt;br&gt;
   first called to validate which is good.&lt;/p&gt;

&lt;p&gt;That concludes the steps this validation process takes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Testing
&lt;/h1&gt;

&lt;p&gt;I tested all the scenarios as mentioned above with &lt;code&gt;XUnit&lt;/code&gt;.&lt;br&gt;
   These includes default (step-wise tests), custom and official tests.&lt;br&gt;
   And those are also included in the repository.&lt;br&gt;
   No tests were added for utility functions as they were manually tested.&lt;br&gt;
   (Tests for these were added later for getting more test coverage)&lt;br&gt;
   Also I had to turn off parallel testing and enable collection per assembly&lt;br&gt;
   options in &lt;code&gt;XUnit&lt;/code&gt; because when executed with vscode it gave me at least&lt;br&gt;
   one error due to tests using shared resources (globals) internally.&lt;/p&gt;

&lt;h1&gt;
  
  
  Benchmarks
&lt;/h1&gt;

&lt;p&gt;It takes under half a second to validate a JSON file that is&lt;br&gt;
   the size of 10MB which I downloaded from the below source.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://examplefile.com/code/json/10-mb-json" rel="noopener noreferrer"&gt;Example File&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Besides the areas I need to cover for scaling up and performance these&lt;br&gt;
   results look good for a simple JSON parser/validator.&lt;/p&gt;

&lt;p&gt;But please note that sometimes under heavy load my pc performs slower&lt;br&gt;
   so the results can be vary from your device.&lt;/p&gt;

&lt;h1&gt;
  
  
  Notes
&lt;/h1&gt;

&lt;p&gt;Thanks to the team at Coding Challenges NewsLetter&lt;/p&gt;

&lt;h1&gt;
  
  
  Repository
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/lizardkingLK/coding-challenges/tree/main/jpTool" rel="noopener noreferrer"&gt;jPTool&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for Reading!&lt;/p&gt;

&lt;p&gt;Keep Coding ツ&lt;/p&gt;

</description>
      <category>intermediate</category>
      <category>json</category>
      <category>openformat</category>
      <category>codingchallenges</category>
    </item>
    <item>
      <title>YouTube's Metered Count</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Thu, 31 Oct 2024 07:08:23 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/youtubes-metered-count-31eb</link>
      <guid>https://forem.com/lizardkinglk/youtubes-metered-count-31eb</guid>
      <description>&lt;h1&gt;
  
  
  What is it?
&lt;/h1&gt;

&lt;p&gt;I had this need to understand how that youtube's view count thing works. I'm talking about that number digits on a video views going up with an animated scrolling while watching a video for a while.&lt;/p&gt;

&lt;p&gt;So I had to break it down using React and also made a react component as an npm package. Check it out &lt;a href="https://www.npmjs.com/package/react-metered-count" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Simple state update
&lt;/h1&gt;

&lt;p&gt;From the looks of it, it was simple, but it was not.&lt;br&gt;
Let's start from the begining.&lt;/p&gt;

&lt;p&gt;We have the parent component that calls to render the Metered count component.&lt;br&gt;
Its goal is to update the &lt;code&gt;count&lt;/code&gt; value whenever it needs to.&lt;/p&gt;

&lt;p&gt;So the child component (this metered count component) takes the new value as a prop and updates it to the latest value.&lt;/p&gt;

&lt;p&gt;This is simple without the animation part. Because when the prop value count updates and if we render it in the child component it gets updated by react.&lt;/p&gt;
&lt;h1&gt;
  
  
  Breaking it down
&lt;/h1&gt;

&lt;p&gt;It took me few hours to implement this using javascript but to do the same in react, was hard and took some time to comprehend.&lt;br&gt;
If you want to think through this problem and try now is the time.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;Let's break it down now.&lt;/p&gt;

&lt;p&gt;There are few steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Containerize the digits to a array for the value as &lt;code&gt;count&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Calculating the difference values as &lt;code&gt;steps&lt;/code&gt; between previous and current digits&lt;/li&gt;
&lt;li&gt;Animating each differences if the difference is greater than one&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using react we can have a useState hook to store the number as an object array.&lt;br&gt;
An object of this array contains properties &lt;code&gt;steps&lt;/code&gt; (which stores the difference of previous and current digit as a number) and the &lt;code&gt;content&lt;/code&gt; (which stores the new values to animate as a array)&lt;/p&gt;

&lt;p&gt;i.e.&lt;/p&gt;

&lt;p&gt;Let's say the value for &lt;code&gt;count&lt;/code&gt; by parent comes as 0. In youtube's terms let's say the views count is 0.&lt;br&gt;
So the containers array will be like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[{steps: 0, content: [0]}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this time let's say the count value goes up to 12. So what will happen now?&lt;br&gt;
The new containers value should be like this below after calculations of the differences of the digits (left to right of the number).&lt;/p&gt;

&lt;p&gt;old count value = '00'&lt;br&gt;
new count value = '12'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[{steps: 1, content: [0, 1]}, {steps: 2, content: [0, 1, 2]}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the graphic below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xbp2hcmq8wao1zxgi83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xbp2hcmq8wao1zxgi83.png" alt="Calculation graphic" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this graphical representation red square is the visible area. The overflowed area is hidden using css property &lt;code&gt;overflowY: hidden&lt;/code&gt;. It should also hide the scrollbar that comes with it.&lt;/p&gt;

&lt;p&gt;So the next thing to do is animating the change.&lt;/p&gt;

&lt;p&gt;With react, once the containers gets updated that change is listened by a useEffect hook that do the animation.&lt;/p&gt;

&lt;p&gt;To do this it requires an animate function that animates all the digits of a single container. In javascript, I handled this using &lt;code&gt;element.scrollTo&lt;/code&gt; function but in react I used &lt;code&gt;element.animate&lt;/code&gt; function that changes translatesY css property thus making the div go up.&lt;/p&gt;

&lt;p&gt;Note that &lt;code&gt;fill&lt;/code&gt; property for animation function needs to be &lt;code&gt;forward&lt;/code&gt; Otherwise the animation resets to previous value.&lt;/p&gt;

&lt;p&gt;See the graphic below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2wyxid1an2tabzma7uk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2wyxid1an2tabzma7uk5.png" alt="Animation graphic" width="800" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See the source code &lt;a href="https://github.com/lizardkingLK/react-metered-count" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for Reading! :)&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>DocsShare - Share Your documents</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Sun, 13 Oct 2024 16:44:35 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/docsshare-share-your-documents-2657</link>
      <guid>https://forem.com/lizardkinglk/docsshare-share-your-documents-2657</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/pinata"&gt;The Pinata Challenge &lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;A simple and private serverless file storage with sharable url provider&lt;br&gt;
Powered by Pinata files API + upload groups with ClerkJS authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs-share-two.vercel.app/" rel="noopener noreferrer"&gt;DocsShare - Demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyla7f5f0vo5jzmyuwkve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyla7f5f0vo5jzmyuwkve.png" alt="Upload UI" width="800" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famie8m7pm7ujoo36ubbs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famie8m7pm7ujoo36ubbs.png" alt="List UI" width="800" height="722"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/lizardkingLK/docsShare" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  More Details
&lt;/h2&gt;

&lt;p&gt;Pinata Files API&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authenticated user can upload and share files&lt;/li&gt;
&lt;li&gt;Users can select files to upload using drag and drop interface&lt;/li&gt;
&lt;li&gt;Pinata's files API with group functions (scaled per user) were used&lt;/li&gt;
&lt;li&gt;Signed urls sharable with friends with expiration time of 1 hour&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>pinatachallenge</category>
      <category>webdev</category>
      <category>api</category>
    </item>
    <item>
      <title>News posting website with AWS Amplify</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Mon, 27 May 2024 06:30:38 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/news-posting-website-with-aws-amplify-2oi8</link>
      <guid>https://forem.com/lizardkinglk/news-posting-website-with-aws-amplify-2oi8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/awschallenge"&gt;The AWS Amplify Fullstack TypeScript Challenge &lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Studious&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using AWS Gen 2 services, I developed an open-source news, blog, and post creation and publication application Studious. Users who have registered on this website can view news, draft and publish their own local news articles, and build their own. Add a variety of stuff, such as size-based text, urls for photos, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://main.d3w0oxjx7x9ipa.amplifyapp.com/" rel="noopener noreferrer"&gt;Studious App&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/lizardkingLK/studious-lamp" rel="noopener noreferrer"&gt;Source Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx6vubiyj40b0cutni22h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx6vubiyj40b0cutni22h.png" alt="News List" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0e71cqtezuuo7cx6dep9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0e71cqtezuuo7cx6dep9.png" alt="News Display" width="523" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;I developed this application using the next js (pages routes) for react framework.&lt;/p&gt;

&lt;p&gt;The following AWS services are used by this application&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data&lt;/li&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Serverless Functions&lt;/li&gt;
&lt;li&gt;File Storage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Connected Components and/or Feature Full&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This application also uses the Amplify UI React library for the frontend UI Framework, also with the auth and storage connected UI components which speeds up and simplifies development.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks for reading! 🤝🏿&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>awschallenge</category>
      <category>amplify</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Friendly Waffle 🧇</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Sun, 12 May 2024 10:54:29 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/friendly-waffle-81g</link>
      <guid>https://forem.com/lizardkinglk/friendly-waffle-81g</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/netlify"&gt;Netlify Dynamic Site Challenge&lt;/a&gt;: Visual Feast.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;This project demonstrates images which are statically saved and gets re-rendered based on the adjustments made by the form controls by user. This uses netlify's imagecdn features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://66409c783a5fbfa5789f0d38--friendlywaffle.netlify.app/" rel="noopener noreferrer"&gt;Click to Try&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gxoufb5rakywqlnmyj5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7gxoufb5rakywqlnmyj5.png" alt="Screenshot" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Platform Primitives
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Size width and height adjustments&lt;/li&gt;
&lt;li&gt;Format conversion from .jpg to .png&lt;/li&gt;
&lt;li&gt;Quality adjustments from 1 to 99&lt;/li&gt;
&lt;li&gt;Fit feature (uses cover)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading... 🧇&lt;/p&gt;

</description>
      <category>netlifychallenge</category>
      <category>devchallenge</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Hacktoberfest23</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Sat, 11 Nov 2023 14:33:34 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/hacktoberfest23-l4l</link>
      <guid>https://forem.com/lizardkinglk/hacktoberfest23-l4l</guid>
      <description>&lt;h2&gt;
  
  
  Contribution to Hacktoberfest 2023
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Intro
&lt;/h3&gt;

&lt;p&gt;Hacktoberfest has always been more than just a month-long celebration; it's a community-driven initiative that encourages collaboration, learning, and growth.&lt;/p&gt;

&lt;p&gt;It is a pleasure to announce that I have completed this year's event.&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/lizardkingLK" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F53265303%3Fv%3D4%3Fs%3D400" height="192" class="m-0" width="192"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/lizardkingLK" rel="noopener noreferrer" class="c-link"&gt;
          lizardkingLK · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          lizardkingLK has 52 repositories available. Follow their code on GitHub.
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg" width="32" height="32"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  Highs and Lows
&lt;/h3&gt;

&lt;p&gt;I was struggling to find some repos to contribute to because it was overwhelming at first. But finally, I could kick it off around the 2nd week.&lt;/p&gt;

&lt;p&gt;So I mainly focused on improving styling with techs like tailwindCSS. Starting from there I also worked on UI and date-related issue fixings.&lt;/p&gt;

&lt;h3&gt;
  
  
  Growth
&lt;/h3&gt;

&lt;p&gt;As a contributor, there are things to improve with the help of others in the community. So it is always important to ask what this does and this. They will help you out.&lt;/p&gt;

&lt;p&gt;Thanks for reading! ❤🎃🤟🏿&lt;/p&gt;

</description>
      <category>hack23contributor</category>
      <category>newbie</category>
    </item>
    <item>
      <title>Expense Tracker App</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Wed, 19 Jul 2023 22:36:42 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/expense-tracker-app-4pdc</link>
      <guid>https://forem.com/lizardkinglk/expense-tracker-app-4pdc</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;Expense and Income tracker using Supabase and Material UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sample-azure-gamma.vercel.app/" rel="noopener noreferrer"&gt;App&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5gyg5hm6gdxb8g43fc0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5gyg5hm6gdxb8g43fc0.png" alt="Screenshot" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;p&gt;As a first time user of refine.dev, trying refine was fun and it was maintainable as I go. It was actually reducing the development time compared to vanilla next app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/lizardkingLK/sample" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;p&gt;Apache-2.0 license&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Expense tracker is an app we can save our costs and incomes to not miss anything and spend with caution. This application's goal is to simplify it.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I built it
&lt;/h3&gt;

&lt;p&gt;MaterialUI components were refined using scaffolding, custom data provider, and inferencer for understanding components. Database connections and filters were utilized. &lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;

</description>
      <category>refinehackathon</category>
    </item>
    <item>
      <title>Cleaning an object</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Mon, 03 Jul 2023 13:34:56 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/cleaning-an-object-32em</link>
      <guid>https://forem.com/lizardkinglk/cleaning-an-object-32em</guid>
      <description>&lt;p&gt;Let's say we have a javascript object or JSON object literal that we use to do some task. And let's say those object values weren't predicted which means it can cause problems in the task execution due to nullish values. These nullish values may consist of the follwing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;undefined, null, ""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our goal is to change the given object to a clean record.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2mdss7ec6zvtywcxqqf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2mdss7ec6zvtywcxqqf.jpg" alt="suspended bridge , Pakding, Nepal" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://unsplash.com/@sebaspenalambarri" rel="noopener noreferrer"&gt;Photo by Sebastian Pena Lambarri&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's assume we are given the following object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj = {
    "foo": "",
    "bar": null,
    "max": undefined,
    "firstName": "John",
    "lastName": "Doe",
    "age": 42
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Points to consider
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;for-in loop&lt;/code&gt; takes an object and makes it an iterable of keys. In other words it returns the indexes/keys of that object. We can use this to iterate the object and access each element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The built-in function &lt;code&gt;includes&lt;/code&gt; uses to check if an element contains in the given array. In here we are using it to check if the value given available within the items we have.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The operator/function &lt;code&gt;delete&lt;/code&gt; removes an element/value by the key of the object given.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How to do it
&lt;/h3&gt;

&lt;p&gt;With this below function we can achieve our goal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (const i in obj) {
    if ([null, undefined, ""].includes(obj[i])) {
        delete obj[i];
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function demonstrates the points mentioned above. It iterates the object via the keys (for-in loop) and checks the value contains in the array given (includes). If so it removes the key-value pair from the object (delete).&lt;/p&gt;

&lt;p&gt;Finally we are left with the object containing clean values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ firstName: 'John', lastName: 'Doe', age: 42 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Roman to Integers</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Fri, 16 Jun 2023 18:22:32 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/roman-to-integers-1o5c</link>
      <guid>https://forem.com/lizardkinglk/roman-to-integers-1o5c</guid>
      <description>&lt;p&gt;Hello everyone!&lt;/p&gt;

&lt;p&gt;There is &lt;a href="https://leetcode.com/problems/roman-to-integer/" rel="noopener noreferrer"&gt;this&lt;/a&gt; leetcode challenge which is to convert roman numbers to integers. &lt;/p&gt;

&lt;p&gt;This is a beginner level problem I tried to solve and it was fun. &lt;br&gt;
You can try it before continuing with the post. Maybe you might come up with an efficient solution as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzjktas1yoogdiazo3yg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzjktas1yoogdiazo3yg.jpg" alt="Colloseum" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  &lt;a href="https://unsplash.com/@cadop" rel="noopener noreferrer"&gt;Photo by Mathew Schwartz&lt;/a&gt;
&lt;/h6&gt;

&lt;p&gt;Hope you are now familiar with the problem.&lt;br&gt;
Let's see our function that returns according integers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GetInteger(string roman)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch (roman)
{
  case "I": return 1;
  case "V": return 5;
  case "X": return 10;
  case "L": return 50;
  case "C": return 100;
  case "D": return 500;
  case "M": return 1000;
  default: return -1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Call it and output should give accurate results.&lt;/p&gt;

&lt;p&gt;But what if this input that is a string called roman was not a single letter? As an example "IX".&lt;/p&gt;

&lt;p&gt;If so the case should jump to default case and it has to be resolved.&lt;/p&gt;

&lt;p&gt;First let's make the input string a char array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char[] characters = roman.ToCharArray();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We assign the returning value as the integer value of last letter.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;number -&amp;gt; 'X' -&amp;gt; 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We are going to iterate from one before last to first of this char array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We take the current value as the integer value of current char.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;current -&amp;gt; 'I' -&amp;gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We take the previous value as the integer value of char to the right  of the current char.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;previous -&amp;gt; 'X' -&amp;gt; 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We add or subtract returning value if current value becomes more or less than the previous value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;current -&amp;gt; 1, previous -&amp;gt; 10, previous &amp;gt; current -&amp;gt; yes
number -&amp;gt; previous - current -&amp;gt; 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Therefore the returned value for IX becomes 9.&lt;br&gt;
This applies for any roman number given.&lt;/p&gt;

&lt;h5&gt;
  
  
  Source code below.
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static int GetInteger(char c)
{
    switch (c)
    {
        case 'I': return 1;
        case 'V': return 5;
        case 'X': return 10;
        case 'L': return 50;
        case 'C': return 100;
        case 'D': return 500;
        case 'M': return 1000;
        default: return -1;
    }
}

public static int RomanToInt(string s)
{
    char[] characters = s.ToCharArray();
    int number = GetInteger(characters[characters.Length - 1]);
    for (int i=characters.Length-2, previousValue, currentValue; i&amp;gt;=0; i--)
    {
        currentValue = GetInteger(characters[i]);
        previousValue = GetInteger(characters[i + 1]);
        number = previousValue &amp;gt; currentValue
            ? number - currentValue
            : number + currentValue;
    }
    return number;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>beginners</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Hourglass Problem</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Sun, 24 Apr 2022 06:42:22 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/hourglass-problem-e9a</link>
      <guid>https://forem.com/lizardkinglk/hourglass-problem-e9a</guid>
      <description>&lt;p&gt;This problem is based on a challenge on hackerrank. It is a bit tricky beginner level problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem is to find the maximum of all the hourglass shaped number sums in a given 2d integer array&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A 6 x 6 array (2d) is given.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you notice, there is hourglass shaped numbers.&lt;br&gt;
The first one is below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 1 1
  1
1 1 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sum of this hourglass is (1 + 1 + 1) + (1) + (1 + 1 + 1) = 7 &lt;br&gt;
7 being the largest.&lt;/p&gt;

&lt;p&gt;So now to the problem. You are given the below 2d array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-9 -9 -9  1 1 1 
 0 -9  0  4 3 2
-9 -9 -9  1 2 3
 0  0  8  6 6 0
 0  0  0 -2 0 0
 0  0  1  2 4 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to find the maximum sum of hourglass looking numbers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ek48yntcryompzv3lyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ek48yntcryompzv3lyn.png" alt="Some hourglasses" width="155" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this I have circled some hourglass looking numbers.&lt;/p&gt;

&lt;p&gt;Sum of Red hourglass is &lt;br&gt;
(-9 + -9 + -9) + (-9) + (-9 + -9 + -9) = -63&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fri6vixflnx42kplsfzht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fri6vixflnx42kplsfzht.png" alt="Sum of Red hourglass" width="155" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the rest of hourglass sums are like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-63, -34, -9, 12, 
-10,   0, 28, 23, 
-27, -11, -2, 10, 
  9,  17, 25, 18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The maximum hourglass is below. It's sum is 28&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngwiidhy9c9rjkq6mimo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngwiidhy9c9rjkq6mimo.png" alt="Sum of maximum" width="155" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So How do we calculate the maximum of the hourglass looking numbers ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should follow these steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loop through each index of the array.&lt;/li&gt;
&lt;li&gt;Find the hourglass sum of the each regional hourglass.&lt;/li&gt;
&lt;li&gt;If the current sum is higher than the previous, maximum = current.&lt;/li&gt;
&lt;li&gt;Print the maximum.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Starting from the first row first column is the index (0, 0). It contains the hourglass below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-9 -9 -9
   -9
-9 -9 -9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So you need to find the sum of this hourglass using another nested loop.&lt;/p&gt;

&lt;p&gt;Then the second hourglass is in the index of (0, 1). It contains the hourglass below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-9 -9  1
-9  0  4
-9 -9  1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sum is calculated in this second one too.&lt;/p&gt;

&lt;p&gt;If the second is higher than the first you can assign the maximum as the second sum. This is repeated until the end.&lt;/p&gt;

&lt;p&gt;But we should not need to go until the last element since at (0, 4) index and indexes after that we can't make a hourglass shaped numbers.&lt;/p&gt;

&lt;p&gt;And also for the row-wise it is invalid to go for (4, 0) index since hourglasses not shaped in thereafter.&lt;/p&gt;

&lt;p&gt;Find the source code using below link&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/lizardkingLK/hourglass_problem" rel="noopener noreferrer"&gt;https://github.com/lizardkingLK/hourglass_problem&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hackerrank</category>
      <category>beginners</category>
      <category>java</category>
    </item>
    <item>
      <title>HasAllChildren</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Sat, 19 Mar 2022 05:16:44 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/hasallchildren-55lh</link>
      <guid>https://forem.com/lizardkinglk/hasallchildren-55lh</guid>
      <description>&lt;p&gt;The below is a function to check if an sub array consist of all the elements of a given array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const hasChild = (array, child) =&amp;gt; {
    const ruleA = array !== undefined;
    const ruleB = child !== undefined;
    const ruleC = array.find(c =&amp;gt; c === child) === child;
    return ruleA &amp;amp;&amp;amp; ruleB &amp;amp;&amp;amp; ruleC;
}

const hasAllChildren = (array, subArray) =&amp;gt; {
    const ruleA = array !== undefined;
    const ruleB = subArray !== undefined;
    const ruleC = subArray
        .filter(c =&amp;gt; hasChild(array, c))
        .length === array.length;
    return ruleA &amp;amp;&amp;amp; ruleB &amp;amp;&amp;amp; ruleC;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, What this function &lt;code&gt;hasAllChildren(array, subArray)&lt;/code&gt; does when called is checking if all items match to be available in the array. &lt;/p&gt;

&lt;p&gt;Notice - This method does not check if these passed arrays are equal. It simply checks if the elements are available.&lt;/p&gt;

&lt;p&gt;First it checks all the arguments passed to our method are defined.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;array (original array)&lt;/li&gt;
&lt;li&gt;subArray (comparing array)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For each element we need to check if element is available in the array. We need &lt;code&gt;hasChild(array, child)&lt;/code&gt; to do this. It finds the element in the array and returns &lt;code&gt;true&lt;/code&gt; if found. For all &lt;code&gt;subArray&lt;/code&gt; elements it needs to return true;&lt;/p&gt;

&lt;p&gt;The reason to check if &lt;code&gt;undefined&lt;/code&gt; is that if not it returns &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If all elements contains we can say that count of all checked available items is equal to the original array's size.&lt;/p&gt;

&lt;p&gt;Finally we return if all rules and checks passed by returning &lt;br&gt;
&lt;code&gt;ruleA * ruleB * ruleC&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Thank for reading.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CSS with Superpowers</title>
      <dc:creator>lizardkinglk</dc:creator>
      <pubDate>Sat, 26 Feb 2022 09:47:22 +0000</pubDate>
      <link>https://forem.com/lizardkinglk/scss-or-css-with-superpowers-23mk</link>
      <guid>https://forem.com/lizardkinglk/scss-or-css-with-superpowers-23mk</guid>
      <description>&lt;h3&gt;
  
  
  What is SCSS ?
&lt;/h3&gt;

&lt;p&gt;Sass or Scss is a supertype of CSS (Cascading Style Sheets). Sass was officially described as CSS with superpowers. &lt;/p&gt;

&lt;p&gt;Sass and Scss are same in terms of what it does. It is okay to use one of the two for your project with your preference. &lt;/p&gt;

&lt;p&gt;The main difference between scss and sass is their  coding standards. Scss uses the standard css coding conventions whereas sass uses indentation and short hand methods.&lt;/p&gt;

&lt;h4&gt;
  
  
  .scss
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button {
   background-color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  .sass
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button
   background-color: red
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What SCSS do for us ?
&lt;/h3&gt;

&lt;p&gt;We use CSS to make our web pages structured , beautiful and responsive. SCSS helps to do this easily and in less time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features of SCSS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Nesting&lt;/li&gt;
&lt;li&gt;Mixins&lt;/li&gt;
&lt;li&gt;Inheritance&lt;/li&gt;
&lt;li&gt;Import&lt;/li&gt;
&lt;li&gt;Use&lt;/li&gt;
&lt;li&gt;Forward&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Variables
&lt;/h4&gt;

&lt;p&gt;Variables are used to allocate a key and a value for reusable values throughout an application. Easy to use when long text required as the value of the property because we don't need to remember it because we only need to use the variable name as the value. Dollar sign refers to variable names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$dark: #000000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Nesting
&lt;/h4&gt;

&lt;p&gt;Let's assume the below scenario in a html page given to you for style it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="myDiv"&amp;gt;
   &amp;lt;h1 class="myHeading"&amp;gt;Hello&amp;lt;/h1&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The css way of doing styles for this should be as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div.myDiv {
   background: red;
}

div.myDiv  h1.myHeading {
   color: white;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And as we can see the css selectors getting longer gradually when nested elements being added to our html. To address this issue we use nesting in scss. The scss solution is like below. By doing it this way we don't need to repeat the css selector (&lt;code&gt;div.myDiv&lt;/code&gt;) again and again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div.myDiv {
   background: red;

   h1.myHeading {
      color: white;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Mixins
&lt;/h4&gt;

&lt;p&gt;Mixins are css rulesets that are referenced in a scss  stylesheet that are usable as a function which returns that ruleset. It can involve passing with (parameters) or not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@mixin background-color($primary: red) {
   background-color: $primary;
}

div.myDiv {
   @include background-color(teal);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Inheritance
&lt;/h4&gt;

&lt;p&gt;Inheritance used to inherit styles from defined styles for elements or defined utility classes and override them using their class reference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.yourDiv {
   background-color: red;
   color: white;
}

.myDiv {
   @extend .yourDiv;
   text-decoration: underline;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;a class="mentioned-user" href="https://dev.to/import"&gt;@import&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Import functionality uses the adpotation of modular usage of css which means we can define stylesheets based on their responsibility and use them in a single scss file using &lt;code&gt;@import&lt;/code&gt; keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import 'typography';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;a class="mentioned-user" href="https://dev.to/use"&gt;@use&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;This functionality loads other css rulesets, mixins and variables defined in another sass stylesheet in scss stylesheet. &lt;a class="mentioned-user" href="https://dev.to/use"&gt;@use&lt;/a&gt; works like import as a variable reference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@use 'typography';

h3.myHeading {
   font-size: typography.$fs-m;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using it as opposed to import we can scope our rulesets from referencing with the stylesheet reference. As an example this helps if we have different dark and light css themes together to use.&lt;/p&gt;

&lt;h4&gt;
  
  
  @Forward
&lt;/h4&gt;

&lt;p&gt;This functionality loads scss stylesheets for use when there are nested imports need to take place. So when you need to use scss sheets in a main scss file this helps by loading it to use. This reduces your import statements and use statements you need in your stylesheet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@forward 'myVariables'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to apply SCSS ?
&lt;/h3&gt;

&lt;p&gt;SCSS is great in many ways but we can't use &lt;code&gt;.scss&lt;/code&gt; or &lt;code&gt;.sass&lt;/code&gt; files directly in our html using a link tag like we did with css. There is a procedure to convert scss files into css which is called precompiling scss to css. &lt;/p&gt;

&lt;p&gt;Precompilers get the scss files and convert them to css as you command. Then it gives the output as a css stylesheet which you can use in your application with a link tag. &lt;/p&gt;

&lt;p&gt;To use a precompiler we have few options.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;For static web apps use an &lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.live-sass" rel="noopener noreferrer"&gt;extension&lt;/a&gt; available for your IDE / Editor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For node based apps use an automated task runner like &lt;a href="https://www.npmjs.com/package/gulp-sass" rel="noopener noreferrer"&gt;gulp-sass&lt;/a&gt; which automatically watches for changes in your given directory and compile it at the same time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  When to use SCSS ?
&lt;/h3&gt;

&lt;p&gt;You can use scss rather than conventional css in,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stylings for single page web applications&lt;/li&gt;
&lt;li&gt;Stylings for enterprise level web applications&lt;/li&gt;
&lt;li&gt;When starting with a scss theme or to make a theme&lt;/li&gt;
&lt;li&gt;To modify css more in a html template before use&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Learn more about scss with following links&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sass-lang.com/documentation" rel="noopener noreferrer"&gt;https://sass-lang.com/documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.live-sass" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=ritwickdey.live-sass&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/gulp-sass" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/gulp-sass&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
