<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yubaraj singh</title>
    <description>The latest articles on DEV Community by yubaraj singh (@yubarajsingh).</description>
    <link>https://dev.to/yubarajsingh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F507721%2F39ee4c3d-e31f-4c25-b87a-712e06eae7fb.jpeg</url>
      <title>DEV Community: yubaraj singh</title>
      <link>https://dev.to/yubarajsingh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yubarajsingh"/>
    <language>en</language>
    <item>
      <title>Hosting website from centos</title>
      <dc:creator>yubaraj singh</dc:creator>
      <pubDate>Sun, 13 Mar 2022 17:15:09 +0000</pubDate>
      <link>https://dev.to/yubarajsingh/hosting-website-from-centos-1onc</link>
      <guid>https://dev.to/yubarajsingh/hosting-website-from-centos-1onc</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install http using command&lt;br&gt;
&lt;code&gt;sudo yum install httpd&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;check status of server&lt;br&gt;
&lt;code&gt;systemctl status httpd&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;start the httpd service&lt;br&gt;
&lt;code&gt;sudo systemctl enable httpd&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo systemctl start httpd&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the go the /var/www/html/&lt;br&gt;
 &lt;code&gt;cd /var/www/html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;create new index.html &lt;br&gt;
 &lt;code&gt;vi index.html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;write html code here and save the code&lt;/p&gt;

&lt;p&gt;now your site is hosted in your ip or localhost.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Updating WebDriver matching with browser automatically using python</title>
      <dc:creator>yubaraj singh</dc:creator>
      <pubDate>Wed, 09 Mar 2022 17:17:13 +0000</pubDate>
      <link>https://dev.to/yubarajsingh/updating-webdriver-matching-with-browser-automatically-using-python-3k90</link>
      <guid>https://dev.to/yubarajsingh/updating-webdriver-matching-with-browser-automatically-using-python-3k90</guid>
      <description>&lt;p&gt;I had built a web application that need web automation. So I used python Selenium for web automation. The application software was running smoothly and it has only one problem that occurs when my browser(chrome) update automatically and the software stops working. So to keep running, I frequently download the matching version of webdriver and replace the old webdriver. So to automatically download the new webdriver of chrome here are the steps to follow:&lt;br&gt;
import required package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from selenium import webdriver
import requests
import wget
import zipfile
import os

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;get Chrome browser version and chrome webdriver version&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver = webdriver.Chrome()
browser_version = driver.capabilities['browserVersion']
driver_version = driver.capabilities['chrome']['chromedriverVersion'].split(' ')[0]
print("browser version",browser_version)
print("driver version",driver_version)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to check if the chrome version is matching or not and apply if-else condition&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if browser_version[0:2] != driver_version[0:2]: 

    driver.close()
    driver.quit()

    os.remove(r'chromedriver.exe')

    # get the latest chrome driver version number
    url = 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE'
    response = requests.get(url)
    version_number = response.text

    # build the donwload url
    download_url = "https://chromedriver.storage.googleapis.com/" + version_number +"/chromedriver_win32.zip"

    # download the zip file using the url built above
    latest_driver_zip = wget.download(download_url,'chromedriver.zip')
    # extract the zip file
    with zipfile.ZipFile(latest_driver_zip, 'r') as zip_ref:
        zip_ref.extractall() # you can specify the destination folder path here
    # delete the zip file downloaded above
    os.remove(latest_driver_zip)

else:
    print("rock and roll your are good to go")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so hereafter I checked the version and using if condition the version isn't matching then I close the running webdriver and quit the webdriver.&lt;br&gt;
Afterwards, using request.get to get the latest version of chrome webdriver.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Then using wget , I download the zip file.&lt;/li&gt;
&lt;li&gt;lastly, unpack the zip file using zip_ref and remove the zip file. 
Now we are good to go with if the version isn't matching condition. If the version are matching then our web automation will run smoothly without any trouble and there is no need to update the webdriver manually.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So in this way I was able to automatically download the matching version of chrome webdriver.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Reference:&lt;br&gt;
Automatic download of appropriate chromedriver for Selenium in Python - Stack Overflow&lt;/em&gt;&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>python</category>
      <category>automation</category>
      <category>web</category>
    </item>
    <item>
      <title>My first experience in deploying Django Restful to Azure</title>
      <dc:creator>yubaraj singh</dc:creator>
      <pubDate>Mon, 21 Jun 2021 04:25:34 +0000</pubDate>
      <link>https://dev.to/yubarajsingh/my-first-experience-in-deploying-django-restful-to-azure-37f9</link>
      <guid>https://dev.to/yubarajsingh/my-first-experience-in-deploying-django-restful-to-azure-37f9</guid>
      <description>&lt;p&gt;My first experience in deploying Django Restful to Azure&lt;/p&gt;

