<?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 simi on Medium]]></title>
        <description><![CDATA[Stories by simi on Medium]]></description>
        <link>https://medium.com/@iamsimi?source=rss-bd36b0dae678------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mR8h6028HWMheyc6M0ZsNQ.jpeg</url>
            <title>Stories by simi on Medium</title>
            <link>https://medium.com/@iamsimi?source=rss-bd36b0dae678------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:49:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iamsimi/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[Build a backend api with an npm package, a package.json and .env.]]></title>
            <link>https://iamsimi.medium.com/build-a-backend-api-with-an-npm-package-a-package-json-and-env-41aad4c2718f?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/41aad4c2718f</guid>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 22:30:07 GMT</pubDate>
            <atom:updated>2025-10-30T22:30:07.735Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build a backend api with an npm package, a package.json and .env.</h3><p>Hi, I am simi and I am the author of silobase.</p><p>Silobase is a backend-as-a-service project like supabase but not tied to only postgresdb or firebase with a proprietary database. Using silobase you can bring your own database and setup a backend project using the env file.</p><p>In this tutorial, I will setup a database on render and use the silobase npm package to spin up a backend project that will be deployed on render too.</p><p>Deploying the database.</p><ol><li>Setup the database</li></ol><p>Use this link to create a postgres database on render and fill in the appropriate details: <a href="https://dashboard.render.com/new/database">https://dashboard.render.com/new/database</a>.</p><p>Remember to keep your credentials (database url, db username and db password) so you can use it to connect the Backend project to the database.</p><p>2. Create tables on the database.</p><p>Typically using firebase or supabase, you have to login to the UI to create the table but since I am managing the database myself, I would have to create the tables i need. or if i have an existing table i can scrap this step and step 1.</p><p>2.1 Connect to the database using a db tool like Dbeaver or PgAdmin for postgres. Use the credentials given to you by render. And create a table, here is a sample of the script to create on</p><pre>CREATE TABLE users (<br>    id SERIAL PRIMARY KEY,<br>    username VARCHAR(50) UNIQUE NOT NULL,<br>    email VARCHAR(100) UNIQUE NOT NULL,<br>    password_hash TEXT NOT NULL,<br>    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,<br>    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP<br>);</pre><p>Deploying the backend.</p><ol><li>Create a a GitHub repository and add a package.json to it, here is a sample:</li></ol><pre>{<br>  &quot;name&quot;: &quot;silobase-app&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;Silobase deployment on render&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;silobase start&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;silobase&quot;: &quot;1.0.0&quot;<br>  },<br>  &quot;engines&quot;: {<br>    &quot;node&quot;: &quot;&gt;=18&quot;<br>  }<br>}</pre><p>this script installs silobase package and then starts the backend server. When I clone locally and run</p><pre>npm install &amp;&amp; npm start</pre><p>this logs show to show that the server is starting</p><pre><br>&gt; silobase-app@1.0.0 start<br>&gt; silobase start<br><br>{&quot;level&quot;:30,&quot;time&quot;:1759347355686,&quot;pid&quot;:90989,&quot;hostname&quot;:&quot;miro&quot;,&quot;msg&quot;:&quot;Server listening at http://127.0.0.1:3000&quot;}<br>🚀 Server running on port 3000<br>{&quot;level&quot;:30,&quot;time&quot;:1759347355687,&quot;pid&quot;:90989,&quot;hostname&quot;:&quot;miro&quot;,&quot;msg&quot;:&quot;Server listening at http://192.168.1.3:3000&quot;}</pre><p>2. Deploy on render</p><p>Create a new service and connect it to your GitHub account. Once connected to your GitHub, select the repo you created previously.</p><p>Update the build command to npm build</p><p>And the start command to npm start</p><p>Then include the environment variables to connect the database to the backend api and also setup the API keys that clients can use to call the rest endpoint.</p><p>Here is a sample of a .env file</p><pre>DB_CLIENT=pg          <br>DB_HOST=localhost<br>DB_USER=myuser<br>DB_PASSWORD=mypassword<br>DB_PORT=5432<br>DB_NAME=mydb<br><br>API_KEY_READ=read_key<br>API_KEY_WRITE=write_key<br>API_KEY_FULL=admin_key<br><br>MASK_FIELDS=password,ssn</pre><p>fill in the db credentials with what you copied from having setup the database in section 1.</p><p>For the different api keys, generate some with an MD5 hash key generator to secure the api calls.</p><p>Once it’s all done click on the button to deploy web service.</p><p>3. Testing the deployment</p><p>The deployed app on render should show a url like this :<br><a href="https://silobase-medium-test.onrender.com/">https://silobase-medium-test.onrender.com/</a></p><p>Based on the sample request docs for silobase here: <a href="https://silobase.vercel.app/getting-started/example-requests.html">https://silobase.vercel.app/getting-started/example-requests.htm</a>l and the table created previously and the api key. Here is a curl script to get users from the users table created with the read api key</p><pre>curl --location &#39;https://silobase-medium-test.onrender.com/rest/v1/users&#39; \<br>--header &#39;x-api-key: &lt;API_KEY_READ&gt;&#39; \<br>--data &#39;&#39;</pre><p>here is a sample result</p><pre>{<br>    &quot;status&quot;: &quot;success&quot;,<br>    &quot;data&quot;: {<br>        &quot;count&quot;: 5,<br>        &quot;rows&quot;: [<br>            {<br>                &quot;id&quot;: 1,<br>                &quot;username&quot;: &quot;alice&quot;,<br>                &quot;email&quot;: &quot;alice@example.com&quot;,<br>                &quot;password_hash&quot;: &quot;******&quot;,<br>                &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>                &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>            },<br>            {<br>                &quot;id&quot;: 2,<br>                &quot;username&quot;: &quot;bob&quot;,<br>                &quot;email&quot;: &quot;bob@example.com&quot;,<br>                &quot;password_hash&quot;: &quot;******&quot;,<br>                &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>                &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>            },<br>            {<br>                &quot;id&quot;: 3,<br>                &quot;username&quot;: &quot;charlie&quot;,<br>                &quot;email&quot;: &quot;charlie@example.com&quot;,<br>                &quot;password_hash&quot;: &quot;******&quot;,<br>                &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>                &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>            },<br>            {<br>                &quot;id&quot;: 4,<br>                &quot;username&quot;: &quot;diana&quot;,<br>                &quot;email&quot;: &quot;diana@example.com&quot;,<br>                &quot;password_hash&quot;: &quot;******&quot;,<br>                &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>                &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>            },<br>            {<br>                &quot;id&quot;: 5,<br>                &quot;username&quot;: &quot;eve&quot;,<br>                &quot;email&quot;: &quot;eve@example.com&quot;,<br>                &quot;password_hash&quot;: &quot;******&quot;,<br>                &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>                &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>            }<br>        ]<br>    },<br>    &quot;code&quot;: 200<br>}</pre><p>the password_hash is masked as it is built into silobase to mask sensitive fields and you can also add more fields to mask in the .env settings here</p><pre>MASK_FIELDS=password,email</pre><p>And that is how you have a backend api setup using only a package.json file and .env file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41aad4c2718f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy a Backend API in Minutes with Silobase]]></title>
            <link>https://iamsimi.medium.com/how-to-deploy-a-backend-api-in-minutes-with-silobase-f6f7cf79e33e?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6f7cf79e33e</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Wed, 01 Oct 2025 20:21:39 GMT</pubDate>
            <atom:updated>2025-10-02T03:22:10.277Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Locl8k9uIGmFt7aI" /></figure><p>Hi, I’m Simi, the author of <a href="https://silobase.vercel.app/introduction/what-is-silobase.html">Silobase</a>.</p><p>Silobase is an <strong>open-source backend-as-a-service (BaaS)</strong>, similar to Supabase or Firebase — but without vendor lock-in. Instead of being tied to Postgres (Supabase) or a proprietary database (Firebase), Silobase lets you <strong>bring your own database</strong>.</p><p>With just a package.json and a .env file, you can spin up a REST API on top of your database in minutes. In this tutorial, I’ll show you how to:</p><ol><li>Set up a Postgres database on Render</li></ol><p>2. Deploy Silobase as your backend on Render</p><p>3. Test the API with sample requests</p><h4>1. Set up your database</h4><h4>Create a database on Render</h4><p>Head to <a href="https://dashboard.render.com/new/database">Render’s dashboard</a> and create a new Postgres database.<br> Save the credentials (database URL, username, password, host, and port) — you’ll need them later.</p><h4>Create tables</h4><p>Unlike Firebase or Supabase, where you log into a web UI to create tables, with Silobase <strong>you control your own database schema</strong>.</p><p>Connect to your Render Postgres database with a tool like <strong>DBeaver</strong> or <strong>PgAdmin</strong>, then run this SQL to create a users table:</p><pre>CREATE TABLE users (<br>    id SERIAL PRIMARY KEY,<br>    username VARCHAR(50) UNIQUE NOT NULL,<br>    email VARCHAR(100) UNIQUE NOT NULL,<br>    password_hash TEXT NOT NULL,<br>    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,<br>    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP<br>);</pre><p>If you already have existing tables, you can skip this step.</p><h4>2. Set up Silobase locally</h4><p>First, create a new GitHub repository and add a package.json like this:</p><pre>{<br>  &quot;name&quot;: &quot;silobase-app&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;Silobase deployment on Render&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;silobase start&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;silobase&quot;: &quot;1.0.0&quot;<br>  },<br>  &quot;engines&quot;: {<br>    &quot;node&quot;: &quot;&gt;=18&quot;<br>  }<br>}</pre><p>Install dependencies and start the backend locally:</p><pre>npm install &amp;&amp; npm start</pre><p>You should see logs confirming the server is running:</p><pre>&gt; silobase-app@1.0.0 start<br>&gt; silobase start<br><br>Server running on port 3000<br>Server listening at http://127.0.0.1:3000</pre><h4>3. Deploy Silobase on Render</h4><h4>Create a new Render service</h4><ul><li>Link your GitHub repository</li><li>Set the <strong>Build Command</strong>: npm build</li><li>Set the <strong>Start Command</strong>: npm start</li></ul><h4>Configure environment variables</h4><p>Add a .env file to store your DB connection and API keys. Example:</p><pre>DB_CLIENT=pg<br>DB_HOST=your-db-host<br>DB_USER=youruser<br>DB_PASSWORD=yourpassword<br>DB_PORT=5432<br>DB_NAME=yourdbname<br><br>API_KEY_READ=read_key<br>API_KEY_WRITE=write_key<br>API_KEY_FULL=admin_key<br>MASK_FIELDS=password,ssn</pre><ul><li>Fill in the DB credentials from your Render database</li><li>Generate secure API keys (you can use an online MD5/UUID generator)</li><li>Add any sensitive fields you want masked in API responses</li></ul><p>Click <strong>Deploy Web Service</strong> and wait for Render to build and launch your backend.</p><h4>4. Test your API</h4><p>Once deployed, Render will give you a URL like:</p><pre>https://silobase-demo.onrender.com/</pre><p>Now you can query your database through Silobase. For example, to fetch all users with your read-only API key:</p><pre>curl --location &#39;https://silobase-demo.onrender.com/rest/v1/users&#39; \<br>--header &#39;x-api-key: &lt;API_KEY_READ&gt;&#39;</pre><p><strong>Sample response:</strong></p><pre>{<br>  &quot;status&quot;: &quot;success&quot;,<br>  &quot;data&quot;: {<br>    &quot;count&quot;: 5,<br>    &quot;rows&quot;: [<br>      {<br>        &quot;id&quot;: 1,<br>        &quot;username&quot;: &quot;alice&quot;,<br>        &quot;email&quot;: &quot;alice@example.com&quot;,<br>        &quot;password_hash&quot;: &quot;******&quot;,<br>        &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>        &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>      },<br>      {<br>        &quot;id&quot;: 2,<br>        &quot;username&quot;: &quot;bob&quot;,<br>        &quot;email&quot;: &quot;bob@example.com&quot;,<br>        &quot;password_hash&quot;: &quot;******&quot;,<br>        &quot;created_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;,<br>        &quot;updated_at&quot;: &quot;2025-10-01T19:37:41.290Z&quot;<br>      }<br>    ]<br>  },<br>  &quot;code&quot;: 200<br>}</pre><p>Notice how password_hash is automatically masked—Silobase ensures sensitive fields don’t leak through your API. You can configure additional fields to mask via the .env file:</p><pre>MASK_FIELDS=password,email</pre><h4>That’s it!</h4><p>In just a few steps, you’ve:</p><ul><li>Created a Postgres database on Render</li><li>Deployed Silobase as your backend API</li><li>Queried your database securely with API keys and field masking</li></ul><p>With Silobase, deploying a backend API is as simple as writing a package.json and a .env file. No boilerplate code, no custom backend, no vendor lock-in. Just your database + Silobase = production-ready API.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6f7cf79e33e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Watering your own garden. Breathing life into your own existence.]]></title>
            <link>https://iamsimi.medium.com/watering-your-own-garden-breathing-life-into-your-own-existence-3b2e0af3d655?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b2e0af3d655</guid>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 18:04:41 GMT</pubDate>
            <atom:updated>2025-01-13T18:04:41.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RDCoiNHlVPRcc7kJ" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve seen the phrase somewhere before: “water your garden and let the butterflies come.” It’s often used to describe the concept of attraction — that when you focus on nurturing yourself, the things you want in life will naturally come to you. But that’s not the context today.</p><p>Today, this is about you. About being unapologetically selfish — or maybe it’s better to say, about putting yourself first. Watering your own garden. Breathing life into your own existence.</p><p>It’s about letting everything burn to the ground and finally realizing that you don’t have to be the savior. Your time on this planet isn’t infinite, and you can only give so much. It’s time to evaluate your life, to identify what nurtures <em>you</em>.</p><p>Maybe that’s a solo date to your favorite cafe. Maybe it’s signing up for that kung fu class you’ve always been curious about. Or perhaps you’ve been wanting to try archery — find a local club and give it a shot. If these things feel too costly, ask yourself how much money you’ve spent on things that aren’t essential. You’ve probably justified spending on other people’s needs while putting your own wants on the backburner. Suddenly, the swimming lessons you were going to take become less of a priority when someone else urgently needs your time or money. It’s easy to let other people’s needs overshadow your own.</p><p>But here’s the thing: <strong>being selfish isn’t the problem</strong>. Maybe “selfish” is too harsh a word. Perhaps a better way to frame it is: <em>putting yourself first</em>. If your version of “watering your garden” means being the person who pours into others, that’s okay — but only if it’s truly your delight in life. If you genuinely love being there for others and it fills you up, then go ahead. But if it drains you, it’s time to change.</p><p>So, here’s a little reminder: Listen to that jazz playlist while sipping your concocted cocktail — the one with noodles and fried eggs. You worked hard for it, so savor it. Enjoy that moment.</p><p>You’ve earned it. And remember: <strong>YOLO</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b2e0af3d655" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quants self-study journal]]></title>
            <link>https://iamsimi.medium.com/quants-self-study-journal-a210020ca20c?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/a210020ca20c</guid>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 16:54:04 GMT</pubDate>
            <atom:updated>2024-10-07T16:54:04.689Z</atom:updated>
            <content:encoded><![CDATA[<p><em>My name is Simi I have a background in Mechanical in Engineering (Graduated 2019). Spent (and currently) the last five years as a Software Engineer and in those years I have fallen in love with finance.</em></p><p><em>This is a personal journal at trying to break into the work of quantitative finance. I know I have to focus(revisit) Mathematics, Finance and Programming.</em></p><p><em>Caveat — I write C# and python but I am trying to pick up C++ with it.</em></p><p><strong><em>Here is the syllabus I am following:</em></strong></p><pre>Maths <br>Linear Algebra.<br>https://www.khanacademy.org/math/linear-algebra<br><br>Single &amp; Multivariable Calculus.<br>https://www.khanacademy.org/math/multivariable-calculus <br><br>Probability &amp; Statistics<br>https://www.khanacademy.org/math/statistics-probability<br><br>Finance <br>Hull book <br><br>C++<br>https://youtube.com/playlist?list=PLdo5W4Nhv31YU5Wx1dopka58teWP9aCee&amp;si=LI-_j-SPAi9f9Tjc<br>https://roadmap.sh/cpp  <br><br>DSA<br>https://techdevguide.withgoogle.com/paths/data-structures-and-algorithms/ <br>https://careersonair.withgoogle.com/events/data-structure-series </pre><p><em>I would be uploading my notes every time I study both for myself and myself.</em></p><p><strong><em>Notes:</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a210020ca20c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Development on the M1 Mac: Connecting to Microsoft SQL Server using Python.]]></title>
            <link>https://iamsimi.medium.com/development-on-the-m1-mac-connecting-to-microsoft-sql-server-using-python-14fd5012c8d6?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/14fd5012c8d6</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 10:20:11 GMT</pubDate>
            <atom:updated>2023-09-13T10:20:11.444Z</atom:updated>
            <content:encoded><![CDATA[<p>Last night (August 12, 2023), I tried to connect a Python script to a Microsoft SQL Server and it was not the best of the experience. I have installed it now, so I am documenting the steps for my future self and others.</p><p>There are two packages that <a href="https://learn.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server?view=sql-server-ver16"><em>Microsoft places its testing efforts and its confidence</em></a><em>, </em>the <a href="https://pypi.org/project/pyodbc/"><strong>pyodbc</strong></a> and the <a href="https://pypi.org/project/pymssql/"><strong>pymssql</strong></a><strong>. I</strong> would be writing about pyodbc cos that was what worked for me.</p><h4>step 1: Install the ODBC driver using homebrew</h4><pre>brew install unixodbc</pre><h4>step 2: Install the binary of the pyodbc instead of following what you see on the python package index:</h4><pre>pip install - pre - no-binary :all: pyodbc</pre><p>try to run the script that uses the pyodbc to see if it works cos some people said this one step fixed it for them. If it worked. Then you’re good to go, if not step three.</p><h4>step 3. Install the drivers. On running step 2, you should get an error about a certain version of the driver being missing. In my case, it complained about the Microsoft ODBC driver 17, which was sorted with this command from the Microsoft page</h4><pre>/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)&quot;<br>brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release<br>brew update<br>HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools</pre><p>Your case might be different. But you can check out these pages.</p><p>To install for Mac: <a href="https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15">https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15</a></p><p>To install for Linux: <a href="https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15&amp;tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline">https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15&amp;tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline</a></p><h4>A key thing to note is to listen to the errors, they have a way of directing you. I think that’s a thing for everything software engineering.</h4><p>Happy tinkering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14fd5012c8d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Theory of Maintainable Energy: The energy to lasting things.]]></title>
            <link>https://iamsimi.medium.com/the-theory-of-maintainable-energy-the-energy-to-lasting-things-bd1559baab0f?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd1559baab0f</guid>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[life-hacking]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[lifestyle]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 19:01:20 GMT</pubDate>
            <atom:updated>2023-08-02T19:01:20.488Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever had an idea and jumped on it but after some days you could not continue because the “motivation” is no longer there? Have you ever met a new person and it was electric you both were chatting every day and after some days it felt like there is no“fire” anymore.</p><h4>Well, I have a theory of why that is. I call it the Theory of maintainable Energy.</h4><p>Stay with me.</p><p>Growing up I loved running long distances. I was not the best at it but I didn’t suck at it either. So if you ever run a long-distance race (marathon, 400 m race), one thing they would always tell you, is do not start on a high note. My coach then would tell us to conserve our energy for the final lap cos as humans you cannot maintain high energy throughout the race. You have to find your maintainable Energy. You can peak once in a while in the race to gain an advantage but always remember you cannot peak throughout the race so save your “peaks”.</p><p>Are you still here?</p><p>Now let’s move to start an activity. When you and I start a new activity, our brain is excited. We start to process new information for this adventure and our neurons are firing against each other — literally fire in our bones. But as it turns out this “fire in our bones” cannot run on forever. After a while, it starts to dim and grows dimmer till it’s put out. Then you have unfinished projects 100. At times we try to rekindle it but because our brain has set the acceptable like for the fire it needs, the fire that is brought back on rekindling it is not big enough to joust us to start on this new activity again. We want to feel that stream of energy we started with but Naha, we may not be able to.</p><p><em>So what does the theory of maintainable Energy tell us:</em></p><p><strong>The Theory of Maintainable Energy states that, for an event that is expected to take a substantial amount of time, it is necessary that at the beginning, the parties involved find the right amount of energy that can be maintained over the course of the event. This energy serves as the baseline for all energies and no energy can go below this energy.</strong></p><blockquote><em>A very important note: The theory is that the energy being discussed is not the worst-case scenario or the bare minimum. It is the resting energy from which you can touch the zenith and still have a soft landing without compromising the event. (See 2nd Law of Thermodynamics)</em></blockquote><h3>Okay, how does one apply it?</h3><h4>Find excesses and trim it</h4><p>Let’s track back to when you had an idea. Typically the first feeling we have is that of excitement and so big of an excitement we are <strong>daydreaming</strong> of how it would change the world or exit at an IPO in x-years, and that’s the first excess. We have not built the app and we are already having IPO problems, regulatory issues, etc.</p><p><strong>So stop the mental calculations and focus on only solving the problem. </strong>Not changing the world or turning it into a billion-dollar app. Just focus on what the idea is about and start work. Daydreaming drains a lot of energy from you and this is not an energy you can maintain. No one can. You’d realize dropping this amount of energy gives you the energy that can be maintained.</p><p><strong>Wait, am I saying daydreaming is bad? </strong>Say 80% of the time — haha. Dreaming is the good one. Dreaming is big plans that have an end while daydreaming is at best wishful thinking.</p><p><strong>Another excess is going around to tell everyone about your ideas</strong>. Asides from the fact that people can steal your idea or they may tell you it’s a dumb one, you should ask yourself, what’s the aim of telling anyone? Honestly why tell anyone about your idea if they are not going to make it come to life? I wouldn’t dwell much on this but there are so many scientific papers on why you should.</p><p><em>Another way to follow the Theory</em></p><h4>Don’t start with that great energy in the first place</h4><p>Yeah, that’s another way to apply it. I gave an illustration at the beginning of a 400m race earlier but if sports doesn’t do it for you music should. The word is <em>Crescendo</em>.</p><p><strong>Crescendo your energy. </strong>Start from the most reasonable and increase it with time. Space the increase so you can evaluate after every increase if you can go on or you should revert to earlier energy.</p><p>So when talking to a new babe or guy, don’t try to talk every day or every minute. Yeah, we all spend an ungodly amount of time on our phones and we buy data before we buy food. But you shouldn’t be talking to them all the time because you and them cannot maintain the same electric energy all the conversation. If we are actually talking about romance, longing is actually a good ingredient every literature out there talks about it.</p><p>Even with longing not being a good romance, you cannot always have something to talk about all day — well if you have then maybe that’s some co-dependency right there, we can talk about that later. But you catch the drift. <strong>Allow time. </strong>Time to find good topics, to find the energy that you can both maintain and not feel like you are drained at the end of the day.</p><p>I know you what them to fall for you as fast as possible cos you’re already daydreaming about the cute picture and hugs and kisses etc. But remember what we said about daydreaming? It’s good, but a chunk of our energy should not go there. I mean who knows if you would all be friends by the next moon season?</p><p>I could go on with the raw cases of how the “theory of maintainable energy” comes into our life but I believe you get the gist now.</p><h3><strong>Though one question that might be popping into your mind is this energy might be boring.</strong></h3><p>But is boring inherently bad? I mean if you are not an amusement park you are expected to have boring days. It’s totally fine to have boring days. In an actual sense, we would have more boring days than fun days because that’s what makes it fun. Friday night is fun because we get to go to the club after 5 days of going to work seeing the same set of people, doing the same thing, and walking the same route. Switch it and start partying every night and with time it also becomes boring. So maybe our definition of boring is erred.</p><p><strong>If we try to define fun in the concept of energy, it is the ability to change your energy every day. Wait did I just say change? I meant you have to continually increase your energy every day if you want a non-boring life. If you did sky-diving today you have to top it tomorrow to keep up with the excitement and on and on.</strong></p><p>Scientifically the energy would be represented as a random walk that increases with time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*kOXhHkBQv1w_6TBE.png" /></figure><p>and no human can because we are not a never-exhausting machine, our energies are finite.</p><p>So yeah we are all boring at the end of the day.</p><h4><strong>Does “Maintainable Energy” lead to a boring life? Absolutely not. Does it lead to boring days? Totally. A boring day is not a boring life.</strong></h4><p><strong>Maintainable energy </strong>is a resting energy that allows you to increase your energy as high as you want and come back without anyone telling you, “I don’t think we should be together anymore, it’s not you it’s me”. So your 4 days can be boring, but 5th day is a jam. That’s what the energy is talking about. And once you figure out this energy, you begin to have more energy for those “fun” days that come, like saving for the rain.</p><p>And boy do they last long. I mean they are easy to maintain duh.</p><p>There are a couple of misconceptions about boring. For one, we correlate that boringness to sadness which is not. Boring can be sad but not every boring is sad. And when you look at the baseline of boring, it is good. Boring is the one that works on a schedule, and does something regardless of motivation. It is boring that has something to say when it has something to say and shuts up when it doesn’t.</p><p>I’ll end on this note.</p><p>For over a decade now, there is one name on the richest man in the world, Warren Buffet. To most, Warren has had a “boring approach” — sticking to one thing — to gathering wealth and that’s investing in companies. He has never for once tried to change his energy at gathering wealth even in the tech boom when everyone was creating tech companies here and there. The man of Omaha knew the energy he can maintain. He knows can read about a company, evaluate it, and put money in it. He is not interested in creating the next social network or joining the AI craze or the space race — remember blue origins. And he has maintained this for years.</p><p>The ultimate evidence of why boring things last</p><h4><strong>Now if your aim is not to last but to burn quickly like a shooting star, fire one and follow the principle of a shooting star. Move very fast and pray that the energy carries you through your time.</strong></h4><p><strong>PS: This is based on readings and observations from the author’s perspective and the author recognizes that there could exist outliers.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd1559baab0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a Web Server in C#]]></title>
            <link>https://iamsimi.medium.com/writing-a-web-server-in-c-12b93134082b?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/12b93134082b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-server]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 05:41:06 GMT</pubDate>
            <atom:updated>2023-03-07T17:48:48.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxBRUnHoGIwt6jAHc4-lqw.jpeg" /><figcaption>sof</figcaption></figure><p>A Web Server is an application that is expecting a request from a client on a particular port and returns (serves) website components (HTML files, JS files, CSS files, images etc.) to that client. The server is said to be listening on this port.</p><p>The web server or HTTP (<em>HyperText Transfer Protocol)</em> server consists of software and hardware components. The hardware part stores the website components while the software accepts request that follows the HTTP protocol and serves the corresponding file.</p><p>A client (e.g. web browser) requests a particular file to a web server on one of its open ports using either HTTP/HTTPS over the internet. The web server validates this request and retrieves the requested resource/file from the storage. If the resource is available, it returns it otherwise it returns with a Not Found (404).</p><p>This article assumes you’re already familiar with HTTP/HTTPS, and that you have a moderate level of programming experience in C#.</p><h4>Opening a Port</h4><p>Though the web browser makes a request to a web server through a domain name (www.google.com), the web servers make use of IP addresses. Thus, before the request hits the web server, the request from the browser first hits a DNS (Domain Name System) which translates it to an IP address (216.58.223.238) of the web server. A port on the server is dedicated to listening to/expecting the request from the web browser/client.</p><p>Here is a sample of setting up the web server with the address and port and also listening for requests:</p><pre>private static TcpListener myListener;<br>private static int port = 5050;<br>private static IPAddress localAddr = IPAddress.Parse(&quot;127.0.0.1&quot;);<br><br>//web server path<br>private static string WebServerPath = @&quot;WebServer&quot;;<br><br>static void Main(string[] args)<br>        {<br>             myListener = new TcpListener(localAddr, port);<br>                myListener.Start();<br>   Console.WriteLine($&quot;Web Server Running on {localAddr.ToString()} on port {port}... Press ^C to Stop...&quot;);<br>                Thread th = new Thread(new ThreadStart(StartListen));<br>                th.Start();<br>        }<br><br>private static void StartListen()<br>        {<br>            while (true)<br>            {<br>                TcpClient client = myListener.AcceptTcpClient();<br>                NetworkStream stream = client.GetStream();<br>client.Close();<br>             }<br>        }</pre><h4>Setup the hardware component</h4><p>Create a folder named WebServer in the project to contain all the files that the server wants to serve.</p><p>Add a file namedefault.htmlto it. The default.htmlwill be the file to serve when the root page of the website is requested. Other routes like the contact page and about page will require corresponding files.</p><h4>Accepting Browser Requests</h4><p>When the request from the browser comes to the server, it comes with a payload/body and headers information depending on the type of HTTP request that is made.</p><p>For a typical GET request to the homage page of a website, here is a sample of what the browser sends in the header.</p><pre>GET / HTTP/1.1<br>Host: developer.mozilla.org<br>User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate, br<br>Referer: https://developer.mozilla.org/testpage.html<br>Connection: keep-alive<br>Upgrade-Insecure-Requests: 1<br>If-Modified-Since: Mon, 18 Jul 2016 02:36:04 GMT<br>If-None-Match: &quot;c561c68d0ba92bbeb8b0fff2a9199f722e3a621a&quot;<br>Cache-Control: max-age=0</pre><p>The server then interprets this request. The first line indicates the command; GET, the HTTP version; HTTP/1.1 and the resource to fetch; /. The entire line is then translated to “fetch the resource at the root directory using the HTTP/1.1 protocol.</p><p>If the server receives a different or malformed request, it returns an error to the client.</p><p>Here is the code to accept, extract and validate the header information.</p><pre> private static void StartListen()<br> {<br><br>while (true)<br>  {           <br>        TcpClient client = myListener.AcceptTcpClient();<br>        NetworkStream stream = client.GetStream();<br><br>        //read request <br>        byte[] requestBytes = new byte[1024];<br>        int bytesRead = stream.Read(requestBytes, 0, requestBytes.Length);<br><br>        string request = Encoding.UTF8.GetString(requestBytes, 0, bytesRead);<br>        var requestHeaders = ParseHeaders(request);<br><br>        string[] requestFirstLine = requestHeaders.requestType.Split(&quot; &quot;);<br>        string httpVersion = requestFirstLine.LastOrDefault();<br>        string contentType = requestHeaders.headers.GetValueOrDefault(&quot;Accept&quot;);<br>        string contentEncoding = requestHeaders.headers.GetValueOrDefault(&quot;Acept-Encoding&quot;);<br><br>        if (requestFirstLine != “GET”)<br>         {<br>           //response headers to broswer                <br>         }<br>         client.Close();<br>   }<br>}<br><br> private static (Dictionary&lt;string, string&gt; headers, string requestType) ParseHeaders(string headerString)<br> {<br>      var headerLines = headerString.Split(&#39;\r&#39;, &#39;\n&#39;);<br>      string firstLine = headerLines[0];<br>      var headerValues = new Dictionary&lt;string, string&gt;();<br>      foreach (var headerLine in headerLines)<br>      {<br>         var headerDetail = headerLine.Trim();<br>         var delimiterIndex = headerLine.IndexOf(&#39;:&#39;);<br>         if (delimiterIndex &gt;= 0)<br>         {<br>            var headerName = headerLine.Substring(0, delimiterIndex).Trim();<br>            var headerValue = headerLine.Substring(delimiterIndex + 1).Trim();<br>            headerValues.Add(headerName, headerValue);<br>         }<br>       }<br>       return (headerValues, firstLine);<br>  }</pre><p>The `ParseHeaders` takes the header information coming from the browser and</p><ul><li>extract the first line to the `firstLine` variable, and</li><li>extract the other browser information into a dictionary.</li></ul><h4>Responding to Browser</h4><p>The server in this tutorial only accepts a GET request and in a case wherein the request is different like a POST, an error is sent back to the browser.</p><p>For an error to be sent back, a payload and header information is required. This will inform the browser on how to treat the response.</p><p>Valid header information starts with the HTTP version, Status Code and the message all in the first line.</p><pre>HTTP/1.1 200 OK</pre><p>To send header information back to the browser in c#:</p><pre>private static void SendHeaders(string? httpVersion, int statusCode, string statusMsg, string? contentType, string? contentEncoding,<br>            int byteLength, ref NetworkStream networkStream)<br>        {<br>            string responseHeaderBuffer = &quot;&quot;;<br><br>            responseHeaderBuffer = $&quot;HTTP/1.1 {statusCode} {statusMsg}\r\n&quot; +<br>                $&quot;Connection: Keep-Alive\r\n&quot; +<br>                $&quot;Date: {DateTime.UtcNow.ToString()}\r\n&quot; +<br>                $&quot;Server: MacOs PC \r\n&quot; +<br>                $&quot;Content-Encoding: {contentEncoding}\r\n&quot; +<br>                &quot;X-Content-Type-Options: nosniff&quot;+<br>                $&quot;Content-Type: application/signed-exchange;v=b3\r\n\r\n&quot;;<br><br>            byte[] responseBytes = Encoding.UTF8.GetBytes(responseHeaderBuffer);<br>            networkStream.Write(responseBytes, 0, responseBytes.Length);<br>        }</pre><p>Update the `StartListen` method to respond.</p><pre>   if (requestFirstLine != “GET”)<br>   {<br>//response headers to browser<br>        SendHeaders(httpVersion, 405, &quot;Method Not Allowed&quot;, contentType, contentEncoding, 0, ref stream);<br>  }</pre><p>Since this is an error, the server does not respond with a payload.</p><p>In a case where the request is valid, the first line is GET / HTTP/1.1 The request path is extracted from the first line and that path is searched in the web server path — the folder that was created.</p><p>The root path / is the request path in this sample which the server translates to requesting the default.html file. The requested file is read and sent to the client.</p><p>If the path that was requested does not exist, a not found error is returned.</p><p>Here is the C# implementation of the procedure to find the file at the requested path:</p><pre> string request = Encoding.UTF8.GetString(requestBytes, 0, bytesRead);<br> var requestHeaders = ParseHeaders(request);<br><br>string[] requestFirstLine = requestHeaders.requestType.Split(&quot; &quot;);<br>var requestedPath = requestFirstLine[1];<br>                    var fileContent = GetContent(requestedPath);<br>                    if(fileContent is not null)<br>                    {<br>                        SendHeaders(httpVersion, 200, &quot;OK&quot;, contentType, contentEncoding, 0, ref stream);<br>                        stream.Write(fileContent, 0, fileContent.Length);<br>                    }<br>                    else<br>                    {<br>                        SendHeaders(httpVersion, 404, &quot;Page Not Found&quot;, contentType, contentEncoding, 0, ref stream);<br>                    }<br><br>…<br> private static byte[] GetContent(string requestedPath)<br>        {<br>            if (requestedPath == &quot;/&quot;) requestedPath = &quot;default.html&quot;;<br>            string filePath = Path.Join(WebServerPath, requestedPath);<br><br>            if (!File.Exists(filePath)) return null;<br><br>            else<br>            {<br>                byte[] file = System.IO.File.ReadAllBytes(filePath);<br>                return file;<br>            }<br>        }</pre><h4>Put together</h4><p>Program<em>.</em>cs</p><pre>using System.Net;<br>using System.Net.Sockets;<br>using System.Text;<br><br>namespace Webserver_csharp<br>{<br>    class Program<br>    {<br><br>        private static TcpListener myListener;<br>        private static int port = 5050;<br>        private static IPAddress localAddr = IPAddress.Parse(&quot;127.0.0.1&quot;);<br>        private static string WebServerPath = @&quot;WebServer&quot;;<br>        private static string serverEtag = Guid.NewGuid().ToString(&quot;N&quot;);<br><br>        static void Main(string[] args)<br>        {<br>            try<br>            {<br><br>                myListener = new TcpListener(localAddr, port);<br>                myListener.Start();<br>                Console.WriteLine($&quot;Web Server Running on {localAddr.ToString()} on port {port}... Press ^C to Stop...&quot;);<br>                Thread th = new Thread(new ThreadStart(StartListen));<br>                th.Start();<br>            }<br>            catch (System.Exception)<br>            {<br><br>                throw;<br>            }<br>        }<br><br>        private static void StartListen()<br>        {<br>            while (true)<br>            {<br>             <br>                TcpClient client = myListener.AcceptTcpClient();<br>                NetworkStream stream = client.GetStream();<br><br>                //read request <br>                byte[] requestBytes = new byte[1024];<br>                int bytesRead = stream.Read(requestBytes, 0, requestBytes.Length);<br><br>                string request = Encoding.UTF8.GetString(requestBytes, 0, bytesRead);<br>                var requestHeaders = ParseHeaders(request);<br><br>                string[] requestFirstLine = requestHeaders.requestType.Split(&quot; &quot;);<br>                string httpVersion = requestFirstLine.LastOrDefault();<br>                string contentType = requestHeaders.headers.GetValueOrDefault(&quot;Accept&quot;);<br>                string contentEncoding = requestHeaders.headers.GetValueOrDefault(&quot;Acept-Encoding&quot;);<br><br>                if (!request.StartsWith(&quot;GET&quot;))<br>                {<br>                    SendHeaders(httpVersion, 405, &quot;Method Not Allowed&quot;, contentType, contentEncoding, 0, ref stream);<br>                }<br>                else<br>                {<br>                    var requestedPath = requestFirstLine[1];<br>                    var fileContent = GetContent(requestedPath);<br>                    if(fileContent is not null)<br>                    {<br>                        SendHeaders(httpVersion, 200, &quot;OK&quot;, contentType, contentEncoding, 0, ref stream);<br>                        stream.Write(fileContent, 0, fileContent.Length);<br>                    }<br>                    else<br>                    {<br>                        SendHeaders(httpVersion, 404, &quot;Page Not Found&quot;, contentType, contentEncoding, 0, ref stream);<br>                    }<br>                }<br><br>                client.Close();<br>            }<br>        }<br><br>        private static byte[] GetContent(string requestedPath)<br>        {<br>            if (requestedPath == &quot;/&quot;) requestedPath = &quot;default.html&quot;;<br>            string filePath = Path.Join(WebServerPath, requestedPath);<br><br>            if (!File.Exists(filePath)) return null;<br><br>            else<br>            {<br>                byte[] file = System.IO.File.ReadAllBytes(filePath);<br>                return file;<br>            }<br>        }<br><br>        private static void SendHeaders(string? httpVersion, int statusCode, string statusMsg, string? contentType, string? contentEncoding,<br>            int byteLength, ref NetworkStream networkStream)<br>        {<br>            string responseHeaderBuffer = &quot;&quot;;<br><br>            responseHeaderBuffer = $&quot;HTTP/1.1 {statusCode} {statusMsg}\r\n&quot; +<br>                $&quot;Connection: Keep-Alive\r\n&quot; +<br>                $&quot;Date: {DateTime.UtcNow.ToString()}\r\n&quot; +<br>                $&quot;Server: MacOs PC \r\n&quot; +<br>                $&quot;Etag: \&quot;{serverEtag}\&quot;\r\n&quot; +<br>                $&quot;Content-Encoding: {contentEncoding}\r\n&quot; +<br>                &quot;X-Content-Type-Options: nosniff&quot;+<br>                $&quot;Content-Type: application/signed-exchange;v=b3\r\n\r\n&quot;;<br><br>            byte[] responseBytes = Encoding.UTF8.GetBytes(responseHeaderBuffer);<br>            networkStream.Write(responseBytes, 0, responseBytes.Length);<br>        }<br><br>        private static (Dictionary&lt;string, string&gt; headers, string requestType) ParseHeaders(string headerString)<br>        {<br>            var headerLines = headerString.Split(&#39;\r&#39;, &#39;\n&#39;);<br>            string firstLine = headerLines[0];<br>            var headerValues = new Dictionary&lt;string, string&gt;();<br>            foreach (var headerLine in headerLines)<br>            {<br>                var headerDetail = headerLine.Trim();<br>                var delimiterIndex = headerLine.IndexOf(&#39;:&#39;);<br>                if (delimiterIndex &gt;= 0)<br>                {<br>                    var headerName = headerLine.Substring(0, delimiterIndex).Trim();<br>                    var headerValue = headerLine.Substring(delimiterIndex + 1).Trim();<br>                    headerValues.Add(headerName, headerValue);<br>                }<br>            }<br>            return (headerValues, firstLine);<br>        }<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12b93134082b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a website monitoring tool using .NET]]></title>
            <link>https://iamsimi.medium.com/build-a-website-monitoring-tool-using-net-8957fe28262a?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/8957fe28262a</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 08:04:02 GMT</pubDate>
            <atom:updated>2023-02-10T08:04:02.499Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build a website monitoring tool using .NET</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wmn4PTQjp-SZnYkz" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Having your website up and running all of the time is great, but knowing when it is down is even better. While there are a lot of tools out there to monitor your website, building one that is custom-made for you can be the best option.</p><p>In this article, you will build a website monitoring tool using .NET.</p><h3>Introduction</h3><p>Website monitoring is the process of knowing whether a website is online or offline which are called the uptimes and downtimes respectively. And the major reason you monitor your website is that in event of downtimes, you can go into making sure that is up again. Without website monitoring, you may not know when your website is down as it is impossible to keep tabs on it 24/7.</p><h4>Pre-requisite</h4><p>Here are some of the things you will need to follow along with:</p><ol><li>.NET installed on your machine.</li><li>An IDE (VSCode with C# extension, Visual Studio, Jet Rider, etc.)</li><li>Some knowledge of C#.</li></ol><h3>Development</h3><p>Create a new console application.</p><pre>dotnet new console -o monitoring_tool</pre><p>Update the Program.cs file with the following code.</p><pre>class Program<br>{<br>    static void Main(string[] args)<br>    {<br>        string websiteAddress = &quot;http://google.com&quot;;<br>        if (args.Length &gt; 0) websiteAddress = args.Single();<br>        new Timer((e) =&gt;<br>        {<br>            using (var client = new HttpClient())<br>            {<br>                HttpResponseMessage response = client.GetAsync(websiteAddress).Result;<br>                if (response.IsSuccessStatusCode)<br>                {<br>                    Console.WriteLine($&quot;{DateTime.Now}: {websiteAddress} is up and running. Recieved {response.Content.Headers.ContentLength} bytes&quot;);<br>                }<br>                else<br>                {<br>                    Console.WriteLine($&quot;{DateTime.Now}: {websiteAddress} is down.&quot;);<br>                }<br>            }<br>        }, null, TimeSpan.Zero, TimeSpan.FromSeconds(5));<br><br>        Console.ReadLine();<br>    }<br>}</pre><ul><li>The URL of the site to be monitored is passed in the args when running the app, but if it is not a default website (http://google.com) is monitored.</li><li>The C# Timer class triggers thehttpClient method that makes a GETrequest to the website every 5 seconds and the result of each request is printed to the console.</li></ul><p>Now, run the app and pass a website URL.</p><pre>dotnet run https://twitter.com/home</pre><p>Here is a sample of the output:</p><pre>2/9/2023 2:21:46 PM: https://twitter.com/home is up and running. Recieved 180504 bytes<br>2/9/2023 2:21:51 PM: https://twitter.com/home is up and running. Recieved 180504 bytes<br>2/9/2023 2:21:56 PM: https://twitter.com/home is up and running. Recieved 180446 bytes</pre><h3>Conclusion</h3><p>In this tutorial, you built a website monitoring tool, but there are a couple of features/advancements that you could add:</p><ul><li>Gather the analytics of time, up or down, amount of bytes received, etc. to build a dashboard.</li><li>When there is downtime, write a service to send an sms or an email (or make a call to you).</li></ul><p><a href="https://github.com/mrsimi/monitoring_tool_console_app">Here is a link to the code on GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8957fe28262a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a CRUD Web API using ASP.NET Core Minimal Web API and Firebase Database.]]></title>
            <link>https://iamsimi.medium.com/how-to-build-a-crud-web-api-using-asp-net-core-minimal-web-api-and-firebase-database-cf153c355ca6?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf153c355ca6</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Sun, 08 May 2022 16:45:18 GMT</pubDate>
            <atom:updated>2022-05-08T16:45:18.748Z</atom:updated>
            <content:encoded><![CDATA[<p>This article will serve as a step-by-step guide on how to implement a CRUD Web API using ASP.NET core minimal API and Firebase Database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QtlHcxyL-zUOIpSI" /><figcaption>Photo by <a href="https://unsplash.com/@freeche?utm_source=medium&amp;utm_medium=referral">Kvistholt Photography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>This article will serve as a step-by-step guide on how to implement a CRUD Web API using ASP.NET core minimal API and Firebase Database.</p><h4>Overview</h4><p>ASP.NET Core Minimal API is a way to create HTTP APIs in ASP.NET Core with minimal dependencies, the minimum number of files and features.</p><p>This tutorial teaches Minimal Web API by building a Book Store API with a CRUD (Create, Read, Update and Delete) functionality. The data for the API would be stored in Firebase Database which is accessed over the Firebase Database API.</p><p>VS Code is the IDE for this tutorial.</p><h4>Prerequisites</h4><ul><li>Download and Install Visual Studio Code from <a href="https://code.visualstudio.com/">here</a></li><li>Install the C# Extension for Visual Studio Code from <a href="https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp">here</a></li><li>Install .Net Core 6.0 SDK from <a href="https://dotnet.microsoft.com/download/dotnet/6.0">here</a></li></ul><h4>Source Code</h4><p><a href="https://github.com/mrsimi/BookStore-MinimalAPI">Here</a> is a link to the Source Code on GitHub.</p><h4>Table of Contents</h4><ol><li>Setting up Firebase Database</li><li>Create a minimal Web API Project</li><li>Update the generated Code</li><li>Create the BookStoreService Class and add the Create method Code</li><li>Add the Get methods for Book Service Class</li><li>Add the Delete Method in the BookStoreService Class</li><li>Add the Update method to the BookStoreService Class</li><li>Complete Code for BookStoreService</li><li>Update the Program.cs</li><li>Testing the API</li><li>Conclusion</li></ol><h4>Setting up Firebase Database</h4><p>To setup our Firebase Database, follow these steps:</p><ol><li>Open Firebase console <a href="https://console.firebase.google.com/">here</a> . If you are not previously logged in, a prompt to login with your google account is shown. On successful log in you will see a couple of cards.</li><li>Click on the <strong>+ Add Project</strong> card. You will be redirected to a new page to enter Project Name.</li><li>Enter a Project name and click Continue. There is a redirection to another page about Google analytics. Toggle off the <strong>Enable Google Analytics for this project </strong>option and Click <strong>Create Project</strong>.</li><li>After a couple of minutes, a <strong>Continue </strong>button is shown. Once you click on the <strong>Continue </strong>button you are redirected to the Firebase Panel</li><li>Click on the <strong>Realtime Database</strong> option at the left side of the Panel.</li><li>Click the <strong>Next </strong>Button and set Security Rules to <strong>Start in test mode. </strong>Then click the <strong>Enable </strong>button to complete the Database Creation process. A database Panel is shown on the right. The link:<strong> https://&lt;project-name&gt;-default-rtdb.firebaseio.com </strong>would be used in the web API project</li></ol><h4>Create a minimal Web API Project</h4><p>Follow these steps to create a minimal web API.</p><ol><li>Create a new folder with name <strong>bookstoreapi</strong>that will contain the project</li><li>Open Visual Studio Code</li><li>Use <strong>File &gt; Open Folder </strong>menu to open the folder in Visual Studio Code</li><li>Use the Terminal menu with <strong>Terminal &gt; New Terminal</strong> to open an integrated terminal in Visual Studio Code.</li><li>Run the following command: <strong>dotnet new webapi -minimal</strong>The folder is populated with files. The <strong>Program.cs </strong>file is containing all the code to run the web API and it contains a lot of boilerplate code. But for now, leave it.</li><li>Press <strong>Crtl+F5</strong> to run the app.</li><li>When prompted to Select an Environment, select .NET 5+ and .NET Core. A new folder with <strong>launch.json</strong> and <strong>tasks.json</strong>files is created. This is a one-time thing for every project you create.</li><li>Press Ctrl+F5again. This time a browser window is opened. Append /swagger<strong> </strong>to the URL in the browser, for example <strong>https://localhost:7111/swagger </strong>and a swagger page is displayed with a URL of swagger/index.html.Swagger is an API tool use to generate useful documentation for web APIs, and it is part of the feature provided to us by default when creating a ASP.NET Core web API.</li><li>On the Swagger page. Select <strong>GET &gt; Try it out &gt; Execute. </strong>The Curl, Request URL and Server Response a list of JSON object about the weather is displayed.</li></ol><p>Copy and past the URL from the Request URL section into your browser: <strong>https://localhost:&lt;port&gt;/weatherforecast. </strong>A JSON similar to the one generated earlier from the swagger page is shown.</p><h4>Update the generated Code.</h4><p>Replace the code in Program.cswith the code below. This helps us focus on creating the simple CRUD web API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a873e0fa67e08b8a47fba96b56faac89/href">https://medium.com/media/a873e0fa67e08b8a47fba96b56faac89/href</a></iframe><p>The code starts off with building a <strong>WebApplication</strong>in <strong>Line 1–2</strong> with a set of preconfigured defaults. Then the next block of code contains a command to create an HTTP GET endpoint of [/] which returns <strong>Hello World</strong>string. Finally the code <strong>app.Run()</strong>runs the app.</p><p>Press <strong>Ctrl+F5</strong>to see the results.</p><p><em>PS: Do not append </em><strong><em>/swagger </em></strong><em>to the route this time. Remember all functionalities including swagger is removed.</em></p><h4>Create the BookStoreService Class and add the Create method Code</h4><p>Create a new file with name <strong>BookStoreService.cs</strong> Copy and Paste the following code into it. This class will house all our CRUD methods then we use this class in <strong>Program.cs</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c11c021034902e5ec40dec2e98aa9a67/href">https://medium.com/media/c11c021034902e5ec40dec2e98aa9a67/href</a></iframe><p><strong>The Model class</strong></p><p>The sample code contains the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95fadc66013edea9fda0633d1706563b/href">https://medium.com/media/95fadc66013edea9fda0633d1706563b/href</a></iframe><p>A model is a class that represents the data in the system, in this case, the Book that is being store.</p><p><strong>The Service Class and Create Method</strong></p><p>The following code shows how to process of adding a book to the store database.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/584098b67205f327859ad6b078199941/href">https://medium.com/media/584098b67205f327859ad6b078199941/href</a></iframe><p>The code specifies the <strong>firebaseDatabaseUrl </strong>which is the URL that can be found on the Firebase Realtime Database Panel of format: <strong>https://&lt;project-name&gt;/default-rtdb.firebaseio.com</strong> and the <strong>firebaseDatabaseDocument </strong>which would contain all the books.</p><p>Then we proceed to creating an HttpClient<strong> </strong>object which would help us to make HTTP Calls to the Firebase Database.</p><p>The sequence for the <strong>add method</strong> is as follows:</p><ol><li>Take in a Book parameter.</li><li>Generates a GUID</li><li>Send a HTTP PUT to the Firebase Database with a full URL like this<strong>: </strong><strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/BookStore/&lt;book-id&gt;.json</strong></li></ol><p>The use of an HTTP PUT on the full Firebase Database URL indicates that the book should be inserted at the <strong>&lt;book-id&gt;</strong> location on the Firebase Database Document with the name <strong>BookStore</strong>.</p><p>On successful request, the response is Deserialize to a Book object and returned.</p><h4>Add the Get method for Book Service Class</h4><p>Add the following Get- methods code into the<strong> </strong><strong>BookStoreService</strong> class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44a087d827c8dcc5a459a1ef7af43ff2/href">https://medium.com/media/44a087d827c8dcc5a459a1ef7af43ff2/href</a></iframe><p>The <strong>GetById </strong>method<strong> </strong>takes an <strong>id</strong>parameter and makes an HTTP GET request to the full Firebase Database URL:<strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/BookStore/&lt;book-id&gt;.json</strong></p><p>After which, the response is deserialized to a Book Object.</p><p>The <strong>GetAll </strong>method also makes an HTTP GET request to the full Firebase Database URL but without the <strong>book-id </strong>part. This retrieves all the data in the Firebase Database Document with the name <strong>BookStore</strong>. The URL in this case is this: <strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/BookStore.json</strong></p><blockquote><strong><em>All requests are made to a URL that ends with a .json.</em></strong></blockquote><h4>Add the Delete Method in the BookStoreService Class</h4><p>Add the following code to the BookStoreService Class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1df00b9362d4daee3abd8c899babf1cc/href">https://medium.com/media/1df00b9362d4daee3abd8c899babf1cc/href</a></iframe><p>The <strong>DeleteById</strong> method takes an <strong>id</strong>parameter of the book and makes an HTTP DELETE request to that particular resource in firebase using the full Database URL: <strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/BookStore/&lt;book-id&gt;.json</strong></p><h4>Add the Update method to the BookStoreService Class</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00b1f5e46824af4506b4edfe818efde6/href">https://medium.com/media/00b1f5e46824af4506b4edfe818efde6/href</a></iframe><p>The <strong>Update </strong>method takes the <strong>book</strong>and <strong>id </strong>parameter. The <strong>id </strong>is assigned to the book due to the update operate, then an HTTP PUT request is made to the full database URL:<strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/BookStore/&lt;book-id&gt;.json</strong></p><h4>Complete Code for BookStoreService</h4><p>Here is how the complete code looks like</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc7a4b461a70e5e8cb3d516e58479866/href">https://medium.com/media/fc7a4b461a70e5e8cb3d516e58479866/href</a></iframe><p>Notables:</p><ul><li>To retrieve a resource from Firebase Database always append the URL with a <strong>.json.</strong></li><li>To retrieve, update, or delete a particular resource at a destination pass in the URL in format: <strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/&lt;database-name&gt;/&lt;book-id&gt;.json</strong></li><li>To retrieve all resources in a database pass URL in format: <strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/&lt;database-name&gt;.json</strong></li><li>A HTTP PUT on a URL: <strong>https://&lt;project-name&gt;-default-rtdb.firebaseio.com/&lt;database-name&gt;/&lt;id&gt;.json</strong>, will put the resource at the <strong>id </strong>location in the database.</li></ul><h4>Update the <strong>Program.cs</strong></h4><p>Update the <strong>Program.cs </strong>file to look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d44e9862d64016c61914ed30e4a7e9e/href">https://medium.com/media/6d44e9862d64016c61914ed30e4a7e9e/href</a></iframe><p>The <strong>Program.cs</strong>app Methods - <strong>app.MapGet(), app.MapPost(), app.MapPut(), app.MapDelete()</strong>makes use of the <strong>BookStoreService</strong> that we added code to earlier. Each of the methods follows this sequence:</p><ul><li>Takes in a parameter for with the exception of <strong>app.MapGet(&quot;/books),</strong></li><li>Pass the parameter to the corresponding method in <strong>BookStoreService</strong> and gets the response in the <strong>result </strong>variable,</li><li>If the result<strong> </strong>is null, a corresponding response is sent to the API (e.g. <strong>Results.NotFound(), Results.Problem()</strong>)</li><li>If the <strong>result </strong>variable is not null, an <strong>Results.Ok(result) </strong>is sent to the API.</li></ul><p>The <strong>BookStoreService</strong> Class helps us to keep the <strong>Program.cs </strong>file clean. The same code in that class could be written here and still work as expected.</p><h4>Testing the API</h4><ol><li>Press Ctrl+F5 to run the app</li><li>Use an API Client (Postman, Insomnia, Fiddler) to test the endpoints.</li></ol><p>When logged into the Firebase Database Console <a href="https://console.firebase.google.com/">here</a>. The data added from the API is present.</p><p>Here is a table of endpoints, sample request and sample response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ntZyrDqkfRDxcG0OM5Tcw.jpeg" /><figcaption>a table of endpoints, sample request and sample response</figcaption></figure><h4>Conclusion</h4><p>ASP.NET Core Minimal API is a great framework to use when building microservices or building APIs that does not require a lot of complexity and features to be built into it.</p><p>With Minimal API each feature that is needed can be incrementally added to it. The Swagger for example can be added back. Dependency Injection can be utilized. And many more. As you build more applications out of it, you begin to understand it the more and appreciate it simplicity.</p><p>I hope you have enjoyed this article and I hope it was useful for you. I appreciate your feedback.</p><p><a href="https://github.com/mrsimi/BookStore-MinimalAPI">Here</a> is a link to the Source Code on GitHub <a href="https://github.com/mrsimi/BookStore-MinimalAPI">https://github.com/mrsimi/BookStore-MinimalAPI</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf153c355ca6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Sort Algorithms in plain English.]]></title>
            <link>https://iamsimi.medium.com/quick-sort-algorithms-in-plain-english-bd21542fb528?source=rss-bd36b0dae678------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd21542fb528</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[quicksort]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <dc:creator><![CDATA[simi]]></dc:creator>
            <pubDate>Thu, 27 Jan 2022 13:15:49 GMT</pubDate>
            <atom:updated>2022-01-30T00:45:33.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quick Sort Algorithms in plain English and JS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*ZHxfCQNojKOu2agslpG51w.png" /></figure><h3>Introduction</h3><p>In this article we would be talking and implementing a very interesting sorting algorithms, Quick Sort Algorithms. These kind of sorting algorithms are the underlying algorithms that run when you call for example Array.sort() in JavaScript. As a matter of fact Chrome JavaScript (before V8 Chrome) engine once used it as their underlying sort algorithms. So before V8 when you called Array.Sort() in Chrome, you were actually using the Quick Sort Algorithm. Interesting isn’t it?</p><blockquote>So before V8 when you called Array.Sort() in Chrome JavaScript Engine, you were actually using the Quick Sort Algorithm.</blockquote><p>But what is it actually.</p><h4>What is a Quick Sort Algorithm?</h4><p>An algorithm for sorting — e.g. say numbers from smallest to the largest — duh.</p><p>Though according to Wikipedia,</p><blockquote>Quicksort is a divide-and-conquer algorithm. It works by selecting a ‘pivot’ element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. For this reason, it is sometimes called <strong>partition-exchange sort.</strong></blockquote><p>A lot of buzz words right? Yeah. Let’s talk more on it.</p><p>Say you have an<strong> list of elements [numbers] you want to sort [lowest to highest]</strong>, then you <strong>pick an element in the list [your pivot] then you arrange other elements around it [lesser than it, or greater than it]</strong>.</p><p>Now the ones that are lesser than the pivot and greater than the pivot are a sub-array because your pivot has not acted as partition.</p><p>Thereafter you treat the sub array the same way you treated the whole array — find a pivot, arrange around the pivot, then partition. You continue with that until you have two elements in your partition in which can the pivot is one of the element and the other element is either to the right or to the left of the pivot.</p><p>The partitions being created is where the<strong> divide and conquer</strong> concept comes from because we create sub-arrays from the main array and solve that array and on and on until the last sub-array [an array of two elements].</p><p>So how long does it take...the algorithm we mean</p><h3>Time Complexity of the Algorithm</h3><p>Time complexity is expressed in a notation called Big O. It is a functional expression defined in terms of the input (n).</p><p><strong>So, O(n) is pronounced Big O of N. </strong>Big O notation is a functional expression which mean we are dealing with a linear complexity here.</p><p><strong>In best case</strong> [a case where our pivot is the mean element], the complexity of the algorithm is:</p><blockquote>O(Nlog(N))</blockquote><p><strong>In worst case</strong> [a case where our pivot is the largest or smallest element of the list], the complexity of the algorithm here is:</p><blockquote><strong>O(n²)</strong></blockquote><p><strong>For base understanding O(1) is faster than O(log(N)) which is faster than O(N) which is faster than O(NLog(N)) which is faster than O(N²).</strong></p><p>Now let’s talk about the procedure shall we?</p><h3>How Quick Sort Works?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQZPWr3uEDLqyaB06SInPw.jpeg" /><figcaption>quicksort</figcaption></figure><p>Lets say we have a list of numbers to sort.</p><p><strong>Step — 1:</strong> Pick a pivot. Could be any of the elements [typically last or first element, could be middle element].</p><p><strong>Step — 2:</strong> Arrange the element around the Pivot. Meaning if we chose the last element of the list, look to the left of the list and any number that is greater than the Pivot move to the right or else we leave it on the left.</p><p><strong>Step — 3:</strong> From your Pivot, Create a Partition. So you have the left elements [those lesser than the pivot], and the right elements [those greater than the pivot].</p><p><strong>Step — 4:</strong> Start Step — 1 to Step — 3 again for each partition simultaneously [pick a pivot, arrange around pivot, create partition].</p><p><strong>Step — 5:</strong> Repeat until the partition contains a Pivot and another element [2 elements]. Then run Step — 2.</p><p><strong>Step — 6:</strong> Merge all the results together.</p><p>So far we have gotten somewhere and a lot of theory...how about the code?</p><h3><strong>Implementing Quick Sort in JavaScript.</strong></h3><p>Open up your favourite JavaScript Editor or if you like me right-click this browser, go to Inspect, then Console (yeah could be our own JS Editor).</p><p>Write in the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19652fe4d2263fb0134ab3f315c7f2ab/href">https://medium.com/media/19652fe4d2263fb0134ab3f315c7f2ab/href</a></iframe><p>Yeah that’s our quick sort function.</p><ul><li>line 2–4: is for house keeping when array length is equal or lesser than 1.</li><li>line 6: we select the pivot [for our case we selected the last element]</li><li>line 8–9: we created the sub-array. The lefts [lesser than the pivot]. The rights [greater than the pivot]</li><li>line 11–13: we sorted the enter every element asides the last element into their respective sub arrays.</li><li>line 15: we call the function on the new sub-arrays and then merge it with the pivot. That way the result of the sub-array calls the function and on and on and on until array length is less than or equal to one. <em>This is where the recursive nature of the algorithm comes from.</em></li></ul><h4>Some Testing:</h4><pre>var unsorted = [10, 21, 1, 90, 23, 45]<br>quicksort(unsorted)<br>//[1, 10, 21, 23, 45, 90]  #Output</pre><p>Voila!</p><p>You have implemented the underlying algorithms of some sorting function in some programming languages.</p><h3>Conclusion</h3><p>In this tutorial, we have successfully discussed what Quick Sort Algorithms is, how it works and successfully implemented it in JavaScript.</p><p>There are a number of things you could do:</p><ul><li>Time the function on various length of list and find ways to improve it. Remember best case scenarios occurs when your pivot are the mean element (mean of all the values of the element).</li><li>Try it out for strings. This would require you to know how to classify strings as greater than or lesser than.</li></ul><p>Hopefully this has been a good run. Cheers.</p><p><strong>Resources:</strong></p><p>Quick Sort Wikipedia <a href="https://en.wikipedia.org/wiki/Quicksort">https://en.wikipedia.org/wiki/Quicksort</a></p><p>Getting things sorted in V8 <a href="https://v8.dev/blog/array-sort">https://v8.dev/blog/array-sort</a></p><p>Quick Sort Algorithms Stack Overflow Discussion <a href="https://stackoverflow.com/questions/5185864/javascript-quicksort">https://stackoverflow.com/questions/5185864/javascript-quicksort</a></p><p>Quick Sort Tutorial by CSE Stack <a href="https://www.csestack.org/quicksort/">https://www.csestack.org/quicksort/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd21542fb528" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>