<?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 Anwesh Budhathoki on Medium]]></title>
        <description><![CDATA[Stories by Anwesh Budhathoki on Medium]]></description>
        <link>https://medium.com/@anweshb?source=rss-ec8424fe46f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*T1hgYvwy5-0TmlBMuPJPng.png</url>
            <title>Stories by Anwesh Budhathoki on Medium</title>
            <link>https://medium.com/@anweshb?source=rss-ec8424fe46f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:41:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anweshb/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[Building to Deploying and Running DContainer in Cloud]]></title>
            <link>https://anweshb.medium.com/building-to-deploying-and-running-docker-container-in-cloud-f7e98f2bc256?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7e98f2bc256</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[azure-container-registry]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[azure-container-instances]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Sun, 01 Nov 2020 15:12:34 GMT</pubDate>
            <atom:updated>2020-11-01T15:30:08.951Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building to Deploying and Running Docker Container in Cloud</h3><p>This blog does not contain Docker installation, refer <a href="https://docs.docker.com/get-docker/">https://docs.docker.com/get-docker/</a> for installation. We will be talking about basis of Docker, creating Docker images, deploying it to Azure Container Registry and run the container in Azure Container Instances.</p><p>Let’s start with docker. Docker is an OS-level virtualization platform used to deliver software in an isolated environment called containers. This means your application runs on the Docker Engine, which furthermore runs on the OS you are using. Docker architecture can be clearer with the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oNHpka-AXr02xTvn" /><figcaption>Docker Architecture</figcaption></figure><p>To get started with containers, we need to have an application of course as we are keeping applications in a container. I have a simple node.js application using express framework. It simply returns “Welcome to Docker express.”</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const port = 3000;<br>app.get(&#39;/&#39;,(req,res)=&gt;{<br>    res.send(&quot;Welcome to Docker Express&quot;);<br>}) <br>app.listen(port,()=&gt; console.log(`Server running at port ${port}`));</pre><p>Let&#39;s create a Dockerfile which stores all the configurations for our application.</p><pre>FROM node:alpine </pre><pre>RUN mkdir /nodeapp<br>WORKDIR /nodeapp<br>COPY ./* /nodeapp/ </pre><pre>RUN npm install<br>EXPOSE 3000</pre><pre>CMD [&quot;node&quot;,&quot;index.js&quot;]</pre><p>It says to pull the ‘node’ image. Then create /nodeapp folder and set the present working directory of our container to /nodeapp. Now, copy the contents from present working directory of our local machine to /nodeapp/ of our container. Of course, we do not want to copy the dependencies container in our node_modules folder. So create a .dockerignore file to ignore, like the gitignore file used in git. Then run npm install command to install all the dependencies of our application. And finally, expose port 3000 which is used by our application and run the application.</p><p>Now lets build our Docker image. To build the image, run docker build -t express-demo:v1 . This tells docker to build an image with tag express-demo:v1, from the Dockerfile in the current directory. Providing a tag is just giving a name to our image and v1 is to tell the version.</p><figure><img alt="docker build" src="https://cdn-images-1.medium.com/max/687/1*EZDNx6HUwe0M2tevQ6L-7g.png" /></figure><p>To see the list of images, just run docker image ls</p><figure><img alt="docker image ls" src="https://cdn-images-1.medium.com/max/851/1*1xtuvRoRFYmJlJ8kFn9H5A.png" /></figure><p>Now, we need to run our container. To run the container, run docker run -d -p 80:3000 express-demo:v1.</p><p>This tells us to run express-demo:v1 container, the one we just created, map the port 80 of our local machine to port 3000 of the container, and to run in detached mode. Now every request sent to our localhost:80 port will go to 3000 port of our container. To verify this, open the browser and go to localhost. I am using curl for this.</p><figure><img alt="Verify running Container" src="https://cdn-images-1.medium.com/max/529/1*xQHELuP8OzlQJB5bitx0Hg.png" /></figure><p>Now, we have created and run our image in our machine. But to make our container accessible globally, we need to deploy it somewhere. So, we are using Azure Container Registry. You can use any of the container registries like Docker Hub, GitLab container registry, AWS Elastic Container Service, Google Cloud Container Registry, or anyone.</p><p>Let’s head to <a href="https://portal.azure.com/">portal.azure.com</a>, and search for Container Registry in Marketplace or SearchBox. Select create container registry . Create a new resource group and select Registry name. As the Registry name is globally unique, we need to verify the name. Select the location of your preference. I have chosen Southeast Asia as it is the nearest Azure Data Center. Choose SKU and create the Container Registry.</p><figure><img alt="Create Azure Container Registry" src="https://cdn-images-1.medium.com/max/770/1*a82aIbvjtODqn3wIfshOjg.png" /></figure><p>Now, after the deployment is complete, go to the resource. Here you will find options for the Container Registry. Navigate to Access Keys and turn on the admin user. Then we will get a username and password to log in. There are various other methods to authenticate, which we can refer to <a href="https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication#authentication-options">https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication#authentication-options</a>, but for now we are using the Admin user.</p><p>To login, we will need either az cli or docker login. We are using docker login for this as we do not need to install azcli.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*zVPEhnUXERtHkkK2rh__3Q.png" /></figure><p>Now as we have our docker image ready and have logged in to Container Registry, we need to push our image to the Container Registry. But before that, we need to give a proper name to our image according to our Registry. To achieve this, we will tag our express-demo:v1 container with a new name expressdemo.azurecr.io/express-demo:v1 Run docker image tag express-demo:v1 expressdemo.azurecr.io/express-demo:v1To verify our name, list the images with docker image ls | grep express</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*qAExysyx4gmENtr_IXQYlA.png" /></figure><p>Now we need to push our image. Run docker push expressdemo.azurecr.io/express-demo:v1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*RJmOgcR5FgderROfZebGIA.png" /></figure><p>Now we have our container in a Container Registry. To run this container, we can pull this image and run on local storage or use cloud services like Amazon ECS container instance, Azure Container Instances, or any other service. We will be looking into Azure Container Instances.</p><p>Search for Container Instance in the Search bar or Marketplace in Azure Portal. Give Container name and choose the region best for you. In the Image source choose Azure Container Registry. If you had your Container in another container registry, then choose Docker Hub or other registry. Then moving on, Choose Registry name, Image name and Image tag of your container, which we deployed earlier. Choose the size according to our needs. I am using 1 Core CPU with 1.5GiB memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*b9QfFChnNTrahOXI97Di5g.png" /></figure><p>Move to the Networking section and choose port 3000. Port mapping is currently not available and is in backlog, meaning we will get the feature soon. To achieve this, you can change the port of the node app from 3000 to 80 and start by creating Docker image. You can also use a load balancer to map the ports, and this also increases the cost. Apart from the port, we can also choose an FQDN (Fully Qualified Domain Name) provided by Azure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*_i7b8sMZYW0xya3n_izaGg.png" /></figure><p>Now, review and create the Container Instance. After Deployment is complete, you can see a Public IP and FQDN(if you setup earlier). Copy the IP and goto &lt;IP&gt;:3000. If you have FQDN, you can use &lt;FQDN&gt;:3000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*OhxMU0_y8hdWr3IiFvDYCw.png" /></figure><p>And finally, we have deployed our locally created container to a Container Registry and Run it in Container instance. For more info you can visit these links.</p><ul><li>Docker: <a href="https://docs.docker.com/">https://docs.docker.com/</a></li><li>Azure Container Registry: <a href="https://docs.microsoft.com/en-us/azure/container-registry/">https://docs.microsoft.com/en-us/azure/container-registry/</a></li><li>Azure Container Instance: <a href="https://docs.microsoft.com/en-us/azure/container-instances/">https://docs.microsoft.com/en-us/azure/container-instances/</a></li><li>Azure Cli: <a href="https://docs.microsoft.com/en-us/cli/azure/">https://docs.microsoft.com/en-us/cli/azure/</a></li></ul><p>Feel free to drop any queries, feedbacks, and suggestions. I would love to hear. And the code of the demo is available here: <a href="https://github.com/anwesh-b/Docker-workshop/tree/master/nodejs">https://github.com/anwesh-b/Docker-workshop/tree/master/nodejs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7e98f2bc256" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cronjobs]]></title>
            <link>https://anweshb.medium.com/cronjobs-a354e0233fb4?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a354e0233fb4</guid>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[linux-administration]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 14:31:09 GMT</pubDate>
            <atom:updated>2020-07-06T14:31:09.090Z</atom:updated>
            <content:encoded><![CDATA[<h4>Linux — cronjobs</h4><h4>Automate your tasks using cron jobs</h4><p>As a developer or system admin, there comes many time when we need to do certain tasks regularly and repeatedly. The tasks can be anything from running a backup, deleting or modifying files, sending logs, to running certain scripts. Doing the same task over and over again is kind of hectic. And, when we are unavailable, the task cannot be completed which can cause loss. This repeated tasks can easily done using Cron Job in Linux, where you just need to define the task and time to repeat the task.</p><p>Lets begin with the answer to what is cron? Cron is a time-based job scheduler in Unix like Operating System. Each tasks executed are called cronjob and the file containing the cronjobs are called crontab, which is defined in cronjob file. The crontab file is located at “/var/spool/cron/crontabs/&lt;username&gt;” of each users. The crontabs can be categorized into two: global crontabs, which are used by administrators and individual crontab which is used by every user.</p><p>Now, lets begin configuring the cronjobs. You can begin listing the cronjobs using: crontab -l. You might see no crontab for your user. So, let’s create one using: crontab -e, which edits the crontab file. The first time you execute this command, you will be asked to choose the text editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*O7XGyrVSxMGhaLIhtZAlTA.png" /><figcaption>First time executing crontab -e</figcaption></figure><p>I have selected vim, and you can select any of the text editor of your choice. The text editor will appear and its time to add the cronjobs.</p><figure><img alt="Crontab file at the beginning or default crontabfile" src="https://cdn-images-1.medium.com/max/578/1*YoWSsqvFS4UqnR-DHk2m7A.png" /><figcaption>Default crontab file</figcaption></figure><p>The syntax for cron expression is :</p><pre>min hour day month day_of_week &lt;command to be executed&gt;</pre><p>Suppose we have to copy a text from one file to other every 1 am, the syntax will be:</p><pre>0 1 * * * cat ~/file1 &gt;&gt; ~/logs<br>This means to copy the content of file1 to logs. This needs to be executed everyday of week, every month, every day(as * is wildcard for any) and at 1 am and 0 minute, i.e. 1:00 AM.</pre><p>Similarly, if you need to execute the same thing every 5 hours, we need to use:</p><pre>0 */5 * * * cat ~/file1 &gt;&gt; ~/logs</pre><p>Similarly, we can also run a cron job every minute. The command can be anything the user has access to. The syntax might be confusing at first and there are different cronjob generators to help you generate and understand the syntax like Crontab Guru, Crontab Generator.</p><p>Apart from the syntax, there are predefined definitions to define time for the cronjobs. This includes @reboot, @yearly, @monthly, @daily and @hourly with each having certain equivalence.</p><figure><img alt="Source: https://en.wikipedia.org/wiki/Cron" src="https://cdn-images-1.medium.com/max/679/1*jM2YiihBONnVzAYc6lfpHA.png" /><figcaption>Predefines definitions and its equicalence</figcaption></figure><p>Now lets get a list of cron jobs, using:</p><pre>crontab -l</pre><p>To assign cronjob for certain user, we can use:</p><pre>crontab -u &lt;username&gt; -e</pre><p>To remove all the cronjobs</p><pre>crontab -r</pre><p>Well, these are not the only stuffs you can do. We can create /etc/cron.allow and /etc/cron.deny file to allow or restrict the users from accessing the crontab file. If we have cron.allow file, we must specify the username to allow a user to use crontabs. And If we have cron.deny file, the users who needs the crontabs needs to be restricted. The syntax for both the file is simple, we just need to have username listed in new lines.</p><p>In absence of those files only the user having superuser privilege will get access to crontab. Superuser privilege means the user needs to be an ‘sudo’ group on Ubuntu, “wheel’ on ‘RFEL’ depending on the Linux distribution.</p><p>And finally on the last part, time zone on crontab. Suppose we are administrator of a multinational company having branch across various parts of the world. There might be many cronjobs that we need to execute for different branch of different places with different time zones. We can convert time of each time zone to main time zone used. But this increases chances of misconfigurations in time and also a lot of time can be used up. To solve this issue, we can add a line above cronjobs to specify the time zone for the jobs.</p><pre>TZ=&lt;time_zone&gt;</pre><figure><img alt="Configuration of cronjobs for different timezones" src="https://cdn-images-1.medium.com/max/458/1*Unyy-C5oCIZ5K4VmzWQvCQ.png" /><figcaption>Cronjobs configuration for different timezones</figcaption></figure><p>Here, the above cronjob executes according to the timezone of Nepal and the cronjob below executes according to the timezone of New York, America</p><p>Other thing we can do is to define shell for the jobs. We need to add a line SHELL=&lt;path_to_shell&gt; above the cronjob to tell cronjobs which shell to use. All the cron jobs below the line will use the same shell so to change shell for cronjobs in between the file, we must again specify the shell.</p><p>Seems interesting right? The article will surely help anyone without prior experience on using cronjobs to understand and create one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a354e0233fb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First AI Gaming]]></title>
            <link>https://medium.com/microsoft-student-partners-nepal/ai-gaming-ebdb9f8c2880?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebdb9f8c2880</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[ai-gaming]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Thu, 25 Jun 2020 15:12:38 GMT</pubDate>
            <atom:updated>2020-06-29T04:07:41.243Z</atom:updated>
            <content:encoded><![CDATA[<h4>AI Gaming</h4><h4>From basics of Python to winning AI Gaming</h4><p>I took part in AI Gaming held by Microsoft Student Partner Nepal. It was around mid-December, and I was in a dilemma in going to the AI gaming, as I did not have any technical knowledge of Artificial Intelligence. In this article, I will share my experience in AI Gaming and how Cloud providers help to improve our work.</p><p>Before the event, the only thing I knew about AI was that we had some data, we needed to train the data, and based on the training we could obtain our required output. Besides these, I had no idea how the data were trained, how to use the trained result, I had no idea on the different algorithms used in Artificial Intelligence, basically, I only knew the workflow of AI. However, I decided to show up in the event and participate with just a slight knowledge on Python.</p><p>The event began with the basics of Cloud Computing, Microsoft Azure, creating Azure account and Azure portal basics. I came to know about the Azure Cognitive Services and how these cloud technology are saving time we spent working on AI. We learned to subscribe to the Computer Vision API and use that API in our match game and use it to play with other players in <a href="https://www.aigaming.com/">aigaming.com</a>. As we worked in Python and API calls in AI gaming, my knowledge on Python and the web helped me to understand how to play the game quicker.</p><figure><img alt="The image of Match game of AI Gaming, where players needs to match similar tiles and is being played between two players." src="https://cdn-images-1.medium.com/max/957/1*UCTsA6J172xQggfkxd7SFA.png" /><figcaption>Match Game being played between two players</figcaption></figure><p>The game was a match game, where we needed to match the similar tiles. This reminded me of <a href="https://en.wikipedia.org/wiki/Purble_Place">Purble Place</a> game that I used to play in my childhood. There I matched the tiles myself using my head, and here I needed to do exactly the same but using bot. The task was to code the bot using Microsoft Azure Computer Vision, as the tiles were similar but not the same.</p><p>To begin, we were given a code that could play the game to some extent, but it was slow and our task was to improve the speed of the game. We needed to check for the tiles that had animals, landmarks or words differently. Using Microsoft Cognitive Services, we could check if the tiles were same or not. Then side by side writing the code, test tournaments were conducted to make us familiar with the tournament and to test our codes as well. And after few test tournaments, we had amazing lunch and came again for the final tournament. And in the final tournament I won the tournament. I was pretty lucky as the score was same in the final match however I won from the tiles count.</p><p>My first use of AI with Microsoft Azure was really amazing as it was the first time using API with Python as well. The AI on Cloud is more strong due to large number of data. Also we need not rely only on our local machine to do powerful tasks. Tasks that took a long time, now can be done in short span on cloud.</p><p>Are you looking to be an AI engineer, software developer or are you already one? No matter, the cloud computing services of AI and Machine Learning which cloud providers has been providing will surely help you to scale up you work, save time and add value. And most importantly, it will help you to stand out among a huge mass and make you better engineer than other. You can always begin to learn and explore from <a href="https://aischool.microsoft.com/en-us/home">AI School</a> and <a href="https://azure.microsoft.com/en-us/services/cognitive-services/">Microsoft Learn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebdb9f8c2880" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-student-partners-nepal/ai-gaming-ebdb9f8c2880">My First AI Gaming</a> was originally published in <a href="https://medium.com/microsoft-student-partners-nepal">Microsoft Student Ambassadors Nepal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CORS Explained!]]></title>
            <link>https://medium.com/microsoft-student-partners-nepal/cors-explained-2a91a34f72e2?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a91a34f72e2</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Sun, 21 Jun 2020 10:36:32 GMT</pubDate>
            <atom:updated>2020-06-21T10:36:32.287Z</atom:updated>
            <content:encoded><![CDATA[<p>No ‘Access-Control-Allow-Origin’ header is present on the requested resource. This is one of the security mechanism used by the web server of web clients. So, what actually this means? In this article, I will be explaining about the CORS mechanism and how this will add security at an introductory level.</p><p>The above mechanism is Cross-Origin Resource Sharing, which tells the web server or client either allow or to restrict the sharing of any kinds of resource between different origin. The origins can either be a different domain or same domain with different ports. Also, CORS can be implemented for HTTP request methods. Below are some of the images to make you clear on how CORS works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*QuWSmC8FI7PDz0vE7J0QXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*qQDbh_BLW67-vhdhDGWbzg.png" /></figure><h4>So the question comes, is CORS important? Or, how does it add security?</h4><p>Yes, CORS plays an important for security to prevent any malicious behaviors. Let us take an example, we have a web server that is built only to respond to the request from a certain website or web clients. So we need to decline all the requests coming other than from the particular web client. Here, CORS shines in and allows requests only from the required site or client.</p><p>Still, have some confusion? Let me add one more example. You have a server that responds to its client with daily top news. In this case, the client will only need the GET request method. If clients get access to ‘PUT, DELETE or POST’ methods, the news can be deleted or changed. And, there is a high risk of giving fake news to the clients. So, CORS stands out and blocks any of the requests that are not GET request from the client.</p><h4>How is it implemented then?</h4><p>Let’s look at the client-side first. While sending any requests, HTTP header is added telling the domain name of the current page. For example, I am browsing xyz.com and I need to send a request to abc.com. An HTTP header ‘Origin: xyz.com’ is added to tell that the request originated or came from xyz.com. Then the browser looks up for the Origin header. If the Origin header is present, the browser forwards the request, else request is discarded or dropped.</p><p>Now looking on the server-side, the request reaches the server. Now the server looks for the ‘Origin’ header. The origin header we have is ‘Origin: xyz.com’, and the server of abc.com searches the origin in its CORS list. If the domain name is in the whitelist of the server and the HTTP request method is allowed, then the response is sent accordingly by the server. Else, the request is dropped by the server and status 0 is sent to the client with error “No ‘Access-Control-Allow-Origin’ header is present on the requested resource”</p><p>In a nutshell, CORS is <strong>like a Firewall </strong>for the web servers to prevent unwanted requests from entering the server. The article is made beginner friendly so there are still many more things to explore.</p><p>References:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS">https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS</a></p><p><a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">https://en.wikipedia.org/wiki/Cross-origin_resource_sharing</a></p><p><a href="https://fetch.spec.whatwg.org/#origin-header">https://fetch.spec.whatwg.org/#origin-header</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a91a34f72e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-student-partners-nepal/cors-explained-2a91a34f72e2">CORS Explained!</a> was originally published in <a href="https://medium.com/microsoft-student-partners-nepal">Microsoft Student Ambassadors Nepal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing code to send emails]]></title>
            <link>https://medium.com/microsoft-student-partners-nepal/writing-code-to-send-emails-b16de640c534?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b16de640c534</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[email]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Wed, 29 Apr 2020 12:55:47 GMT</pubDate>
            <atom:updated>2020-04-29T12:55:47.071Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I will be sharing on how to send emails using Python and Gmail. As the code is easily customizable, we can easily change how we send the email to the receivers. The full code can be found at: <a href="https://github.com/anwesh-b/Python-Email/blob/master/emails.py"><em>https://github.com/anwesh-b/Python-Email/blob/master/emails.py</em></a></p><h3>Understanding the code:</h3><p>Let’s create a file to store the list of receivers and a file to store message to be sent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*89Sxda0siJ8AS2mDtpYGrw.png" /><figcaption>Receiver file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*S90Ila3Ga4e6GM6mUq-Ctg.png" /><figcaption>The message text</figcaption></figure><p>Now we need to read these files in our main code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*UNN9pDZpuPvpPu5Ys6pF0g.png" /><figcaption>Reading the list of emails and the message content</figcaption></figure><p>Here, we have created function email_list() which reads the list of email and returns the names and emails from the file. And the next function message_content() reads the content of the message. Here we can see, instead of reading and returning the contents, we have used Template which returns an object instead of a string.</p><p>Now going into the main part of the program, we need to setup a SMTP client in order to be able to send emails from our local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*CzwwU3HXkTo8l1XsyTersA.png" /><figcaption>Setting up the SMTP</figcaption></figure><p>Here, we have read the receiver list and the message body. Then we have setup the SMTP to be able to send the messages. The smtp.gmail.com with port number 465 is default provided by Gmail. This can be different for different service providers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*ozmlqie7oAiWl2UjsAicGg.png" /><figcaption>Sending emails to all receivers</figcaption></figure><p>Now, we need to send the email to each of the receivers. For each of the receivers, we have created an empty message. Then we need to add different parameters in our message including Subject, From, To, etc. Then we have replaced the name of the receiver from ${PERSON_NAME} mentioned in the ‘message.txt’ file. Then we have added the contents of the message to the message. And using the SMTP connection we created earlier, we have sent the message. And after sending emails to all the receivers, the SMTP connection is closed and we have successfully sent emails to all the receivers.</p><h3>Adding more flavors</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*4gTELaRGXY_9Usotjb81yQ.png" /><figcaption>Customizing the mail</figcaption></figure><p>Instead of sending plain text, we can add attachments, customize the contents of the email, etc. To customize the contents of the mail, we can use HTML and we need to mention the type of the text as HTML. Now we add an image to the mail as an attachment. To send the image, first we open the image ‘ok.jpg’ in binary. Then we set the name of the image to be Attachment_image.jpg. If you have an image of extension that is not supported by default, you need to mention it as well. Then we attach the image and send the email.</p><h3>What’s more?</h3><p>Apart from this, we can extend our program in multiple ways. We can change it to read the list of the receiver from a CSV file. Also, we can send different attachments to different receivers. Also, we can send the certificates, assignments, or anything each different for each of the receivers.</p><p>If you have anything new that could be added, I would love to hear it.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b16de640c534" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-student-partners-nepal/writing-code-to-send-emails-b16de640c534">Writing code to send emails</a> was originally published in <a href="https://medium.com/microsoft-student-partners-nepal">Microsoft Student Ambassadors Nepal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox:Snake Challenge]]></title>
            <link>https://medium.com/microsoft-student-partners-nepal/hackthebox-snake-challenge-f3dd27605dd5?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3dd27605dd5</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Fri, 25 Oct 2019 06:47:33 GMT</pubDate>
            <atom:updated>2019-10-25T06:49:30.099Z</atom:updated>
            <content:encoded><![CDATA[<p>This is how I solved HackTheBox Reversing Challenge: Snake.</p><p>I was given a python script and I ran it. It first asked for the username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*_KQDESbh3_3nMx2kHICYoQ.png" /></figure><p>I looked into the code where it asked username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*iHx5thVI5kAqP8vHaqUCaQ.png" /></figure><p>The value of aa, db, nn, ef, rr, gh, lr, ty, which were provided above in the Hex code. So, I converted those Hex values into ASCII values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*T7jFaRipNZ6WNSehy1MuEg.png" /></figure><p>I found the username to be anaconda and tried it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*8ZwYBBpu_jLE7tt9Igd2fA.png" /></figure><p>Now I needed to look for password. The password section looked like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*WwUmKhc73DG20fFtLTh_Bw.png" /></figure><p>So, looked up for char and took all the needed variables and created another python script to decrypt the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*6IKwN58mQDAd6gHpdiJBXA.png" /></figure><p>I ran the script and this gave me the key as well as the password for any input given.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*_bH8KjfumnfbWgct-B_gPQ.jpeg" /></figure><p>I copied the password and ran the original script again. And BOOM!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*Hz59L5QrE3O7bdqQ1T06Ow.jpeg" /></figure><p>And I submitted the key and completed the challenge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3dd27605dd5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-student-partners-nepal/hackthebox-snake-challenge-f3dd27605dd5">HackTheBox:Snake Challenge</a> was originally published in <a href="https://medium.com/microsoft-student-partners-nepal">Microsoft Student Ambassadors Nepal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy Subnetting, Easy Networking]]></title>
            <link>https://medium.com/microsoft-student-partners-nepal/easy-subnetting-easy-networking-6aa8442f2c46?source=rss-ec8424fe46f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aa8442f2c46</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[ccna]]></category>
            <category><![CDATA[subnetting]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Anwesh Budhathoki]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 12:24:10 GMT</pubDate>
            <atom:updated>2019-07-15T12:24:10.686Z</atom:updated>
            <content:encoded><![CDATA[<p>Subnetting is the basic foundation of Networking. All the networks in the world is based on Subnetting. Subnetting is dividing the network into many parts for various reasons like improving network security, reducing network traffic, optimising network performance and easier troubleshooting.</p><p>Every network has a network id, valid hosts and broadcast IP. The network ID is used to denote the specific network. Valid hosts are the IP that the IP used in the network. Broadcast IP is the IP that is used for broadcasting various messages.</p><p>The subnetting is done in the following steps:</p><p>Step-1) Finding the subnet mask<br> As per our requirement, we use a CIDR value that is used to define the size of a network. Then using the CIDR value, we find the subnet mask. This is done by writing no of 1 equal to CIDR value and remaining 0 so that there are total 32 0’s and 1’s. Then we convert it into decimal and the obtained result is the new subnet mask.</p><p>Step-2) Finding the total number of networks<br> Now we find the no. of networks that can be made using the subnet mask. The no of network can be calculated using the formula 2^n, where n represents the no. of 1 in the changing octate of the subnet mask.</p><p>Step-3) Finding the total valid host in a network<br> We now calculate the total number of IP that can be used in the network. These are the only IP accessible to any user in the network. The no of valid host is calculated using the formula 2^n-2, where n represents the no of 0 in subnet mask.<br><br>Step-4) Finding the block size of a network<br> Block size, jumping value or magic number all have same meaning that is the size of the network ID that changes in each network. It is calculated by 256-changing octate in subnet mask(in decimal).<br><br>Step-5) Creating a subnetting table:<br> Now we make a subnetting table using the given IP and the calculations we did in Step 1-4.<br>The table includes Network ID, Valid IP and Broadcast IP</p><pre>Example:<br>Subneting 192.168.0.0(/27)<br><br>Step-1) New Subnet Mask<br>/28 means we need to have 28 1’s and remaining 4 0’s<br>New Subnet mask= 11111111.11111111.11111111.11100000<br>New Subnet mask= 255.255.255.224<br><br>Step-2) No. of network<br>For no. of network, we use total no of 1’s exceeding the default subnet mask of the class in the subnet mask. Here there are 3 1’s in the subnet mask.<br>If you got confused on default subnet mask of a class, go to this.<br>No of network = 2^n = 2^3 = 8<br><br>Step-3) No. of valid host<br>For no. of valid host, we use the total off bit in the subnet mask. Here, there are total 5 off bits.<br>No of valid host = 2^n(off bit) – 2 = 2^5 -2 = 32-2 = 30<br><br>Step-4) Block size<br>For block size, we see the leftmost octate in the subnet mask that is not equal to 255. Here that octate is fourth octate with value of 224 <br>Block size = 256-224 = 32<br><br>Step-5) Subneting Table</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*i5wSQncp2ouwJvTjw85O6Q.png" /></figure><p>Reference: <a href="https://www.youtube.com/watch?v=_4p9KHbbXNM">https://www.youtube.com/watch?v=_4p9KHbbXNM</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aa8442f2c46" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-student-partners-nepal/easy-subnetting-easy-networking-6aa8442f2c46">Easy Subnetting, Easy Networking</a> was originally published in <a href="https://medium.com/microsoft-student-partners-nepal">Microsoft Student Ambassadors Nepal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>