<?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 Sworup Shakya on Medium]]></title>
        <description><![CDATA[Stories by Sworup Shakya on Medium]]></description>
        <link>https://medium.com/@sworupshakya?source=rss-61a1dd526e7e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xx6-YF85sCT35WecwVjkBQ.jpeg</url>
            <title>Stories by Sworup Shakya on Medium</title>
            <link>https://medium.com/@sworupshakya?source=rss-61a1dd526e7e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 13:18:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sworupshakya/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[Deploy NodeJS and ReactJS production code on Windows server]]></title>
            <link>https://elasium.com/deploy-nodejs-and-reactjs-production-code-on-windows-server-9e7fe95efcf0?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e7fe95efcf0</guid>
            <category><![CDATA[windows-server]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[build]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Mon, 07 Feb 2022 08:50:58 GMT</pubDate>
            <atom:updated>2022-02-07T11:35:21.197Z</atom:updated>
            <content:encoded><![CDATA[<p>Run the build command to build the application for production. Copy the dist and node_modules folders to the server in a directory we want to host the application on.</p><p>The way I am going to do it is use <a href="https://pm2.keymetrics.io/">pm2</a> to serve the application locally and use <a href="https://www.nginx.com/">nginx</a> to server the application to the outside world through a reverse proxy.</p><p><strong>Note:</strong> Windows server would log off the user when it is in suspended (with the user not logged in) mode. To have the PM2 and nginx servers running we would need to install them as services.</p><h3>Pre-requisite</h3><p>These applications must be installed on Windows server to successfully deploy the application:</p><ul><li>Node.js</li><li>PM2</li><li>nginx</li><li>github cli (optional) (you can technically install github on the server the get the latest repo and build the distribution on server, that is what I would do if I was trying to run any form of CI/CD on the server but this is specifically your choice.)</li></ul><h3>Install pm2</h3><p>Normally you would install pm2 with the command npm install pm2@latest -g, however Windows server would close pm2 after the user has logged off. So you would need to install pm2 as service. To do so, install <a href="https://github.com/jon-hall/pm2-windows-service">pm2-windows-service</a> and follow the instruction guide in readme.</p><h4>Setup our app with pm2</h4><p>Move to the application directory. For example, my applications are in c:\api\dist and c:\frontend\dist directories. Based on which directory is your base, run one of these commands -</p><p>For api, run the command pm2 node main.js — name my_api. This would create a demon to serve our NodeJS app at port 3333.</p><p>For frontend, run the command pm2 serve . 4200 — spa — name my_frontend. This would create a demon to serve our react app at port 4200.</p><p>These would start the servers for api at http://localhost:3333/api and http://localhost:4200/ for frontend.</p><h4>Other useful pm2 commands</h4><ul><li>Do pm2 list to see the two application being served.</li><li>You can delete any demon with pm2 del &lt;name&gt; where &lt;name&gt; is demon’s name or number.</li><li>You can save the list for future use with pm2 save. To use the saved list in the future you can run pm2 resurrect.</li><li>To see the logs use command pm2 logs all or pm2 logs plus application name or process number to see individual app’s log.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*up3D1FdUPNbh3Eaf5w9q0A.jpeg" /></figure><h3>Setup nginx</h3><p>Install nginx normally. Nothing fancy here, just go to the nginx website and download the nginx zip. After that you can go into the directory and double click the nginx exe to run it.</p><h4>Run nginx as a service</h4><p>We would use <a href="https://nssm.cc/">nssm</a> to do this.</p><h4>Steps</h4><ul><li>Go to the nssm folder, for me it’s c:\nssm\win64, that contains the exe nssm.exe.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*IEk00dRUDXCVsIqwSySMrQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*kdifzQV4LSnPxYFJni2jPQ.jpeg" /><figcaption>Install NSSM nginx service</figcaption></figure><ul><li>Once there run the command nssm install nginx to create the nginx service. A window will open allowing you to setup the service.</li><li>Set path as nginx path, for me it’s c:\nginx\nginx.exe.</li><li>Set startup directory as c:\nginx.</li><li>In I\O redirection tab, set input (stdin) as start nginx. Output and Error are log files. Set paths accordingly, for me C:\nginx\logs\service.out.log and C:\nginx\logs\service.error.log.</li><li>Since its a service we need these log files to see the status of the application</li><li>Click the install service button and we are done.</li></ul><h4>Build a reverse proxy with nginx</h4><ul><li>Go to C:\nginx\conf\nginx.conf and add this directive inside the http directive.</li></ul><pre>http {</pre><pre>...</pre><pre>upstream sworupcodes_api {<br>    server 127.0.0.1:3333;<br>    keepalive 64;}</pre><pre>upstream sworupcodes_frontend {<br>    server 127.0.0.1:4200;<br>    keepalive 64;<br>}</pre><pre># HTTPS server<br>server {<br>    listen 4000 ssl;<br>    server_name code.sworup.com.np;</pre><pre>    ssl_certificate sworupcodes.pem;<br>    ssl_certificate_key sworupcodes.pem;<br>    <br>    ssl_session_cache shared:SSL:1m;<br>    ssl_session_timeout 5m;<br>    ssl_ciphers HIGH:!aNULL:!MD5;<br>    ssl_prefer_server_ciphers on;</pre><pre>    location / {<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header Host $http_host;</pre><pre>        proxy_http_version 1.1;<br>        proxy_set_header Upgrade $http_upgrade;<br>        proxy_set_header Connection ‘upgrade’;<br>        <br>        proxy_pass <a href="http://unfpa_frontend;/">http://</a>sworupcodes_frontend<a href="http://unfpa_frontend;/">;</a><br>        proxy_redirect off;<br>        proxy_read_timeout 240s;<br>        proxy_cache_bypass $http_upgrade;<br>    }</pre><pre>    location /api {<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header Host $http_host;</pre><pre>        proxy_http_version 1.1;<br>        proxy_set_header Upgrade $http_upgrade;<br>        proxy_set_header Connection ‘upgrade’;<br>        <br>        proxy_pass <a href="http://unfpa_frontend;/">http://</a>sworupcodes_api/api<a href="http://unfpa_frontend;/">;</a><br>        proxy_redirect off;<br>        proxy_read_timeout 240s;<br>        proxy_cache_bypass $http_upgrade;<br>    }</pre><pre>…</pre><pre>}<br>}</pre><ul><li>This would create a reverse proxy that would expect outside users to connect to <a href="https://code.sworup.com.np/">https://code.sworup.com.np</a>:4000 which would be passed on to http://localhost:4200 while https://code.sworup.com.np:4000/api will be passed on to http://localhost:3333/api.</li><li>You would need to enable ssl into the server with the sworupcodes.pem certificates.</li></ul><blockquote>This is the basic idea, you do not have to do it exactly like this, the variables might vary.</blockquote><h4>Other nginx steps</h4><p>Whenever you make changes to conf files we would need to restart nginx. Stop the service (from windows services window) and start it back again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e7fe95efcf0" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/deploy-nodejs-and-reactjs-production-code-on-windows-server-9e7fe95efcf0">Deploy NodeJS and ReactJS production code on Windows server</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrade react and all other packages to latest]]></title>
            <link>https://elasium.com/upgrade-react-and-all-other-packages-to-latest-4f1de5d64a2a?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f1de5d64a2a</guid>
            <category><![CDATA[upgrade]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[yarn]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Wed, 03 Feb 2021 06:46:07 GMT</pubDate>
            <atom:updated>2021-02-03T06:46:07.081Z</atom:updated>
            <content:encoded><![CDATA[<p>You would have expected upgrading react and other dependencies in your project to be easy, but as it turns out it’s not that straight forward.</p><p>You might expect at least react and its directly related packages such as <strong>react-dom</strong> to upgrade with simple code like this:</p><pre>yarn upgrade react</pre><p>But that would only update react, and that to the last version relating to your semver version. Meaning if you have <strong>~ </strong>ahead of the version number, say 14.1.2, the above command will only update to the latest patch version. Which means you will always get 14.1.X. If you have ^ ahead of the version number, you will get 14.X.X. But what if you want the latest version, which can be 17.2.12 or something?</p><p>Well, you can do</p><pre>yarn upgrade react@17.2.12</pre><p>… to get the specific version. Or you can do</p><pre>yarn upgrade react@latest<br>or<br>yarn upgrade react --latest</pre><p>… to make sure you will always get the latest (stable) version.</p><p>However, as I said earlier, this will only update react to the latest version, to get the rest of your dependencies up-to speed you will have to upgrade them too.</p><p>First you’d want to see which of the packages are outdated with:</p><pre>yarn outdated</pre><p>This will show you a list of packages that are not up to date. You can then upgrade them one-by-one with the upgrade commands above.</p><p>you can even do this if you want</p><pre>yarn upgrade react@latest react-dom@latest react-router-dom@latest</pre><p>But you’d want to do a group upgrade with a simple and intuitive command.</p><p>To actually do group upgrade, you might think this will work:</p><pre>yarn upgrade</pre><p>…well, it doesn’t. This actually get the version of specified in package.json. Nothing more or less.</p><p>Well how about…</p><pre>yarn upgrade --latest</pre><p>The above code will upgrade to higher version following the semantics of version specified in package.json, which means it will sometimes not upgrade to the latest version.</p><p>So you want all you packages to be upgraded to the latest version. There is a command for that:</p><pre>npx yarn-upgrade-all</pre><p>This works, but this will remove and add back all of the packages one by one. Which is quite slow.</p><p>The best way to do this is to run</p><pre>yarn upgrade-interactive --latest</pre><p>This will give you the interactive UI listing all of the packages up for upgrade, their version numbers and color code of which type of version upgrade to expect. You can select each package by press space to check it for upgrade. Easy, simple and intuitive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f1de5d64a2a" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/upgrade-react-and-all-other-packages-to-latest-4f1de5d64a2a">Upgrade react and all other packages to latest</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Docker]]></title>
            <link>https://elasium.com/introduction-to-docker-aac33964c6dc?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/aac33964c6dc</guid>
            <category><![CDATA[introduction]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Fri, 15 Dec 2017 05:18:52 GMT</pubDate>
            <atom:updated>2017-12-15T05:46:59.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*dyAwJQbBjfuRUIvX_ajyVg.png" /><figcaption>Image taken from <a href="https://fossbytes.com/getting-started-with-docker-intro-to-containers-world-part-1/">https://fossbytes.com</a></figcaption></figure><p>Docker goes a step beyond VM (Virtual Machine).</p><p>What it does, is it builds small size VM, for example Debian Jessy is around 80mb in size. It only has the very basic Linux OS, and does not even have a GUI. You can write Dockerfile and then add things you want on top of that to build an image. Once you have built an image with let’s say Linux (Debian Jessy is an Linux image with minimal packages required to get you started) and, Apache and PHP on top of that, you can upload that image to Docker Hub. There are multiple images on Docker Hub already, these images are like permanent starter packs.</p><p>While developing you can start from one of these images with the from command. You build your own custom Dockerfile and at the top of it add a from line, for example FROM mysql:5.7 will start from an mysql image that comes with mysql already installed. You build the specific settings you want your system to have after that, configuration files, additional packages etc. This is called container and its different from image in the sense that you have the dockerfile on your system so you can change it as you see fit.</p><p>When the docker up or docker build command is run, docker will build the system for you. It will first download the image, keep it in your hard drive for future use and then build the container based on your dockerfile. This container will sit in Docker’s memory and can be changed, updated or destroyed at will.</p><p>The main idea of docker is that you build containers. Each container being a seperate VM instance with a specific set of applications running. For example in my setup I have a container that has my own Apache + PHP container, a MySQL container and a Adminair container. The concept here is we build these containers with specific tasks in mind and then docker will setup the network with which these containers will communicate with each other as if they are the same machine. The reason to do this scalability, you can have multiple instances of containers running and balance the load to them, we can dynamically allocate resources to the container as we need. But those sort of things are not our focus in Development.</p><p>In development we do this so that that we can monitor containers in isolation, we can re-spin containers update images and change configurations a lot easier.</p><p>On top of this docker has tools that makes things much easier. There is a tool called docker compose which basically adds a concept of a file named docker-compose.yml that is like a map of which containers communicate with which ones and what resources are shared, over which ports etc. Otherwise we need to do this in command line with would have a lot of arguments that we have to write to start the environment. With this tool we can do something as simple as calling `docker-compose up`.</p><p>Another built in tool is syncing. You can have a directory on your system synced exactly to a directory inside a container. So you develop in your local folder and the changes will propagate to the VM just like Vagrant does.</p><p>Another thing you do is called port mapping. When the container is started, we can tell docker to map certain ports of our local machine to the container’s port. Let’s say we map it to 80:8080. This would mean that our port 8080 is mapped to container’s port 80. Which also means if we open localhost:8080, in our browser, it will run localhost of the container, giving us the development site in our local browser.</p><p>Communications has to be done through ports, files have to be synced from our local machine to the container, but if we do that well, we can run virtually change anything in the containers from our local system.</p><p>We can also ssh into the docker container and change things there, but I prefer to use ssh to monitor and make all changes in dockerfile.</p><p>The beauty of docker is we have these dockerfiles that will spin up a machine for us exactly the same way no matter which OS we are calling it from. We have the same development setup. We can ship the code with these dockerfiles which are just a file and when someone else runs docker up in there system, the image is downloaded and the container is built.</p><p>Of course, Docker can do a whole lot then this, its a lot more complicated then this also and has bit of a learning curve, but its worth the effort.</p><p>Also, it has some permission issued in Windows, so trying to make a container to start flawlessly in Windows can be a bit trickier then other environment. But once figured out and set up in dockerfile, its the same process over and over again.</p><h4>How I got into the world of Docker:</h4><blockquote>I just looked the Dockerfiles written by others. I went to github and looked at numerous container dockerfiles there. It’s the easiest and probably the best way to learn. On top of that, once I got a bit of a hold on the concept I looked into the dockerfiles of images. Images are just containers that are uploaded into Docker Hub so if we go to Docker Hub and on the side open the git repository link, you will see a dockerfile there too, mostly with a FROM code that goes back to `debian:jessy` or any other OS starting image.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aac33964c6dc" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/introduction-to-docker-aac33964c6dc">Introduction to Docker</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build key value pair from database query results for silex ChoiceType]]></title>
            <link>https://elasium.com/build-key-value-pair-from-database-query-results-for-silex-choicetype-3fd0c3ea050d?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fd0c3ea050d</guid>
            <category><![CDATA[choicetype]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[silex]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Wed, 13 Sep 2017 03:59:19 GMT</pubDate>
            <atom:updated>2017-09-13T04:01:26.606Z</atom:updated>
            <content:encoded><![CDATA[<p>array_column is a function that could be used to build array from a single column in the input array. You can specify the key of the column you want the array to be built on. Also if you want the result array to be associative you can specify index key column name.</p><pre>$locations = array(<br>    [ &#39;id&#39; =&gt; 1, &#39;label&#39; =&gt; &#39;New York&#39;],<br>    [ &#39;id&#39; =&gt; 2, &#39;label&#39; =&gt; &#39;Moscow&#39;],<br>    [ &#39;id&#39; =&gt; 2, &#39;label&#39; =&gt; &#39;Paris&#39;],<br>);</pre><pre>// Remember first you input the value and then the key<br>$locations = array_column($location, &#39;label&#39;, &#39;id&#39;);</pre><pre>Result:</pre><pre>[<br>    1 =&gt; &#39;New York&#39;,<br>    2 =&gt; &#39;Moscow&#39;,<br>    3 =&gt; &#39;Paris&#39;<br>]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GSoO0RJpaN2b6NGZrCwtRg.jpeg" /></figure><pre>$query = &quot;SELECT * from location&quot;;<br>$locations = $app[&#39;db&#39;]-&gt;fetchAll($query);<br>...<br>...<br>...</pre><pre>// Form builder instance<br>$builder<br>-&gt;add(&#39;location&#39;, ChoiceType::class, array(<br>                &#39;placeholder&#39; =&gt; &#39;Choose a location&#39;,<br>                &#39;choices&#39; =&gt; array_column($locations, &#39;id&#39;, &#39;name&#39;)<br>            ));</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fd0c3ea050d" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/build-key-value-pair-from-database-query-results-for-silex-choicetype-3fd0c3ea050d">Build key value pair from database query results for silex ChoiceType</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Silex Symfony Component: How to access request outside of controller]]></title>
            <link>https://elasium.com/silex-symfony-component-how-to-access-request-outside-of-controller-8526c4a79b46?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8526c4a79b46</guid>
            <category><![CDATA[httpfoundation-component]]></category>
            <category><![CDATA[silex]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Wed, 13 Sep 2017 03:30:27 GMT</pubDate>
            <atom:updated>2017-09-13T03:30:27.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SxPKjpI2MoBrcTzp0FJLfw.jpeg" /><figcaption>Symfony HttpFoundation component: access request outside of controller</figcaption></figure><p>Sometimes you’d want to get the request object outside of controller for various reasons.</p><p>In my case I needed to refactor a set of procedural code that relied on query variables. Also I needed to build a system where I could use Silex’s DI and other features but not use routes and controllers just yet.</p><p>The request variable could be accessed in such cases with following code:</p><pre>use Symfony\Component\HttpFoundation\Request;<br><br>$request = Request::createFromGlobals();</pre><p>Reference from <a href="https://symfony.com/doc/current/components/http_foundation.html">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8526c4a79b46" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/silex-symfony-component-how-to-access-request-outside-of-controller-8526c4a79b46">Silex Symfony Component: How to access request outside of controller</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My God was dead]]></title>
            <link>https://medium.com/sandwitchslayer/my-god-was-dead-529c4f97c1c3?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/529c4f97c1c3</guid>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Sat, 26 Aug 2017 07:41:33 GMT</pubDate>
            <atom:updated>2017-12-15T05:54:18.597Z</atom:updated>
            <content:encoded><![CDATA[<p>My God was dead!<br>I buried what remained in the backyard of the world that I called home <br>was built by my hands but guided as my God’s own.<br>I never was someone who worshiped<br>so maybe I was the one who killed my God,<br>but I had heard from those who worshiped before me,<br>that Gods, all mighty but benevolent, they resurrect.<br>Heard their hearts are too soft but magnificent,<br>and their love burn so bright,<br>that they melt away even death.<br>So I made a shallow grave….<br>as I sat there waiting…<br>for a resurrection.</p><p>Flowers bloomed and the yard turned green,<br>but I was not happy…<br>as I waited.<br>Unattended the yard turned brown and desolate…<br>setting up a perfect miniature state of my soul<br>…as I waited still.</p><p>The sun burnt away my skin, wind drew lines upon my face,<br>the autumn breeze left me rooted on my spot,<br>Leaves sprout and they fell<br>covered my God’s grave,<br>I collected them all, set them aside<br>….as I waited.</p><p>Rain was the worst, it gave me hope where there was none,<br>it reminded me how I felt loved<br>in the rain, in my God’s presence,<br>and every time rain fell on the shallow grave,<br>the ground felt like it moved,<br>I knew it didn’t and I just wanted to see it move,<br>but yet I sat there,<br>drenched in rain mixed with my tears and emotions,<br>hopeful of a resurrection.</p><p>I talked to my God but got no reply,<br>I shouted and got angry but got no reaction,<br>then I apologized but got no forgiveness.<br>However I kept faith… it was all I had left, faith,<br>…and I waited.</p><p>And then one day,<br>I dragged my broken self out of the desolate yard,<br>pass the broken down house in dire need of a fix,<br>and onto the street that went anywhere and everywhere,<br>and there I saw,<br>my God, in all of the grace, glory and magnificence that I remembered… and more.<br>Smiling and shining with promises of happiness and forever.<br>My God had resurrected…..<br>but somewhere else,<br>my God had been shining throughout my wait,<br>but on someone else.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=529c4f97c1c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sandwitchslayer/my-god-was-dead-529c4f97c1c3">My God was dead</a> was originally published in <a href="https://medium.com/sandwitchslayer">Sworup Shakya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regular expression to filter names]]></title>
            <link>https://elasium.com/regular-expression-5e9d42db2462?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e9d42db2462</guid>
            <category><![CDATA[regex]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Fri, 17 Feb 2017 04:08:02 GMT</pubDate>
            <atom:updated>2017-02-17T04:08:29.270Z</atom:updated>
            <content:encoded><![CDATA[<p>We had a case where we had to filter first names and last name.</p><p>After a lengthy discussion and a bunch of regular expressions we went back and fro with, we finally settled into something quite simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KaEvyEBoVwwgohlNCYp2Fg.jpeg" /><figcaption>Regular expression to filter names</figcaption></figure><p>It is quite simple actually:</p><pre>^[\p{L} \.’\-]+$</pre><p>^ asserts position at start of the string</p><p><strong>Match a single character present in the list below</strong></p><p>[\p{L} \.’\-]+</p><p>+ <strong>Quantifier</strong> — Matches between <strong>one</strong> and <strong>unlimited</strong> times, as many times as possible, giving back as needed (greedy)</p><p>\p{L} matches any kind of letter from any language</p><p>matches the character literally (case sensitive)</p><p>\. matches the character . literally (case sensitive)</p><p>‘ matches the character ‘ literally (case sensitive)</p><p>\- matches the character — literally (case sensitive)</p><p>$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e9d42db2462" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/regular-expression-5e9d42db2462">Regular expression to filter names</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log query in Laravel log file]]></title>
            <link>https://elasium.com/log-query-in-laravel-log-file-6f1c35d09e0?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f1c35d09e0</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Tue, 27 Dec 2016 07:44:12 GMT</pubDate>
            <atom:updated>2016-12-29T09:05:31.810Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*1RERMPCW2-x0N1a2nLsi-Q.jpeg" /></figure><h3>Problem:</h3><p>I had a problem where there was a redirect from a page and I had to log the query that was running in the script that was redirecting it.</p><p>Obviously, I could not use Debugbar or var_dump for it.</p><h3>Solution:</h3><p>Log the query in the log file so that it will be there even after the page refreshes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60c4f2c90d496618a80c36975daf252e/href">https://medium.com/media/60c4f2c90d496618a80c36975daf252e/href</a></iframe><blockquote>Note: This is a listener, so it will log all the queries within the request that comes <strong>after</strong> it has been attached to DB. Therefore, it goes before the query call you want to log.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f1c35d09e0" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/log-query-in-laravel-log-file-6f1c35d09e0">Log query in Laravel log file</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set up JMeter for load testing with ability to export graph images]]></title>
            <link>https://elasium.com/setting-up-jmeter-for-load-testing-with-ability-to-export-graph-images-fb9597a617da?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb9597a617da</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[jmeter]]></category>
            <category><![CDATA[load-testing]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Thu, 22 Dec 2016 09:45:28 GMT</pubDate>
            <atom:updated>2016-12-22T10:08:59.627Z</atom:updated>
            <content:encoded><![CDATA[<p>JMeter is a very handy Java tool that can be used for all sorts of testing. Mostly used for load testing, it can do functional testing also and some other stuff that I haven’t digger into yet.</p><p>JMeter is awesome but I found that it was a bit tricky to get it set up to work the way you want it to. Specially where you’re trying to use its plugins. So I did some research found some awesome resources (that I would try to mention below) and got things to work.</p><p>This tutorial is here so that someone else if looking to use JMeter, could get to the awesomeness of it (load testing with informative and visual graphs in my case) without much hassle.</p><p>Let’s get started then:</p><h3>Step 1: <strong>Download JMeter</strong></h3><p>Download from this <a href="http://jmeter.apache.org/download_jmeter.cgi">link</a>. Untar or unzip to your preferred directory.</p><blockquote>I’m downloading version 3.1. Keep in mind that the older version have some setting differences. Anything earlier then version 2 definitely does.</blockquote><p>With OSX, the easiest and preferred way for downloading JMeter would be through Homebrew.</p><pre>brew install jmeter</pre><p>With extra plugins:</p><pre>brew install jmeter — with-plugins</pre><blockquote>The last time I checked this does not seem to give me the latest version though. I got 3.0. So I decided to used the untar way.</blockquote><h3><strong>Step 2: Download JMeter plugin manager</strong></h3><p>Download from the link within the bracket. (<a href="https://jmeter-plugins.org/get/">plugins-manager.jar</a>)<strong>.</strong></p><p>Copy this jar file in the lib/ext folder.</p><p>Start/Restart JMeter and you can will the plugin manager in Options/Plugin Manger in the top menu.</p><h3>Step 3: <strong>Open JMeter</strong></h3><p>If you’ve installed JMeter through Homebrew it’ll be universally set up. Otherwise you’d have to navigate to the <strong>bin </strong>folder of your JMeter installation from Terminal or bash or command line and run JMeter from there.</p><p>You can go to the bin directory and double click bin/jmeter.sh to run it in Graphical User Interface (GUI) mode.</p><blockquote>Note: Don’t run heavy test on GUI mode, I did it on Mac Book Pro and it crashed when I did a 50 odd thread test. Learnt it the hard way.</blockquote><h3>Step 4: <strong>Install Plugins</strong></h3><p>JMeter does have some graphs and matrices but its not super informative. Unless you absolutely know what you’re looking for, the JMeter readings out of the box will just fly over your head (did for me).</p><p>To get better visual and simpler graph interrelation of your data and readings you need some plugins.</p><p>You can do this in of the two ways, using Plugin Manger or manually:</p><h4><strong>Install the plugins through Plugin Manage</strong>:</h4><ul><li>Here are some plugins that we are going to need, selected.</li><li>Just select the plugins you want to install and then click ‘Apply changes and restart jMeter’.</li><li>You don’t really have to include all the plugins that I have included but most important ones are jpgc — Standard, Command-line Graph Plotting Tools. Other plugins allow you to visualise graphs in GUI mode.</li></ul><blockquote>Note: There is jpgc — Standard Set plugin at the bottom of the list that needs to be selected that I was unable to include in the screenshot.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_ByhdihB2JHmC7CMgKG5g.jpeg" /><figcaption>Just select the plugins you want to install and then click ‘Apply changes and restart jMeter’</figcaption></figure><blockquote>Note: Now this is where it gets a bit tricky. You can download these plugins and they are all required but later when I ran the command it failed. It required some other files relating to Visualisation classes. Basically it will create the test but break while creating graph png images. If that happens you can manually download the plugins I’ll mention below.</blockquote><p>If there is an error while generating graphs after the previous step do this (after looking at jmeter.log file of course) -</p><p>The error in jmeter.log would look something like this:</p><pre>2016/12/22 13:37:43 WARN — kg.apc.jmeter.JMeterPluginsUtils: JMeter env exists. No one should see this normally. <br>2016/12/22 13:37:43 WARN — jmeter.engine.StandardJMeterEngine: Error encountered during shutdown of kg.apc.jmeter.listener.GraphsGeneratorListener@491666ad java.lang.RuntimeException: java.lang.ClassNotFoundException: <strong>kg.apc.jmeter.vizualizers.SynthesisReportGui</strong><br> at kg.apc.jmeter.PluginsCMDWorker.getGUIObject(PluginsCMDWorker.java:237)<br> at kg.apc.jmeter.PluginsCMDWorker.getGUIObject(PluginsCMDWorker.java:234)<br> at kg.apc.jmeter.PluginsCMDWorker.setPluginType(PluginsCMDWorker.java:73)<br> at kg.apc.jmeter.listener.GraphsGeneratorListener.testEnded(GraphsGeneratorListener.java:221)<br> at kg.apc.jmeter.listener.GraphsGeneratorListener.testEnded(GraphsGeneratorListener.java:137)<br> at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:216)<br> at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:437)<br> at java.lang.Thread.run(Thread.java:745)<br>Caused by: java.lang.ClassNotFoundException: kg.apc.jmeter.vizualizers.SynthesisReportGui<br> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)<br> at java.lang.Class.forName0(Native Method)<br> at java.lang.Class.forName(Class.java:264)<br> at kg.apc.jmeter.PluginsCMDWorker.getGUIObject(PluginsCMDWorker.java:227)<br> … 7 more</pre><h4>Fix for above error:</h4><p>Download the jar files and install manually:</p><ul><li>Go to <a href="https://jmeter-plugins.org/">JMeter Plugins Page</a>.</li><li>Download the plugins mentioned below:<br>- Go to the old zipped format of plugin page. (<a href="https://jmeter-plugins.org/downloads/old/">here</a>)<br>- You’re looking for this plugins (Look for the latest versions of these plugins):<br>- <a href="https://jmeter-plugins.org/downloads/file/JMeterPlugins-Standard-1.4.0.zip"><strong>JMeterPlugins-Standard-1.4.0.zip</strong></a><strong> (or newer version)</strong></li><li>The main jar files you’re looking for is JMeterPlugins-Standard.jar which goes into lib/ext directory.</li><li>The hierarchy is shown in the zip file so that you know which jar file goes into lib and which go into lib/ext .</li></ul><h3>Step 5: User Settings for JMeter plugins</h3><p>Open &lt;jmeter home&gt;/bin/user.properties .</p><p>Add these properties at the bottom of the file:</p><pre>jmeter.save.saveservice.output_format=csv jmeter.save.saveservice.data_type=false jmeter.save.saveservice.label=true jmeter.save.saveservice.response_code=true jmeter.save.saveservice.response_data.on_error=false jmeter.save.saveservice.response_message=false jmeter.save.saveservice.assertion_results_failure_message=false jmeter.save.saveservice.successful=true jmeter.save.saveservice.thread_name=true jmeter.save.saveservice.time=true jmeter.save.saveservice.subresults=false jmeter.save.saveservice.assertions=true jmeter.save.saveservice.latency=true jmeter.save.saveservice.bytes=true jmeter.save.saveservice.hostname=true </pre><pre># This will enable correct graphs display <br># which deal with threads after reloading the results file. <strong>jmeter.save.saveservice.thread_counts=true</strong></pre><pre>jmeter.save.saveservice.sample_count=true jmeter.save.saveservice.timestamp_format=HH:mm:ss jmeter.save.saveservice.default_delimiter=; jmeter.save.saveservice.print_field_names=true </pre><pre># This is needed to ensure all results are <br># available when Listener runs <strong>jmeter.save.saveservice.autoflush=true</strong></pre><h3>Step 6: Setup the test and add Graph Generator listener</h3><p>Create the test in the GUI view.</p><p>Then right click on any of the thread groups or thread and navigate to jp@gc — Graph Generator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*j-5S2PKlIm-uDo6TCZWBYw.jpeg" /><figcaption>Graph Generator Listener</figcaption></figure><p>Setup the graph generator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*eayjAgfWrLO3gXHhvRi26g.jpeg" /></figure><p>Here are few settings that I have changed:</p><p><strong>Output Folder:</strong> Obviously its the folder where the output image graphs would be stored.</p><p><strong>JMeter Result File:</strong> So this is the .csv file that JMeter test generates <strong><em>after</em></strong> running the test. This parameter is taken in as variable (that’s why $()) and it could be passed in through command as TEST_RESULTS_FILE . Also it’ll default to the path given as the second parameter of the __P function.</p><p>You can change the rest of the parameters or leave them as it is.</p><blockquote>One interesting parameter is Include only samples where you can actually specify the samples you’d want to include in the graph. If its a large test this could help you narrow down and compare two or more tests or even look at a single sample.</blockquote><h3>Step 7: Run the test</h3><p>Time to run the test.</p><p>In your terminal or command line or bash or whatever run this command to run the test and then generate the graphs:</p><pre>~/Desktop/apache-jmeter-3.1&gt;</pre><pre>bin/jmeter -t /Users/sworup/Desktop/JMeter/Test.jmx -n -l /Users/sworup/Desktop/JMeter/Test.csv -JTEST_RESULTS_FILE=/Users/sworup/Desktop/JMeter/Test.csv</pre><p>Explanation:</p><p><strong>bin/jmeter</strong>: We are running the jmeter executable which resides inside the bin directory since we’re running it from the &lt;JMeter root&gt;.</p><p><strong>-t &lt;path/to/test.jmx&gt;</strong>: This is basically pointing the path to the test file.</p><p><strong>-n</strong>: This means non GUI mode. It is very important if you’re running a heavy test.</p><p><strong>-l &lt;path/to/Test.csv&gt;</strong>:This command sets the files to output the test result. This file can be used to see graphs in GUI version but here we would use this file to generate the graph in the directory we want later.</p><p><strong>-JTEST_RESULTS_FILE=&lt;path/to/Test.csv&gt;</strong>: The -J switch is to set the variable we set in jp@gc Graphs Generator earlier, at JMeter results file. So the path we mention here would override the path set there and if we leave this blank, the default value in GUI should take over.</p><h3>Finally:</h3><p>That’s about it.</p><p>Now we can go to the folder we mentioned as Output Folder and walaah! the reports are there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*Vv36wmUqXysQRuZTbIVkbQ.jpeg" /><figcaption>Output png graph images created</figcaption></figure><h3>References:</h3><p>Here are some of the resources that I found to be helpful. Most of the codes and instructions in this post came from this resources:</p><ul><li><a href="http://www.ubik-ingenierie.com/blog/automatically-generating-nice-graphs-at-end-of-your-load-test-with-apache-jmeter-and-jmeter-plugins/">Automatically generating nice graphs at end of your Load Test with Apache JMeter and JMeter-Plugins</a></li><li><a href="https://www.youtube.com/watch?v=-4F1-OjAgDc">JMeter Custom Graphs — 14thJMeterTrainingVideo</a> (YouTube)</li><li><a href="https://kishorsharma69.wordpress.com/2015/08/12/jmeter-jpgc-graphs-generator/">Jmeter: jp@gc Graphs Generator</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb9597a617da" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/setting-up-jmeter-for-load-testing-with-ability-to-export-graph-images-fb9597a617da">Set up JMeter for load testing with ability to export graph images</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing PHP for Laravel in Ubuntu]]></title>
            <link>https://elasium.com/installing-php-for-laravel-in-ubuntu-8711b72c8690?source=rss-61a1dd526e7e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8711b72c8690</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Sworup Shakya]]></dc:creator>
            <pubDate>Fri, 09 Dec 2016 06:57:29 GMT</pubDate>
            <atom:updated>2016-12-22T19:08:13.219Z</atom:updated>
            <content:encoded><![CDATA[<p>Installing PHP for Laravel in Ubuntu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EclmnV3174ga0LELqy0uJA.jpeg" /><figcaption><a href="http://blog.teamtreehouse.com/wp-content/uploads/2013/02/blog_php.jpg">http://blog.teamtreehouse.com/wp-content/uploads/2013/02/blog_php.jpg</a></figcaption></figure><p>Installed PHP:</p><pre>sudo apt install php libapache2-mod-php</pre><pre>sudo apt install php-cli</pre><pre>sudo apt install php-mysql</pre><p>Install related php modules required for Laravel:</p><pre>sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext php-gd</pre><p>Enabled the modules:</p><pre>sudo phpenmod mcrypt</pre><pre>sudo phpenmod mbstring</pre><p>If there is error regarding zip install this package:</p><pre>sudo apt-get install php7.0-zip</pre><p>Source: <a href="http://askubuntu.com/a/785022">http://askubuntu.com/a/785022</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8711b72c8690" width="1" height="1" alt=""><hr><p><a href="https://elasium.com/installing-php-for-laravel-in-ubuntu-8711b72c8690">Installing PHP for Laravel in Ubuntu</a> was originally published in <a href="https://elasium.com/">Elasium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>