<?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 Arausi Oghenekaro Daniel on Medium]]></title>
        <description><![CDATA[Stories by Arausi Oghenekaro Daniel on Medium]]></description>
        <link>https://medium.com/@arausidaniel?source=rss-9c92fde7f755------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dbZ30HRT5dKI18fj3ETILA.jpeg</url>
            <title>Stories by Arausi Oghenekaro Daniel on Medium</title>
            <link>https://medium.com/@arausidaniel?source=rss-9c92fde7f755------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:29:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arausidaniel/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[My Response to Subomi]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://arausidaniel.medium.com/my-response-to-subomi-c741df45ca9?source=rss-9c92fde7f755------2"><img src="https://cdn-images-1.medium.com/max/2600/1*RM_E_Vnf7db7picKD8q7Cw.jpeg" width="6016"></a></p><p class="medium-feed-link"><a href="https://arausidaniel.medium.com/my-response-to-subomi-c741df45ca9?source=rss-9c92fde7f755------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://arausidaniel.medium.com/my-response-to-subomi-c741df45ca9?source=rss-9c92fde7f755------2</link>
            <guid isPermaLink="false">https://medium.com/p/c741df45ca9</guid>
            <category><![CDATA[faith]]></category>
            <category><![CDATA[born-again]]></category>
            <category><![CDATA[baptism]]></category>
            <category><![CDATA[paul]]></category>
            <category><![CDATA[jesus]]></category>
            <dc:creator><![CDATA[Arausi Oghenekaro Daniel]]></dc:creator>
            <pubDate>Tue, 12 Sep 2023 20:51:35 GMT</pubDate>
            <atom:updated>2023-09-13T16:02:58.857Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Why do we have Leap Years?]]></title>
            <link>https://arausidaniel.medium.com/why-do-we-have-leap-years-98f62adaa266?source=rss-9c92fde7f755------2</link>
            <guid isPermaLink="false">https://medium.com/p/98f62adaa266</guid>
            <category><![CDATA[calendar]]></category>
            <category><![CDATA[time]]></category>
            <category><![CDATA[date]]></category>
            <category><![CDATA[centuries]]></category>
            <category><![CDATA[leap-year]]></category>
            <dc:creator><![CDATA[Arausi Oghenekaro Daniel]]></dc:creator>
            <pubDate>Thu, 07 Jan 2021 12:27:18 GMT</pubDate>
            <atom:updated>2022-05-09T23:07:21.474Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rproQdENpkYMKGXHDd-GSw.jpeg" /><figcaption>image from <a href="https://unsplash.com/s/photos/calendar">Unsplash</a></figcaption></figure><h3>Reality Check</h3><ol><li>Have you ever be asked why we have the 29th day in February in some years and none in some others?</li><li>Have you ever been confronted by a 6 yr old child about why we have 365 days for years and 366 days for some others?</li><li>Did you never listen in school? 🥱</li><li>Did you randomly click this link (you can always close it 😜)</li></ol><p>If your answers are yes to all the questions then you are in the right place.</p><blockquote>TL;DR. we have an extra day to our normal 365 days because we are “trying” to match the number of days to the seasons we have in a year. If unmatched we could have winter in may and spring in december.</blockquote><h4><strong>Quick Analogy</strong></h4><p>Imagine a restaurant in a remote part of town, with an almost fixed number of customers per day. If every day we have about 10 orders, it is logical to think that at the 10th order we should be done for the day and should close up to save costs.</p><p>Now of course while this may be valid for most days, there will be days when this assumption would make the restaurant lose money. For instance, a city boy comes back home and decides to throw a party in that same restaurant or an increase in income of the customers leading to an increase in demand, and a whole lot of economics I would rather not bore you with.</p><h4><strong>Explanation</strong></h4><p>The restaurant analogy above is very similar to how our calendar system works. When the earth spins on its axis, we have day and night, that&#39;s what we call a day. It does this all year long as it also revolves around the sun.</p><p>How we arrive at the year numbers is by counting the number of spins (day and night) for a complete revolution around the sun. keep in mind that these are two disjointed processes and are not exactly connected.</p><p>The common number we arrived at was 365 days, and that&#39;s what we use today. But most interestingly, with that number every year, we go out of sync with the seasons by 1/4th of a day.</p><p>To solve this it was decided to balance the math by adding 1 day every 4 years. Hence the term “leap” year, to jump. The actual term is “intercalation” but then your 6-year-old child won’t be able to ask you 😜.</p><p>So that&#39;s why we have 366 days in leap years.</p><h4>Extra Credit</h4><p>Even with the explanation above we end up getting ahead by 1/100th of a day every year. And so we still need to balance the math as closely as we can.</p><p>The solution to that problem was to skip the leap year every 100 years. And so what that means is, going by our normal 4 year — leap year cycle as explained above. Every start of a new century which is supposed to be a leap year would be skipped.</p><p>This solution seemed great and everything seemed balanced, but not quite yet. We are behind by 1 / 400th every year even with skipping the 100th year.</p><p>To solve this problem it was decided that if the 100th year is divisible by 400 then it’s a leap year. That&#39;s why the year 2000 was a leap year.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98f62adaa266" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL Chat App]]></title>
            <link>https://arausidaniel.medium.com/graphql-chat-app-4445c93d4b5b?source=rss-9c92fde7f755------2</link>
            <guid isPermaLink="false">https://medium.com/p/4445c93d4b5b</guid>
            <category><![CDATA[express]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Arausi Oghenekaro Daniel]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 17:06:46 GMT</pubDate>
            <atom:updated>2021-01-07T12:29:39.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzOKXrWy_fIqMZzC4KK_Ug.jpeg" /></figure><p>This is a contrived example, that was built out of curiosity. Better approaches to creating real-time experiences are included in the references below.</p><p><strong>House Keeping</strong></p><p>This project tech stack comprises of react and react-apollo for the frontend. The backend consists of apollo-server and express.</p><p><strong>INTRODUCTION</strong></p><p>The foundation of this application is based on WebSockets and graphQL subscriptions on both server and client. Subscriptions in GraphQL are a means for monitoring changes to a data bucket in real-time. Practically, they can be used by instantiating a new pubsub class as seen below. They are event-driven, and it’s listening to a defined event name or better said, are subscribed to an event name and publish through that event name the changes that occur. Hence the word pubsub for publishing and subscribing to data events to create real-time experiences.</p><p>full code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2ca18c8d1359329a08dafe38b2080af/href">https://medium.com/media/f2ca18c8d1359329a08dafe38b2080af/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwnA6QELh7lsZ59E620HgA.gif" /></figure><blockquote>I took the html and bootstrap from this wonderful <a href="https://pusher.com/tutorials/chat-graphql-subscriptions">post by pusher</a> which is where the idea behind doing this in react and react hooks stem from.</blockquote><p>REFERENCES</p><p>[1]<a href="https://github.com/arausly/pubsub-chat-application-poc">. Github Link for Chat App Here</a></p><p>[2]. <a href="https://www.apollographql.com/docs/react/data/subscriptions/">https://www.apollographql.com/docs/react/data/subscriptions/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4445c93d4b5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Service Workers Refresher]]></title>
            <link>https://arausidaniel.medium.com/service-workers-refresher-b3d5d9751907?source=rss-9c92fde7f755------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3d5d9751907</guid>
            <category><![CDATA[webworker]]></category>
            <category><![CDATA[ui-thread]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[service-worker]]></category>
            <dc:creator><![CDATA[Arausi Oghenekaro Daniel]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 14:51:28 GMT</pubDate>
            <atom:updated>2021-01-07T12:32:20.104Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wbb8NxbZgqwGAHvviyKozg.jpeg" /></figure><h3>Introduction</h3><p>Service workers have very quickly become more than a trendy peripheral, it is an essential requirement in creating seamless and great experiences both online and offline. As of today it is very much supported by most browsers even IE 10 <a href="https://caniuse.com/#search=web%20workers">[1]</a>.</p><h4><strong>Case for Service Workers:</strong></h4><p>There is a general assumption of a contiguous web experience across multiple end-users in various countries bound by differing network constraints. We easily forget that the point of the web amongst many is to create resource points on different subject matters, making it easily accessible while maintaining the integrity of the data in shape, quality, and experience. Without this assurance, one could argue it’s not any better than our old love of post mails and newspapers. Which could very well guarantee a much more contiguous experience without the very well-favored and absolute millennial essential “real-time” experience. If there was a way to mimic this possibility on the web, an illusion of sorts to cater to our geo-economic differences.</p><p>Javascript as we all know is single-threaded, any blocking operation within this thread would definitely lead to serious problems and ultimately a bad user experience.</p><p>The conventional contrived example below, to further explain a blocking operation:</p><p>HTML</p><pre>&lt;input type=&quot;text&quot; placeholder=&quot;name&quot; /&gt; </pre><p>JS</p><pre>input = document.querySelector(&quot;input&quot;);</pre><pre>input.addEventListener(&quot;input&quot;, function(event){<br>  // do some stuff here<br>  alert(&quot;block&quot;)</pre><pre>})</pre><figure><img alt="Browser Implentation of a blocking Scripts" src="https://cdn-images-1.medium.com/max/1024/1*T8s_7T2lUNRID7lbCMwXiQ.png" /><figcaption>Image[1]: Blocking Image</figcaption></figure><blockquote>From the above, the blocking operation happens when the user types in the input box. At the same time, the alert function is called which immediately halts the browser. This blocking operation obviously contrived in this case could be something else ranging from logging user behaviour entries to a monitoring tool or what not.</blockquote><p>Service workers are a type of web workers in the web browser stack[2]. The Idea mainly is the run a separate thread from the main UI thread where the web application is currently running. As you may guess this could easily be useful in areas where complex business logic may be offloaded to be processed, while the main application is left unfettered.</p><p>One bugging security alarm that may be ticking off in mind is the possibility of a DOS attack by spawning multiple threads from the browser of a user. However, no browser implementation of web workers promises a new thread spawned for every web worker subprocess initialization [3]. But what is of great certainty is the fact that web workers will be assigned to a single thread, absolutely different from the main UI thread that runs the current web application[3].</p><p>Web Workers are categorized into two main types:</p><ol><li>Shared Worker</li><li>Dedicated worker</li></ol><p><strong>SHARED WORKER</strong></p><p>A shared worker can be utilized across multiple pages in an application. Or one application. Communication can happen across pages with this worker.</p><p><strong>DEDICATED WORKER</strong></p><p>A dedicated worker will be utilized only in one page and terminated when the page closes, if several tabs were opened on that same page, multiple dedicated service workers will be spawned. Each of them will ultimately be terminated when they are closed.</p><p>One major difference between a service worker and a web worker is the fact that a service worker is kept alive, running in the background even after the page/application using it has been closed. this doesn’t also imply that service workers are immortals, they are still terminated after a period of idle time(this is handled by the browser mostly).web workers in general are restricted to having only network access, so conventional DOM manipulation is not possible in worker scripts.</p><p><strong>COMMUNICATION BETWEEN PAGES AND WEB WORKERS</strong></p><p>Transferring data between web workers and pages happen through a process structured cloning algorithm <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm">[4]</a>. This is basically “stringifying” data from either side and parsing it in the other. This is very similar to operations like writing to indexDB, localStorage, sessionStorage, etc. However, it’s important to note that like the others, functions and Errors can’t be transferred back and forth. This approach comes with obvious memory shortcomings. an alternative would be to leverage ES7 shared Array Buffer<a href="https://medium.com/@SitePen/the-return-of-sharedarraybuffers-and-atomics-a254032e00a6">[5]</a> to prevent copying and pasting data back and forth pages and web workers.</p><p><strong>WEB WORKER DEEP DIVE</strong></p><p>Quick dive into workers in detail, consider the code example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*iygQoMxdcAmIQyd8qU1CwA.png" /><figcaption>Image[1]: Fibonacci solved with Recursion</figcaption></figure><blockquote>suppose we intend to run some complex logic in our application, which could be blocking. in our case generating a fibonacci series in our browser, in response to a button click.The fibonacci function leverages recursion which is not the best implementation, but it perfectly suits our case.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*lBH4sQ36UooV-SyJCUs3EA.png" /><figcaption>Image[2]: Fibonacci solved with Recursion</figcaption></figure><p>The worker scripts above listen for a message from the page using the onmessage method that receives an event argument with a data property in it. the data property contains information sent from the page scripts.</p><p>The genFib function references the startFib function above that expects a “n” parameter to compute the Fibonacci number. setTimeout placed in the genFib function ensures that the next Fibonacci number is generated after the self.postMessage has been called and cleared of the event loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*3slyyiER3gFdkTRm1vxxmA.png" /><figcaption>Image[3] Page Scripts</figcaption></figure><p>HTML:</p><pre>&lt;h1&gt;Contrived Example&lt;/h1&gt;</pre><pre>&lt;button <em>class</em>=&quot;start-fib&quot;&gt;Start&lt;/button&gt;</pre><pre>&lt;div <em>class</em>=&quot;fib-body&quot;&gt;</pre><pre>&lt;ul&gt;&lt;/ul&gt;</pre><pre>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*szSUpI7UEdDAR0dX09ki9g.gif" /><figcaption>image[4] Total output</figcaption></figure><p>From the above, the Fibonacci function is called and processed in a separate thread thanks to the web worker. After the process is done the web worker returns an output via an event emitted after every nth term in the sequence is generated. This process doesn’t distort the main UI thread as I try to scroll and highlight the screen. The Fibonacci process happens separately oblivious to what the user currently does.</p><h3><strong>SERVICE WORKERS</strong></h3><p>Service workers are effectively still web workers with the major distinguishing feature being the fact that it has a longer lifecycle in comparison to normal web workers. it can still exist even after the page has been closed.</p><p>Service workers are proxies that sit on our browser. It interfaces with every request that goes back and forth the browser. even if the browser tab isn’t open it can still interact with the server on the browser’s behalf.</p><p><strong>Using Service Workers</strong></p><p>A very good tip when using service workers is understanding the lifecycles of a service worker. a service worker is in one of three(3) states at a time.</p><ol><li>installing</li><li>waiting</li><li>active</li></ol><p>These lifecycles ensure that only one service worker is active at a given time, serving a page. The downside to this is, users currently surfing your newly updated applications would get to experience the new features unless the service worker active at that moment is terminated. This will happen either by the user redirecting to another page entirely and then coming back or closing the browser.</p><p>Service worker deep dive.</p><p><strong>INSTANTIATING A NEW SERVICE WORKER</strong></p><pre>const serviceWorkerRegistration = n<em>avigator.serviceWorker.register</em>(<br>   &quot;/sw.js&quot;,<br>   {updateViaCache: &quot;none&quot;}<br>);<br></pre><pre>const serviceWorker = <br><em>serviceWorkerRegistration.</em>installing ||<br><em>serviceWorkerRegistration.</em>waiting||<br><em>serviceWorkerRegistration.</em>active;</pre><pre><em>navigator.serviceWorker.addEventListener</em>(&quot;controllerchange&quot;, () =&gt; { serviceWorker = <em>navigator.serviceWorker.</em>controller;  </pre><pre><em>sendServiceWorkerMsg({ping:&quot;Hi, there I am a page&quot;})</em></pre><pre><em>const sendServiceWorkerMsg = </em>(msg, target) =&gt; {</pre><pre>   if (target) { <em>target.postMessage</em>(msg);</pre><pre>   } else if (serviceWorker) { <em>serviceWorker.postMessage</em>(msg);</pre><pre>   } else { <em>navigator.serviceWorker.postMessage</em>(msg);}</pre><pre>}</pre><p>creating a service worker is a lot different from creating a web worker. For a web worker, all we had to do was to leverage the web worker API using the web worker function constructor and pass in the worker file. With a Service worker, things are a lot more complicated. The web worker acted as a dedicated service hence communication was absolutely straightforward.</p><p>A Service worker has mandatory lifecycles that must occur for a service worker to take control of a page or application. One major drawback to this lifecycle is the fact that a user may be running an outdated version of your application because the new service worker hasn’t be activated. hence the user will have to redirect to another page, then back to the page where it was to see the new changes.</p><p><strong>COMMUNICATION BETWEEN PAGES AND WEB WORKERS</strong></p><pre><em>navigator.serviceWorker.addEventListener</em>(&quot;message&quot;,(event) =&gt; {  </pre><pre>    console.log(data.msgFromServiceWorker); // {pong: &quot;hi there fr&quot;}<br>    console.log(data.ports)</pre><pre>});</pre><p>Service workers communicate with pages via a message channel which is created by a service worker per window client. the message channel consists of two ports, the second port is used by the service worker to send messages to the page while it receives information from the first port.</p><pre>const sendMessage  = (msg) =&gt; {</pre><pre>   var<em> </em>allClients<em> </em>=<em> await clients.matchAll</em>({<em> includeUncontrolled</em>:<em>    true </em>});</pre><pre>   console<em>.</em>log(&quot;all the connected clients&quot;, allClients);</pre><pre><em>   return</em> Promise<em>.all</em>( <em>allClients.map</em>(client =&gt; {</pre><pre>   const<em> newChannel </em>=<em> </em>new<em> </em>MessageChannel();</pre><pre><em>   newChannel.port1.</em>onmessage = serviceWorkerMessageHandler; </pre><pre><em>   return</em> <em>client.postMessage</em>(msg, [<em>newChannel.</em>port2]);}));<br>}</pre><blockquote>The allClients variable targets all the tabs or windows that the service worker is currently controlling/active. This is unlike the web worker which just had one dedicated tab for one web worker.</blockquote><p>From the above, a message channel is created by the service worker for communication between the page and the service worker via the ports created.</p><p><strong>CACHE API</strong></p><p>The cache in the browser interfaces network requests, meaning when resources/assets are required by network requests in our applications, the browser checks the cache to find the requested resource. If it exists, it loads it from the cache. If not, it will start its conventional network request trip through the vast internet mass to find it. think of the cache storage like a key-value store like an object in javascript. For cache, the keys are the URL pathnames and values are the response objects. speaking of response objects, it very important to note that these response objects can only be used once. Any further usage would require a clone. This is usually achieved by calling the clone method on the response object from an ajax response.</p><p>case in point below:</p><pre>const<em> cacheAbleUrls </em>=<em> </em>[</pre><pre>&quot;/styles.css&quot;,</pre><pre>&quot;/index.html&quot;,</pre><pre>&quot;about.html&quot;,</pre><pre>&quot;/index.js&quot;,</pre><pre>&quot;/dashboard.js&quot;</pre><pre>];</pre><pre>const<em> saveToCache </em>=<em> async </em>(<em>refresh </em>=<em> false</em>)<em> </em>=&gt;<em> </em>{</pre><pre>  let<em> </em>cache<em> </em>=<em> await caches.open</em>(&quot;some-random-cache-name&quot;);</pre><pre>  let<em> </em>res;</pre><pre>  if<em> </em>(!refresh)<em> </em>{</pre><pre><em>      return Promise.all</em>(</pre><pre><em>       cacheAbleUrls.match</em>(<em>async url </em>=&gt;<em> </em>{</pre><pre>       res<em> </em>=<em> await cache.match</em>(url);</pre><pre><em>       return </em>res;</pre><pre>       })</pre><pre>     );</pre><pre>  }</pre><pre>   res<em> </em>=<em> await fetch</em>(url,<em> </em>{</pre><pre><em>       method</em>:<em> </em>&quot;GET&quot;,</pre><pre><em>       credentials</em>:<em> </em>&quot;omit&quot;,</pre><pre><em>        cache</em>:<em> </em>&quot;no-cache&quot;,</pre><pre>    });</pre><pre>   if<em> </em>(<em>res.ok</em>)<em> </em>{</pre><pre><em>   await cache.put</em>(url,<em> </em>res);</pre><pre>    }</pre><pre>  };</pre><blockquote>As can be seen above, the function saveToCache takes a boolean argument which allows the functionality of toggling the caching action. This would cater for cases where you would want a fresh load to the cache i.e a new update to the styles or scripts.</blockquote><p><strong>REFERENCES</strong></p><p>[1]<a href="https://caniuse.com/#search=web%20workers">https://caniuse.com/#search=web%20workers</a></p><p>[2] <a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker">https://developer.mozilla.org/en-US/docs/Web/API/Worker</a></p><p>[3] <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers">https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers</a></p><p>[4] <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm">https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm</a></p><p>[5]<a href="https://medium.com/@SitePen/the-return-of-sharedarraybuffers-and-atomics-a254032e00a6">https://medium.com/@SitePen/the-return-of-sharedarraybuffers-and-atomics-a254032e00a6</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3d5d9751907" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>