<?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 Shrestha Rohit on Medium]]></title>
        <description><![CDATA[Stories by Shrestha Rohit on Medium]]></description>
        <link>https://medium.com/@shrestharohit?source=rss-449743df382------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DHKHNpTzBokes9a8.jpg</url>
            <title>Stories by Shrestha Rohit on Medium</title>
            <link>https://medium.com/@shrestharohit?source=rss-449743df382------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 05:31:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shrestharohit/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[Managing large request with AWS Lambda]]></title>
            <link>https://shrestharohit.medium.com/managing-large-request-with-aws-lambda-dba94866cc88?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/dba94866cc88</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Sat, 19 Jun 2021 06:51:38 GMT</pubDate>
            <atom:updated>2021-06-19T07:13:56.758Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, a scenario came in where a data of around 20,000 user had to be proceed. The data had to be calculated in the background and inserted into the DB after the calculation. <br><br>So, would hitting up with such large requests in a production server work? What if the server crashes, slow down in the middle of the operation?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*04zxg60xjgBpOHN6.gif" /></figure><p>Here comes AWS lambda to the rescue. We deployed our code on AWS lambda and this eliminated our hassle of taking caring of server. Also, another reason of choosing AWS lambda was the cost since it calculates the server cost based on resources and the time the server runs.</p><p>Another issue for the solution was triggering AWS lambda for every requests(20,000) could exhaust the server Something that could store all the request,should be secure,reliable and send it to lambda function on request could solve our issue.</p><p>Amazon SQS was the solution to the problem. SQS basically stores the data in queue and could send it to lambda. A certain batch of data is request by lambda and SQS sends its upon the request.</p><p>The basic architecture for the solution we planned is a below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/0*X8Vb3RqLHdpAx7ob.png" /></figure><p>The server retrieves all the info needed for lambda to calculate the required information and sends it to SQS. SQS stores the data and send it to lambda for the calculation and store the values to the database.Without over burden in the server , we could execute large information in over few minutes.</p><p>The below stats show lambda handling upto 454 requests with no error rates. Lambda could easily handle large number of request with no downtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aIelypmB81LARZ3X.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*jZoQZ1lGY1F_dqA7.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dba94866cc88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Going Server-less with AWS Lambda]]></title>
            <link>https://shrestharohit.medium.com/going-server-less-with-aws-lambda-fe8928b25225?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe8928b25225</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 04:37:45 GMT</pubDate>
            <atom:updated>2021-06-10T04:37:45.601Z</atom:updated>
            <content:encoded><![CDATA[<p>The term `Server-less` has gained so much hyped recently. Everyone talks about executing their code on an server-less architecture but first let’s understand what is server-less anyway ?<br><br>Server less is only an fancy word. in fact in an server-less architecture there is an server which you shouldn’t worry about but the provider will take care of the computing power and up time. you just have to worry about your code and rest is handled by the provider in our case i.e. AWS.<br><br>One of the many services AWS provides is AWS lambda. AWS lambda is a function as a service. deploy your code to the server and you are ready to go for production. So, how do we do that ? <br><br><br>Let’s start by creating a lambda function that return the payload send to the function itself.<br>AWS Lambda provides support for many languages. Some of which are javascript, c#, python, Go etc. Let’s create an lambda using python. <br><br>Go to AWS Console &amp; AWS Lambda Section. Click on Create Function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W5689sm-W5EM1Ljj.png" /></figure><p>Add the function and choose python as Runtime Environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O9DkYNRoz-k9hDNV.png" /><figcaption>AWS Lambda Creation Form</figcaption></figure><p>A basic python code which can viewed in code source section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q7bXeqnKJHsmlgUH.png" /><figcaption>AWS Lambda Code View</figcaption></figure><pre>import json<br>def lambda_handler(event, context):<br>     # TODO implement<br>     return {&#39;statusCode&#39;: 200,&#39;body&#39;: json.dumps(event)}</pre><pre>I have modified the code to return payload send to the lambda functions.<br><br><br>Now let&#39;s test if the function works. Go to the `Test` Tab , change the payload.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PDiAF3K37rt5EAGt.png" /><figcaption>Testing AWS lambda</figcaption></figure><pre>Now click Test.<br>you can see the logs above with total time taken and resource utilized.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p4HRQb5WyEGwouq8.png" /><figcaption>AWS Lambda Execution Log</figcaption></figure><pre>There are many other ways the function can be triggered. You can using api-gateway, invoke directly using aws credentials, SNS, SQS services etc.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/0*TN3DqI8wpFUo2hHZ.png" /><figcaption>AWS Lambda Trigger List</figcaption></figure><pre>Benefits of AWS Lambda<br>AWS lambda makes it easy for developers for deploying code without worrying about the infrastructure. the code scales upon the request and also the cost for lambda depends upon your usage. if the lambda is not triggered,you don&#39;t have to pay for the service. You have use it as your email server, process that are triggered on demands only which will cut your cost and increase your saving.<br><br>Happy Coding!!!</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe8928b25225" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go.Data for contact tracing in Nepal]]></title>
            <link>https://shrestharohit.medium.com/go-data-for-contact-tracing-in-nepal-832027eee07?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/832027eee07</guid>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Tue, 30 Mar 2021 18:08:22 GMT</pubDate>
            <atom:updated>2021-03-30T18:08:22.685Z</atom:updated>
            <content:encoded><![CDATA[<p>To take a break from my regular work schedule, I decided to work on something interesting that would help others and keep me motivated. I knew that the Ministry of Health and Population (MoHP) was working on interoperability for health systems in Nepal. There are several DHIS2 systems working separately in various facilities in Nepal. The problem with these systems was that they were all isolated from each other and there lacked a common system which would connect all of them together. This would allow us to view any data from a single system rather than dwelling from one system to another. This was an interesting challenge for me so I started working on it. It took me a week to figure out how I would implement this and I went to my seniors to share the idea. By then, however, my country was hit by the Corona Virus (COVID-19). The country’s first case was detected and everyone was focused towards working on COVID-19 cases. Although I was planning on proposing a solution to the ‘interoperability’ problem, a few days later I was called by a team at GiZ to work on COVID-19 systems. With no regrets, I accepted the offer since it was an opportunity for me to work on building a system for contact tracing Nepal. Basically, contact tracing is the process of identifying the people who were in close contact with a particular person. In our case, contact tracing was used for the identification of people who were in contact with COVID-19 suspects. I was hired as a consultant to work on an app called ‘Go.Data’.</p><h4>What is Go.Data ?</h4><p>Go.Data is an outbreak investigation tool for field data collection in emergency situations. The main functionality of this app are :</p><ul><li>case investigation</li><li>contact follow-up</li><li>visualization of chains of transmission</li></ul><p>Go.Data is the initiative of a group of public health partners and is managed by the Global Outbreak and Response Network coordinated by WHO.</p><h4>First</h4><p>So, i started working on Go.Data, went through its documentation and learnt about Go.Data within a few days. The first priority for us was to convert the physical form to digital forms.<br>The task was easy but challenging at the same time. while paper form was quiet redundant and no ones bothers since it is just a matter of second to write it in paper but in digital form people bothers since the same things if asked times will makes people go crazy. we evaluated he forms several times and were able to create forms for contact investigations ,<br>contact follow up and suspect case. these three forms make it clear for health experts to evaluate the suspect history, its condition and mode of transmission that could have taken place to reach the other people.</p><p>So, how does Go.Data works:<br><br>Let’s suppose a patient is suspected with COVID-19. he/she is registered to the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fUe2JhQ3ZLnMMlC5.png" /><figcaption>Registration Form</figcaption></figure><p>A series of question is asked to the patient to know this mode of transportation, this close contacts, symptoms</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OjVnjoJOgPF27rQU.png" /><figcaption>Questionare</figcaption></figure><p>After filling all the info about the patient then contract tracing is done by asking him about the close contact information which is a seperate form with the contacts information.<br>After all the information is filled. Now, we have all the info of the patients , his contacts. So you might think how does this help us in tracing the contact.<br><br>Now, the interesting things about Go.Data is its follow up schedules and visualization graphs.<br>After all the information are filled, Go.Data can automatically generates us with follow up schedules after knowing the last date of the contact. so looking at the graph we can see the number of people which has been followed and which are left to follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HJq94svlfNhQVQhM.png" /><figcaption>follow up graph</figcaption></figure><p>Also, with all the gathered data, a key program indicators can be generated letting us know the independent chain of transmissions, contacts per cases, contact becoming cases, contact with successful followup etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qZc9fH5vicEpZgm9.png" /><figcaption>KPI</figcaption></figure><p>The most interesting graphs is the chain of transmission graph which help to track down the contact and cases very easily. we could find the source and contact and contact being source very easily.</p><h4>Beyond Go.Data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/0*ld7hsnWbR57V2sxn.png" /><figcaption>Chain of Transmission</figcaption></figure><h4>SMS system for knowing patient response</h4><p>Go.Data itself was a complete package for a well managed data collect and visualization tools. but an idea of integrating a SMS system with this tool made this project more lively.<br>The plan was to send SMS to all the contract traced for 14 days from the date of contact and know their status(well, not well). So, phone number could be extracted from the system and a SMS was sent and the response was sent to server we built which eventually save the data to Go.Data Servers.</p><h4>Automatically generating followups and deducing number if already checked.</h4><p>The problem with Go.Data was followup schedule needs to be created manually. So, every time new contact was created , the follow up list must be manually generated by going through a process which was tedious. so, we planned on creating a cronjob (a service that run in regular time) to create a follow up list.<br><br>Again, the problem with the auto generated list was it generated all the list(tested or not tested). we only need the patient who were not tested. So again, a script to avoid listing a user who were not tested was written to avoid this problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XIuYaWi23sF8Pf5H.png" /><figcaption>Complete workflow diagram for contrac tracing</figcaption></figure><p>The whole project was a great experience for me . I was able see the proper use of data and data turned into information to provide a valuable meaning. Also, contributing directly/indirectly to help nation fight against COVID-19 is a great feeling indeed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=832027eee07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Experience in the National Tuberculosis Center]]></title>
            <link>https://shrestharohit.medium.com/my-experience-in-the-national-tuberculosis-center-b8e8f0581e71?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8e8f0581e71</guid>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 12:31:25 GMT</pubDate>
            <atom:updated>2020-06-01T12:31:25.931Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Background:</strong></p><p>Recently, we got a chance to work for the National Tuberculosis Center, Bhaktapur — a center for tuberculosis treatment, prevention and cure. As a software engineer, people may think about what will I do in a tuberculosis center? But wait! Now, Things are growing so rapidly, we all need interdisciplinary actions for every event. Let it be we trying to generate a graph for a National Stock Exchange, We need help from statisticians or a health professional may need a tool for data management where we can play our role. So, my involvement in the NTB(National Tuberculosis Center) was for data management.</p><p>NTB uses a device named <strong>GeneXpert</strong>.The device which helps for the test of tuberculosis bacteria/ resistance to a drug Rifampicin. A sample of sputum is tested in the device and a result is obtained which doctor use for the diagnosis of TB. Interestingly, the device, after giving a hostname, could send the patient’s data to a server<em>. </em>The data sent by the Genexpert machine uses the HL7 protocol.</p><p><strong>Health Level Seven</strong> or <strong>HL7 </strong>refers to a set of international standards for the transfer of clinical and administrative data between software applications used by various healthcare providers. These standards define how information is packaged and communicated from one party to another, setting the language, structure and data types required for seamless integration between systems. The information includes the patient information, patient results, machine data that<em> are </em>needed for us to visualize the data into something meaningful.</p><p>Here are some samples of hl7 message:</p><pre>MSH|^~\&amp;||.|||199908180016||ADT^A04|ADT.1.1698593|P|2.7<br>PID|1||000395122||LEVERKUHN^ADRIAN^C||19880517180606|M|||6 66TH AVE NE^^WEIMAR^DL^98052||(157)983-3296|||S||12354768|87654321<br>NK1|1|TALLIS^THOMAS^C|GRANDFATHER|12914 SPEM ST^^ALIUM^IN^98052|(157)883-6176<br>NK1|2|WEBERN^ANTON|SON|12 STRASSE MUSIK^^VIENNA^AUS^11212|(123)456-7890<br>IN1|1|PRE2||LIFE PRUDENT BUYER|PO BOX 23523^WELLINGTON^ON^98111|||19601||||||||THOMAS^JAMES^M|F|||||||||||||||||||ZKA535529776</pre><p>The above message is divided into four segments: MSH, PID, NK1, and IN1.</p><p><strong>A segment</strong> contains fields<em> which is </em>separated by the | <em>field separator</em>. <em>Field</em>s can be further separated by ‘^’, the so-called <em>component separator</em>, and contain sub-components denoted by ‘&amp;’ symbol.</p><p><strong>MSH (Message Header)</strong> contains purpose of the message, e.g. its ID, seeding application, sending facility, receiving an application, receiving facility, type, date and time of the message, its HL7 version, etc.</p><p><strong>PID (Patient Identification)</strong> holds information about the patient e.g. their ID, name, DOB, address, gender, race, admission date and time etc.</p><p><strong>NK1 (Next of Kin)</strong> contains details of the person’s closet relative/friend.</p><p><strong>IN1 (Insurance 1)</strong> has details about the health insurance the patient has like Medicare, Medicaid, Tricare, etc. It contains the insurance plan ID, the name of the insurance company, the company’s address, the name of the insured person, policy number, etc…</p><p>(https://stackoverflow.com/a/46302926/5393816)</p><p><strong>Action Plan:</strong></p><p>So, we set up a Linux container that could accept the hl7 data and store it in our database. we used the <em>python-hl7 </em>module to parse the data from the machine. So, our initial architecture looked like these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/0*s38wtjYaEqEBbp1H.png" /></figure><p>The work was almost completed until the request on the server was too much for our server to handle. The server was unable to handle the requests. We initially assumed that the Genexpert Machine would send 10–20 requests per day. After testing for a day, 40,0000 rows were filled in a day making our assumption wrong. Imagine, the huge request that the server handled that day.</p><p>There are nearly 100 Genexpert Devices across the country from which we should be able to retrieve data. Each device sends at most 100s of data a day to a server. In a case where the internet may not run for a few days, the count of data may reach 1000s a day. So, on a worst-case, Let’s say all the device has internet failure for a few days, the count will reach thousands and thousands of request from each server. A single server on handling all these requests will easily crash or ignore most of the requests. So, we need a way of handling all the requests. We knew a load balancer was the answer but, the real question was what/how should we do this?</p><p>In a few research, we found the answer, HaProxy(<a href="http://www.haproxy.org/">http://www.haproxy.org/</a>). HAProxy stands for High Availability Proxy which is a TCP/HTTP load balancer and proxy server. We have written a blog on how to do we set up the load balancer. Here is the link:<a href="http://shrestharohit.com.np/using-ha-proxy-load-balancer/">https://shrestharohit.com.np/using-ha-proxy-load-balancer</a>.</p><p>So, 6 virtual Linux container(server) with a load balancer on the top of it was installed. <em>After using the load balancer, </em>these sever were able to handle all the requests efficiently. <em>The architecture of this connection</em> looks like these.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/0*et435AymK1Skq1x7.png" /></figure><p>Basically, a load balancer with a round-robin algorithm would distribute the request to different servers. The server handles the request and saves the data to the database. Now, the final process was to show all the data into meaningful information. Since we had all the things we needed Patient info, machine info and patient result</p><p>We could see a lot of possibilities. To list a few of them like listing the active devices across the country,the list of machines failing to send response/ is not working for few days, save patient information for future uses, get exact information on certain parameters like total no of patients with RIF resistance detected across the country.</p><p>Some of the works we did with the data are :</p><ol><li>List all the machine operating in across the country with their status(delay to send reports to the server</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zgh77FFxetdcPVp8.png" /></figure><p>2. Get an aggregate report for the purpose of analysis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kc5SbqONuHgtcxuz.png" /></figure><p>3. List machines with delayed data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9TsRT6inPjCFjtnb.png" /></figure><p><strong>Conclusion:</strong></p><p>Being involved in the health sector for a long time, We could see a lot of possibilities for the use of data in our country. Today’s world works on the power of data. Data are powerful in the sense that they help us moving forward with proper judgment.</p><p>The chance to work with NTB for exploring the use of health-related data was very exciting and challenging in itself. It seemed very challenging at first, but on working<strong> </strong>close with the teams,We were able to explore how data could be used for decision making and monitoring various factors across the country.</p><p>Team Members:<br>- Aatish Neupane (<a href="https://librenepal.com/">https://librenepal.com/</a>)<br>- Rohit Shrestha</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8e8f0581e71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving your media file from Linux server to Amazon s3 using s3cmd]]></title>
            <link>https://shrestharohit.medium.com/moving-your-media-file-from-linux-server-to-amazon-s3-using-s3cmd-43ca0d517c0e?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/43ca0d517c0e</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Sat, 30 May 2020 05:26:52 GMT</pubDate>
            <atom:updated>2020-05-30T05:26:52.756Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we will learn how will we move file,folder from your server to Amazon s using s3cmd.</p><p>s3 is one of the most reliable when it comes to storing your data . let it be for for your web application, mobile app or anything.Industry leading tech giants like Netflix, Airbnb use it for storing its content. This shows the reliable, scalable and the uptime performance of Amazon s3.</p><p>We will be looking at how do we move our content from our server to Amazon s3 using <a href="https://github.com/s3tools/s3cmd">s3cmd</a>.</p><p>On an debian/unbuntu type the following command to install<strong> s3cmd</strong>.</p><h4>Installing s3cmd</h4><pre>sudo apt-get install s3cmd</pre><h4>Configure s3cmd</h4><pre>s3cmd --configure</pre><pre>the command will ask for Access Key , Secret Key, Bucket Name &amp; few options.</pre><pre>Retrieving Access Key From AWS</pre><pre>For retrieving your Access Key and Secret Key, In the AWS Console, click my security credentials at the top right for your profile.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/0*RqnFtpCT3DqLSHu-.png" /></figure><pre>You can create a new access key for use an old one from Access Keys column.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*V-ndB54l6PViNCKo.png" /></figure><pre>Now, it&#39;s time to move  your file/folder from server to s3.</pre><pre>Move a single file to s3</pre><pre>s3cmd put file.txt s3://folder/</pre><h4>Move a folder to s3</h4><pre>s3cmd put --recursive source-folder s3://destination-folder</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43ca0d517c0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using HAProxy as a load balancer]]></title>
            <link>https://shrestharohit.medium.com/using-haproxy-as-a-load-balancer-4169455d844a?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/4169455d844a</guid>
            <category><![CDATA[load-balancer]]></category>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Wed, 27 May 2020 11:08:28 GMT</pubDate>
            <atom:updated>2020-05-27T11:08:28.854Z</atom:updated>
            <content:encoded><![CDATA[<p>HAProxy stands for High Availability Proxy which is a TCP/HTTP load balancer and proxy server. Basically what it does is distributing the incoming load to a different server so that request doesn’t saturate in a single server.</p><p>Recently, I came with a problem, where the server was hit so hard that 40,000 rows were filled upon in an hour which means 40,000 requests in a row(not including invalid requests). This made the situation worse since the server handling such a request means not being able to handle all the requests properly. So, a friend(<a href="https://librenepal.com/">https://librenepal.com</a>) suggested me to use HAProxy.</p><p>That was the perfect solution to the problem I was facing. HaProxy as a server takes all the request and distribute to different servers depending upon request based on the load balancing algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*j4_RGd2Fa4sVhTb9.png" /><figcaption>Basic Load-Balancer Configurations</figcaption></figure><p>The above diagram shows how are we going to install the HAProxy Server. The proxy server will be listening to port 80 and distributing its request to the servers on port 8081 depending upon the load balancing algorithm we set in the proxy server.</p><p>The installation was pretty simple:</p><pre>sudo apt-get install haproxy</pre><p>The configuration file is available at</p><pre>/etc/haproxy/haproxy.cfg</pre><pre>global<br>    log /dev/log    local0<br>    log /dev/log    local1 notice<br>    chroot /var/lib/haproxy<br>    stats socket /run/haproxy/admin.sock mode 660 level admin<br>    stats timeout 30s<br>    user haproxy<br>    group haproxy<br>    daemon</pre><pre># Default SSL material locations<br>ca-base /etc/ssl/certs<br>crt-base /etc/ssl/private<br><br># Default ciphers to use on SSL-enabled listening sockets.<br># For more information, see ciphers(1SSL). This list is from:<br>#  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/<br># An alternative list with additional directives can be obtained from<br>#  https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy<br>ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS<br>ssl-default-bind-options no-sslv3</pre><pre>defaults<br>log     global<br>mode    http<br>option  httplog<br>option  dontlognull<br>timeout connect 5000<br>timeout client  50000<br>timeout server  50000<br>errorfile 400 /etc/haproxy/errors/400.http<br>errorfile 403 /etc/haproxy/errors/403.http<br>errorfile 408 /etc/haproxy/errors/408.http<br>errorfile 500 /etc/haproxy/errors/500.http<br>errorfile 502 /etc/haproxy/errors/502.http<br>errorfile 503 /etc/haproxy/errors/503.http<br>errorfile 504 /etc/haproxy/errors/504.http</pre><pre>The global section offers log folder location, setting user and group which is already created while installing haproxy.</pre><pre>and the default section provides additional log levels.</pre><pre>Now to configure the load-balancer, we need two types on nodes <em>frontend</em> and <em>backend</em>.</pre><pre>Add the following lines to /etc/haproxy/haproxy.cfg</pre><pre>frontend haproxynode<br>bind *:80<br>mode http<br>default_backend backendnode</pre><pre>so, we created a <em>haproxynode</em> frontend node which listens to port 80 on http and forwards to <em>backendnodes </em>which we will create now.</pre><pre>backend backendnodes<br>balance roundrobin<br>option forwardfor<br>http-request set-header X-Forwarded-Port %[dst_port]<br>http-request add-header X-Forwarded-Proto https if { ssl_fc }<br>option httpchk HEAD / HTTP/1.1\r\nHost:localhost<br>server node1 10.21.21.1:8081 check<br>server node2 10.21.21.2:8081 check</pre><pre>here the backend node name <em>backendnodes </em>uses round-robin technique for request distribution. round robin uses distribution based on the weight of the server. the request is forwarded to two servers on ip 192.168.2.3 on port 8080 and also health check is done to ensure the servers are running.</pre><pre>We can also view stats for the loadbalancer using listen node.</pre><pre>listen stats<br>bind :8988<br>stats enable<br>stats uri /<br>stats hide-version<br>stats auth someuser:password</pre><pre>here, we enabled the stats page on port 8988 which can be accessed from url at  ip-address/ and a username and password can be set from stats auth option.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*McQ9Yp3XwGv1m8oS.png" /><figcaption>HA stats</figcaption></figure><pre>A similar page can be viewed which shows the server stats, current active connections, sessions stats etc.</pre><pre>The final configuration file looks like this</pre><pre>global<br>log /dev/log    local0<br>log /dev/log    local1 notice<br>chroot /var/lib/haproxy<br>stats socket /run/haproxy/admin.sock mode 660 level admin<br>stats timeout 30s<br>user haproxy<br>group haproxy<br>daemon</pre><pre># Default SSL material locations<br>ca-base /etc/ssl/certs<br>crt-base /etc/ssl/private<br><br># Default ciphers to use on SSL-enabled listening sockets.<br># For more information, see ciphers(1SSL). This list is from:<br>#  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/<br># An alternative list with additional directives can be obtained from<br>#  https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy<br>ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS<br>ssl-default-bind-options no-sslv3</pre><pre>defaults<br>log     global<br>mode    http<br>option  httplog<br>option  dontlognull<br>timeout connect 5000<br>timeout client  50000<br>timeout server  50000<br>errorfile 400 /etc/haproxy/errors/400.http<br>errorfile 403 /etc/haproxy/errors/403.http<br>errorfile 408 /etc/haproxy/errors/408.http<br>errorfile 500 /etc/haproxy/errors/500.http<br>errorfile 502 /etc/haproxy/errors/502.http<br>errorfile 503 /etc/haproxy/errors/503.http<br>errorfile 504 /etc/haproxy/errors/504.http</pre><pre>frontend haproxynode<br>bind *:80<br>mode http<br>default_backend backendnode</pre><pre>backend backendnodes<br>balance roundrobin<br>option forwardfor<br>http-request set-header X-Forwarded-Port %[dst_port]<br>http-request add-header X-Forwarded-Proto https if { ssl_fc }<br>option httpchk HEAD / HTTP/1.1\r\nHost:localhost<br>server node1 192.168.2.2:8080 check<br>server node2 192.168.2.3:8080 check</pre><pre>listen stats<br>bind :8988<br>stats enable<br>stats uri /<br>stats hide-version<br>stats auth someuser:password</pre><pre>Finally,</pre><pre>restart the server</pre><pre>sudo service haproxy restart</pre><pre>Enjoy !</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4169455d844a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DHIS2 implementation in Nepal]]></title>
            <link>https://shrestharohit.medium.com/dhis2-implementation-in-nepal-b82318e34c11?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/b82318e34c11</guid>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Wed, 27 May 2020 11:02:04 GMT</pubDate>
            <atom:updated>2020-05-27T11:02:04.843Z</atom:updated>
            <content:encoded><![CDATA[<p>Nepal is stepping into the world of the digital revolution. While most of the nations are quiet ahead from us, we are in the earlier stage of the digital era. Today I am going to talk about how/why is MoHP(Ministry of Health &amp; Population) entering the digital era and what does it mean for a country like us.</p><h4><strong>Background:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*y_UVUtp2V2iJCUZC" /></figure><p><em>Look at the above picture!</em></p><p>this is a monthly report of the major health service on the basis of the district on the paper forms. imagine how hard life was back then. The accuracy and reliability can’t even be measured. since many paper-based data may have been lost, incorrectly written. No one would bother to cross-check fact on all papers.</p><h4><strong>Present:</strong></h4><p>MoHP(Ministry of Health &amp; Population), Nepal now have emphasized on data entry using DHIS2. DHIS2 is a web-based tool developed by the University of OSLO which is implemented in more than 40 countries for analysis, storage and forecast of health-related information. MoHP(Ministry of Health &amp; Population) has started to use this software in almost every facility of Nepal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*nZAOew8ocFvvWMR-" /></figure><h4><strong>How is MoHP doing this?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*mI1Tg08yWqIW7HTV" /></figure><p>MoHP along with various organizations is rigorously training all the health workers around the country to enable them for data entry and visualization of their own data. Various online video, manuals, on-site coaching staffs are deployed for making e-health successful across the country. This is a long process but almost all the facilities are covered until now.</p><h4><strong>What Does it mean for Country Like Nepal?</strong></h4><p>Most of the facilities now report on DHIS2, this impacts the impact that can be seen is huge. So, I have listed a few points on how is Nepal benefiting directly/indirectly from this.</p><h4><strong>low resource consumption</strong></h4><p>Previously, all the reporting was done on paper. To reach the paper-based form from the capital(Kathmandu) to various parts of the country, it would take months and the to and fro movement from providing paper to filling up the form and getting back to the capitals. The resource we are consuming in paper-based reporting:</p><p>1. Paper</p><p>2. Transport</p><p>3. Time</p><p>4. Human Resource</p><p>such a huge cost was spent on reporting.<br>Replacing this with laptops and internet connectivity may seem costlier in first but will be very cheap in the long run.</p><h4><strong>forecasting made easier</strong></h4><p>It would take 3 4 months to analyze data from the paper-based form. Now that it is made online you can analyze the data in a second. How amazing is that? The central governing body now can have real-time data on a click and predict what is coming in the next run.</p><h4><strong>improved facts and figure</strong></h4><p>Paper-based reporting is costlier the major cost associated with it is a mistake that humans can do in paper form. with the electronic form, the machine itself warns you if you make an error and helps in providing accurate data.</p><h4><strong>quality decision making</strong></h4><p>Previously, the Policymakers without any accurate data would have to do is guess. No data is equal to No decision. Now, Policymakers now can have accurate information to analyze on and provide a quality decision based on the information.</p><p>It is interesting we are going with the digital revolution. But it is challenging for nations like ours to keep our data safe &amp; secure. People have very little knowledge of IT security may cost us in the near future. But Nepal is preparing for it and will tackle it in its own way. Let’s be hopeful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b82318e34c11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Replacing Paper-based Survey using Open Data Kit]]></title>
            <link>https://shrestharohit.medium.com/replacing-paper-based-survey-using-open-data-kit-f672992083ed?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/f672992083ed</guid>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Tue, 26 May 2020 08:22:34 GMT</pubDate>
            <atom:updated>2020-05-26T08:22:34.655Z</atom:updated>
            <content:encoded><![CDATA[<p>It is free and open-source software for collecting, managing, and using data in resource-constrained environments.It has various component. ODKAggregate :Server for collecting datas, ODKCollect : Android App for data collection, ODK Build : A drag and drop form builder</p><h4>Background:</h4><p>Family Welfare Division(FWD), Department of Health Service,Ministry of Health is delivering promotional, preventive, diagnostic, curative, and palliative health care services and other health system related functions through various institutions established at the community- and central-level through the country. One of the specific tasks FWD does it to monitor all health facilities(Health Post, Hospital, CEONC) in regular basis which can be monthly, quarterly or yearly through survey. This survey keep tracks of the quality that health facilities are providing. So, DoHS(Department of Health Service) plans to replace conventional data collection method with Digital Forms.</p><h4>How is it done?(Background)</h4><p>In a regular period of time, every health worker across the country are informed to fill the paper based survey which helps FWD monitor the overall quality of the health facilities.<br>There are total of 8002 Health Facilities in Nepal(source:<a href="https://nhfr.mohp.gov.np/">https://nhfr.mohp.gov.np/</a>).Evaluation on the basis of paper form is a hectic and unproductive task.</p><h4>Problem</h4><p>The problem with the current implementation was</p><ul><li>Time</li><li>waste of resource(paper)</li><li>human resource</li><li>Low quality data</li></ul><h4><strong>Solution</strong></h4><p>To avoid this, we planned on using <strong>openODK</strong>. It is <em>free</em> and<em> open-source</em> software for collecting, managing, and using data in resource-constrained environments.<br>It has various component:<br><a href="https://docs.opendatakit.org/aggregate-intro/"><strong>ODKAggregate</strong></a> :Server for collecting datas<br><a href="https://docs.opendatakit.org/collect-intro/"><strong>ODKCollect</strong></a> : Android App for data collection<strong><br></strong><a href="https://docs.opendatakit.org/build-intro/"><strong>ODK Build</strong></a><strong> </strong>: A drag and drop form builder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*h0uR5PVOPN-qZOjN.png" /></figure><h4>Why ODKCollect?</h4><ul><li>Easy to <strong>Deploy</strong></li><li>Easy to <strong>Collect Information</strong></li><li>Easy for <strong>Data Analysis</strong></li><li>It’s <strong>Free and Proven</strong> at massive scale</li><li>Data can be collected <strong>offline</strong> and send it it server when internet is available using the app</li><li>From monitoring rain forests to observing elections to tracking outbreaks, It has been <strong>standard</strong> for data collection in mobile platform.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*BupKEHdgG-WdXH6E" /><figcaption>ODK Ecosystem</figcaption></figure><h4>Screenshots:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*-LVop5KU6G5pIirk.png" /><figcaption>ODK Collect App</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HV2ks8rTXZOuYzXD.png" /><figcaption>ODK Aggregate Server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*F17GL55b5cEcfnGR.png" /><figcaption>ODK Builder for building form</figcaption></figure><p>This is one of the few steps from the government of Nepal to replace paper based system and minimum human resource and increase effectiveness in work. Replacing paper based system is a huge challenge in Nepal since people are not used to computers.But within few years, i am quiet positive that we will have electronic system all over the country.It has been an necessity for the people since paper based data are not reliable and takes time for any actions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f672992083ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new with Android N ?]]></title>
            <link>https://shrestharohit.medium.com/what-s-new-with-android-n-39d9f788c0d5?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/39d9f788c0d5</guid>
            <category><![CDATA[android-n]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Thu, 10 Mar 2016 15:02:54 GMT</pubDate>
            <atom:updated>2016-03-12T21:34:39.739Z</atom:updated>
            <content:encoded><![CDATA[<p>With a quiet bit of surprise Google has come up with brand new ‘Android N’ developer preview version.We were not expecting this thing soon but thanks to Google for such a wonderful surprise to all developers around the world.Well N stands for … it has not been named yet.</p><h4>Suggestion</h4><p>For all the people interested to see Android N to their cell phone . i will request them to wait for a while for an stable version since it is a work in progress.</p><p>Here are the things <em>Android N</em> has come up with :</p><ol><li><em>Multi-Window:</em></li></ol><p>So, This feature in Android N is the most interesting features Google has come up with.You can use multiple application at the same time .A new manifest attribute <strong>android:resizableActivity </strong>when set to true , your activity can be launched in split screen modes.Lifecycle changes in same as switching from landscape to portrait.Configuration are handled itself .App when re launched is set to a new dimension . <strong>android:supportsPictureInPicture</strong> when set to true , lets apps run a video activity in the pinned window while another activity continues in the background.</p><p>2.<em>Direct reply notifications:</em></p><p>Direct reply notifications let you reply to the notification with leaving your app</p><p>3.<em>Bundled notifications :</em></p><p>Android N let you bundle notification from the same app . When clicked on bundled notification it takes you to individual notification using gestures.</p><p>4.<em>Efficiency:</em></p><p>Previously in Android M ,Doze was introduced to save battery effectively.In the current version , an effort on reducing the memory leaks in the application is taken care of</p><p><em>5.Improved Java 8 language support:</em></p><p>With Android N , it has come up with support for Java 8 features like default and static methods, streams, and functional interfaces.Isn&#39;t it amazing getting rid of those old code and minimizing boilerplate code.</p><p>With all this features flooding down the new Android N , i am pretty excited to give all this features a try. Are you ready ?</p><p>Links below</p><ol><li><a href="http://developer.android.com/intl/ja/preview/index.html">Android N preview</a></li><li><a href="http://android-developers.blogspot.com/2016/03/first-preview-of-android-n-developer.html">Android Developer’s Blog</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39d9f788c0d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom ArrayAdapter]]></title>
            <link>https://shrestharohit.medium.com/custom-arrayadapter-2c69ecc0f734?source=rss-449743df382------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c69ecc0f734</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[recyclerview]]></category>
            <dc:creator><![CDATA[Shrestha Rohit]]></dc:creator>
            <pubDate>Mon, 26 Oct 2015 17:40:31 GMT</pubDate>
            <atom:updated>2016-02-24T20:27:11.916Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that’s placed into the list.-</em><a href="http://developer.android.com/"><em>http://developer.android.com/</em></a></blockquote><p>So we will start with making a simple listview and move towards using CustomAdapter which provide a custom way of representing our own XML .</p><p>Lets get started:</p><p>To show a vertical row of scrollable item in our application.</p><p>First we need is a ListView</p><p>ListView is then populated with Adapter</p><p>Simplest Adapter used is ArrayAdapter which converts a list of array (ArrayList) to views in ListView</p><p>ArrayAdapter acts as a mediator between Datasource(ArrayList,Cursor) and AdapterView(ListView,GridView,Spinner)</p><h3>Using Basic ArrayAdapter</h3><p>To use basic ArrayAdapter, we just need to initialize the array adapter and attach them to ListView</p><pre>ArrayAdapter&lt;String&gt; itemsAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, items);</pre><p>ArrayAdapter Uses three argument:</p><p>1st Argument:takes a context or a Activity Instance</p><p>2nd Argument:it takes the layout of a xml file</p><p>3rd Argument:its a array of data</p><p>Next we just need to connect adapter to the listview</p><pre>ListView listView = (ListView) findViewById(R.id.lvItems);</pre><pre>listView.setAdapter(itemsAdapter);</pre><h3>Using Custom Adapter</h3><p>When we want to use our own custom XML layout for each item in the list we use custom adapter.To do this we need to create our own custom ArrayAdapter.<br> For creating custom Adapter , let us think what are we keeping in the list .so i am going to create a list of my friend with their photos and phone number.<br> First ,So lets create a class named ‘Friend’ which contains name.phone number and their image location.<br> Now we define the xml layout of the ListView</p><p>Now we just convert the java object to view .Here what we need to do is extends ArrayAdapter</p><p>For Enhanced performance , ViewHolder is used to make the system smooth. Since every time the item in the list is loaded it has to perform TextView task . <strong>getView Method :</strong> Called each time for data size. <strong>LayoutInflater :</strong> Inflate (Add) view/xml file for ListView Row. <strong>Holder : </strong>Contain Inflated / added xml Elaments. Now lets attach adapter to listview</p><pre>// Construct the data source</pre><pre>ArrayList arrayOffriends = new ArrayList();</pre><pre>// Create the adapter to convert the array to views</pre><pre>CustomAdapter adapter = new CustomAdapter(this, arrayOffriends);</pre><pre>// Attach the adapter to a ListView</pre><pre>ListView listView = (ListView) findViewById(R.id.lvItems);</pre><pre>listView.setAdapter(adapter);</pre><h3>Populating Data into ListView</h3><p>now since the adapter is attach we can attach item anytime on the list</p><p>// Add item to adapter</p><pre>Friend rohit = new Friend(“github.com/rohitsthaa”, “rohit”,”9845422250&quot;);</pre><pre>Friend hilson = new Friend(“hilson”, “hilson”,”98011000&quot;);</pre><pre>Friend aatish = new Friend(“aatish”, “aatish”,”980000125&quot;);</pre><pre>adapter.add(rohit);</pre><pre>adapter.add(hilson);</pre><pre>adapter.add(aatish);</pre><p>// Or even append an entire new collection</p><p>// Fetching some data, data has now returned</p><p>// If data was JSON, convert to ArrayList of User objects.</p><pre>JSONArray jsonArray = …;</pre><pre>ArrayList&lt;Friend&gt; newfriend = User.fromJson(jsonArray)</pre><pre>adapter.addAll(newfriend);</pre><p>also can clear at anytime</p><p>You can find the project at :<a href="https://github.com/rohitsthaa/CustomListView">https://github.com/rohitsthaa/CustomListView</a></p><p><em>Originally published at </em><a href="http://shrestharohit.com.np/blog/custom-arrayadapter-android/"><em>shrestharohit.com.np</em></a><em> on October 26, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c69ecc0f734" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>