<?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 nofanto ibrahim on Medium]]></title>
        <description><![CDATA[Stories by nofanto ibrahim on Medium]]></description>
        <link>https://medium.com/@nofanto?source=rss-c50096a5119------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by nofanto ibrahim on Medium</title>
            <link>https://medium.com/@nofanto?source=rss-c50096a5119------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:48:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nofanto/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[Optimising an ReactJS App]]></title>
            <link>https://medium.com/@nofanto/optimising-an-reactjs-app-a086b6a725cb?source=rss-c50096a5119------2</link>
            <guid isPermaLink="false">https://medium.com/p/a086b6a725cb</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[nofanto ibrahim]]></dc:creator>
            <pubDate>Mon, 05 Oct 2020 07:18:27 GMT</pubDate>
            <atom:updated>2020-10-05T07:18:27.432Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I will show how to squeeze last bit of performance on typical ReactJS app, there are some technique and concept that perhaps will useful for an idea on where to start when optimising an ReactJS app.</p><blockquote><strong>App for test</strong></blockquote><p>Here I will be use <a href="https://github.com/nofanto/react-tutorial">a forked version of React-Tutorial</a> app from Tania Rascia , there is a branch called baseline for our code baseline and branch called optimize-render for optimised version. This app is used for add and remove a person data (name and job) to the list, as you can see from the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GP1ePU7CrsQcP9gbSj-xjQ.png" /></figure><blockquote><strong>Test Scenario</strong></blockquote><p>The test scenario is typical user interaction (add ten person data and then delete the last three), you can see the complete test in <a href="https://github.com/nofanto/react-tutorial-e2e-test">this repository</a> (I used <a href="https://codecept.io/">CodeceptJS</a> for building the test).</p><blockquote><strong>How to test</strong></blockquote><ol><li>Build the application</li><li>Publish application to pushstate-server</li><li>Run test script</li><li>Analyze test result</li><li>Repeat step 3 and 4 ten times</li></ol><blockquote><strong>Test Result</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*IHHS_Ia-nBzCIl0P7PBerw.png" /></figure><p>As you can see from the result above, there’s an around one percent improvement from the baseline, not bad at all considering the changes that needed for optimisation.</p><blockquote><strong>Optimisation</strong></blockquote><p>There are two concept that need to remembered when doing optimisation on ReactJS app:</p><ul><li><strong>Avoid unnecessary component rendering</strong></li></ul><p>How ReactJS work is by having it’s virtual DOM to keep track on what is change on it’s component and determine whether to show the change in the DOM by comparing changes with previous changes (that have been showed in the DOM), if its the same then ReactJs doesn’t need to update the DOM thus improving performance, but the process of comparing it self also have performance cost, therefore the less need for comparing changes and less need for updating DOM is preferable for performance.</p><p>One way to achieve this is that by using stateless functional component when possible, See these following code changes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xNgJI0KzrOCtqGLO2fVE9A.png" /></figure><p>Those code changes above will lead to better performance, because React doesn’t need to render table header every time table is updated.</p><ul><li><strong>Separate UI state and Data state</strong></li></ul><p>Some of you may ask about what if the component need to have state? we can’t use stateless functional component for sure. The question should be rephrased to do the component really need to have state? to answer that question we should separate the UI state and Data state.<br>UI state is state of the component that non-related to the data, and Data state is state of the component that related to data, since ReactJs component is often presentational or UI component so the UI state must be resides in the component it self and data state better from the outside component (lifting data state up).</p><p>See this component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e16f55a06319c434c29e307f46e814e1/href">https://medium.com/media/e16f55a06319c434c29e307f46e814e1/href</a></iframe><p>This component doesn’t have UI state or Data state, so we can make it as functional stateless component and it will perform faster than its as component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58bd811f73c45ca3a30443910f758afc/href">https://medium.com/media/58bd811f73c45ca3a30443910f758afc/href</a></iframe><p>And we can use it in memoized way like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/982f66577a108da93d7b7fb76115721e/href">https://medium.com/media/982f66577a108da93d7b7fb76115721e/href</a></iframe><p>In short, by implementing those two concept above, any ReactJS app can be more performant, how much the performance improvement of course is depend on how complex the application it self, I believe the more complex the more we can see the improvement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a086b6a725cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automatically do the Web Page Profiling with CodeceptJs and Puppeteer]]></title>
            <link>https://medium.com/@nofanto/automatically-do-the-web-page-profiling-with-codeceptjs-and-puppeteer-91d663f8d35?source=rss-c50096a5119------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d663f8d35</guid>
            <category><![CDATA[we]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[nofanto ibrahim]]></dc:creator>
            <pubDate>Sun, 28 Jun 2020 13:46:26 GMT</pubDate>
            <atom:updated>2020-06-28T13:46:26.939Z</atom:updated>
            <content:encoded><![CDATA[<p>I was in need to do optimisation in web site project, a single page application to be exact, and it was involving of frequently repeating these steps manually: <br>- load the page<br>- start the profiler<br>- do some action on the page<br>- stop the profiler<br>- analyse the profiler result</p><p>It’s no brainer that those steps above is need to be automated (not including the analyse step of course), so in this article, I will show you how to automated web page profiling.</p><blockquote><strong>Ingredients</strong></blockquote><p>This is the list of what we need:</p><ol><li>An application to be profiled obviously, in this example I’ll use this <a href="https://github.com/taniarascia/react-tutorial">react tutorial</a>, but you can use any web application.</li><li><a href="https://github.com/puppeteer/puppeteer/">Puppeteer</a>, we need something that can control the browser so that we can test the application.</li><li><a href="https://codecept.io/">Codeceptjs</a>, provide a nice API and boiler plate on top of Puppeteer, so we can quickly to write the test.</li></ol><blockquote><strong>Setting Up</strong></blockquote><ol><li>Run the application<br>git clone <a href="https://github.com/taniarascia/react-tutorial.git">https://github.com/taniarascia/react-tutorial.git</a><br>npm install<br>npm run start</li><li>Install and configure Codeceptjs and Puppeteer<br>mkdir react-tutorial-e2eTest<br>npm install codeceptjs puppeteer --save<br>npx codeceptjs init <br>There will be several prompt, you can choose the default option by press enter, we can configuring it later.</li><li>Configure Codeceptjs<br>Open codecept.conf.js and replace the WebDriver and url in the helpers section in to Puppeteer and http://localhost:3000 , final result will be like this :</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4849c68ba3f8c7998160c96d765eaf0/href">https://medium.com/media/c4849c68ba3f8c7998160c96d765eaf0/href</a></iframe><blockquote><strong>Writing and Running the Test</strong></blockquote><ul><li>Open the _test.js file and replace its content with this:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/feeb44ac57d70db49c7dfa5cf074e26c/href">https://medium.com/media/feeb44ac57d70db49c7dfa5cf074e26c/href</a></iframe><p>The test code it self is self explanatory, you can refer to Codeceptjs documentation for more detail.</p><ul><li>Run the test with this command npx codeceptjs run and you can see the test are pass and you can also manually verify the screenshot in output folder.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*k9D_84IXQYeXU5lYuyt_KA.png" /><figcaption>CodeceptJs’s run test output</figcaption></figure><blockquote><strong>Attaching Profiler</strong></blockquote><ul><li>Creating helper for Puppeteer<br>run this command npx codeceptjs gh enter profiler as name of the helper when prompted</li><li>Edit the profiler_helper.js file, replace its content with this :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41fc37a56cc89d2291e4503bc1083b33/href">https://medium.com/media/41fc37a56cc89d2291e4503bc1083b33/href</a></iframe><ul><li>Attach the profiler to the test case<br>Open the _test.js file and uncomment the line 9 and 37 to enable the profiler.</li><li>Run the test again, npx codeceptjs run and in the output folder you’ll find a json file that contain the profiler data.</li><li>Load the profile file into Chrome Developer Tools<br>Open Chrome browser, press Command+Option+C (Mac) or Control+Shift+C (Windows, Linux, Chrome OS), and go to Performance tab and then click Load Profile and select the generated json file to load the profiler data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4NS7x1wnjpgTuhb1nRnpug.png" /><figcaption>Loaded Profiler data in Chrome Developer Tools</figcaption></figure><blockquote><strong>Conclusion</strong></blockquote><p>By utilising Codeceptjs API and it’s ability to configure Puppeteer, we can quickly create end to end test and extending it to enable profiling in test.</p><p>See the complete code in my <a href="https://github.com/nofanto/codeceptjs-profiling">github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d663f8d35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Driven Container Development]]></title>
            <link>https://medium.com/@nofanto/test-driven-container-development-b7d8b54bce0f?source=rss-c50096a5119------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7d8b54bce0f</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[nofanto ibrahim]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 08:27:31 GMT</pubDate>
            <atom:updated>2020-06-23T08:27:31.719Z</atom:updated>
            <content:encoded><![CDATA[<p>For a project that I working on, I need to do some test in a Linux machine (I’m using OSX), it was pretty straight forward to accomplish my goal with the help of Docker. All I have to do is creating a docker file and run that docker file and do the test on the container.</p><p>The hardest part is to get familiar with the docker it self, it was involved with trial and error and I have to check manually whether my docker container is suitable for my test or not. So, there must be a better way to do container development than this.</p><p>Well, we can use <a href="https://serverspec.org/">ServerSpec</a> to validate the container, but it involved setting ruby environment which is too much for my liking, so while searching, i’m stumbled upon <a href="https://github.com/aelsabbahy/goss">goss</a>, which is built with go, it has no dependencies (great), and it have <a href="https://github.com/aelsabbahy/goss/tree/master/extras/dgoss">Dgoss</a> to work with docker (double great), so let’s try it.</p><blockquote><strong>Setup Dgoss</strong></blockquote><ul><li>Download suitable goss for the container that need to test, in my case is Linux, so I’m downloading the linux binary and save as file named goss</li></ul><pre>curl -L <a href="https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64">https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64</a> -o goss</pre><ul><li>Download Dgoss and save as file named dgoss</li></ul><pre>curl -L <a href="https://raw.githubusercontent.com/aelsabbahy/goss/master/extras/dgoss/dgoss">https://raw.githubusercontent.com/aelsabbahy/goss/master/extras/dgoss/dgoss</a> -o dgoss</pre><ul><li>Add executable permission for dgoss</li></ul><pre>chmod +rx dgoss</pre><ul><li>Add PATH variable for dgoss</li></ul><pre>export PATH=$PATH:&lt;your dgoss folder&gt;</pre><ul><li>Add GOSS_PATH variable for goss</li></ul><pre>export GOSS_PATH=&lt;your goss folder&gt;/&lt;your goss filename&gt;</pre><blockquote><strong>Test Driven Container Development</strong></blockquote><p>Once we’ve got goss setup, now let’s try to build a container that suitable for Java development with TDD, you’ll need a docker setup and running in your system.</p><p>The requirement for the container is to have have these SDK installed:</p><ul><li>JDK 11.0.7</li><li>Maven 3.6.3</li></ul><p>Given the requirement, the test case should be:</p><ul><li>when checking java version in the container, the output should contain 11.0.7 (indicating that Java version 11.0.7 has been installed correctly)</li><li>when checking maven version, the output should contain 3.6.3 (indicating that Maven version 3.6.3 has been installed correctly)</li></ul><blockquote><strong>Creating test case</strong></blockquote><p>Create file named goss.yaml with content like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f1ad58c14606fa6c16a08ee28b0edd1/href">https://medium.com/media/8f1ad58c14606fa6c16a08ee28b0edd1/href</a></iframe><p>the test case is self explanatory (with comment), basically your test and assertion is group by the goss’s test.</p><blockquote><strong>Run the test</strong></blockquote><p>Once we had the test case, then we move to the implementation. For the implementation, rather than creating a dockerfile, we’ll use the images that already on docker hub and run our test against it.</p><p>First, let’s pull openjdk-11 image, by running this command docker pull openjdk:11.0.7-jdk</p><p>once the image already pulled, let’s run the test dgoss run — name test-dgoss openjdk:11.0.7-jdk</p><p>and see the test result like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*2UON3_Tc8N5jdNpEGk1nRQ.png" /></figure><p>As you’ve already guessed, the test case 2 failed because there’s no maven installed in docker image</p><p>Now, let’s pull maven 3.6.3 jdk 11 image, by running this command docker pull maven:3.6.3-jdk-11</p><p>Then run test againts the image that we just pull, by running this command dgoss run — name test-dgoss maven:3.6.3-jdk-11</p><p>And now all test case are success</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*LYZD97cMWXu6C6U4-YairQ.png" /></figure><blockquote><strong>Summary</strong></blockquote><p>That’s it simple example how to test driven the container development using goss, for more complex scenario, you can refer to <a href="https://github.com/aelsabbahy/goss/blob/master/docs/manual.md">goss documentation</a> to see the goss capabilities</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7d8b54bce0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup and run PostgreSQL without any administrative rights in MacOS]]></title>
            <link>https://medium.com/@nofanto/setup-and-run-postgresql-without-any-administrative-rights-in-macos-69ff94f61b56?source=rss-c50096a5119------2</link>
            <guid isPermaLink="false">https://medium.com/p/69ff94f61b56</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[nofanto ibrahim]]></dc:creator>
            <pubDate>Sat, 25 Apr 2020 06:33:47 GMT</pubDate>
            <atom:updated>2020-04-25T06:35:42.339Z</atom:updated>
            <content:encoded><![CDATA[<p>Often if not always, in order to make things more secure, we are sacrificing our flexibility. This things happened in our life and in software engineering as well.</p><p>Recently I have a macbook that have been provisioned by IT department where I work to be secure to that point i don’t have a local administrative rights. I was astonished given the macbook should be used as software development machine, but turn out as long as the machine able to download from the internet, you can setup it as development machine.</p><p>So here is the guide to setup local database development using PostgreSQL for the user without administrative rights:</p><ol><li><strong>Download and install PostgreSQL</strong><br>Since mostly installer or package of PostgreSQL will write to the system directory which we don’t have access, so we’ll use the binaries version, go to <a href="https://www.enterprisedb.com/download-postgresql-binaries">https://www.enterprisedb.com/download-postgresql-binaries</a> and download the desired version. Once the download finished, extract the zip file and you’ll find the pgsql directory, this is where the PostgreSql installed.</li><li><strong>Setup default database in PostgreSql</strong><br>Before we can use the newly installed PostgreSQL, we need to create a default database. <br>Open terminal and change directory to pgsql and make a new data directory ( mkdir data ), after that execute this command ./bin/initdb -D ./data/ -U postgres -A trust</li><li><strong>Start and Stop PostgreSQL server</strong><br>After creating the default database, you can start the PostgreSql server with this command ./bin/pg_ctl -D ./data/ -l ./data/logfile start<br>Once started, you can connect to the server with this command ./bin/psql -h localhost -U postgres<br>For stopping the server you can use this command ./bin/pg_ctl -D ./data/ -l ./data/logfile stop</li></ol><p>Notes:</p><ul><li>You might encounter error during step 2, when macOS prompted about security, you can bypass it by using these commands in terminal at pgsql directory xattr -d com.apple.quarantine ./bin/initdb &amp;&amp; xattr -d com.apple.quarantine ./lib/libcrypto.1.1.dylib &amp;&amp; xattr -d com.apple.quarantine ./lib/postgresql/dict_snowball.so &amp;&amp; xattr -d com.apple.quarantine ./lib/postgresql/plpgsql.so &amp;&amp; xattr -d com.apple.quarantine ./lib/postgresql/llvmjit.so &amp;&amp; xattr -d com.apple.quarantine ./bin/pg_ctl &amp;&amp; xattr -d com.apple.quarantine ./bin/psql</li><li>You can use the bash script from my <a href="https://github.com/nofanto/macos-postgres-install">github</a> to automate the installation by using this command at terminal curl -s &quot;https://raw.githubusercontent.com/nofanto/macos-postgres-install/master/install-postgres.sh&quot; | bash , this will install PostgreSql in the current directory</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69ff94f61b56" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>