<?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 Noel Varghese on Medium]]></title>
        <description><![CDATA[Stories by Noel Varghese on Medium]]></description>
        <link>https://medium.com/@noel.varghese.22?source=rss-339eb2f1b2c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6Uv0UnVL1gl9lrLAI8ATpw.jpeg</url>
            <title>Stories by Noel Varghese on Medium</title>
            <link>https://medium.com/@noel.varghese.22?source=rss-339eb2f1b2c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:10:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@noel.varghese.22/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[How I coded my way to Early Tickets for Avengers Endgame]]></title>
            <link>https://medium.com/hackernoon/how-i-coded-my-way-to-early-tickets-for-avengers-endgame-f2efa3a128a8?source=rss-339eb2f1b2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2efa3a128a8</guid>
            <category><![CDATA[avengers]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[entertainment]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[hackernoon-top-story]]></category>
            <dc:creator><![CDATA[Noel Varghese]]></dc:creator>
            <pubDate>Fri, 05 Jul 2019 06:35:00 GMT</pubDate>
            <atom:updated>2019-07-09T03:41:54.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztSIM39EhIvWCdN7NBv1nA.jpeg" /><figcaption><a href="https://www.marvel.com/movies/avengers-endgame">https://www.marvel.com/movies/avengers-endgame</a></figcaption></figure><p><em>On 26th April 2019, the most hyped and most anticipated movie of our generation was released Avengers Endgame, and I managed to grab the best seats in the hall for the first day first show in IMAX, Bangalore.</em></p><p>When the release date for the movie was announced, I found out that I had booked a flight to go home in the evening for the exact same day three months ago. Living in Bangalore, with the airport being almost 3hrs away I knew that If I’m not able to get the tickets for the morning show, the movie I was waiting for almost a year will most probably get spoiled &amp; I won’t be able to view it in IMAX which I was dying for.</p><p>I was in a tough spot, this is a city where you need to book tickets at least 3–4 days in advance for the weekends, and with the added hype around Avengers, something had to be done. My friends and I would be regularly refreshing <a href="https://in.bookmyshow.com/">bookmyshow</a>, a popular event ticket booking portal so that we don’t miss out on the tickets, but I knew this strategy would never work.</p><p>The only solution was to automate this somehow, write a script that periodically refreshes the site and when the tickets are available to alert us in a way that we don’t miss it.</p><h4>Finding out when the tickets are out</h4><p>So every movie which is <strong>coming soon</strong> on bookmyshow gets a page of its own, for every city it is different. For Avengers Endgame for Bangalore, it was this <a href="https://in.bookmyshow.com/bengaluru/movies/avengers-endgame/ET00090482">https://in.bookmyshow.com/bengaluru/movies/avengers-endgame/ET00090482</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2f2WvDYWjBeC1zkBaYu8Q.png" /><figcaption>Screenshot from bookmyshow.com portal</figcaption></figure><p>The only difference was it didn’t have the <strong>Book Tickets</strong> button at the time when it was still in the <strong>coming soon</strong> phase. So all I needed to do was periodically load the page and check when it finally gets the button element. The shell script for it was pretty simple.</p><pre># curl the bookmyshow website</pre><pre>output=`curl -s <a href="https://in.bookmyshow.com/bengaluru/movies/avengers-endgame/ET00090482">https://in.bookmyshow.com/bengaluru/movies/avengers-endgame/ET00090482</a> | grep -c &#39;Book Tickets&#39;`</pre><pre>if [ $output -gt 0 ]<br>then<br>  # Alert somehow, will come to that later<br>fi</pre><p>To periodically run it, I had to run the script as a <a href="https://en.wikipedia.org/wiki/Cron">cron job</a>. But adding it in my own machine meant I had to keep it on at all times which wasn’t feasible. I needed to add this cron job in some remote server which will keep running no matter what. So I added it in a remote AWS server that I had provisioned for testing. You can refer to the first part of my other <a href="https://medium.com/@noel.varghese.22/setting-up-a-production-environment-using-our-local-development-server-and-aws-f5eea3b5be60">medium article</a> in case you need to provision an ec2 AWS instance for yourself. And I added the below crontab entry</p><pre># Run the check_ticket script every minute as a scheduled cron<br>*/1 * * * * sh /home/ec2-user/check_ticket.sh</pre><h4>Alert when the tickets are available</h4><p>Now I needed some way in which the script could alert us after the tickets were available. The only thing I have on my person at all times is my mobile, so either sending a text message or triggering an automated call seemed the best option for me. I figured out that I can use <a href="https://www.twilio.com/">Twilio</a> APIs to achieve the same for free since they provide enough credits at the start to make quite a lot of calls &amp; messages.</p><p>The first part was to get a Twilio number and to register a few mobile numbers with them which would be getting the calls &amp; messages using the docs provided <a href="https://www.twilio.com/docs/usage/tutorials/how-to-use-your-free-trial-account">here</a>. The quickstart guides for both <a href="https://www.twilio.com/docs/sms/quickstart/python">SMS</a> and <a href="https://www.twilio.com/docs/voice/quickstart/python">Voice</a> were simple enough to follow. I ended up with one script which would alert both by calling &amp; messaging different numbers to ensure at least someone in my group is alerted.</p><pre>#!/usr/bin/python</pre><pre>from twilio.rest import Client</pre><pre># Your Account SID from twilio.com/console<br>account_sid = &quot;xxxx&quot;<br># Your Auth Token from twilio.com/console<br>auth_token  = &quot;xxxx&quot;</pre><pre>client = Client(account_sid, auth_token)</pre><pre>message = client.messages.create(<br>    to=&quot;+xxxxxxxxxxxx&quot;,<br>    from_=&quot;+zzzzzzzzzzzz&quot;,<br>    body=&quot;Book Tickets for avengers endgame&quot;)</pre><pre>call = client.calls.create(<br>    to=&quot;+yyyyyyyyyyyy&quot;,<br>    from_=&quot;+zzzzzzzzzzzz&quot;,<br>    url=&quot;https://handler.twilio.com/twiml/xxxx&quot;)</pre><pre># Send message<br>print(message.sid)</pre><pre># Trigger a call<br>print(call.sid)</pre><p>And my <strong>check_ticket.sh </strong>script changed to calling the above script when it figures out the tickets are available.</p><pre># Curl the bookmyshow website</pre><pre>output=`curl -s <a href="https://in.bookmyshow.com/bengaluru/movies/avengers-endgame/ET00090482">https://in.bookmyshow.com/bengaluru/movies/avengers-endgame/ET00090482</a> | grep -c &#39;Book Tickets&#39;`</pre><pre>if [ $output -gt 0 ]<br>then<br>  /usr/bin/python /home/ec2-user/alert_by_twilio.sh<br>fi</pre><h4>Conclusion</h4><p>And that’s all folks — two small scripts on a remote server are all it takes to set everything up. When I set it up for Avengers I &amp; my friend got a call &amp; message respectively, we immediately head over to the site. It took some time for the portal to upload the tickets for the various halls in different locations. After multiple failed payments we finally got the best seats in the hall and had an amazing spoiler-free, first time, IMAX experience for the movie.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2efa3a128a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/how-i-coded-my-way-to-early-tickets-for-avengers-endgame-f2efa3a128a8">How I coded my way to Early Tickets for Avengers Endgame</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a Production Environment using a Local Development Server and AWS]]></title>
            <link>https://faun.pub/setting-up-a-production-environment-using-our-local-development-server-and-aws-f5eea3b5be60?source=rss-339eb2f1b2c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5eea3b5be60</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ssh]]></category>
            <dc:creator><![CDATA[Noel Varghese]]></dc:creator>
            <pubDate>Mon, 10 Jun 2019 02:35:29 GMT</pubDate>
            <atom:updated>2020-01-22T03:50:09.156Z</atom:updated>
            <content:encoded><![CDATA[<p>Working in a localhost development environment, we are often met with a ton of problems, like CORS, not able to use certain APIs due to non-https url and not having a valid domain name. Also to get feedback from other people they need to set the whole thing up on their own localhost which is a time consuming and rather frustrating process due to missing libraries etc.</p><p>There are tools like <a href="https://ngrok.com/">ngrok</a> which help you to get an https enabled, publicly accessible URL which you can share with others, but the only downside is that you get a <strong>random URL</strong> every time, which in case if you are using facebook/google APIs can get rather frustrating since they ask you to register the domain name from which the calls will be made.</p><p>So what I came up with is a self-hosted free solution in which you have all the control, choosing the domain name you need(without even buying one), with https enabled, publicly accessible by everyone so you can test production environment flows just by using your local development server.</p><h3>The Idea</h3><p>To access any application on the internet we need a host and a port, by default this host is either a public IP on the internet or a hostname which makes is easier to remember than a combination of random digits which is the IP, the port though not mentioned is by default port 80 for HTTP URLs and port 443 for https. In our case, the development server is running on our local machine which has a private IP and some associated port which most of the times is neither 80 nor 443 instead it is a random port like 8080 or 8000. So let us list our requirements to achieve our goal:</p><ol><li>Acquire a<strong> Remote server</strong> with <strong>Public IP</strong> accessible by people on the Internet</li><li><strong>Route</strong> requests from this remote server with public IP to our local development server with <strong>Private IP</strong> on a <strong>random port</strong> by establishing a <strong>secure tunnel</strong> between the two machines.</li><li>Run a <strong>web server</strong> that listens on 80/443 port on a remote server that will handle the incoming requests and forward it to the established tunnel.</li></ol><h3>Step 1: Getting a remote server with a Public IP</h3><p>This is the part where AWS comes in, it lets you spawn Linux servers and gives you a public IP for it. With the free plan of AWS, you can run a t2.micro(1GB Ram &amp; 1CPU) instance for free, for our case we will use an RHEL 7 operating system instance. The AWS dashboard can be a lot to take in at first, so we will instead use the aws-cli to spawn an EC2 Instance (Virtual Servers on Cloud).</p><h4>Account Creation</h4><p>Create a FREE account with <a href="https://aws.amazon.com/">Amazon AWS</a>, once the account is verified after the small token payment, download the access keys from the accounts section to configure the aws-cli.</p><h4>CLI Commands for EC2 Instance creation</h4><p>Once our account is created we can now use the aws-cli commands to spawn our instance without touching the dashboard again.</p><pre><strong># Download aws-cli for your OS distribution and then configure it</strong><br>$ aws configure</pre><pre><strong># Generate private-public key pair to access instance</strong><br>$ aws ec2 create-key-pair --key-name <em>MyAWSKey</em> --query &#39;KeyMaterial&#39; --output text &gt; <em>Aws.pem</em></pre><pre><strong># Generate security group, acts like a firewall, set of inbound and outbound rules ( outputs group id )</strong><br>$ aws ec2 create-security-group --group-name <em>port-forwarding</em> --description &quot;<em>Security group for port forwarding instance</em>&quot;</pre><pre><strong># Get outbound public ip </strong><br>$ curl <a href="https://checkip.amazonaws.com/">https://checkip.amazonaws.com</a><br>106.51.234.93</pre><pre><strong># Add inbound rules with public ip</strong></pre><pre><strong># For enabling ssh access &amp; port forwarding (port: 22)<br></strong>$ aws ec2 authorize-security-group-ingress --group-id <em>sg-0ce1ec3f06b85227d</em> --protocol tcp --port <em>&lt;port&gt;</em> --cidr <em>106.51.234.93/24</em></pre><pre><strong># For http/s inbound traffic &amp; port forwarding  (port: 80,443,4000)<br></strong>$ aws ec2 authorize-security-group-ingress --group-id <em>sg-0ce1ec3f06b85227d</em> --protocol tcp --port <em>&lt;port&gt;</em> --cidr 0.0.0.0/0</pre><pre><strong># Start instance<br></strong>$ aws ec2 run-instances --image-id <em>ami-5b673c34</em> --count 1 --instance-type <em>t2.micro</em> --key-name <em>MyAWSKey </em>--security-group-ids <em>sg-0ce1ec3f06b85227d</em></pre><pre><strong># Get instance details<br></strong>$ aws ec2 describe-instances</pre><pre><strong># Connect to instance using PublicDNSName from above by setting appropriate permissions for the key<br></strong>$ chmod 400 /path/to/key<br>$ ssh -i /path/to/key ec2-user@PublicDNSName</pre><h3>Step 2: Securely routing the requests</h3><p>Now that the first step is done, the next part is to securely route the requests from our AWS EC2 Instance to our local machine. To achieve this we will be using an interesting ssh command which is <strong>SSH</strong> <strong>Remote Port Forwarding</strong>.</p><h4>SSH What is it?</h4><p>In our previous section, we saw the use of ssh to login to a remote server, what is happening behind the scenes is that the local ssh client establishes a secure connection to the remote ssh server listening to port 22.</p><pre><strong># on remote server</strong><br>[ec2-user@ip-172-31-17-70 ~]$ sudo netstat -tulpn | grep sshd<br>tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1160/sshd<br>tcp6       0      0 :::22                   :::*                    LISTEN      1160/sshd</pre><p>It uses symmetric &amp; asymmetric encryption, the former one is used for encrypting the entire connection while the latter is used for authentication, which can also be done through a password based method.</p><p>Using the same underlying principles we can create a tunnel from a port on the remote machine to a port on the local client machine. To test this let us first start a simple HTTP server on our local machine using python.</p><h4>Starting a simple local development server</h4><p>Execute the below python command to start an HTTP server for any file directory. I am taking a directory with a single file with some HTML content</p><pre><strong># Start simple http python server</strong><br>$ python -m SimpleHTTPServer<br>Serving HTTP on 0.0.0.0 port 8000 ...</pre><pre><strong># Test server</strong><br>$ curl localhost:8000/hello.html<br>&lt;body&gt;&lt;h1&gt;Hello Testing Remote Port Forwarding&lt;/h1&gt;&lt;/body&gt;</pre><p>Now we have a local development server running on port 8000, and IP as 0.0.0.0, hmm what is this ?, what it implies is that it is listening on all IPv4 addresses on the machine on port 8000, and not on any specific IP. Having set up the local server we can now do our ssh trick of remote port forwarding.</p><h4>Remote SSH Server Config</h4><pre><strong># Editing ssh server config on remote server<br># Need to make sure these two options in /etc/ssh/sshd_config are set to yes</strong><br>AllowTcpForwarding yes<br>GatewayPorts yes</pre><pre><strong># Restart sshd service on remote server</strong><br>[ec2-user@ip-172-31-17-70 ~]$ sudo systemctl restart sshd</pre><p><strong>AllowTcpForwarding</strong> option enables ssh port forwarding, it is usually enabled by default. <strong>GatewayPorts </strong>option lets the tunnel listen to all interfaces when switched off the tunnel when created will expose the remote port only on localhost also called loopback interface. Since we need it to be on public IP we will be enabling it.</p><p>As we go further in this tutorial we will improve our current setup so that we don’t have to enable the GatewayPorts options.</p><h4>Remote Port Forwarding</h4><pre><strong># Setting up a secure tunnel<br></strong>$ ssh -N -i /path/to/key ec2-user@aws-hostname -R 4000:localhost:8000</pre><p>Let us break down the above command step by step</p><ol><li>-N directly as it says from the man page of ssh, Do not execute a remote command. This is useful for just forwarding ports.</li><li>-i we give the path to the identity file or the private key file to authenticate our connection to our remote host to create an ssh tunnel.</li><li>-R is the key to begin remote port forwarding instructing the ssh command that though the connection is being initiated from the client to the remote, the port forwarding will happen in the reverse direction i.e from the remote to the client.</li><li>4000 is the port that will be opened on the remote server by the tunnel requests coming onto that port will be forwarded onto the client machine from where the ssh session was initiated on localhost:8000 where our development server is running.</li></ol><h4>Testing</h4><p>We should be able to now access our localhost environment over the public internet.</p><pre><strong># Testing on public ip<br></strong>$ curl 13.233.229.115:4000/hello.html<br>&lt;body&gt;&lt;h1&gt;Hello Testing Remote Port Forwarding&lt;/h1&gt;&lt;/body&gt;</pre><h3>Step 3: Setting up a web server</h3><p>The reason we are setting a web server is to take this DIY approach a step further. What if you run multiple instances of your application on various ports on multiple laptops with port forwarding set up for all? you will be able to handle a decent amount of load. To achieve this we will need something that sits in front of all these instances to distribute the load to them, this is where a web server comes in, also it will help us to setup https for our domain name.</p><h4>Acquiring a domain name</h4><p>I mentioned at the start that we don’t even need to buy a domain name to use it. Instead, we can add an /etc/hosts entry in our UNIX based systems like this</p><pre><strong># /etc/hosts</strong><br>13.233.229.115 abc.com</pre><p>To resolve any domain name the system uses the /etc/hosts entry before resolving it using public DNS resolvers. So now you can add a self-signed certificate for abc.com in the Nginx configuration to setup SSL for the same.</p><h4>Nginx with SSL using a self-signed certificate</h4><p>Nginx can be installed using standard yum commands on the ec2 instance since we are using RHEL 7. Configuring https for a domain with Nginx is a well documented &amp; standard practice, so I won’t be covering that in this article but will link to my Github gists to help you set up the same if you are new to it. We will be doing a proxy pass from Nginx to our tunnel running on port 4000.</p><pre><strong># Install epel repo<br></strong>[ec2-user@ip-172-31-17-70 ~]$ sudo yum install -y <a href="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm">https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm</a></pre><pre><strong># Install nginx<br></strong>[ec2-user@ip-172-31-17-70 ~]$ sudo yum install nginx</pre><pre><strong># Disable selinux to allow proxy pass from nginx to localhost<br></strong>[ec2-user@ip-172-31-17-70 ~]$ setenforce 0</pre><p><strong>Configuring Nginx with SSL and proxy pass:</strong> <a href="https://gist.github.com/envy7/4a602a30aba8de70c58902dce9d8aa64">https://gist.github.com/envy7/4a602a30aba8de70c58902dce9d8aa64</a></p><p><strong>Acquiring a self-signed cert for a domain:</strong><br><a href="https://gist.github.com/envy7/de511cb1012eab14eca8ce5bd4ed2769">https://gist.github.com/envy7/de511cb1012eab14eca8ce5bd4ed2769</a></p><h4>Trusting a self-signed certificate</h4><p>When using a self-signed cert the browser will still throw a warning saying that the cert is not signed by a known authority. To bypass this warning we can make our system trust the certificate. For instance, on mac os, we can do that by a single command.</p><pre>sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain &lt;cert&gt;</pre><blockquote>GatewayPorts yes</blockquote><blockquote>As we go further in this tutorial we will improve our current setup so that we don’t have to enable the GatewayPorts options.</blockquote><p>We can also revert the GatewayPorts option we enabled before since we are performing the listening via Nginx &amp; proxy passing the request to localhost.</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*zbU1UG2l6GwaAnXd8ikm7g.png" /></figure><p>We successfully set up a production environment using a development server running on localhost. To summarise we spawned an <strong>AWS ec2 instance</strong> since aws gives us a <strong>Public IP</strong> which we can use with the instance, then set up a <strong>remote port forwarding tunnel</strong> from this remote instance to our localhost server.</p><p>We then installed Nginx a <strong>web server</strong> on the remote instance to help us install <strong>SSL</strong> for the domain of our choice and handle the public traffic and proxy it to this tunnel. For anyone trying to access our application over the internet, they only have to add an <strong>/etc/hosts</strong> entry with the provided domain, IP &amp; trust the certificate or ignore the warning once in the browser.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5eea3b5be60" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/setting-up-a-production-environment-using-our-local-development-server-and-aws-f5eea3b5be60">Setting up a Production Environment using a Local Development Server and AWS</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>