<?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 Leekhitame on Medium]]></title>
        <description><![CDATA[Stories by Leekhitame on Medium]]></description>
        <link>https://medium.com/@leekhitame?source=rss-c6e00383ab1d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ii_JGwka7hSETShSet6vbA.jpeg</url>
            <title>Stories by Leekhitame on Medium</title>
            <link>https://medium.com/@leekhitame?source=rss-c6e00383ab1d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:44:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leekhitame/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[Extract Transform Load (ETL)]]></title>
            <link>https://medium.com/the-repo/extract-transform-load-etl-12b779edbb49?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/12b779edbb49</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Thu, 17 Sep 2026 13:23:45 GMT</pubDate>
            <atom:updated>2026-09-17T13:23:45.399Z</atom:updated>
            <content:encoded><![CDATA[<p>Extract Transform Load or Extract Load Transform, which process might you choose?</p><p>It is an automated data engineering process that collects data from various sources, transform them in clean and structured format and store it dedicated warehouse or a targeted storage system which can be use for reporting, analysing and business intelligence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JuZVEFKcsfXlZpqD" /></figure><p>Its key stage is in its name itself:</p><ol><li>Extract</li></ol><p>At first, we extrac data from various sources like CSV files, APIs, Relational DB and keep them in staging area.</p><p>2. Transform</p><p>From that staging area, these data is is transformed to clean and universally structued format. Data should be filterized, sort, agregate rows and join distinct datasets together.</p><p>3. Load</p><p>Now, the transformed data should be load in centralized storage system. Storage system could be in cloud like Amazon Redshift, Snowflake, Bigquery etc. from where it can become reporting and analytics read for business intelligence.</p><p>There is another way to perform these steps which is ELT.</p><p>In ELT, we load first then transform the load data. This process is good if we need agility in re-transforming historical data.</p><p>Why choose ETL?</p><p>If the data is sensitive that cannot enter the warehouse legally or complex non-SQL business rules then we can transform it then load to the storage system.</p><p>Enjoy Your Life</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12b779edbb49" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-repo/extract-transform-load-etl-12b779edbb49">Extract Transform Load (ETL)</a> was originally published in <a href="https://medium.com/the-repo">The Repo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A step deeper in SQL: IV]]></title>
            <link>https://blog.devgenius.io/a-step-deeper-in-sql-iv-43fa07dbc49e?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/43fa07dbc49e</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[advanced-sql-techniques]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 15:32:36 GMT</pubDate>
            <atom:updated>2026-09-16T11:38:26.721Z</atom:updated>
            <content:encoded><![CDATA[<p>Here, we discuss about Advance SQL: CTEs, Views and Window Functions</p><h3>CTEs</h3><ul><li>Common Table Expressions</li><li>It is a temporary table result set with a <strong>WITH </strong>clause which exists only the duration of one query.</li><li>It is a complex piece of readable name instead of a chain of nested parenthesis.</li><li>You can reference it, more than once in the outer query</li></ul><p>Example:</p><pre>WITH or_em_total AS (<br>  SELECT e.employee_id, e.full_name, sum(o.amount) AS total_sales<br>  FROM employees e<br>  JOIN orders o ON o.employee_id = e.employee_id<br>  GROUP BY e.employee_id, e.full_name<br>)<br>SELECT * FROM or_em_total<br>WHERE total_sales &gt; 15000<br>ORDER BY total_sales DECS;</pre><p>There is subquery also which can make the same things done but CTEs is much more systematic, readable and reusable.</p><h3>Subquery v/s CTE</h3><p>Here is an example showing how both can be written.</p><pre>-- Method 1: Using a Subquery in the FROM clause<br>SELECT emp.employee_id, emp.name, sub.total_amount<br>FROM employees emp<br>JOIN (<br>    SELECT employee_id, SUM(amount) AS total_amount<br>    FROM transactions<br>    GROUP BY employee_id<br>) sub ON emp.employee_id = sub.employee_id;<br><br>-- Method 2: Using a Common Table Expression (CTE)<br>WITH employee_totals AS (<br>    SELECT employee_id, SUM(amount) AS total_amount<br>    FROM transactions<br>    GROUP BY employee_id<br>)<br>SELECT emp.employee_id, emp.name, cte.total_amount<br>FROM employees emp<br>JOIN employee_totals cte ON emp.employee_id = cte.employee_id;</pre><h3>Recursive CTEs</h3><p>It joins its own output back to itself until no new rows are produced.</p><pre>WITH RECURSIVE employee_hierarchy AS (<br>  SELECT employee_id, name, manage_id, 1 as level<br>  FROM employees<br>  WHERE manager_id IS NULL<br><br>  UNION ALL<br><br>  SELECT e.employee_id, e.name, e.manager_id, eh.level + 1<br>  FROM employees e<br>  JOIN employee_hierarchy ON e.manager_id = eh.employee_id<br>)<br><br>SELECT * FROM employee_hierarchy;</pre><h3>VIEWS</h3><p>It is a saved SELECT statement that works as a virtual table. It stores no data of its own. It runs against live data every time we query it.</p><p>It’s features are:</p><ul><li>Security</li></ul><p>We can grant access to a view instead of the raw table limiting the expose of our data to other team members.</p><ul><li>Simplicity</li></ul><p>It hides complex join or aggregation behind a simple select query.</p><ul><li>Reusability</li></ul><p>We can write the logic once and reuse it in every report and dashboard queries in the same definition.</p><h3>Creating, Replacing and Dropping a view</h3><p>Here is an example of creating, replacing and dropping a view:</p><pre>-- Creating a view for active customer transactions<br>CREATE VIEW active_employee_transactions AS<br>SELECT emp.employee_id, emp.name, t.amount, t.transaction_date<br>FROM employees emp<br>JOIN transactions t ON emp.employee_id = t.employee_id<br>WHERE t.status = &#39;completed&#39;;<br><br>-- Replacing an existing view to include department info<br>CREATE OR REPLACE VIEW active_employee_transactions AS<br>SELECT emp.employee_id, emp.name, emp.department, t.amount, t.transaction_date<br>FROM employees emp<br>JOIN transactions t ON emp.employee_id = t.employee_id<br>WHERE t.status = &#39;completed&#39;;<br><br>-- Dropping a view when it is no longer needed<br>DROP VIEW IF EXISTS active_employee_transactions;</pre><p>Materialized views</p><p>It runs the query once and physically stores the result on disk. It is fast but it goes stale as soon as the underlying data changes.</p><pre>CREATE MATERIALIZED VIEW employee_store_mv AS<br>  SELECT ORDER_TRUNC(&#39;month&#39;, order_date) AS order_month,<br>    category,<br>    SUM(amount) AS total_amount,<br>    COUNT(*) AS order_count<br>  FROM orders<br>  GROUP BY DATE_TRUNC(&#39;month&#39;, order_date), category<br>WITH DATA;</pre><p>The materialized view do not update its data until we refresh it. For example:</p><pre>REFRESH MATERIALIZED VIEW employee_stor_mv;<br><br>-- concurently lets readers keep querying the old data while the refresh runs<br>-- but requires a unique index on the view first<br>CREATE UNIQUE INDEX employee_stor_mv <br>  ON employee_stor_mv (order_month, category);<br><br>REFRESH MATERIALIZED VIEW CONCURENTLY employee_stor_mv;</pre><p>Lets look into the VIEW VS. MATERIALIZD VIEW</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*pQS2qHvUT31TVNmotfCA7g.png" /></figure><h3>Windows Functions</h3><p>It applies aggregate, ranking and analytic function over a particular window -&gt; set of rows.</p><p>It uses OVER clause to define that window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*3feU0sq2fjTAEAJkM_fxKg.png" /></figure><pre>FUNCTION_NAME() OVER (<br>  PARTITION BY table_name<br>  ORDER BY column DESC<br>)</pre><p>For example:</p><pre>SELECT department,<br> first_name || &#39; &#39; || last_name AS employee_name,<br> salary,<br> ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS row_num,<br> RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS salary_rank,<br> DENSE_RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS dense_rank<br>FROM employees<br>ORDER BY department, salary DESC;</pre><p>we can also add conditions using window function using WHERE clause.</p><h3>Window Functions — Navigation</h3><p>LAG() and LEAD()</p><p>It is use to look at the neighboring rows without performing an expensive self-join.</p><p>LAG(): fetch data from a previous row (looks backward)</p><p>LEAD(): fetch data from a subsequent row (looks forward)</p><p>FIRST_VALUE(): fetch data from the first row</p><p>LAST_VALUE(): fetch data from the last row</p><p>running total: SUM() it shows the total amount with preceeding rows and current row</p><p>running average: ROUND(AVG(column_name) it is use to get the average of previous rows till current row.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*JQcN_wkAH5e7NAyolObHpQ.png" /></figure><p>Thank you for reading.</p><p>Enjoy Your Life</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43fa07dbc49e" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/a-step-deeper-in-sql-iv-43fa07dbc49e">A step deeper in SQL: IV</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL: III Sub-queries and Set operations.]]></title>
            <link>https://medium.com/the-repo/sql-iii-b5aca3c22a65?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5aca3c22a65</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[advanced-sql]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[subquery]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Tue, 01 Sep 2026 02:52:34 GMT</pubDate>
            <atom:updated>2026-09-01T07:48:40.348Z</atom:updated>
            <content:encoded><![CDATA[<h4>It is the continuation of the SQL: I. It talks about sub-queries and set operations.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RUi7ws1SgI7p2gLD" /><figcaption>Photo by <a href="https://unsplash.com/@rubaitulazad?utm_source=medium&amp;utm_medium=referral">Rubaitul Azad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Sub-queries and Nested Queries</h3><p>It is a complete SELECT statement nested inside another SQL statement. We can perform complex filtering, aggregation and data manipulation by using the result of one query inside another one. PostgreSQL runs the SQL statement as one and provide us the single list.<br>For example:</p><pre>SELECT * FROM Customers<br>WHERE order_items &gt; ( SELECT AVG(order_idtems) FROM Customers );</pre><p>the syntax will be:</p><pre>SELECT column_name<br>FROM table_name<br>WHERE column_name operator<br>      (SELECT column_name <br>       FROM table_name <br>       WHERE condition);</pre><p>Now, Lets go to the type of sub-queries:</p><ol><li>Single-Row Subquery</li></ol><p>It returns only one value; exactly one row as a result. It commonly use the comparison operators such as =, &gt;, &lt;</p><p>For example:</p><pre>SELECT * FFROM employees <br>WHERE salary = (SELECT MAX(salary) FROM employees);</pre><p>2. Multi-Row Subquery</p><p>It returns more than one row as result. It requires operators that can handle multiple values, such as IN, ANY or ALL.</p><p>For example:</p><pre>SELECT * FROM employees<br>WHERE department_id <br>IN (SELECT department_id FROM departments WHERE location = &#39;New York&#39;);</pre><p>3. Correlated Subquery</p><p>It depends on the outer query for its values. It executes once for each row of outer query, making it slower for large dataset.</p><p>For Example:</p><pre>SELECT e.name, e.salary FROM employees<br>WHERE e.salary &gt; (SELECT AVG(salary) FROM employees WHERE department_id = e.department_id);</pre><p>Here are some syntax of using Subqueries:</p><ul><li>Fetching data using where clause</li></ul><pre>SELECT column_name/s <br>FROM table<br>WHERE column_name IN (<br>    SELECT column_name/s <br>    FROM table2<br>    WHERE column_name = &#39;A&#39;<br>);</pre><ul><li>Using delete</li></ul><pre>DELETE FROM table <br>WHERE column_name IN (<br>  SELECT column_name FROM (<br>  SELECT column_name FROM table where column_name &lt;= &#39;value&#39; OR column_name = &#39;value&#39;<br>  )<br>)</pre><ul><li>with update</li></ul><pre>UPDATE table <br>SET column_name = &#39;value&#39;<br>WHERE column_name IN (<br>  SELECT column_name/s FROM table WHERE column_name IN (&#39;value&#39;, &#39;value&#39;)<br>)</pre><ul><li>with FROM</li></ul><pre>SELECT column_name/s<br>FROM (<br>    SELECT column_name/s<br>    FROM table<br>    WHERE column_name LIKE &#39;L%&#39;<br>) AS subquery_table;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*vWPPDMiOTRdZZO2X" /></figure><h3>Extras</h3><h3>Union (AUB)</h3><p>It combines two result sets with one into other, then removes exact duplicate row. Its same as two separate queries, de-duplicated.</p><pre>SELECT column_name FROM table<br>UNION<br>SELECT column_name FROM table 2<br>ORDER BY column_name;</pre><h3>Intersect</h3><p>Its result shows the rows that appear in both tables. Its same as AND between two queries.</p><pre>SELECT column_name FROM tables<br>INTERSECT<br>SELECT column_name FROM tables_2</pre><h3>EXCEPT (A-B)</h3><p>It shows the rows of first query that do not appear in second.</p><pre>SELECT column_name FROM tables<br>INTERSECT<br>SELECT column_name FROM tables_2<br>// shows result of tables that is not in table_2</pre><h3>Group by</h3><p>It shows the result by showing the column of group by column_name and its resulted value on another column.</p><pre>SELECT column1, aggregate_function(column2), column3, ...<br>FROM table_name<br>WHERE condition<br>GROUP BY column1, column3<br>ORDER BY column_name;</pre><h3>Having</h3><p>We use having with group by. It filters the result of group by based on aggregate functions.</p><pre>SELECT column1, aggregate_function(column2), column3, ...<br>FROM table_name<br>WHERE condition<br>GROUP BY column1, column3<br>HAVING condition<br>ORDER BY column_name;</pre><p>This is it.</p><p>Enjoy your Life</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5aca3c22a65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-repo/sql-iii-b5aca3c22a65">SQL: III Sub-queries and Set operations.</a> was originally published in <a href="https://medium.com/the-repo">The Repo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL: II — Make SQL JOINs Actually Make Sense]]></title>
            <link>https://medium.com/the-repo/sql-ii-lets-make-sql-joins-actually-make-sense-45f50853516a?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/45f50853516a</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-joins]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Sun, 30 Aug 2026 14:32:44 GMT</pubDate>
            <atom:updated>2026-08-30T14:41:59.004Z</atom:updated>
            <content:encoded><![CDATA[<h4>It tells you a story of JOINS in SQL in clean and easy form.</h4><p>If SQL tables are like different notebooks holding different pieces of information, then <strong>JOINs are how we connect those notebooks together.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SJ7Ca7OlRIK3Pwtuw9N3A.png" /></figure><p>Imagine you have an online store.</p><p>You have:</p><ul><li>👤 <strong>customers</strong> — who your customers are</li><li>🛒 <strong>orders</strong> — what they ordered</li><li>💳 <strong>transactions</strong> — how their orders were paid for</li></ul><p>These tables don’t need to store everything in one place.</p><p>Instead, they are connected through related columns.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*92XJfBuFiJB5o7vBu3feNA.png" /></figure><h3>Notice something?</h3><p>customer_id appears in multiple tables.</p><p>That’s our connection.</p><blockquote><strong><em>A JOIN lets us bring related information from different tables together.</em></strong></blockquote><p>And once you understand that idea, the different types of JOINs become much easier.</p><h3>🔗 INNER JOIN</h3><h3>“Show me the customers who actually placed an order.”</h3><p>An <strong>INNER JOIN</strong> returns only the rows where there is a match in <strong>both tables</strong>.</p><p>From our example:</p><ul><li>Alice → has orders ✅</li><li>Bob → has an order ✅</li><li>Charlie → no order ❌</li><li>Diana → no order ❌</li></ul><p>So Charlie and Diana disappear from the result.</p><pre>SELECT <br>    c.customer_id,<br>    c.first_name,<br>    o.order_date<br>FROM customers AS c<br>INNER JOIN orders AS o<br>    ON c.customer_id = o.customer_id;</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*L64y6I5N4iJVMZ88f2icKw.png" /></figure><p>Notice that Alice appears <strong>twice</strong>.</p><p>Why?</p><p>Because Alice placed <strong>two orders</strong>.</p><p>That’s an important thing to remember:</p><blockquote><em>JOINs don’t necessarily return one row per customer.<br>They return rows based on the matching records.</em></blockquote><h3>Want to connect three tables?</h3><p>You can keep joining:</p><pre>SELECT <br>    c.customer_id,<br>    c.first_name,<br>    o.order_date,<br>    t.amount<br>FROM customers AS c<br>INNER JOIN orders AS o<br>    ON c.customer_id = o.customer_id<br>INNER JOIN transactions AS t<br>    ON c.customer_id = t.customer_id;</pre><p>Now we’re connecting:</p><p><strong>customers → orders → transactions</strong></p><p>This is where JOINs become really powerful. 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*JfbznOgeBR1NBECs0FVSRg.png" /></figure><h3>👈 LEFT JOIN</h3><h3>“Show me ALL customers, even if they never ordered anything.”</h3><p>This is where <strong>LEFT JOIN</strong> becomes useful.</p><p>A LEFT JOIN keeps <strong>every row from the left table</strong> and brings matching data from the right table.</p><pre>SELECT <br>    c.customer_id,<br>    c.first_name,<br>    o.order_date<br>FROM customers AS c<br>LEFT JOIN orders AS o<br>    ON c.customer_id = o.customer_id;</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*SCQ80NRIV7ntRbh7GzVRxg.png" /></figure><p>Charlie and Diana are still there. 🎉</p><p>They don’t have orders, so SQL gives us NULL for the order columns.</p><p>Think of it like:</p><blockquote><strong><em>LEFT JOIN = “Don’t forget anyone from my left table.”</em></strong></blockquote><h3>Want only customers who have NEVER ordered?</h3><p>This is a very common interview question.</p><pre>SELECT <br>    c.customer_id,<br>    c.first_name<br>FROM customers AS c<br>LEFT JOIN orders AS o<br>    ON c.customer_id = o.customer_id<br>WHERE o.customer_id IS NULL;</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*iHmd9i7qiZ3rBn4vVof5Mg.png" /></figure><p>The trick is:</p><ol><li>LEFT JOIN keeps everyone.</li><li>Customers without orders get NULL.</li><li>WHERE o.customer_id IS NULL keeps only those customers.</li></ol><p>This pattern is worth remembering. 🧠</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UBRBapo1rhGg-T6_rgFkpw.png" /></figure><h3>👉 RIGHT JOIN</h3><h3>“Show me ALL orders, even if there isn’t a matching customer.”</h3><p>A <strong>RIGHT JOIN</strong> does the opposite of a LEFT JOIN.</p><p>It keeps <strong>every row from the right table</strong> and includes matching rows from the left table.</p><pre>SELECT <br>    c.customer_id,<br>    c.first_name,<br>    o.order_id<br>FROM customers AS c<br>RIGHT JOIN orders AS o<br>    ON c.customer_id = o.customer_id;</pre><p>Think:</p><blockquote><strong><em>LEFT JOIN → keep everything on the left.</em></strong><em><br></em><strong><em>RIGHT JOIN → keep everything on the right.</em></strong></blockquote><p>In practice, many developers prefer using a LEFT JOIN instead of a RIGHT JOIN because you can simply switch the table order and make the query easier to read.</p><p>For example:</p><pre>-- RIGHT JOIN<br>customers<br>RIGHT JOIN orders</pre><pre>-- can usually be written as</pre><pre>-- LEFT JOIN<br>orders<br>LEFT JOIN customers</pre><p>Same idea, different direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ikJGiPiz-RPstPPuAUm8Og.png" /></figure><h3>🔄 FULL OUTER JOIN</h3><h3>“I want EVERYTHING. I don’t care whether it matches.”</h3><p>A <strong>FULL OUTER JOIN</strong> returns:</p><ul><li>matching rows from both tables ✅</li><li>unmatched rows from the left table ✅</li><li>unmatched rows from the right table ✅</li></ul><p>Imagine:</p><p><strong>Customers:</strong> Alice, Bob, Charlie</p><p><strong>Orders:</strong> Alice, Bob, David</p><p>A FULL JOIN gives you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*r2PMZjQSKo8WfMOYT8GgXg.png" /></figure><p>Charlie exists as a customer but has no order.</p><p>David has an order but doesn’t have a matching customer.</p><p>Nobody gets left behind. 😄</p><pre>SELECT <br>    c.customer_id,<br>    c.first_name,<br>    o.order_id<br>FROM customers AS c<br>FULL OUTER JOIN orders AS o<br>    ON c.customer_id = o.customer_id;</pre><h3>Want to find the unmatched records?</h3><pre>SELECT <br>    c.customer_id,<br>    c.first_name,<br>    o.order_id<br>FROM customers AS c<br>FULL OUTER JOIN orders AS o<br>    ON c.customer_id = o.customer_id<br>WHERE c.customer_id IS NULL<br>   OR o.customer_id IS NULL;</pre><p>This gives you records that exist on <strong>only one side</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*G6CZpimKZNgcQO8dIowDeg.png" /></figure><h3>🪞 SELF JOIN</h3><p>Now things get interesting.</p><p>A <strong>SELF JOIN</strong> is when a table joins with <strong>itself</strong>.</p><p>Why would we do that?</p><p>Consider an employees table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MC53g12VZP_IGIbh7eJv1Q.png" /></figure><p>Here, manager_id refers back to another employee_id in the <strong>same table</strong>.</p><p>So we can use a SELF JOIN to answer:</p><blockquote><em>“Who is each employee’s manager?”</em></blockquote><pre>SELECT <br>    e.name AS employee,<br>    m.name AS manager<br>FROM employees AS e<br>LEFT JOIN employees AS m<br>    ON e.manager_id = m.employee_id;</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*oMh0wcMx9dzzkt_LB7GvBg.png" /></figure><p>We used the same table twice:</p><pre>employees AS e  → employee<br>employees AS m  → manager</pre><p>That’s why aliases are important here.</p><h3>🧠 The easiest way to remember JOINs</h3><p>Don’t memorize complicated definitions.</p><p>Just remember what each JOIN is trying to <strong>keep</strong>.</p><p>JOINThinkINNER JOIN🤝 Only matching recordsLEFT JOIN👈 Keep everything on the leftRIGHT JOIN👉 Keep everything on the rightFULL OUTER JOIN🔄 Keep everything from bothSELF JOIN🪞 Table joins with itself</p><p>Or even simpler:</p><pre>INNER<br>🤝<br>Only the intersection<br></pre><pre>LEFT<br>👈<br>Everything from LEFT + matches from RIGHT<br></pre><pre>RIGHT<br>👉<br>Everything from RIGHT + matches from LEFT<br></pre><pre>FULL<br>🔄<br>Everything from BOTH<br></pre><pre>SELF<br>🪞<br>The table talks to itself</pre><h3>🎯 One Final Example</h3><p>Let’s say your manager asks:</p><blockquote><em>“Give me all customers, their orders, and their transaction amounts — even if they haven’t ordered anything.”</em></blockquote><p>You might write:</p><pre>SELECT<br>    c.customer_id,<br>    c.first_name,<br>    o.order_id,<br>    o.order_date,<br>    t.amount<br>FROM customers AS c<br>LEFT JOIN orders AS o<br>    ON c.customer_id = o.customer_id<br>LEFT JOIN transactions AS t<br>    ON c.customer_id = t.customer_id;</pre><p>And suddenly, three separate tables become <strong>one meaningful result</strong>.</p><p>That’s the real power of JOINs.</p><p>You aren’t just combining tables.</p><p><strong>You’re connecting pieces of a story.</strong></p><h3>The takeaway</h3><p>When you see a JOIN, don’t immediately think about SQL syntax.</p><p>First ask:</p><p><strong>“What information am I trying to connect, and which records do I want to keep?”</strong></p><p>Once you answer that, choosing the JOIN becomes much easier.</p><p>SQL JOINs aren’t really about memorizing INNER, LEFT, RIGHT, or FULL.</p><p>They’re about understanding <strong>relationships between data.</strong></p><p>And honestly, that’s where SQL starts getting interesting.</p><p>ENJOY YOUR LIFE</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45f50853516a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-repo/sql-ii-lets-make-sql-joins-actually-make-sense-45f50853516a">SQL: II — Make SQL JOINs Actually Make Sense</a> was originally published in <a href="https://medium.com/the-repo">The Repo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL: I]]></title>
            <link>https://medium.com/@leekhitame/sql-i-7e480f535879?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e480f535879</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Sat, 29 Aug 2026 16:13:07 GMT</pubDate>
            <atom:updated>2026-08-29T16:13:07.565Z</atom:updated>
            <content:encoded><![CDATA[<p>Structured Query Language. This article tells you the basics of SQL with practicals and proper definition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XgN1TIA2uBXmsj-D.png" /></figure><h3>Databases, Tables, Data</h3><p>In a SQL, there is databases which is like a cabinet to store data in drawer so that those data can be accessed, stored or update in a managerial way. Now, By cabinet, I mean a place to keep data organized and by drawer, I mean tables which has specific kind of data like customer’s data in customers table or account data in accounts table which can be linked with customers table with customer_id as foreign key.</p><h3>Primary Key and Foreign Key</h3><p>Every tables have primary key which is their incremental ids and in order to join tables there is foreign keys which are the same incremental unique id in one’s table.</p><h3>Schemas</h3><p>It is the blueprints of a table, the table is made of rows and columns. Column shows what kind of data each one holds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*ZiscZgceO5tuDuImQT9MBA.png" /></figure><h3>DDL — creating tables</h3><p>It is the statement that define our schema. DDL — Data Definition Language.</p><ul><li>CREATE TABLE syntax</li><li>DROP TABLE and ALTER TABLE</li><li>Constraints: PRIMARY KEY, FOREIGN KEY, NOT NULL, UNIQUE, CHECK, DEFAULT</li></ul><h3>CREATE TABLE</h3><pre>CREATE TABLE customers (<br>  customer_id     INT PRIMARY KEY,<br>  customer_name   VARCHAR(20) NOT NULL,<br>  address         VARCHAR(20) DEFAULT &#39;local&#39;<br>);</pre><p>here,</p><p><strong>CREATE TABLE</strong> is <strong>keyword</strong><br><strong>customers</strong> is <strong>name<br>customer_id is column<br>INT/VARCHAR </strong>is <strong>Datatype<br>PRIMARY KEY / NOT NULL / DEFAULT </strong>is <strong>Rule</strong></p><h3>Constraints:</h3><p>Its the rule that protects our data. <br>Each table has <strong>primary key</strong> in order to identifies data in a table and do not let duplicate data exists. <br><strong>Foreign key</strong> links with another table with their id. <br><strong>Not null</strong> makes the column have value anyhow. Unique says that there should be different value in each row. <br><strong>Check</strong> keeps a condition to pass. <br><strong>Default</strong> has a value to be save in the row if nothing else is comes to over-ride.</p><h3><strong>DROP &amp; ALTER</strong></h3><p>After you create a table, you might want to delete or alter the table sometimes. So, for that</p><pre>-- To drop the table<br>DROP TABLE customers;</pre><pre>-- to alter the table<br>ALTER TABLE customers ADD COLUMN phone VARCHAR(20);</pre><h3>DML — Inserting &amp; Modifying Data</h3><p>Its about Data Manipulation Language. Its the statements that change your data.</p><p>There are three ways to change Data:</p><ul><li>Add a row</li></ul><pre>INSERT INTO customers (<br>  customer_id, first_name, last_name, phone<br>) Values (<br>1, &#39;Debby&#39;, &#39;Wilson&#39;, &#39;9841293933&#39;<br>)</pre><ul><li>Change a row</li></ul><pre>UPDATE customers SET phone = &#39;977 9741282937&#39; WHERE customer_id = 1;</pre><ul><li>Remove a row</li></ul><pre>DELETE FROM customers WHERE customer_id = 1 AND is_active = FALSE;</pre><h3>NOTE:</h3><ul><li>You should always use where when update or delete.</li><li>You should select the data first then see if its the data you want to delete / update then perform its deletion or updation.</li></ul><h3>SELECT — Querying Data</h3><p>DDL, Data Query Language. Its where we select statement used to retrieve data.</p><p>SELECT …FROM and WHERE</p><pre>SELECT first_name, last_name from customers WHERE phone like &#39;977%&#39;;</pre><p>ORDER BY … ASC / DESC</p><pre>SELECT first_name, phone FROM customers ORDER BY salary DESC;</pre><p>LIMIT and OFFSET</p><pre>SELECT first_name, salary FROM customers ORDER BY salary DESC LIMIT 3 OFFSET 3;</pre><p>DISTINCT, and column/table aliases with AS</p><pre>SELECT DISTINCT customer_id FROM customers;<br><br>SELECT cus.first_name as &quot;First Name&quot; cus.salary as &quot;Annual Salary&quot; from customers as cus ORDER BY &quot;Annual Salary&quot; DESC;</pre><p>This is it for the basic concepts.</p><h3>Enjoy Your Life</h3><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e480f535879" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pagination Looks Simple Until Your Database Starts Fighting Back]]></title>
            <link>https://medium.com/the-repo/pagination-looks-simple-until-your-database-starts-fighting-back-aef0c0eaed41?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/aef0c0eaed41</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[offset-vs-keyset]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 06:01:16 GMT</pubDate>
            <atom:updated>2026-08-18T07:54:22.801Z</atom:updated>
            <content:encoded><![CDATA[<h4>Pagination sounds like one of those backend problems you solve in five minutes:</h4><pre>SELECT *<br>FROM users<br>LIMIT 15<br>OFFSET 30;</pre><p>Done, right?</p><p>Not quite.</p><p>There are actually <strong>two different problems</strong> hiding inside this innocent-looking query: <strong>consistency</strong> and <strong>performance</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*g6MitwK-SnGAZixe" /></figure><h3>First Rule: Never Paginate Without an ORDER BY</h3><p>When you use LIMIT and OFFSET, you are essentially telling the database:</p><blockquote><em>“Give me this particular slice of the result set.”</em></blockquote><p>But there is an important question:</p><p><strong>A slice of what order?</strong></p><p>If you don’t specify an ORDER BY, PostgreSQL is free to return rows in whatever order is convenient. That order is <strong>not guaranteed to remain the same</strong> between requests.</p><p>For example, imagine your API returns 15 users per page.</p><p>A user requests Page 1 and gets:</p><pre>1, 2, 3, 4, 5, ... 15</pre><p>Then they request Page 2:</p><pre>LIMIT 15 OFFSET 15</pre><p>You might expect:</p><pre>16, 17, 18, ... 30</pre><p>But without an explicit ordering, PostgreSQL makes no such promise.</p><p>The underlying execution plan can change. Rows can be updated. Indexes can be used differently. The physical arrangement of data can change.</p><p>Suddenly, Page 2 might contain records the user already saw on Page 1 — or completely miss records they should have seen.</p><p>And that’s where things get really annoying: <strong>the bug can be intermittent.</strong></p><p>It might work perfectly in development, then appear under production load when background jobs, updates, and database maintenance are happening.</p><h3>Give the Database a Rule</h3><p>Instead, make the ordering explicit:</p><pre>SELECT *<br>FROM users<br>ORDER BY id<br>LIMIT 15<br>OFFSET 30;</pre><p>Now you’ve told PostgreSQL exactly what the result set should look like.</p><p>Even better, make sure the ordering is <strong>unique</strong>.</p><p>For example:</p><pre>ORDER BY last_name, id</pre><p>Why include id?</p><p>Because last_name isn&#39;t unique. There could be hundreds of users named Smith.</p><p>The id acts as the final tie-breaker, giving every row a deterministic position.</p><p>A good mental model is:</p><blockquote><strong><em>If you’re going to cut a result set into pages, first decide exactly how the result set is sorted.</em></strong></blockquote><h3>Then Comes the Scalability Problem</h3><p>Once you’ve added ORDER BY, you&#39;ve fixed one problem.</p><p>But OFFSET still has another trick up its sleeve.</p><p>Consider this query:</p><pre>SELECT *<br>FROM users<br>ORDER BY id<br>LIMIT 15<br>OFFSET 100000;</pre><p>At first glance, it looks reasonable:</p><blockquote><em>“Skip the first 100,000 users and give me the next 15.”</em></blockquote><p>But PostgreSQL can’t simply teleport to row number 100,001.</p><p>It generally has to walk through the rows that come before your requested page, processing enough of them to determine which rows should be skipped.</p><p>So the database effectively does something like:</p><pre>Read 100,000 rows<br>        ↓<br>Throw them away<br>        ↓<br>Read 15 more rows<br>        ↓<br>Return those 15</pre><p>That’s a lot of work for a very small response.</p><p>And the deeper you go, the worse the problem becomes.</p><p>Page 1 might be cheap:</p><pre>OFFSET 0 LIMIT 15</pre><p>Page 100 might still be fine:</p><pre>OFFSET 1485 LIMIT 15</pre><p>But eventually you reach:</p><pre>OFFSET 1000000 LIMIT 15</pre><p>Now your database is doing a huge amount of work just to return <strong>15 rows</strong>.</p><p>On large, busy tables, those unnecessary reads can translate into increased CPU usage, I/O pressure, longer query times, and a database that starts spending more and more effort servicing requests that don’t actually need much data.</p><p>This is the <strong>scalability wall of offset pagination</strong>.</p><h3>Enter Keyset Pagination</h3><p>Instead of saying:</p><blockquote><em>“Skip the first 100,000 rows.”</em></blockquote><p>Keyset pagination says:</p><blockquote><em>“Start after this particular row.”</em></blockquote><p>For example:</p><pre>SELECT *<br>FROM users<br>WHERE id &gt; 100000<br>ORDER BY id<br>LIMIT 15;</pre><p>The important difference is that we’re no longer asking PostgreSQL to count its way through 100,000 rows.</p><p>We’re giving it a <strong>starting point</strong>.</p><p>If id is indexed, PostgreSQL can jump to the relevant part of the index and continue from there.</p><h3>A Real API Example</h3><p>Imagine your API returns the first 5 users:</p><pre>SELECT *<br>FROM users<br>ORDER BY id<br>LIMIT 5;</pre><p>The database returns:</p><pre>id<br>---<br>101<br>102<br>103<br>104<br>105</pre><p>The API can now treat 105 as the cursor.</p><p>The response might look like:</p><pre>{<br>  &quot;data&quot;: [<br>    { &quot;id&quot;: 101, &quot;name&quot;: &quot;Alice&quot; },<br>    { &quot;id&quot;: 102, &quot;name&quot;: &quot;Bob&quot; },<br>    { &quot;id&quot;: 103, &quot;name&quot;: &quot;Charlie&quot; },<br>    { &quot;id&quot;: 104, &quot;name&quot;: &quot;David&quot; },<br>    { &quot;id&quot;: 105, &quot;name&quot;: &quot;Emma&quot; }<br>  ],<br>  &quot;next_cursor&quot;: 105<br>}</pre><p>When the client asks for the next page, instead of saying:</p><pre>page = 2<br>offset = 5</pre><p>it says:</p><pre>after = 105</pre><p>The database then runs:</p><pre>SELECT *<br>FROM users<br>WHERE id &gt; 105<br>ORDER BY id<br>LIMIT 5;</pre><p>And returns:</p><pre>106<br>107<br>108<br>109<br>110</pre><p>The next request uses 110 as the cursor:</p><pre>SELECT *<br>FROM users<br>WHERE id &gt; 110<br>ORDER BY id<br>LIMIT 5;</pre><p>And the process continues.</p><p>There is no growing OFFSET.</p><p>The database always knows exactly where to continue.</p><h3>What If Your Sort Uses Multiple Columns?</h3><p>This is where keyset pagination gets even more interesting.</p><p>Suppose you’re displaying users ordered by:</p><pre>ORDER BY last_name, id</pre><p>You can’t simply say:</p><pre>WHERE last_name &gt; &#39;Smith&#39;</pre><p>because there may be multiple users with the same last name.</p><p>Instead, you can use the combination of both columns as your cursor:</p><pre>SELECT *<br>FROM users<br>WHERE (last_name, id) &gt; (&#39;Smith&#39;, 105)<br>ORDER BY last_name, id<br>LIMIT 15;</pre><p>Here, the cursor represents:</p><pre>last_name = Smith<br>id        = 105</pre><p>The database finds everything that comes <strong>after that exact position</strong> in the ordering.</p><p>This is why having a unique tie-breaker such as id is so important—not only for deterministic offset pagination, but also for building reliable keyset pagination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*3sSwHLBi-9Ms41Qc" /></figure><h3>Offset vs. Keyset</h3><p>The difference is easier to understand this way:</p><p><strong>Offset pagination:</strong></p><blockquote><em>“Take the first 1,000,000 records, throw them away, then give me 15.”</em></blockquote><p><strong>Keyset pagination:</strong></p><blockquote><em>“Start after this record and give me the next 15.”</em></blockquote><p>The first approach is convenient.</p><p>The second approach is designed to keep working when your database gets big.</p><p>That doesn’t mean OFFSET is bad. For small datasets, admin dashboards, internal tools, or situations where users need to jump directly to arbitrary pages, offset pagination can be perfectly reasonable.</p><p>But for large datasets — especially APIs powering feeds, timelines, activity logs, or continuously growing tables — <strong>keyset pagination is often the better long-term design.</strong></p><h3>The Takeaway</h3><p>There are two pagination rules worth remembering:</p><p><strong>1. Always define an explicit, deterministic order.</strong></p><pre>ORDER BY id</pre><p>or, when necessary:</p><pre>ORDER BY last_name, id</pre><p><strong>2. Be suspicious of large offsets.</strong></p><pre>OFFSET 1000000</pre><p>may be a sign that your pagination strategy needs to change.</p><p>And when the dataset gets large, consider switching from:</p><pre>LIMIT 15 OFFSET 1000000</pre><p>to something like:</p><pre>WHERE id &gt; 1000000<br>ORDER BY id<br>LIMIT 15</pre><p>Pagination isn’t just about putting LIMIT 15 at the end of a query.</p><p>You’re designing a contract between your API and your database:</p><p><strong>What does “next page” actually mean, and how much work should the database have to do to find it?</strong></p><p>Get the ordering wrong, and users can see duplicates or missing records.</p><p>Rely on huge offsets, and the database can eventually spend enormous amounts of effort finding 15 rows.</p><p>Get both right, and your pagination remains <strong>predictable for users and scalable for your database.</strong></p><p>Enjoy Your Life</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aef0c0eaed41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-repo/pagination-looks-simple-until-your-database-starts-fighting-back-aef0c0eaed41">Pagination Looks Simple Until Your Database Starts Fighting Back</a> was originally published in <a href="https://medium.com/the-repo">The Repo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ultimate reference guide for asynchronous programming in JavaScript and TypeScript]]></title>
            <link>https://medium.com/@leekhitame/ultimate-reference-guide-for-asynchronous-programming-in-javascript-and-typescript-1ee24fe8f8b9?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ee24fe8f8b9</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[javascript-promise]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[asynchronous-programming]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 13:58:55 GMT</pubDate>
            <atom:updated>2026-08-12T13:58:55.818Z</atom:updated>
            <content:encoded><![CDATA[<p>Handling time-consuming tasks — like network requests, file operations, or database queries — without freezing your main application thread is critical to writing high-performance web applications.</p><h3>1. The Core Idea of a Promise (and Its 3 States)</h3><p>At its heart, a Promise is a JavaScript object that acts as a placeholder for a value that is not yet known but will be resolved in the future. It is a contractual guarantee that an asynchronous operation will eventually finish, allowing you to write non-blocking code.</p><p>A Promise always exists in one of three mutually exclusive states:</p><pre>┌───────────────┐<br>                  │    PENDING    │ (Work in progress)<br>                  └───────┬───────┘<br>                          │<br>            ┌─────────────┴─────────────┐<br>            ▼                           ▼<br>    ┌───────────────┐           ┌───────────────┐<br>    │   FULFILLED   │           │   REJECTED    │<br>    │ (Successful)  │           │   (Failed)    │<br>    └───────────────┘           └───────────────┘</pre><ol><li>Pending: The default starting state. The asynchronous operation is still executing.</li><li>Fulfilled: The operation completed successfully, resolving the Promise with a concrete value.</li><li>Rejected: The operation failed, rejecting the Promise with an error or reason.</li></ol><h3>Practical TypeScript Example: Initializing a Promise</h3><p>In TypeScript, we declare the type of the resolved value using the generic Promise&lt;T&gt; interface. This ensures compile-time type checking on whatever data eventually exits the promise container.</p><pre>// 1. Define our strongly typed user model<br>interface UserProfile {<br>  id: number;<br>  username: string;<br>  status: &quot;active&quot; | &quot;inactive&quot;;<br>}</pre><pre>// 2. Define a function that returns a Promise resolving to our UserProfile model<br>function fetchUserProfile(userId: number): Promise&lt;UserProfile&gt; {<br>  return new Promise&lt;UserProfile&gt;((resolve, reject) =&gt; {<br>    console.log(`[Pending] Initiating network request for user: ${userId}...`);<br>    <br>    // Simulate a network latency delay of 1 second<br>    setTimeout(() =&gt; {<br>      const networkSuccess = true; // Simulated condition</pre><pre>      if (networkSuccess) {<br>        const mockUser: UserProfile = {<br>          id: userId,<br>          username: &quot;alex_dev&quot;,<br>          status: &quot;active&quot;<br>        };<br>        console.log(&quot;[Fulfilled] Profile retrieved successfully.&quot;);<br>        resolve(mockUser); // Transition state to Fulfilled<br>      } else {<br>        console.log(&quot;[Rejected] Network request failed.&quot;);<br>        reject(new Error(&quot;Database connection failed.&quot;)); // Transition state to Rejected<br>      }<br>    }, 1000);<br>  });<br>}</pre><pre>// 3. Consuming the Promise<br>fetchUserProfile(101)<br>  .then((user) =&gt; {<br>    // TypeScript knows &#39;user&#39; is of type &#39;UserProfile&#39;<br>    console.log(`Success! Logged in as ${user.username.toUpperCase()}`);<br>  })<br>  .catch((error: Error) =&gt; {<br>    console.error(`Error encountered: ${error.message}`);<br>  });</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BYusdqhyXcNtz-7O.png" /></figure><h3>2. Flat Promise Chaining and Error Recovery</h3><p>Before Promises, executing sequential asynchronous tasks required nesting callbacks within callbacks, creating unmaintainable code patterns known as Callback Hell.</p><p>Promises elegantly resolve this using Promise Chaining. When you return a value or a new Promise from within a .then() block, JavaScript automatically wraps that value and forwards it to the next .then() down the chain. This keeps your execution pipeline perfectly flat and highly readable.</p><h3>Downstream Error Propagation</h3><p>One of the most robust aspects of Promise chains is how they handle errors. You do not need to attach error-handling code to every single step in your sequence. If an error is thrown or a Promise is rejected anywhere in the pipeline, JavaScript halts normal execution and bubbles the error downstream until it strikes the very first available .catch() block.</p><pre>Step 1 (.then) ──► Step 2 (Error thrown!) ──► Step 3 (.then skipped) ──► Catch Block (.catch)</pre><p>By placing a .catch() block in the middle of a chain rather than only at the end, you can establish an error recovery detour. If the middle catch block returns fallback data, the chain is considered successfully recovered, and subsequent .then() blocks continue executing downstream using that recovery data.</p><h3>Practical TypeScript Example: Sequential Orders Pipeline</h3><pre>interface OrderItem {<br>  sku: string;<br>  quantity: number;<br>}</pre><pre>interface Order {<br>  orderId: string;<br>  items: OrderItem[];<br>  totalAmount: number;<br>}</pre><pre>interface Invoice {<br>  invoiceId: string;<br>  paid: boolean;<br>  amount: number;<br>}</pre><pre>// Step 1: Validate payment eligibility<br>function validateOrder(items: OrderItem[]): Promise&lt;Order&gt; {<br>  return new Promise((resolve) =&gt; {<br>    const processedOrder: Order = {<br>      orderId: &quot;ORD-9988&quot;,<br>      items: items,<br>      totalAmount: 120.00<br>    };<br>    resolve(processedOrder);<br>  });<br>}</pre><pre>// Step 2: Charge the card (simulating a potential processing failure)<br>function processPayment(order: Order): Promise&lt;Invoice&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    const paymentGatewayOnline = false;<br>    if (paymentGatewayOnline) {<br>      resolve({ invoiceId: &quot;INV-102&quot;, paid: true, amount: order.totalAmount });<br>    } else {<br>      reject(new Error(&quot;Payment gateway timeout.&quot;));<br>    }<br>  });<br>}</pre><pre>// Step 3: Run processing pipeline with early error recovery<br>const cart: OrderItem[] = [{ sku: &quot;TS-BOOK-01&quot;, quantity: 1 }];</pre><pre>validateOrder(cart)<br>  .then((order) =&gt; {<br>    return processPayment(order);<br>  })<br>  .catch((paymentError: Error) =&gt; {<br>    // Recovery block: Log the error and recover by generating an offline invoice<br>    console.warn(`Payment failed (${paymentError.message}). Falling back to Offline Invoice.`);<br>    const fallbackInvoice: Invoice = { invoiceId: &quot;INV-OFFLINE&quot;, paid: false, amount: 120.00 };<br>    return fallbackInvoice; // The pipeline recovers! This value transitions back to a resolved status.<br>  })<br>  .then((invoice) =&gt; {<br>    // This step runs regardless of whether step 2 succeeded or step 2 was caught and recovered<br>    console.log(`Success! Invoice ${invoice.invoiceId} prepared. Is paid: ${invoice.paid}`);<br>  })<br>  .catch((fatalError: Error) =&gt; {<br>    console.error(`Fatal system crash: ${fatalError.message}`);<br>  });</pre><h3>3. Async/Await Syntactic Sugar with Try/Catch</h3><p>While Promise chains are flat and clean, they still contain a fair amount of boilerplate code (.then(), callback closures, etc.). To solve this, Modern ECMAScript introduced async/await.</p><p>Async/await is syntactic sugar built on top of native Promises. It does not introduce new compiler features or performance optimizations; instead, it acts as a human-friendly wrapper that makes asynchronous code look and behave exactly like synchronous, line-by-line code.</p><h3>The Async/Await Syntax Rules</h3><ul><li>async: Preceded before a function, it guarantees that the function will always return a Promise wrapper around whatever value is ultimately returned.</li><li>await: Used only inside async functions, it pauses the execution of <em>only</em> that function block until the awaited Promise settles. Once settled, it extracts the raw resolved value and lets you assign it directly to a local variable.</li><li>Error Handling: Instead of attaching .catch() methods, you wrap your sequential await statements inside a standard, synchronous-style try/catch block. If an awaited promise rejects, it throws the error directly on that line, forcing execution into the catch bracket.</li></ul><h3>Practical TypeScript Example: Complete User Auth Pipeline</h3><pre>interface AuthorizedUser {<br>  userId: string;<br>  token: string;<br>}</pre><pre>interface UserSettings {<br>  theme: &quot;dark&quot; | &quot;light&quot;;<br>  notificationsEnabled: boolean;<br>}</pre><pre>// Helper mock API services<br>function authenticateUser(username: string): Promise&lt;AuthorizedUser&gt; {<br>  return Promise.resolve({ userId: &quot;usr_882&quot;, token: &quot;JWT_SECRET_XYZ&quot; });<br>}</pre><pre>function fetchSettings(userId: string): Promise&lt;UserSettings&gt; {<br>  // Simulating an unexpected database query failure<br>  return Promise.reject(new Error(&quot;Database connection timed out.&quot;));<br>}</pre><pre>// The async/await execution block wrapper<br>async function loadDashboardFlow(username: string): Promise&lt;void&gt; {<br>  try {<br>    console.log(`Logging in user: ${username}`);<br>    <br>    // Await pauses execution, retrieving the raw inner AuthorizedUser object directly<br>    const auth: AuthorizedUser = await authenticateUser(username);<br>    <br>    // Sequential progression using the local variable established in the previous line<br>    const settings: UserSettings = await fetchSettings(auth.userId);<br>    <br>    console.log(`Successfully configured theme: ${settings.theme}`);<br>  } catch (error) {<br>    // Intercepts any thrown error or rejection occurring on either await line above<br>    const runtimeError = error as Error;<br>    console.error(`Failed to complete user initialization sequence: ${runtimeError.message}`);<br>  } finally {<br>    console.log(&quot;Dashboard authorization sequence concluded.&quot;);<br>  }<br>}</pre><pre>// Trigger the flow<br>loadDashboardFlow(&quot;dev_alex&quot;);</pre><p>The End ❤</p><p>Enjoy Your Life</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ee24fe8f8b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Short Note on “ELECTRONIC SPAM FILTERING BASED ON NEURAL NETWORKS”]]></title>
            <link>https://blog.devgenius.io/a-short-note-on-electronic-spam-filtering-based-on-neural-networks-edc88be9ec52?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/edc88be9ec52</guid>
            <category><![CDATA[spam-filtering-solutions]]></category>
            <category><![CDATA[lvq-algorithm]]></category>
            <category><![CDATA[bayesian-statistics]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 09:14:26 GMT</pubDate>
            <atom:updated>2026-08-18T13:44:43.089Z</atom:updated>
            <content:encoded><![CDATA[<p>This entry reflects on a journal I encountered while searching for matrix multiplication in context of neural network, I came across a relevant paper on spam filtering.</p><p><strong>Problem Statement</strong></p><p>Attackers can you our Email ID in order to steal our personal and secretive information by mailing us malicious links or docs. We might also get unnecessary advertisement mails, subscription mails, newsletters etc. This can be stop by using spam filtering. The normal spam filtering by saving spam identifying words in database i.e. <strong>linguistic signals</strong>, mails filtering methods set by system administrator i.e. <strong>message filtering rules </strong>gets ineffective as spam mails can get update itself over time. For this, the paper approach the methods of artificial intelligence, especially artificial neural network. This approach focuses on classifiers, setting on important parameters. marking important messages and preparing training sample in order to evaluate the classification accuracy of actual dataset.</p><p><strong>Core</strong></p><p>The paper talks about a system that detects and prevents network attacks using neural networks. It analyse and summarize the contents to know the meaning of the content, then prevent attacks by learning and teaching itself.</p><p>The system works on predefined statistical and non-statistical message attributes —</p><p><strong>Statistical Parameter</strong></p><ul><li>exact number of parameter which should be called spam</li><li>exact number of phrases, and content to be suspected</li></ul><p><strong>Non-Statistical Data Parameter</strong></p><ul><li>semantic Adjectives</li><li>text direction</li><li>morphological features — relationship between parts of speech and correct expression of sentences</li><li>spelling — incorrect replacement of words</li></ul><p>A vector of numerical input is created from the above properties. Then, a special dictionary can came into existence using the statistical parameter which can be used to reduce the false positives and increase the accuracy of decision making. This uses Bayesian theorem which is uses to see how often a word shows up in spam vs in normal mail. But the Bayes’ Theorem is somehow tweaked in here.</p><p>First lets talk about Bayes’ Theorem:</p><p>It is a mathematical formula that calculates how you should update your belief in a hypothesis (A) when you observe new evidence (B).</p><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*T0UsGzIFzv9zHRVSzKg8vA.png" /></figure><p>where,</p><p>P(B|A) — likelihood : the probability of observing the evidence given that the hypothesis is true (e.g.: if an email is spam, how often does it contain the word “VIAGRA”?)</p><p>P(A) — Prior Probability : you baseline belief that an event is true before seeing evidence (e.g.: what percentage of all incoming emails are spam?)</p><p>P(B) — Marginal Likelihood : The overall probability of seeing that evidence across all emails.</p><p>P(A\B) — Posterior Probability : Your updated belief after considering the evidence (e.g.: given that this email contains the word “VIAGRA”, what is the probability it is spam?)</p><p><strong>The Tweak</strong></p><p>In data representation, numerical vectors (embeddings) capturing semantic meaning, spelling patterns and phonetic similarities instead of classic bayesian spam filter which is discrete counts and explicit conditional probabilities. For storage mechanism, its <strong>synaptic weights — </strong>a numerical parameters adjusted during training that dictate how signals travel between neurons<strong>, </strong>distributed across hidden layers of interconnected artifical neurons. It generalizes from experience. It identifies underlying abstract features so it can flag disguised or novel spam words. It learns non-linear, multi-parameter dependencies between words, context, sentence structure, and tone simultaneously.</p><p><strong>Algorithms</strong></p><p><strong>Kohonen Algorithm ( Unsupervised Learning )</strong></p><p>For improving the neural network, the paper suggests Kohonen Algorithm which is also known for <strong>SOM Algorithm</strong>; Self-Organizing Map). It learns without a teacher to cluster and visualize incoming email data. It is unsupervised learning and works with clustering over categorization. Rather than making a direct binary choice (spam or non-spam), it automatically groups incoming messages into clustures (such as 4 distinct groups) based on inheritent data similarities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/0*Us8rE7AULzJEwi4K.png" /><figcaption>Kohonen Algorithm</figcaption></figure><p><strong>Problem in Pure SOM<br></strong>It talks about “gray area” which is the problem not resolved by only pure Kohonen.</p><ul><li>It lacks predefined classes<br>SOM does not natively included predefined class definitions, making it difficult to set exact number of clusters or classify emails directly into binary categories.</li><li>Overlapping Groups<br>When clusters containing both spam and non-spam emails are merged, “gray area” which are uncertain zone are also merges creating misclassification errors when trying to strictly sort emails as either spam or clean.</li><li>Sensitivity to Parameters<br>SOM requires precise and careful selection of mathematical coefficients to function properly.</li></ul><p><strong>Solution with LVQ <br></strong>LVQ; Learning Vector Quantization is a type of supervised ML which is inspired by how our brain processes.<br>Lets know how it works as well:<br> <strong>1.</strong> Picks up the starting point called weight from each classes<br> <strong>2.</strong> Find the closest weight using distance, measures how far it is from another weight<br> <strong>3.</strong> Update the closest weight</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/0*8ADNLQ0iif2ciq2o" /><figcaption>LVQ Algorithm</figcaption></figure><ul><li>Hybrid Approach (SOM + LVQ)<br>Combining the LVQ algorithm with SOM eliminates the gray area problem and allows precise classification.</li><li>Supervised Class Alignment<br>LVQ maps the data vector grouped by SOM into defined, specific classes.</li><li>Flexible Multi-Class Categorization<br>This combined setup supports both binary sorting (spam vs. Non-spam) and multi-class categorization (e.g., spam, news, ads, simple messages).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*GpS7MkNUAy8tcTq3oAFp6A.png" /><figcaption>structure of neural network technology for classifying emails</figcaption></figure><p>To classify emails as spam or non-spam, we first need to pick key features from the text and feed them into the neural network.</p><p>The most important features for spotting spam includes:</p><ul><li>How often capital letters are used</li><li>How often specific letters appear</li><li>The number of different text colors used</li><li>The total length of the email</li><li>The number of blank lines in the message</li></ul><p>To train the system, we collect email samples from various sources and organize them into a table. Each row represents a single email, each column represents one of these features, and the cells hold the specific values measured for that email.</p><p>The papers concludes with the indication of the system being effective and can reduce human presence for this span identification as the model learns itself.</p><p><strong>The End</strong></p><p>Really insightful read on modern spam detection! Paper: <em>“Electronic Spam Filtering Based on Neural Networks”</em> by Bekmuratov et al. (<em>Chemical Technology, Control and Management</em>). Loved how it breaks down fixing SOM’s classification “gray areas” using LVQ.</p><p>🔗 Read it here: <a href="https://ijctcm.researchcommons.org/cgi/viewcontent.cgi?article=1174&amp;context=journal">https://ijctcm.researchcommons.org/cgi/viewcontent.cgi?article=1174&amp;context=journal</a></p><p>Enjoy Your Life</p><p>LA</p><p><strong>Note to the writer:</strong> Loved reading. If you do not intend me publishing this small note on your journal, I could remove it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edc88be9ec52" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/a-short-note-on-electronic-spam-filtering-based-on-neural-networks-edc88be9ec52">A Short Note on “ELECTRONIC SPAM FILTERING BASED ON NEURAL NETWORKS”</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advance Python Concept II]]></title>
            <link>https://medium.com/@leekhitame/advance-python-concept-ii-933c4563f252?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/933c4563f252</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[advanced-python-topic]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[advance-python]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 15:05:11 GMT</pubDate>
            <atom:updated>2026-08-07T15:05:11.892Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>Serialization</strong></li></ol><p>Python provides you a built-in JSON libraries to encode and decode JSON.</p><pre>import json</pre><p>Ther are two basic formats for JSON data; string or the object data structure. In object, elements can be add, list, search and remove as in lists and dictionaries. String format is use to pass data into another program or load into a data structure.</p><pre>import json<br>json_string = json.dumps([1, 2, 3])<br></pre><p>Python has a proprietary data serialization method called <strong>pickle. </strong>There is another alternative to it named <strong>cPickle</strong> which is faster.</p><pre>import pickle<br>pickled_string = pickle.dumps([1, 3, a, s])<br>print(pickle.loads(pickled_string))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*B9HM7D64LcOtrRI-" /></figure><p><strong>2. Partial Functions</strong></p><p>There is partial function from functions library. It allows you to derive a function with a parameter to a function with fewer parameters and fix value set for more limited function.</p><pre>from functools import partial<br><br>def add(x, y):<br>        return x +y<br><br>dbl = partial(add, 2)<br>print(dbl(4))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*hVov5_DeGoxGLi_S" /></figure><p><strong>3. Code Introspection</strong></p><p>Code introspection is a program’s ability to examine the type, properties, structure, or values of an object and its code metadata at runtime. It lets developers inspect classes, functions and modules while an app runs to see what they do and contain.</p><p>It is commonly used for debugging — to inspect the unexpected change of state or values of the variables and object, frameworks and ORMS — to automatically map database fields to code properties.</p><p>Some popular tools in python are:- type(), dir(), help(), isinstance(). id(), callable() and so on.</p><p><strong>4. Closures</strong></p><p>Closure is a nested function that remembers and accesses variables from its outer function’s scope, even after the outer function has finished its execution. Nested function is another function which is inside a function.</p><pre>def print_msg(number):<br>    def printer():<br>        print(number)<br>    printer()<br><br>print_msg(9)</pre><p>Its major advantage is it can avoid use of global variables and provides some form of data hiding. It is use for data encapsulation, memory efficiency and function factories.</p><p><strong>5. Decorators</strong></p><p>Decorators is a design pattern that allows you to modify or extend the behavior of a function or class without permanently changing its source code. Its common usages are logging, access control, caching and measuring execution time.</p><pre>def changecase(func):<br>  def myinner():<br>    return func().upper()<br>  return myinner<br><br>@changecase<br>def myfunction():<br>  return &quot;Hello Sally&quot;<br><br>@changecase<br>def otherfunction():<br>  return &quot;I am speed!&quot;<br><br>print(myfunction())<br>print(otherfunction())</pre><p><strong>6. Map, Filter, Reduce</strong></p><p><strong>Map</strong> function returns a list.</p><pre>my_list = [&#39;zippy&#39;, &#39;yolk&#39;, &#39;maxine&#39;]<br>upper = list(map(str.upper, my_list))</pre><p>here, upper takes one argument so we passed one iterable to it.</p><p><strong>Filter</strong> function returns boolean values and then passes each element in th iterable through the functions.</p><pre>num = [34. 32, 90. 53, 80]<br><br>def isLessThanFifty(n):<br>  return num &lt; 50<br><br>lessNum = list(filter(isLessThanFifty, num))<br>print(lessNum)</pre><p><strong>Reduce</strong> applies a function of two arguments cumulatively to the elements of an iterable, optionally its starts with an initial argument. <br>syntax: reduce(func, iterable[ , initial])</p><pre>from functiontools import rduce<br><br>num = [4, 3, 2, 9, 7]<br><br>def custom_sum(first, second):<br>  reutrn first + second<br><br>result = reduce(custom_sum, numbers)</pre><p><strong>7. Parsing CSV Files</strong></p><p>CSV — Comma Separated Value. A standard way to parse <strong>CSV</strong> files in python is by using built-in csv module.</p><pre>import csv<br><br>with opn(&quot;data.csv&quot;, mode=&quot;r&quot;, encoding=&quot;utf-8&quot;) as file:<br>  reader = csv.reader(file)<br>  for row in reader:<br>    print(row)</pre><p>Some common features are:</p><p>csv.writer<br>csv.writer<br>csv.field_size_limit etc.</p><p>That’s it. Now, you are I, we both know equal amount of python.</p><p>Enjoy Your Life</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=933c4563f252" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advance Python Concept I]]></title>
            <link>https://medium.com/@leekhitame/advance-python-concept-i-29de3049dbd9?source=rss-c6e00383ab1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/29de3049dbd9</guid>
            <category><![CDATA[advance-python]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Leekhitame]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 16:49:39 GMT</pubDate>
            <atom:updated>2026-08-05T16:49:39.000Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>The Memory Overhead Challenge</strong></h4><p>In conventional Python programming, data structures like lists, tuples, and dictionaries offer excellent versatility. However, they come with a significant performance trade-off: memory footprint. When you instantiate a list with, say, 1 million integers, the interpreter allocates a contiguous block of memory large enough to hold references to all those objects simultaneously. This <em>eager evaluation</em> strategy is often suboptimal — or entirely infeasible — for applications dealing with large-scale data streams, log files, or IoT telemetry. It can lead to high RAM consumption, garbage collector thrashing, and ultimately, MemoryError exceptions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*4aasNxrK8QshTwqf" /><figcaption>fig: not the one I am talking about</figcaption></figure><ol><li><strong>Generators</strong></li></ol><h4>The Generator Paradigm</h4><p>Generators solve this architectural bottleneck through lazy evaluation — a hallmark of functional programming. A generator does not compute all values at once. Instead, it pauses its state after yielding a value and resumes exactly where it left off when requested. This means they operate with O(1) memory complexity regardless of the total sequence length, as they only store the current state of the frame, not the entire dataset.</p><h4>Under the Hood: The yield Keyword</h4><p>Unlike standard functions that use return to terminate execution and discard the local scope, a generator function uses the yield keyword. This transforms the function into a generator object that implements the iterator protocol—specifically the __next__() method.</p><p>When you call next(gen), the function executes until it hits a yield, emits the value, and suspends its stack frame (including local variables, loop counters, and instruction pointer). Upon the subsequent next() call, the frame is reactivated, and execution continues seamlessly.</p><pre>def generators:<br>  for i in range(400):<br>    yield i<br><br>gen = generators()<br>print(next(gen)) #prints 0<br>print(next(gen)) #prints 1</pre><p><strong>2. List Comprehension</strong></p><p>It creates a new list based on the another list, in a single and readable form.<br>It helps you write multiple lines of code in a single one.</p><p>In the below example:<br>word_len2 = [len(word) for word in words if word != ‘are’]</p><p><strong>len(word)</strong> the return value<br><strong>for word in words </strong>the for loop<br><strong>if word != ‘are’</strong> its condition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovHIVy5wEX-eQf0Ioanx-Q.png" /></figure><p>3. Lambda Function</p><p>Lambda function is an inline function which is defined at the same place we want to call it. Other def function is defined at one place and called at another. Lambda function is easy to track and find what is being done in this function. It is also known as anonymous function.</p><p>syntax:<br>my_lambda_function = lambda x, y : x + y<br><strong>my_lambda_function</strong> function name<br><strong>lambda </strong>keyword<br><strong>x, y</strong> inputs<br><strong>:</strong> colon to separate input and output<br><strong>x + y</strong> outputs</p><pre>which_num = lambda x : &#39;even&#39; if x % 2 == 0 else &#39;odd&#39;<br>print(which_num(2))<br><br>numbers = [2, 3, 4, 5, 7]<br><br># lambda way<br>ans = lambda i : &#39;even&#39; if i % 2 == 0 else &#39;odd&#39;<br>results = list(map(ans, numbers))<br>print(results)<br>    <br># list comprehension<br>results = [&#39;even&#39; if num % 2 == 0 else &#39;odd&#39; for num in numbers ]<br>print(results)</pre><p><strong>4. Multiple Function Argument</strong></p><p>Functions in python gets predefined number of argument.</p><pre>def func (a, b, c):<br>  if a != 0:<br>    return a<br><br>print(func(3, 4, 5)</pre><p>If we pass another argument *options, it can pass multiple argument. We can pass multiple argument using *options where arguments are passed as a tuple. If we use **options then it wants argument to be passed as dictionary.</p><ul><li><strong>options </strong>when you don’t know how many positional argument you may pass<br>commonly known as <strong>*agrs</strong></li><li><strong>**options </strong>when you don’t know how many keywords argument you may pass<br>commonly known as <strong>**kwargs</strong></li></ul><pre><br>def func (a, b, c, *options):<br>    if a != 0:<br>        if options[0] == &#39;add&#39;:<br>            return a + b + c<br><br>print(func(1, 2, 5, &#39;add&#39;))<br><br>def func1 (a, b, c, **options):<br>    if options.get(&#39;actions&#39;) == &quot;subs&quot;:<br>        return b - c<br>        <br>print(func1(7, 9, 1, actions = &#39;subs&#39;, attri = &#39;mul&#39;))</pre><p><strong>5. Regular Expression</strong></p><p>It is use to match the pattern of text. For an example:</p><pre>import re<br><br>text = &quot;I have 2 dogs and 15 cats.&quot;<br><br>numbers = re.findall(r&quot;\d+&quot;, text)<br><br>print(numbers)</pre><p>here, we are using re module then with re.findall we are finding all 0-9 digits from text. \d is the key to find 0–9 digits.</p><p><strong>6. Exception Handling</strong></p><p>Sometimes, our code might blast due to various reason. In order to handle error and perform anything when the certain exception is raised then we can do exception error handling <em>try/except</em> block.</p><pre>try:<br>    a = 10<br>    b = 0<br>    print(a / b)<br>except ZeroDivisionError:<br>    print(&quot;You cannot divide by zero.&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*GcRd1spSsFhx7A1sLs6-ww.png" /></figure><p><strong>7. SETS</strong></p><p>Set do not let any duplicate value to enter in its list.</p><pre>print(set(&quot;my name is likhita and likhita is my duplicate name&quot;.split()))</pre><p>functions in sets are:</p><p><strong>system_difference:</strong> to find difference in both set</p><p><strong>difference: </strong>to find who is in only one set</p><p><strong>intersection: </strong>to find which is in both set</p><p><strong>union: </strong>to find who are in both sets</p><pre>a = set([&quot;ann&quot;, &quot;billy&quot;, &quot;cabel&quot;])<br>b = set([&quot;billy&quot;, &quot;rino&quot;])<br><br>print(a.symmetric_difference(b)) <br>print(b.symmetric_difference(a))<br><br>print(a.difference(b))<br>print(b.difference(a))<br><br>print(a.intersection(b))<br>print(b.intersection(a))<br><br>print(a.union(b))</pre><p>Thank you for reading. Take a break, get a sip of water. And, wait for part two of this article with more advance concept on python.</p><p>Enjoy Your Life.</p><p>LA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29de3049dbd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>