&lt;p&gt;So recently my build API based on Django Restful framework. I was not quite familiar with Django even though I could set up the Django code and it needed to be deployed to the server. I Recently had claimed a GitHub student benefit pack and I claimed $100 credit for the Azure student account. &lt;br&gt;
So I login to the account and started my deployment process by creating an App service. So here are the things that were need for creating an app service.&lt;br&gt;
runtime stack: python 3.7&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qH4Yimm3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71mxn6ydwrzajwmr2syg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qH4Yimm3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71mxn6ydwrzajwmr2syg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I use a free service that serves as the site's requirement &lt;br&gt;
The project of Django was already uploaded in the GitHub so after creating the app service, it was ready for deployment. In the app, service left sidebar after scrolling there is a deployment section. I choose GitHub as a source so you may choose where you have uploaded it.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L7-OxEK9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yje9ddzrwkt5wwacphr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L7-OxEK9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yje9ddzrwkt5wwacphr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
After this my site was up and running…&lt;/p&gt;

</description>
      <category>azure</category>
      <category>webdev</category>
      <category>django</category>
      <category>sqlite</category>
    </item>
    <item>
      <title>your favorite Shell commands</title>
      <dc:creator>yubaraj singh</dc:creator>
      <pubDate>Thu, 28 Jan 2021 09:41:02 +0000</pubDate>
      <link>https://dev.to/yubarajsingh/your-favorite-shell-commands-3n71</link>
      <guid>https://dev.to/yubarajsingh/your-favorite-shell-commands-3n71</guid>
      <description>&lt;p&gt;Comment your favorite CLI's commands.&lt;/p&gt;

&lt;h1&gt;
  
  
  happy learning
&lt;/h1&gt;

</description>
    </item>
    <item>
      <title>My first Scrimba web weekly challenge: currency exchange</title>
      <dc:creator>yubaraj singh</dc:creator>
      <pubDate>Fri, 15 Jan 2021 06:06:43 +0000</pubDate>
      <link>https://dev.to/yubarajsingh/my-first-scrimba-web-weekly-challenge-388p</link>
      <guid>https://dev.to/yubarajsingh/my-first-scrimba-web-weekly-challenge-388p</guid>
      <description>&lt;p&gt;I am currently enrolled in Scrimba's frontend master. I liked the teaching practice of Scrimba as they have an interactive teaching environment.In addition, they are doing a web weekly challenge and this week was a challenge to make a currency exchange page. link to challenge: &lt;a href="https://scrimba.com/scrim/coa164702a455306fc9062373?utm_source=discord&amp;amp;utm_medium=social&amp;amp;utm_campaign=wwdc&amp;amp;utm_content=wwdc_leanne_converter"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so in order to solve this problem, I use a javascript query selector to select the input value and assigning the value to a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const OriginalCurrencyAmount=document.getElementById('original-currency-amount')
const currencyUnit=document.getElementById('original-currency-unit')
const newCurrency=document.getElementById('new-currency-unit')
const exchangeRate=document.getElementById('exchange-rate')
const button=document.getElementById('exchange')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, I had to make the button click work, so I added eventlistener in the button so when it is clicked then I will trigger a function to do the calculation and show the money exchange price.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button.addEventListener('click',function(){

})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, I checked if the value is filled in the text box for validation. If the user clicked without filling in all the values then it will display a message to fill all values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(OriginalCurrencyAmount.value ==="" || currencyUnit.value ==="" || exchangeRate.value ==="" || exchangeRate.value ===""){
        document.getElementById('output-text').textContent=" please fill all values 💰"

    }
    else
   { var exchange=OriginalCurrencyAmount.value * exchangeRate.value
   document.getElementById('output-text').textContent=" your exchange rate of "+OriginalCurrencyAmount.value+ "💰 "+currencyUnit.value+ " will be "+ exchangeRate.value +" " +newCurrency.value+" currency"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, if all the values are filled then it will calculate the money exchange value simply by multiplying the exchange rate with input currency value.&lt;/p&gt;

&lt;p&gt;so here is my solution to the challenge.&lt;br&gt;
&lt;a href="https://scrimba.com/scrim/co4c841a9a41c9781769f9085"&gt;link&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Swapping A and B without 3rd variable</title>
      <dc:creator>yubaraj singh</dc:creator>
      <pubDate>Wed, 13 Jan 2021 05:55:02 +0000</pubDate>
      <link>https://dev.to/yubarajsingh/swapping-a-and-b-without-3rd-variable-14lj</link>
      <guid>https://dev.to/yubarajsingh/swapping-a-and-b-without-3rd-variable-14lj</guid>
      <description>&lt;p&gt;So my teacher gave me a task, a simple task to swap two values in our new Java class. That was an easy task as we had a good background in the Programming language. But he stated that no more than two elements were allowed. That seems a tricky one and everyone in the class was clueless cause this was the mathematical approach for solving.&lt;br&gt;
So it was a bit confusing and after finding a solution I was a bit surprised as there was indeed a better technique for swapping.&lt;br&gt;
      &lt;strong&gt;steps&lt;/strong&gt;&lt;br&gt;
        * add a and b and assign to a&lt;br&gt;
        * subtract a from b and assign to b&lt;br&gt;
        * subtract a from b and assign to a&lt;br&gt;
Now, this became our simple swapping without using the third parameter.&lt;br&gt;
Here is a code in java.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SwapTest {

  public static void main(String arg[]) {
    int a = 999999999;

    int b = 999999999;
    a = a + b;
    b = a - b;
    a = a - b;
    System.out.println("a=" + a + " b=" + b);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;disadvantage of this method in java is that while using integer it will overflow when the number is large&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>java</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
