<?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 Ankush Singh on Medium]]></title>
        <description><![CDATA[Stories by Ankush Singh on Medium]]></description>
        <link>https://medium.com/@ankushkun?source=rss-2e453df3b6b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VHAgI2qCv7leu0Q8IH3qSA.png</url>
            <title>Stories by Ankush Singh on Medium</title>
            <link>https://medium.com/@ankushkun?source=rss-2e453df3b6b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 23 Jun 2026 18:43:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankushkun/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[Publish to NPM from Github actions using OIDC]]></title>
            <link>https://ankushkun.medium.com/publish-to-npm-from-github-actions-using-oidc-c7e4702f3b94?source=rss-2e453df3b6b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7e4702f3b94</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[oidc]]></category>
            <dc:creator><![CDATA[Ankush Singh]]></dc:creator>
            <pubDate>Sat, 20 Dec 2025 11:17:52 GMT</pubDate>
            <atom:updated>2025-12-20T11:17:52.042Z</atom:updated>
            <content:encoded><![CDATA[<p>I frequently create developer tools and publish node packages on npmjs, but recently classic tokens got deprecated, granular token are limited to 90 days, require 2FA and a bunch of changes were introduced to improve security around publishing packages. More about that on this <a href="https://github.blog/changelog/2025-12-09-npm-classic-tokens-revoked-session-based-auth-and-cli-token-management-now-available/">github announcement</a>.</p><p>One of the improvements was the introduction of <a href="https://openid.net/developers/how-connect-works/">OpenID Connect</a> (OIDC), which allows developers to automate package publishing through github actions, without having to setup any kind of api key or access token, and today we are having a look at how you can implement it for your packages as well.</p><h3>Step 1: setup a node package (or skip if you already have one)</h3><p>As an example, we’ll create a fresh package which just logs hello world to console</p><p><strong>NOTE: this package is only meant as a demo for this blog. It is not recommended to create such packages for yourself and you should just setup OIDC on your existing packages :)</strong></p><pre>mkdir npm-oidc-demo &amp;&amp; cd npm-oidc-demo<br>npm init -y<br>touch index.js</pre><pre>export function helloWorld() {<br>    console.log(&quot;Hello World&quot;);<br>}</pre><p>Update your package.json to look like this:</p><pre>{<br>  &quot;name&quot;: &quot;npm-oidc-demo&quot;,<br>  &quot;version&quot;: &quot;1.0.1&quot;,<br>  &quot;description&quot;: &quot;A simple hello world package&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;type&quot;: &quot;module&quot;,<br>  &quot;exports&quot;: {<br>    &quot;.&quot;: &quot;./index.js&quot;<br>  },<br>  &quot;repository&quot;: {<br>    &quot;type&quot;: &quot;git&quot;,<br>    &quot;url&quot;: &quot;https://github.com/ankushKun/npm-oidc-demo&quot;<br>  },<br>  &quot;keywords&quot;: [<br>    &quot;npm&quot;,<br>    &quot;oidc&quot;<br>  ],<br>  &quot;author&quot;: &quot;&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;<br>}</pre><p>an already published package is required to use OIDC<strong> </strong>(might change in the future, who knows…)</p><p>Run <strong><em>npm login</em></strong> and follow the steps to link the npm cli with your npmjs account, when successful, run <strong><em>npm whoami</em></strong><em> </em>and it should print your username.</p><p>and we are ready for publishing, just run <strong><em>npm publish</em></strong></p><p><strong>NOTE: If you ignored the previous note and still followed this guide to publish the demo package yourself, you might need to change your package name as I have already used “npm-oidc-demo”</strong></p><pre>$ npm whoami<br>ankushkun<br><br>$ npm publish<br>npm notice<br>npm notice 📦  npm-oidc-demo@1.0.0<br>npm notice Tarball Contents<br>npm notice 428B README.md<br>npm notice 64B index.js<br>npm notice 239B package.json<br>npm notice Tarball Details<br>npm notice name: npm-oidc-demo<br>npm notice version: 1.0.0<br>npm notice filename: npm-oidc-demo-1.0.0.tgz<br>npm notice package size: 602 B<br>npm notice unpacked size: 731 B<br>npm notice shasum: 338ccdfe6ad57442bef858098fc247680fb23c9e<br>npm notice integrity: sha512-XAKUT4avwrfcV[...]lEjW6hNUMJieQ==<br>npm notice total files: 3<br>npm notice<br>npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access<br>Authenticate your account at:<br>https://www.npmjs.com/auth/cli/5f8fa35b-c07a-4af8-9851-831f191efc3e<br>Press ENTER to open in the browser...<br><br>+ npm-oidc-demo@1.0.0</pre><p>The package is now available at <a href="https://www.npmjs.com/package/npm-oidc-demo">https://www.npmjs.com/package/npm-oidc-demo</a></p><h3>Step 2: Update OIDC details on package settings</h3><p>Head over to the settings tab on our freshly published package and select GitHub Actions as the trusted publisher</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s0fSghe8DIxQPw6K-OhozA.png" /><figcaption>npmjs package settings tab</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Fc2oJ3_Ijr8uLga0P4v_A.png" /><figcaption>GitHub actions trusted publisher settings</figcaption></figure><p>I have already created a github repo at <a href="https://github.com/ankushKun/npm-oidc-demo">ankushKun/npm-oidc-demo</a>, now we just need to create a workflow file. Put this inside <strong><em>.github/workflows/publish.yml</em></strong></p><pre>name: Publish to npm<br><br>on:<br>  release:<br>    types: [published]<br>  workflow_dispatch:<br><br>jobs:<br>  publish:<br>    runs-on: ubuntu-latest<br>    permissions:<br>      contents: read<br>      id-token: write<br>    steps:<br>      - uses: actions/checkout@v4<br><br>      - uses: actions/setup-node@v4<br>        with:<br>          node-version: &quot;20.x&quot;<br>          registry-url: &quot;https://registry.npmjs.org&quot;<br><br>      - name: Update npm<br>        run: npm install -g npm@latest<br><br>      - name: Publish to npm<br>        run: npm publish</pre><p>Push the yml file to the repo and update the OIDC details on the package settings. I have kept the environment name empty because I don’t have any explicit environment setup for actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fjfYVS4FfV6Av8xqeaMNqw.png" /></figure><p>Now when you create a new release on the github repo, a workflow will start running which will publish the package to npm with provenance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vdxP7PcaEI51ntX42K5_A.png" /><figcaption>successful workflow run</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CYJjIDfnPq3HfLTo8G37vA.png" /><figcaption>build and publishing verification on the package page</figcaption></figure><p>And that’s how one can setup cicd to publish npm packages from github actions without having to create any access tokens themselves!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7e4702f3b94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A noobs guide to web APIs]]></title>
            <link>https://ankushkun.medium.com/a-noobs-guide-to-web-apis-ac49b80e8b0b?source=rss-2e453df3b6b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac49b80e8b0b</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ankush Singh]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 16:44:01 GMT</pubDate>
            <atom:updated>2025-02-19T16:44:01.612Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Alllll riiiight lets do this one more time</em>, my name is Ankush and I’m your friendly neighbourhood web developer, here to educate your <em>pathetic ass</em> a bit about web APIs, how they can be used to connect your frontend with your backend and how you can write an API using NodeJS 🫡</p><p>An API — Application Programming Interface, defines how different applications can talk to each other and exchange data through structures requests and responses</p><p>API Types?<br>1. <strong>Web APIs</strong> — the one we will be focusing on today<br>2. OS APIs — Windows APIs, Android APIs, etc<br>3. Library APIs — Like a python library<br>4. Hardware APIs — allow accessing hardware functions (embedded libraries?)</p><h3>RESTful Web APIs</h3><p>A RESTful Web API is one that follows the “REST” (Representational State Transfer) principles, a software architecture style that ensures scalability, simplicity, and stateless communication between servers and clients.</p><p><strong>Common REST HTTP Methods</strong><br>There are 4 common methods/requests to call REST APIs<br>1. GET — to <em>get</em> some data from the server<br>2. POST — to send/<em>create</em> some data from the server and get a response<br>3. PUT — to <em>update</em> existing data on a server<br>4. DELETE — to <em>remove</em> some data form a server</p><p>When browsing the web, GET request is used to fetch the client side content that gets rendered by the browser</p><p><strong>API response codes<br></strong>Whenever an API is called, it will always return a <em>status code</em> (a number) to signify the result of the request. Categorised into 1XX (informational response), 2XX (success codes), 3XX (redirects), 4XX (client errors), 5XX (server errors)</p><p>200 — OK, successful request<br>301 — Moved Permanently<br>400 — Bad Request, invalid inputs<br>401 — Unauthorised<br>404 — Not Found<br>500 — Internal Server Error</p><h3>Lets write an API endpoint ourselves</h3><p>Make sure you have NodeJS + NPM already installed and follow these steps</p><pre>mkdir api-test<br>cd api-test<br>npm init -y<br>npm i express<br>touch index.js</pre><p>This will create a folder for our express API backend and create a JS file to write code in</p><p>Edit the index.js file and add this code</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    res.send(&#39;Hello World&#39;);<br>});<br><br>app.listen(3000, () =&gt; {<br>    console.log(&#39;Server is running on port 3000&#39;);<br>});</pre><p>We have just initialised an express backend which is serving the “Hello World” string at root (/) endpoint. i.e. on sending a GET request to /, Hello World will be returned</p><p>Run this file with node index.js and open http://localhost:3000/ on any browser. It should show Hello World</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*fh2r1wAEpvcPK0bZpV9Y-Q.png" /><figcaption>Server running and serving Hello World at port 3000</figcaption></figure><p>Try changing the string in res.send(&#39;this one&#39;) to a simple HTML like &lt;h1&gt;Hi there&lt;/h1&gt; and restart the express server (ctrl+c and node index.js again), check if something changes on the served page</p><p>But this is just for GET requests, we cannot make POST requests to this endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*cJV5BQAHvocrDKE_LO1jMQ.png" /></figure><p>As you can see it gives an error if we try to make a POST request to the GET endpoint we created</p><p>Lets define a POST endpoint now</p><pre>// add this after defining defining the app<br>app.use(express.json());<br><br>// POST endpoint<br>app.post(&#39;/&#39;, (req, res) =&gt; {<br>    const name = req.body.name<br>    res.send(`Hello ${name}!`);<br>});</pre><p>restart the app and let’s try sending a post request to the server</p><p>You can use any HTTP client like Thunder Client on VSCode or Postman. I am going to use cURL coz simple</p><pre>curl http://localhost:3000/ -d &#39;{ &quot;name&quot;: &quot;Ankush&quot; }&#39;</pre><p>this should print the response as Hello Ankush!</p><p>BOOM! You just created a GET and POST request! A majority of web APIs are comprised of just GET and POST requests</p><h3>Time to write some frontend</h3><pre>&lt;html&gt;<br>  &lt;body&gt;<br>    &lt;input type=&quot;text&quot; id=&quot;name&quot; name=&quot;name&quot; placeholder=&quot;Enter your name&quot;&gt;<br>    &lt;button onclick=&quot;handleSubmit()&quot;&gt;Submit&lt;/button&gt;<br>    &lt;script&gt;<br>      async function handleSubmit() {<br>        const name = document.getElementById(&#39;name&#39;).value;<br>        const response = await fetch(&#39;/&#39;, {<br>          method: &#39;POST&#39;,<br>          headers: {&#39;Content-Type&#39;: &#39;application/json&#39;},<br>          body: JSON.stringify({ name })<br>        });<br>        const data = await response.text();<br>        document.body.innerHTML = data;<br>      }<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>We will serve this HTML through the GET endpoint we created earlier</p><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    res.send(`<br>        &lt;html&gt;<br>            &lt;body&gt;<br>                &lt;input type=&quot;text&quot; id=&quot;name&quot; name=&quot;name&quot; placeholder=&quot;Enter your name&quot;&gt;<br>                &lt;button onclick=&quot;handleSubmit()&quot;&gt;Submit&lt;/button&gt;<br>                &lt;script&gt;<br>                    async function handleSubmit() {<br>                        const name = document.getElementById(&#39;name&#39;).value;<br>                        const response = await fetch(&#39;/&#39;, {<br>                            method: &#39;POST&#39;,<br>                            headers: {<br>                                &#39;Content-Type&#39;: &#39;application/json&#39;<br>                            },<br>                            body: JSON.stringify({ name })<br>                        });<br>                        const data = await response.text();<br>                        document.body.innerHTML = data;<br>                    }<br>                &lt;/script&gt;<br>            &lt;/body&gt;<br>        &lt;/html&gt;<br>    `);<br>});</pre><p>Restart the express app and refresh localhost:3000, and try entering your name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*KhXDm_zbhiECJnoVBZE-XA.png" /></figure><p>Now if you open developer tools and go into the network tab, you can see the POST request being sent and the different data associated with it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wkbk2CrKOqYMwyQ11P9Eiw.png" /></figure><p>Congrats you just sent a POST request with some data, received some data back in response and showed it on the frontend!</p><p>Final Code:</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>app.use(express.json());<br><br>// To test this endpoint using curl, you can use the following command:<br>// curl http://localhost:3000/ <br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    res.send(`<br>        &lt;html&gt;<br>            &lt;body&gt;<br>                &lt;input type=&quot;text&quot; id=&quot;name&quot; name=&quot;name&quot; placeholder=&quot;Enter your name&quot;&gt;<br>                &lt;button onclick=&quot;handleSubmit()&quot;&gt;Submit&lt;/button&gt;<br>                &lt;script&gt;<br>                    async function handleSubmit() {<br>                        const name = document.getElementById(&#39;name&#39;).value;<br>                        const response = await fetch(&#39;/&#39;, {<br>                            method: &#39;POST&#39;,<br>                            headers: {<br>                                &#39;Content-Type&#39;: &#39;application/json&#39;<br>                            },<br>                            body: JSON.stringify({ name })<br>                        });<br>                        const data = await response.text();<br>                        document.body.innerHTML = data;<br>                    }<br>                &lt;/script&gt;<br>            &lt;/body&gt;<br>        &lt;/html&gt;<br>    `);<br>});<br><br>// To test this endpoint using curl, you can use the following command:<br>// curl http://localhost:3000/ -d &#39;{ &quot;name&quot;: &quot;Ankush&quot; }&#39;<br>app.post(&#39;/&#39;, (req, res) =&gt; {<br>    const name = req.body.name;<br>    res.send(`Hello ${name}!`);<br>});<br><br>app.listen(3000, () =&gt; {<br>    console.log(&#39;Server is running on port http://localhost:3000&#39;);<br>});</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac49b80e8b0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Mandelbrot Fractal generation with SYCL Programming]]></title>
            <link>https://ankushkun.medium.com/automating-mandelbrot-fractal-generation-with-sycl-programming-22da4a89e012?source=rss-2e453df3b6b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/22da4a89e012</guid>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[iit-roorkee]]></category>
            <category><![CDATA[cognizance]]></category>
            <category><![CDATA[intel]]></category>
            <category><![CDATA[oneapi]]></category>
            <dc:creator><![CDATA[Ankush Singh]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 12:54:26 GMT</pubDate>
            <atom:updated>2023-03-30T12:54:26.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HiYIE_ehe_7jpMEYs9meew.jpeg" /><figcaption>High resolution Mandelbrot Fractal with SYCL</figcaption></figure><h3>What’s this about?</h3><p>I had recently attended a workshop by <strong>Intel</strong> on their <strong>oneAPI programming model</strong> which was conducted by <a href="https://medium.com/u/af7b551ddcdb">Abhishek Nandy</a> at IIT Roorkee during the Cognizance 2023. I attended this workshop with my friend, <a href="https://medium.com/u/81d41cb48956">Krish Agrawal</a> who is also the co-author of this blog. The workshop was held for 2 days in which Abhishek Sir on the first day told about this new model by Intel and how to get started with its implementation with the help of <strong>JupyterLab</strong>. Before ending the day, we were told that there is a hackathon where he will take ideas by all the students in the form of teams as to how we use Intel oneAPI in real-life projects.</p><p><strong>SYCL </strong>(/sɪkl/) is a programming model for high-performance computing that allows developers to write code for heterogeneous systems that use accelerators such as GPUs, FPGAs, and other specialised processing units. It is an open standard developed by the Khronos Group, an industry consortium that also develops other widely used graphics and compute APIs such as OpenGL and Vulkan. SYCL code can be executed on a variety of devices, including CPUs, GPUs, and FPGAs, without modification.</p><p><strong>Fractals</strong> are fascinating geometric shapes that repeat themselves infinitely on different scales. They are created through a process of repeating a simple mathematical equation or algorithm to form increasingly intricate patterns. These fractal shapes are naturally occurring and can be observed in many aspects of nature, such as the <strong>patterns of a fern leaf</strong>, the <strong>coastlines of continents</strong>, and even the <strong>formation of clouds</strong>. One of the most well-known and captivating fractals is the <strong>Mandelbrot fractal</strong>. This type of fractal is generated through an iterative process using complex numbers, resulting in a shape that is renowned for its intricate detail and infinite complexity. It’s a true marvel of mathematics!</p><p>Now that we know what our project revolves around, let’s see its implementation in JupyterLab.</p><h3>Getting started on DevCloud</h3><p><strong>DevCloud</strong> is sandbox that intel provides to learn and try out their oneAPI ecosystem. We will be using the devcloud jupyter lab to run our SYCL fractal generation project. It is way easier and quicker to run SYCL projects on the sandbox than on your local machine.</p><p>So head over to <a href="https://devcloud.intel.com/oneapi/">https://devcloud.intel.com/oneapi/</a> and create an account. Navigate to the ‘Getting Started’ tab, scroll down to ‘Connect with JupyterLab’ and Launch a JupyterLab instance. It might take some time or get loaded instantly depending on the server load so have some patience.</p><figure><img alt="Landing page for the JupyterLab sandbox" src="https://cdn-images-1.medium.com/max/1024/1*8JUHbOpbnWCiTXeLqpqEPQ.png" /><figcaption>Landing page for JupyterLab sandbox</figcaption></figure><p>Once launched, you will find a bunch of folders in the file explorer, including a ‘mandelbrot’ folder.</p><p>Open the Terminal from the landing page, cd into the mandelbrot directory and run the build script.</p><pre>cd mandelbrot<br>chmod +x build.sh<br>./build.sh</pre><figure><img alt="build script output" src="https://cdn-images-1.medium.com/max/954/1*62IvxnuK0M2Maf3cG43Cjw.png" /><figcaption>build script output</figcaption></figure><p>This will compile and run the project and create a ‘mandelbrot.png’ file inside the ‘build’ folder. As you can see the image is 1024x1024 pixels and it took just 190 milliseconds to generate the image (serial time + parallel time). Now if we were to do the same in python or regular C++ without SYCL, it would take seconds to generate the same result. So that’s the power of SYCL.</p><p>If you checkout the ‘src/mandel.hpp’ file, you can find 4 variables row and column size, max iterations and repetitions. We can modify these values to generate Mandelbrot sets of different resolutions and qualities.</p><p>Try changing these values and see how much time it takes for the images of different configurations to generate.</p><h3>Automate it</h3><p>Let’s now write a <strong>bash script</strong> that automatically changes the values in the C++ file and builds the project.</p><p>Create a file ‘autogen.sh’ and inside it write the following lines.</p><pre>#!/bin/bash<br><br>PASSES=(10 100 500 1000 5000)<br>SIZES=(1024 2048 4096 8192 16384)<br><br>EDIT_FILE=&quot;src/mandel.hpp&quot;<br>BUILD_FILE=&quot;build.sh&quot;<br><br>prev_size=100<br>prev_pass=100<br>let count=0</pre><p>The variable ‘PASSES’ contains a list of iterations that will be used in each image of the image generated and sizes contains the list of resolutions for the images in pixels. ‘prev_size’ and ‘prev_pass’ is a placeholder that we will use later. Count is the number of images generated.</p><pre>for SIZE in ${SIZES[@]}; do<br>    for PASS in ${PASSES[@]}; do<br>        echo &quot;&quot;<br>        echo &quot;Generating fractal for $SIZE x $SIZE with $PASS passes&quot;<br>        echo &quot;&quot;<br><br>        ...<br><br>    done<br>done</pre><p>We create a nested loop for the values of SIZES and PASSES, so we can have all the combinations of sizes and passes to generate the images with. In the body of the loop we print a message to display to the user.</p><p>In order to edit the values of the 3 variables in the .hpp file we will use the sed command.</p><pre>sed -ie &quot;s/row_size=$prev_size/row_size=$SIZE/g&quot; $EDIT_FILE<br>sed -ie &quot;s/col_size=$prev_size/col_size=$SIZE/g&quot; $EDIT_FILE<br>sed -ie &quot;s/max_iterations=$prev_pass/max_iterations=$PASS/g&quot; $EDIT_FILE<br>sed -ie &quot;s/repetitions=$prev_pass/repetitions=$PASS/g&quot; $EDIT_FILE<br><br>prev_size=$SIZE<br>prev_pass=$PASS<br>count=$((count+1))</pre><p>This uses find and replace to replace the previous values of the variables with new values and updates the count in each iteration of the bash loop.</p><p>To run the build command we simply do</p><pre>./$BUILD_FILE<br><br>echo &quot;&quot;<br>echo &quot;Generated for $SIZE x $SIZE with $PASS passes&quot;<br>echo &quot;&quot;</pre><p>The project is built and image is saved in the build folder, so we will have to copy it from there into a location of our choice. Create a folder images in the mandelbrot folder and add the following copy command to the autogen.sh script</p><pre>cp &quot;./build/mandelbrot.png&quot; &quot;./images/$count.mandelbrot_${SIZE}_${PASS}.png&quot;</pre><p>This copies the image from build into images folder and also renames it to contain useful information such as size and number of passes and the count.</p><p>Run the autogen script and let the fractals be created!</p><pre>chmod +x autogen.sh<br>./autogen.sh</pre><p>Here is the full autogen script</p><pre>#!/bin/bash<br><br>PASSES=(10 100 500 1000 5000)<br>SIZES=(1024 2048 4096 8192 16384)<br><br>EDIT_FILE=&quot;src/mandel.hpp&quot;<br>BUILD_FILE=&quot;build.sh&quot;<br><br>prev_size=100<br>prev_pass=100<br>let count=0<br><br>for SIZE in ${SIZES[@]}; do<br>    for PASS in ${PASSES[@]}; do<br>        echo &quot;&quot;<br>        echo &quot;Generating fractal for $SIZE x $SIZE with $PASS passes&quot;<br>        echo &quot;&quot;<br>        sed -ie &quot;s/row_size=$prev_size/row_size=$SIZE/g&quot; $EDIT_FILE<br>        sed -ie &quot;s/col_size=$prev_size/col_size=$SIZE/g&quot; $EDIT_FILE<br>        sed -ie &quot;s/max_iterations=$prev_pass/max_iterations=$PASS/g&quot; $EDIT_FILE<br>        sed -ie &quot;s/repetitions=$prev_pass/repetitions=$PASS/g&quot; $EDIT_FILE<br><br>        prev_size=$SIZE<br>        prev_pass=$PASS<br>        count=$((count+1))<br><br>        ./$BUILD_FILE<br><br>        echo &quot;&quot;<br>        echo &quot;Generated for $SIZE x $SIZE with $PASS passes&quot;<br>        echo &quot;&quot;<br><br>        cp &quot;./build/mandelbrot.png&quot; &quot;./images/$count.mandelbrot_${SIZE}_${PASS}.png&quot;<br>        <br>    done<br>done</pre><figure><img alt="Images folder showing a 4K resolution image with 100 iterations" src="https://cdn-images-1.medium.com/max/1024/1*Wu-I9mjifg7MeS8DIU_Q9g.png" /><figcaption>List of images generated</figcaption></figure><p>More iterations means better quality of the image, you can zoom in and see the small details and tiny fractal repetitions, but to see these clearly the resolution must be increased.</p><h4>The winning moment</h4><p>It was Day 2 and we both had absolutely nothing with us. We sat at the back thinking what we would present the crowd with. We had about 3 hours in our hands to build something. While brainstorming, we were randomly playing with the Mandelbrot directory already given by Intel in their Virtual Private Server. We ran the code with the proper command and was later told to rerun using qbus -I which then redirected usto another portal maybe through some kind of routing. We then decided to create a bash script to randomise four values in the original program i.e. row_size, column_size, max_iterations and repetitions. We were able to do this and now we had started generating images in a folder. Some images with higher resolution or more repetitions took more time than the rest. The longest time was taken by 16K resolution image with 1000 repetitions which took approximately 50 minutes (still wayy less than an average C++ or Python script generating the same iterations and resolution).</p><p>We presented our solution made on a presentation made on Keynote. We remarkably remember that we were the only team with the minimal interaction with Abhishek Sir and also the only ones to receive a round of applause from him. At the end of all prizes, 6 stood out of 13 and were congratulated on stage for the same. Then came the cash prizes for the Top 3. As soon as second was done, we thought the claps were consolatory of nature and we were already packing. But then we realised, we were indeed 1st. (Out of excitement, I slammed the top of Krish’s Macbook Pro 😂). In the end we got ₹12000 as a prize in the form of Amazon Vouchers.</p><p>If you scrolled till this point, you may as well checkout my <a href="https://ankushKun.github.io/links">social handles </a>and leave a follow, Thanks for reading ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22da4a89e012" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>