[{"content":"A simple c program to analyze text file.\nLook into ==strtok_r== or ==strchr== Data Strcuture: ==linkedList== or ==hash table==\nNew post test.\n","date":"2026-03-09T00:00:00Z","image":"https://plus.unsplash.com/premium_photo-1685086785636-2a1a0e5b591f?q=80\u0026w=2832\u0026auto=format\u0026fit=crop\u0026ixlib=rb-4.0.3\u0026ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D","permalink":"/post/text-file-analyzer/","title":"Text File Analyzer"},{"content":"The ordered list is the collection of items where each items maintains it\u0026rsquo;s position unlike Unordered list. The ordering of the item is typically ascending and descending and we assume that items are ordered with meaningful comparison operation.\nOperations of Ordered List OrderedList(): Creates new ordered list that is empty. Returns empty list. add(item) : adds a new item to the list maintaining the order. Returns nothing. remove(item): removes the item from the list , assuming the item is present in the list. Returns boolean(True or False) search(item): Searches for the item in the list. Returns boolean(True of False). is_empty(): Test to see whether the list is empty. Returns boolean. size(): Returns the number of the item in the list. index(item): Returns the position of the item in the list. pop(): Removes and returns the last item in the list. pop(pos): Removes and returns the position at the position pos. How to search in the list? Since the list is ordered it is pretty straight-forward to search through the list. There are two things we need to consider, item the data or the value that we are searching for and current.data the data or the value of the current node.\n","date":"2025-01-22T00:00:00Z","image":"https://miro.medium.com/v2/resize:fit:1024/1*wA75yhv1kptx0bW_c9ooAQ.jpeg","permalink":"/post/the-ordered-list-implemenatation/","title":"The ordered list implemenatation"},{"content":"Before learning about promise it\u0026rsquo;s important to know what Asynchronous programming .\nIn asynchronous programming, the program continues to execute tasks without waiting for other program to complete any task. It is independent and it uses callbacks, ==promises== to wait for the tasks. This technique allows the program to run concurrently and use resources efficiently.\n\"I Promise a Result!\" \"Producing code\" is code that can take some time\n\"Consuming code\" is code that must wait for the result\nA Promise is an Object that links Producing code and Consuming code\n\u0026nbsp; \u0026#9432; Note: Arrow function expressions can have an implicit return; so, () =\u0026gt; x is short for () =\u0026gt; { return x; } . A simple example code in Javascript We are using fetch API to get the data from the endpoint and then chaining the result.\nHow it works First the fetch return a promise that resolves to Response object if success or Reject if failed. Our first .then block processes the resolved Response object.Here either error or the promise is thrown. Our second .then block processes the parsed JSON data. Our last chain catches error if there\u0026rsquo;s any. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 let jsonData; const items = fetch(\u0026#39;https://dummyjson.com/products\u0026#39;) //returns a Response or Reject Promise object. .then(response =\u0026gt; { if(!response){ throw new Error(\u0026#39;Response network error\u0026#39;); //returns error } return response.json(); // returns json promise }) .then(data =\u0026gt; { jsonData = data; }) .catch(error =\u0026gt; { console.error(error); }); console.log(\u0026#34;jsonData: \u0026#34;+jsonData); // output: undefined [i.e this gets executed before the data is assigned to the jsonData] Our above example is a good example of using promise but there is a small bug where the data is not stored correctly in the jsonData variable.\nWhy the heck is the data not being stored in our variable?\nThis is because the whole point of promise is to let other synchronous code run and not block the rest of the program to execute. It is a feature and not a bug.\nLet\u0026rsquo;s understand this when the fetch() function is called , it is supposed to return a new Promise object, which takes times as it has to connect to the network and get the data right? So, our code doesn\u0026rsquo;t get blocked, it instead leaves all the things inside the fetch() function like other .then() and .catch() to run later after the fetch() resolves the result and directly moves to execute other part of the code, which in our case is console.log(\u0026quot;jsonData: \u0026quot;+jsonData); since nothing has been returned by the promise yet the output results to undefined\nHow to fix this ? The easiest fix is to log the data inside the second .then block, which then makes sure that the data is initialized and logged only after.\n1 2 3 .then(data =\u0026gt; {\tconsole.log(data); }) \u0026#9432; Note: We can also use Async/Await to solve the problem, but that's something new to learn. \u0026nbsp; Summary In short, promise is a easer and more cleaner way to write asynchronous functions , avoiding callback hell , more maintainable code and other many advantages over class callback functions!\n","date":"2024-12-31T00:00:00Z","image":"/images/promise_thumbnail.jpg","permalink":"/post/how-to-use-promise-in-javascript/","title":"How to use Promise in Javascript"},{"content":"Understanding Unordered List The simplest way to describe about unordered list is it is a container of items with no ordering, meaning it can be anywhere on the container. This list contains a collection of individual nodes that has pointer to another node. It is important to know about Node before learning unordered list.\n\u0026#9432; Node: A node is a container which has two fields [data, next]. Data contains the actual value on the node and next contains the pointer to the next node if there is any otherwise it contains null. To understand it more clearly here is the figure that explains the entire analogy of Singly unordered list aka. Singly Linked List. We have list of items that starts with 5 also known as head of the list, which then points to the other data of the list.\nThings to point\nEach item on the list is a node not an individual data, where node contains both data and the pointer to another node known as next. The only reference of the list is set by the head which points to the latest node inserted. The list which is created only knows the head of the whole linked list so there is no way to get the value by index. How to add a node to the list? There are many ways to add data to the list, we can add either way , to the front or to the end of the list. The order of the list is not important as this is unordered. Here i will show you how to add to the front of the list i.e the head of the list. Since we already know the head of the list as the only reference to the list is the head. We do the following to add the item to the list.\nCreate a node with data, and the pointer to null. We need to store this on some variable because we need to point it\u0026rsquo;s next to the current head of the list. Then we point the next of the temp to the current head and then assign the head to the temp. Python code to implement the list 1 2 3 4 def add(self, data): temp = Node(data) temp.set_next(self.head) self.head = temp \u0026#9432; Time Complexity: Since we only have to work with the first pointer the time complexity is O(1). Getting the size of the List How do we get the size of the list? Can you try and think of a solution to get the size? The most obvious thing that comes to mind is going through all the nodes and counting them right? YES! that\u0026rsquo;s the solution. How do we implement that? 1. First thing is we need something to store the count of the list. 2. Then we start from the head (because we only have head as the reference of the list) 3. We then go step by step and increase the count of the variable until we hit the null pointer of the Node. 4. When we hit the null we stop and return the count of the list.\nPython code to implement the list 1 2 3 4 5 6 7 def size(self): count = 0 current = self.head while current != None: count += 1 current = current.get_next() return count ","date":"2024-12-30T00:00:00Z","image":"https://miro.medium.com/v2/resize:fit:1024/1*wA75yhv1kptx0bW_c9ooAQ.jpeg","permalink":"/post/the-unordered-list-singly-linked-list-implementation/","title":"The Unordered List (Singly Linked List) Implementation"},{"content":"****# How do we write clean code? To write clean code, follow the Don\u0026rsquo;t Repeat Yourself (DRY) principle and keep your code modular. Use meaningful variable names, functions, and comments to explain complex logic. Avoid deep nesting and use whitespace effectively to improve readability. This will make your code maintainable, efficient, and easy to understand.\nHow to write clean python codes. When it comes to writing clean code, there are several best practices that can help improve the quality and readability of your Python code. One important aspect is to use meaningful variable names. Instead of using single-letter variables like x or y, consider using more descriptive names like user_age or product_price. Another key principle is to keep your code organized and structured. Use functions, classes, and modules to break down complex logic into smaller, manageable pieces. This makes it easier for others (and yourself!) to understand what the code is doing. For example, instead of writing a long, convoluted function like this:\n1 print(\u0026#34;Hello world!\u0026#34;) Function with a clear and descriptive name. This makes the code more readable and maintainable. Similarly, when it comes to formatting your code, use consistent indentation and spacing to make it easier to read. Avoid using too many lines of code or complex logic that\u0026rsquo;s hard to follow. By following these best practices, you can write clean, readable, and maintainable Python code that makes it easy for others (and yourself!) to understand what it does.\nWorking in reverse, this is the logic that we apply to good integration and deployment: one PR, one change. Shipping isolated, atomic changes means that if something goes wrong, we can disambiguate based on time because we can pinpoint the change that caused a change in behaviour.\nCode Blocks Code block with backticks 1 2 3 4 5 6 7 8 9 10 \u0026lt;!doctype html\u0026gt; \u0026lt;html lang=\u0026#34;en\u0026#34;\u0026gt; \u0026lt;head\u0026gt; \u0026lt;meta charset=\u0026#34;utf-8\u0026#34;\u0026gt; \u0026lt;title\u0026gt;Example HTML5 Document\u0026lt;/title\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;p\u0026gt;Test\u0026lt;/p\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; Code block indented with four spaces \u0026lt;!doctype html\u0026gt; \u0026lt;html lang=\u0026quot;en\u0026quot;\u0026gt; \u0026lt;head\u0026gt; \u0026lt;meta charset=\u0026quot;utf-8\u0026quot;\u0026gt; \u0026lt;title\u0026gt;Example HTML5 Document\u0026lt;/title\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;p\u0026gt;Test\u0026lt;/p\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; Code block with Hugo\u0026rsquo;s internal highlight shortcode 1 2 3 4 5 6 7 8 9 10 \u0026lt;!doctype html\u0026gt; \u0026lt;html lang=\u0026#34;en\u0026#34;\u0026gt; \u0026lt;head\u0026gt; \u0026lt;meta charset=\u0026#34;utf-8\u0026#34;\u0026gt; \u0026lt;title\u0026gt;Example HTML5 Document\u0026lt;/title\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;p\u0026gt;Test\u0026lt;/p\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; Diff code block 1 2 3 4 5 [dependencies.bevy] git = \u0026#34;https://github.com/bevyengine/bevy\u0026#34; rev = \u0026#34;11f52b8c72fc3a568e8bb4a4cd1f3eb025ac2e13\u0026#34; - features = [\u0026#34;dynamic\u0026#34;] + features = [\u0026#34;jpeg\u0026#34;, \u0026#34;dynamic\u0026#34;] List Types Ordered List First item Second item Third item Unordered List List item Another item And another item Nested list Fruit Apple Orange Banana Dairy Milk Cheese Other Elements — abbr, sub, sup, kbd, mark GIF is a bitmap image format.\nH2O\nXn + Yn = Zn\nPress CTRL + ALT + Delete to end the session.\nMost salamanders are nocturnal, and hunt for insects, worms, and other small creatures.\nHyperlinked image ","date":"2024-12-29T00:00:00Z","image":"https://plus.unsplash.com/premium_photo-1685086785636-2a1a0e5b591f?q=80\u0026w=2832\u0026auto=format\u0026fit=crop\u0026ixlib=rb-4.0.3\u0026ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D","permalink":"/post/a-new-post-on-programming-topic/","title":"A New post on Programming topic"},{"content":"How do we become more active and get things done? 1 2 3 if(life == \u0026#34;OK\u0026#34;){ return \u0026#34;Life is doing okay\u0026#34; } Writing Markdown is not easy but doing it consistently will help me , make my writing habit good.\nPython C# Java What is this? is this block quote? This should be the paragraph right? My favourite search engine is [Duck Duck Go] (https://duckduckgo.com).\nCreating a simple table S.N Name 1 Nitesh Raya 2 Ayon Rai \u0026hellip;.. [!Whaat?] Callout Title Callout Contents\n****** Updated Blog\n","date":"2024-12-29T00:00:00Z","image":"https://plus.unsplash.com/premium_photo-1682308170035-ec5ef069ee10?q=80\u0026w=3014\u0026auto=format\u0026fit=crop\u0026ixlib=rb-4.0.3\u0026ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D","permalink":"/post/how-to-learn-anything/","title":"How to learn anything?"}]