<?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: Damon Marc Rocha II</title>
    <description>The latest articles on DEV Community by Damon Marc Rocha II (@dmarcr1997).</description>
    <link>https://dev.to/dmarcr1997</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%2F333567%2Fd19e0571-f331-44e1-8fd0-3728af08c6d5.jpg</url>
      <title>DEV Community: Damon Marc Rocha II</title>
      <link>https://dev.to/dmarcr1997</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmarcr1997"/>
    <language>en</language>
    <item>
      <title>Bash Transform and Sort commands</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sat, 07 Nov 2020 22:25:04 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/bash-transform-and-sort-commands-202</link>
      <guid>https://dev.to/dmarcr1997/bash-transform-and-sort-commands-202</guid>
      <description>&lt;p&gt;The Transform and Sort commands are another useful set of tricks to add to your bash toolbelt. The Transform command is used to replace parts of a string, file, or text with a chosen delimiter. The next section covers how to use this command and gives a few examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transform
&lt;/h2&gt;

&lt;p&gt;The template for the transform command is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;any type of text | tr "replace" "with" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before the pipe, any type of string or text reading can be used. Then after the transform or 'tr', you can put what you want replaced in the first set of parentheses and what you want it replaced within the second. A few examples are displayed below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "Hello" | tr "e" "E"
//=&amp;gt; HEllo

echo "Hello how are you" | tr " " '-'
//=&amp;gt; Hello-how-are-you

echo "Hello how are you 1234" | tr -d [0-9]
//=&amp;gt; Hello how are you 

echo "Hello how Are You" | tr -d [:lower:]
//=&amp;gt; H A Y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The third and fourth example implements an alternate template to use with the transform command. Instead of directly replacing a certain character you can instead give a flag, like the delete flag above, and then provide what you want that flag applied to. So the third command above says to delete all numbers in the text and the fourth tells the transform to delete all lowercase letters. The tr command can be used to format text in hundreds of ways, if you want to read some more on tr look &lt;a href="https://www.thegeekstuff.com/2012/12/linux-tr-command/"&gt;here&lt;/a&gt;. Now on to the sort command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sort
&lt;/h2&gt;

&lt;p&gt;So as its name implies, the sort command will sort input in text or TSV formats in various different ways. A number of flags are often used in addition to sort which changes the sorting method to the following: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No Flag: The vanilla sort command simply sorts the lines of the input file in lexicographical order.&lt;/li&gt;
&lt;li&gt;-n Flag: sorts the file on the basis of the numeric fields available if the first word or column in the file is a number.&lt;/li&gt;
&lt;li&gt;-r Flag: option reverses the sorting order to either the reverse of the usual lexicographical ordering or descending order while sorting in numerical mode.&lt;/li&gt;
&lt;li&gt;-k Flag: useful while sorting a table of data (tsv, csv etc.) based on a specified column (or columns).&lt;/li&gt;
&lt;li&gt;-t Flag: used while specifying a delimiter in a particular file where columns are separated by tabs, spaces, pipes etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Due to the examples of sort being lengthy, I decided to leave them out and either allow you to try it out yourself or look at the resources. Here are a few links with some great examples of using sort&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Sort_%28Unix%29"&gt;Sort Wiki Page&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.thegeekstuff.com/2013/04/sort-files/"&gt;Sort examples&lt;/a&gt;&lt;br&gt;
&lt;a href="https://youtu.be/h5MpG3QYSSk"&gt;Youtube video&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
    </item>
    <item>
      <title>JavaScript Proxy</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Mon, 26 Oct 2020 03:32:18 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/javascript-proxy-1nf7</link>
      <guid>https://dev.to/dmarcr1997/javascript-proxy-1nf7</guid>
      <description>&lt;p&gt;I decided to take a break from the bash blogs I have been writing to cover something I recently discovered while traversing through the world of JavaScript, Proxies.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Proxies
&lt;/h2&gt;

&lt;p&gt;A JavaScript Proxy is an object that wraps around another object and intercepts/redefines any operation on it. So in other words, A proxy watches what happens to an object and conducts methods defined by the programmer. To create a proxy you need an object and a handler function. An example is shown below&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const proxy1 = new Proxy(target, handler)

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

&lt;/div&gt;



&lt;p&gt;The target is the object you are trying to control using the handler you define. A handler usually falls into four categories: lookup, assignment, enumeration, and function invocations. These functions can implement methods called traps. In this article, I will cover get() and set().&lt;/p&gt;

&lt;h3&gt;
  
  
  get() Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
    firstName: 'John',
    lastName: 'Doe',
    email: 'john.doe@example.com',
}

const handler = {
    get(target, property) {
        return property === 'fullName' ?
            `${target.firstName} ${target.lastName}` :
            target[property];
    }
};

let proxy = new Proxy(target, handler);
console.log(proxy.fullName) //=&amp;gt; John Doe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The get trap is called when an object is accessed via the proxy item. It takes in the object and property that is being called and then returns various types of information; even that which was not originally stored in the object (e.g fullName).&lt;/p&gt;

&lt;h3&gt;
  
  
  set() Example:
&lt;/h3&gt;

&lt;p&gt;The set trap controls behavior on the object when a property is changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const triangle = {
    base: 100,
    height: 50,
}

const handler = {
    get: function (target, property){
        if(property === 'area'){
           return 0.5*target.base*target.height
        }
        return target[property]
    },
    set: function (target, property, value) {
            if (typeof value !== 'number') {
                throw new Error(`${property} must be a number.`);
            }
            if (value &amp;lt; 0) {
                throw new Error(`The ${property} must be 18 or older.`)
            }
        }
        target[property] = value;
    }
};

const proxyUser = new Proxy(triangle, handler);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Other Traps
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;apply()&lt;/li&gt;
&lt;li&gt;construct &lt;/li&gt;
&lt;li&gt;getPrototypeOf &lt;/li&gt;
&lt;li&gt;setPrototypeOf &lt;/li&gt;
&lt;li&gt;isExtensible &lt;/li&gt;
&lt;li&gt;preventExtensions &lt;/li&gt;
&lt;li&gt;getOwnPropertyDescriptor &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now I know a lot of this can be created via classes now, but I know there are &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Examples"&gt;some&lt;/a&gt;  places where a lightweight customizable Proxy would be a great option. If you agree with this then here is another &lt;a href="https://hackernoon.com/introducing-javascript-es6-proxies-1327419ab413"&gt;resource&lt;/a&gt;.&lt;br&gt;
Thanks for reading and it's back to bash next week. See you then.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>The Head and Tail of bash </title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sun, 18 Oct 2020 16:58:18 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/the-head-and-tail-of-bash-5enc</link>
      <guid>https://dev.to/dmarcr1997/the-head-and-tail-of-bash-5enc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uMUJZLiD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://64.media.tumblr.com/bc00d9419e7001c1df300c3ee942f96c/tumblr_ns7ok5rMMR1rcqnnxo1_400.gifv" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uMUJZLiD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://64.media.tumblr.com/bc00d9419e7001c1df300c3ee942f96c/tumblr_ns7ok5rMMR1rcqnnxo1_400.gifv" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Heads and Tails are not limited to the sides of a coin. In bash, these two words can be used to read from a file straight to your terminal. I found these two commands to be really useful recently and have been using them consistently. &lt;/p&gt;

&lt;h2&gt;
  
  
  Head
&lt;/h2&gt;

&lt;p&gt;Starting with head, this command allows you to read a file into your terminal starting from the beginning. By default, the first twenty lines are read but there are ways to modify this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head [filename] //=&amp;gt; First 20 lines
head -n 11 [filename] //=&amp;gt; First 11 lines  
head -30   [filename] //=&amp;gt; First 30 lines 
head -c 20 [filename] //=&amp;gt; First 20 characters  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above shows four different implementations of the head command along with the line flag(-n) and the character flag(-c).&lt;br&gt;
These can be combined with other commands to display some unique terminal outputs. &lt;a href="http://www.linfo.org/head.html"&gt;More Here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Tail
&lt;/h2&gt;

&lt;p&gt;Now onto tail; this command is similar to head but instead of reading from the beginning of the file it starts at the end. The default, like head, reads the first 20 lines from the end. The example below shows some basic uses of tail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tail [filename] //=&amp;gt; Last 20 lines
tail -n 11 [filename]  //=&amp;gt; Last 11 lines  
tail -30   [filename] //=&amp;gt; Last 30 lines
tail -c 20 [filename] //=&amp;gt; Last 20 characters  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="http://www.linfo.org/tail.html"&gt;More Here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Middle??
&lt;/h2&gt;

&lt;p&gt;By combining these commands it is possible to get sections of the text that do not start at the beginning or end. The example below reads a file from line 12 to line 22.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head -22 [filename] | tail -11 [filename]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the '|' between the two commands works as an 'and' operator so that the only lines read are those that are in the first 22 and the last 11 lines of the file. This results in terminal reading lines 12-22.&lt;/p&gt;

</description>
      <category>bash</category>
    </item>
    <item>
      <title>Bash Cut Operation</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Mon, 12 Oct 2020 21:50:31 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/bash-cut-operation-4ecf</link>
      <guid>https://dev.to/dmarcr1997/bash-cut-operation-4ecf</guid>
      <description>&lt;p&gt;As promised, here is the next addition to my bash blog series. In this article, I wanted to cover the cut operation. With knowledge of the cut operation parsing, sorting, and reading data becomes a lot easier in bash. This post covers the basics of cut and should give a good foundation to use it how you see fit. &lt;/p&gt;

&lt;h2&gt;
  
  
  Cut
&lt;/h2&gt;

&lt;p&gt;To get the information you want from your string, data, or whatever else just follow it with | cut and the flag of your choice. The example below uses the character flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read line
echo $line | cut -c 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above reads in a line and then outputs the third character of whatever was input. This is done by placing the -c(character flag) after cut and then giving the placement of the character you want from the string(starting from 1). This can also be extended to cut multiple characters using either a '-' or ','. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read line //=&amp;gt; Hello World
echo $line | cut -c 1-5 //=&amp;gt; Hello
echo $line | cut -c 1,5,8 //=&amp;gt; Hoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ATR3sXYC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1x9ibs5ronzmxpda4z7j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ATR3sXYC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1x9ibs5ronzmxpda4z7j.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cutting Flags
&lt;/h2&gt;

&lt;p&gt;There are many different flags that can be used with cut other than the character flag; read more &lt;a href="https://www.folkstalk.com/2012/02/cut-command-in-unix-linux-examples.html"&gt;here&lt;/a&gt;. I want to cover two very useful flags the -d, and -f flags. The -d or the delimiter flag specifies what to cut the input on. The -f or field flag allows you to specify the index of the items you want back from what you split with the delimiter flag. These two are often used together to get back specific chunks of information.&lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read line //=&amp;gt; hi how are you
echo $line cut -d $' ' -f 1-3 //=&amp;gt; hi how are
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are many more ways to use this command and other flags to explore. I would love to see any examples I missed here and hear any feedback to make this series better. Next week I will cover reading from a text file.  &lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
    </item>
    <item>
      <title>Linux Bash Control Flow and Arithmetic</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Mon, 05 Oct 2020 19:22:19 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/linux-bash-control-flow-and-arithmetic-35e</link>
      <guid>https://dev.to/dmarcr1997/linux-bash-control-flow-and-arithmetic-35e</guid>
      <description>&lt;p&gt;As promised, here is the next section in my Bash blog series; control flow and arithmetic. These concepts are not too hard to follow but require knowledge of their basic structure. The first section here covers control flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Control Flow
&lt;/h2&gt;




&lt;p&gt;Control flow in bash allows for comparison using &amp;lt;, &amp;gt;, =, and so many &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html"&gt;more&lt;/a&gt; operators. With this, one can compare variables to one another, or operate on files under certain conditions. &lt;br&gt;
I will give a basic example here using variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read x
read y
if [[ $x &amp;gt; $y ]]
then
    echo "X is greater than Y"
elif [[ $x &amp;lt; $y ]]
then 
    echo "X is less than Y"
else
    echo "X is equal to Y"
fi

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

&lt;/div&gt;



&lt;p&gt;For this to successfully run it is important to format the control statements as shown above; especially the spacing inside of the [[]]. Other than that, the example above is a classic and really speaks for itself. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DDNzo-P9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d2qhqvj63tgqr87bglln.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DDNzo-P9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d2qhqvj63tgqr87bglln.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Arithmetic
&lt;/h2&gt;




&lt;p&gt;It is possible to solve complex calculations using bash, and as a bonus, it is not hard to format the output. &lt;/p&gt;

&lt;h4&gt;
  
  
  Using these mathematical statements:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;5+50*3/20 + (19*2)/7&lt;/li&gt;
&lt;li&gt;-105+50*3/20 + (19^2)/7&lt;/li&gt;
&lt;li&gt;(-105.5*7+50*3)/20 + (19^2)/7&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the program below will output the solution rounded to the third decimal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read math
printf "%.3f" `echo $math |bc -l`
//=&amp;gt; first read 17.929
//=&amp;gt; second read -45.929
//=&amp;gt; third read 22.146
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mathematical statements can be read into a variable. However, to show their solution you must either wrap the variable in double parens $((..)), if you are only using integers, or use the |bc -l command if your output needs to be floating point numbers. Then this can be inserted into an echo as shown above. For more about bc go &lt;a href="https://www.geeksforgeeks.org/bc-command-linux-examples/"&gt;here&lt;/a&gt;. &lt;br&gt;
To format the output the printf must come before the echo. Then the number after the % formats your output to that decimal place.&lt;br&gt;
These commands are really useful foundations of bash that will come into play quite often. Hope you guys enjoyed this, I will get another post up sometime this week covering String Slicing and formating.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
    </item>
    <item>
      <title>Some Linux Bash Stuff</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sun, 27 Sep 2020 19:06:09 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/some-linux-bash-stuff-5ejb</link>
      <guid>https://dev.to/dmarcr1997/some-linux-bash-stuff-5ejb</guid>
      <description>&lt;p&gt;Bash stands for Bourne again shell. Bash is an interpreted language meaning it does not have to be compiled to convert the code to machine language. This is done by the shell reading the input commands and then finding the corresponding machine commands to replace each line of code. &lt;br&gt;
In this blog series, I want to cover a few of the operations of Bash. Starting with writing, reading, variables, and loops in this article.&lt;/p&gt;
&lt;h2&gt;
  
  
  Writing
&lt;/h2&gt;

&lt;p&gt;When writing to the terminal you must use the echo command followed by what you want to be written out to the screen encased in double-quotes. An example is shown below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "This is Bash"

This is Bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output strings can be customized by adding variables that can be determined at runtime. This is shown in the next section&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading and variables
&lt;/h2&gt;

&lt;p&gt;To read a variable into your bash program simply type read followed by the variable name. Then to access the variable's value put a $ before its name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;read name
echo "Hello $name!"

Hello (value in name)!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In bash, there are only four variable types available to use. These include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Integer variables&lt;/li&gt;
&lt;li&gt;Strings variables&lt;/li&gt;
&lt;li&gt;Constant variables&lt;/li&gt;
&lt;li&gt;Array variables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Declaring and instantiating an integer uses the same process as strings. As for the others, I will cover constants and arrays in a later post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loops
&lt;/h2&gt;

&lt;p&gt;The main loop used in bash is a for loop. However, there are a lot of different variations on how to implement this. I will cover the basic structure, and if you want to see more versions look at these &lt;a href="https://www.cyberciti.biz/faq/bash-for-loop/"&gt;docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The basic method is to use a range as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in {1..99..2}
do 
  echo $i
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The numbers in brackets tell the script to loop from 1 to 99 by twos and output the current number. The range can be replaced by any number of multiple items, arrays, integers, or strings.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
    </item>
    <item>
      <title>Merge Sort Algorithm </title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Tue, 22 Sep 2020 03:35:55 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/merge-sort-algorithm-82p</link>
      <guid>https://dev.to/dmarcr1997/merge-sort-algorithm-82p</guid>
      <description>&lt;p&gt;The merge sort algorithm is an effective algorithm to use when sorting a list. To sort a list, using the merge sort, two steps must be taken; split the list until the sublists are compromised of only one element and merge the sublists until the sorted array is reached.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;So first we must have a function which can split the array until its length is equal to one&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let unsorted_array = [3,5,7,2,1]

let merge_sort = (arr) =&amp;gt; {
    let mid = arr.length/2
    let first_half = arr.slice(0, midp
    let second_half = arr.slice(mid, array.length)
    if (arr.length &amp;lt; 2){
       return arr
    }
    else{
       return merge(merge_sort(first_half), merge_sort(second_half))
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above is pretty straight forward; an unsorted array and merge_sort function are created. This function splits the array and passes the two halves into itself until the array is less than two in length. Once this is achieved the single subarray are all run through the merge function.&lt;br&gt;
The next part we need to implement is the merge function. This function will return a sorted array composed of the two halves.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let merge = (first_half, second_half) =&amp;gt; {
    let sorted = []
    while(first_half.length !== 0 &amp;amp;&amp;amp; second_half.length !== 0){
          let currentMin = find_min_and_remove(first_half, second_half)
          sorted.pus(currentMin)
    return sorted.concat(first_half).concat(second_half)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The merge function appends the minimum from the two lists to the sorted array and also removes this item from its corresponding list. When one of the lists is empty the remaining elements are appended to sorted. The double append here is due to the fact that either list could become empty and allows for the absence of a check to determine which list is empty.&lt;br&gt;
Lastly, we must create the find_min_and_remove function. This function will compare the first items of every list to find the minimum&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let find_min_and_remove = (first, second) =&amp;gt; {
    let min_first = first[0]
    let min_second = second[0]
    if (min_first &amp;lt; min_second)
       return first.shift()
    else:
       return first.shift()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the list will be split into single items the first element of every list will be the minimum. So the list that contains the smaller element will have it removed and sent back to be appended to the sorted list in the merge function. &lt;br&gt;
And that is it.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Custom Middleware Function in Express </title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sun, 13 Sep 2020 21:25:45 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/custom-middleware-function-in-express-5h7a</link>
      <guid>https://dev.to/dmarcr1997/custom-middleware-function-in-express-5h7a</guid>
      <description>&lt;p&gt;So this last week I learned how to created custom middleware functions when using Express. Middleware functions are run before the main routes and can be executed on every route call or conversely when calling specific routes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Middleware functions in Express are used to accomplish four things:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Execute any code.&lt;/li&gt;
&lt;li&gt;Make changes to the request and the response objects.&lt;/li&gt;
&lt;li&gt;End the request-response cycle.&lt;/li&gt;
&lt;li&gt;Call the next middleware in the stack.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Express has a vast amount of middleware functions available for use, but if you cannot find one that fits your needs it is sooo easy to make your own. Before that, however, I want to briefly cover how to use middleware functions in Express.&lt;/p&gt;

&lt;h2&gt;
  
  
  So How Do I Use Middleware
&lt;/h2&gt;

&lt;p&gt;There are three simple ways to use middleware in express:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.use(cors())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/', cors(), (req,res) =&amp;gt;{..Controller Function..})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.post('/',[cors(), json, morgan('dev')], (req,res) =&amp;gt; {..Controller Function..})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So to explain the three examples I gave above; app.use allows the middleware function passed in to be run before every request, the next example uses middleware as the second argument in a route call and then calls the function before the controller in the route. The last example passes a list of middleware functions to be run before the controller. For more information on how to use middleware, you can go to the &lt;a href="https://expressjs.com/en/guide/writing-middleware.html"&gt;Express&lt;/a&gt; middleware page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting to the Point
&lt;/h3&gt;

&lt;p&gt;So now you know how to use middleware and want to implement your own. Well, the good news is there is only one thing to learn, the next function. Middleware functions take in three arguments the request, response, and next. The request and response are the same as what you would use in routes, so I am not going to cover that here. However, the next parameter is extremely important, if you do not want your request to time out. At the end of your middleware function, you must call next() otherwise the server will never leave your function. To show this I built a simple middleware function that logs the data to be passed into a post route.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const logData = (req,res, next) =&amp;gt; {
      console.log(`Data: ${req.body}`)
      next() 
}
app.post('/data', logData, (req,res) =&amp;gt; {
    res.send({message: 'Got the data'})
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice anything, familiar. The middleware function is nothing special, it is literally a javascript function that can be anything you want as long as it ends in next() and is either set up to be called by express using app.use or in a route as shown above.&lt;br&gt;
So go create some awesome middleware. I would love to see the things you guys can create with this.&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Node, Express, and Postman</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sun, 06 Sep 2020 23:28:49 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/node-express-and-postman-4pc4</link>
      <guid>https://dev.to/dmarcr1997/node-express-and-postman-4pc4</guid>
      <description>&lt;p&gt;I love the freedom Node and Express give you in creating APIs. Having started my back-end journey in Ruby on Rails, my first impression of Express was not great due to the lack of structure in setup. However, after some tutorials and walkthroughs, I saw the beauty of Node and Express. As for Postman, it is an awesome application that makes creating APIs and testing servers a lot easier, download it &lt;a href="https://www.postman.com/downloads/"&gt;here&lt;/a&gt;. &lt;br&gt;
The purpose of this blog is to show the set up of a simple Webserver in Node and Express and to show the awesomeness of Postman.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F3TMl3F3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/03d7pioqscz1v20k84ry.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F3TMl3F3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/03d7pioqscz1v20k84ry.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Node and Express Webserver Setup
&lt;/h2&gt;

&lt;p&gt;So first make sure you have &lt;a href="https://nodejs.org/en/download/"&gt;Node&lt;/a&gt; and &lt;a href="https://expressjs.com/en/starter/installing.html"&gt;Express&lt;/a&gt; installed. Once you have these run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev nodemon 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows your app to continuously update along with the changes you make in your code. Now with all of your dependencies setup run &lt;strong&gt;&lt;em&gt;npm init -y&lt;/em&gt;&lt;/strong&gt; and make sure your JSON file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "back_end",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "nodemon index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "uuid": "^8.3.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.4"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Ok let's actually start now
&lt;/h4&gt;

&lt;p&gt;First, create an index.js file and a folder named routes with a user.js file. In the index.js file, a couple of things need to be set up before we can start the server. First import all of your awesome packages and stuff&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express';
import bodyParser from 'body-parser';
import usersRoutes from './routes/users.js';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you need to create an express app and set up the port you want your server to run on&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const app = express();
const PORT = 5000;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Depending on what your server returns this step can vary. If you plan on using something other than JSON refer to the docs &lt;a href="http://expressjs.com/en/resources/middleware/body-parser.html"&gt;here&lt;/a&gt;. Otherwise set the app to use JSON with the bodyparser.json() function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.user(bodyParser.json());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost there, all that's left is to set up the listener function and the root route. To set up the listener call app.listen() with the PORT variable as the first parameter and a function to be called on the successful running of the server as the second parameter. The root route requires you to call app.get() as shown below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.listen(PORT, () =&amp;gt; console.log(`Server running on PORT: http://localhost:${PORT}`));

app.get('/', (req, res) =&amp;gt; res.send('Hello from Homepage'))

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

&lt;/div&gt;



&lt;p&gt;The first argument of the get function sets the routes name; for example, I set up the route / above. The second argument is a function that takes in two arguments the request and response. The request argument, or req, are the parameters sent to the webpage and are how we are going to get the user id and create new users later on. The response argument, or res, sends information to the browser using res.send(). With that all done, the Webserver is setup. &lt;/p&gt;

&lt;h3&gt;
  
  
  Now On to the Good Stuff
&lt;/h3&gt;

&lt;p&gt;At this point, the webserver does not do much. To remedy this we will create a user index, show, and post route(which I will show in the postman section).&lt;br&gt;
First, go into users.js and import some stuff&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express';
import { v4 as uuidv4 } from 'uuid'; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then set up an Express router. Router creates a mini-application that performs middleware and routing functions similar to our app in the index file. Router cannot, however, send or receive information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const router = express.Router();

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

&lt;/div&gt;



&lt;p&gt;To get the index and show requests working you must first create two routes in the user.js file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const users = []

//using / because we will set up /users in index.js
router.get('/', (req, res) =&amp;gt; {
    res.send(users); //displays users in the browser
})

router.get('/:id', (req, res) =&amp;gt; {
    const { id } = req.params; //gets parameters from browser
    //namely the :id 
    let foundUser = users.find((user) =&amp;gt; user.id === id);
    //gets user from list of users
    if (!foundUser){
        foundUser = {"error" : "User not found"} ;
        //if user not found return error
    }
    res.send(foundUser); //send user to browser
})
router.post('/', (req, res) =&amp;gt;{
    const user = req.body; //get post request content
    users.push({ "id": uuidv4(), ...user}); //add an id 
    res.send(users) //display updated users
})
export default router;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the first route might look like it over-rights the root directory, but this is not the case. In index.js we import the user routes exported and set its parent director to /users. This then appends the / or the /:id; depending on which is requested in the browser. At this point, we can look at all of the users, any individual user, and create a new user, so we are done. &lt;/p&gt;

&lt;h2&gt;
  
  
  POSTMAN
&lt;/h2&gt;

&lt;p&gt;Most browsers only allow users to implement get requests. Postman is an application that gives developers access to any type of request available. I can think of so many projects that this project would have made so much easier. Below are a few screenshots I took testing out the webserver we created above.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IlJRtKf9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i44yiw5pnjucqcrr1wvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IlJRtKf9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i44yiw5pnjucqcrr1wvk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i_Y505g3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cvp78p1xisbzbygt7vya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i_Y505g3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cvp78p1xisbzbygt7vya.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>postman</category>
    </item>
    <item>
      <title>Binary Search </title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Tue, 01 Sep 2020 15:40:52 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/binary-search-10ie</link>
      <guid>https://dev.to/dmarcr1997/binary-search-10ie</guid>
      <description>&lt;p&gt;Binary Search is an algorithm that finds an item in a list by continuously comparing the middle list item with the item you are looking for. It then splits the list to the left if the middle is greater or to the right if the middle is smaller. &lt;br&gt;
I have seen a lot of programs that implement this with arrays and numbers which is very useful but I wanted to create a version with an array of objects, which encase strings and numbers, that finds a certain entry based on the number.&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;So to start making this, get an object, any will do but in case you are having a hard time thinking of one here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let names = [
  {"Adeline Garrett": 11},
  {"Carlene Stevenson": 24},
  {"Glen Moyer": 36},
  {"Tamara Vega": 47},
  {"Cecile Dixon": 54},
  {"Sebastian Burton": 69},
  {"Natasha Sloan": 75},
  {"Roger Crawford": 83},
  {"Damien Hensley": 93},
  {"Josie Frost": 103},
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now for the binary search, create a function that splits the array in half and gets the value from the midpoint. Since the array is already sorted this is pretty easy. Then implement recursion until the entry is found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
let binSearchObj = ( arr, numb) =&amp;gt; {
    let midPoint = Math.floor(arr.length / 2); //get mid index
    let mid = Object.values(arr[midPoint])[0]; //get mid value
    if (mid &amp;gt; numb) {
        let newArr = arr.slice(0, midPoint); 
        //slice the array from the beginning to the midPoint 
        return binSearchObj(newArr, numb); 
        //recursively call the function again with the sliced 
        //array
    }
    if (mid &amp;lt; numb) {
        let newArr = arr.slice(midPoint, arr.length); 
        //slice the array from the midpoint to the end
        return binSearchObj(newArr, numb);
        //recursively call the function again with the sliced 
        //array
    return arr[midPoint];
    //if the function gets to this point then the only thing left 
    //is what you are looking for
}

console.log(binSearchObj(names, 103))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try this out with some different arrays. The example above did not implement a check for non-existent search items yet, so I leave that to you to figure out how to do it. This is just a good start for a more robust binary search algorithm&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Deutsch's algorithm </title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sun, 23 Aug 2020 22:07:56 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/deutsch-s-algorithm-4cc</link>
      <guid>https://dev.to/dmarcr1997/deutsch-s-algorithm-4cc</guid>
      <description>&lt;p&gt;This week I decided to cover Deutsch's algorithm. Deutsch's algorithm is a simple demonstration of quantum parallelism and interference. So first, let me explain quantum parallelism and interference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quantum parallelism
&lt;/h2&gt;

&lt;p&gt;Quantum parallelism is the ability for quantum memory to exist in a superposition of states. So this means that any bit or qubit of memory can simultaneously be a 1 or a 0. This allows for faster calculations to complex problems since the entire range of variables can be tested at the same time. This, however, results in multiple outputs of what the solution could be. These outputs are attached to a probability of how correct the answer is. One of the main uses of Deutsch's algorithm is to simulate this issue and output an answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quantum Interference
&lt;/h2&gt;

&lt;p&gt;Quantum interference is a result of superposition. In quantum computers, this allows for a collapse of the multiple states into probabilities of the desired outcome. Then using an algorithm, similar to the one explained later in this article, the solution can easily be determined from these variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Deutsch's Algorithm
&lt;/h2&gt;

&lt;p&gt;Deutsch's Algorithm was created by David Deutsch and Richard Jozsa in 1992 as a simple example of how quantum computers could easily outperform a standard computer. The algorithm determines whether a function is balanced or constant based on two separate inputs. If these inputs are the same the function returns a zero otherwise it returns a one. To solve this function using a classical computer both inputs must be examined separately but using a quantum computer this can be done simultaneously due to the properties explained in the first two sections.&lt;/p&gt;

&lt;h1&gt;
  
  
  Ok So How to Put this in code
&lt;/h1&gt;

&lt;p&gt;To translate this into code first we must import random, cirq, and to make our lives easier directly import some of cirq's methods&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import random 
import cirq
from cirq import H, X, CNOT, measure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we must create two helper functions. The first function makes the oracle, which will determine what each number is and then return circuit moments based on this number. Then the other creates the circuit which we will use towards the end of the main function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def make_oracle(q0, q1, secret_numbers):

    if secret_numbers[0]:
        yield[CNOT(q0,q1), X(q1)] 
        #if the first number is 1 yield 
        #CNOT gate and X gate moments

    if secret_numbers[1]:
        yield CNOT(q0, q1) 
        #if the second number 
        #is 1 yield CNOT gate

def make_circuit(q0, q1, oracle):
    c = cirq.Circuit()

    c.append([X(q1), H(q1), H(q0)]) 
    #append X gate and 
    #two H gates to the circuit

    c.append(oracle) 
    #append oracle to circuit

    c.append([H(q0), measure(q0, key='result')]) 
    #append H gate on first qubit 
    #and then a mesure function to determine the output.

    return c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now since this is done, all that is left is to create two LineQubits, create a list of random numbers, call our helper functions, and then run them through a simulator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def main():
    q0, q1 = cirq.LineQubit.range(2) 
    #create 2 qubits

    secret_numbers = [random.randint(0,1) for i in range(2)] 
    #create list of two numbers

    oracle = make_oracle(q0, q1, secret_numbers) 
    #create oracle moment to process 
    #the numbers in the list
    print('Secret function:\nf(x) = &amp;lt;{}&amp;gt;'.format(', '.join(str(e) for e in secret_numbers))) 
    #print out list numbers

    circuit = make_deutsch_circuit(q0,q1, oracle) 
    #create circuit
    print("Circuit:") 
    print(circuit) 
    #print it out

    simulator = cirq.Simulator() 
    #create simulator
    result = simulator.run(circuit)
    #run circuit through simulator
    print('Result of f(0)⊕f(1):') 
    print(result) #print result

if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a simple application of quantum computers and in the future, I will post some more complicated examples. I recommend you run this one a few times to see the different outputs and circuits that are created.&lt;br&gt;
For some examples of more gates or to read on the ones listed here go to &lt;a href="https://cirq.readthedocs.io/en/stable/gates.html"&gt;Gates&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>cirq</category>
    </item>
    <item>
      <title>Selenium Webdriver for Automation</title>
      <dc:creator>Damon Marc Rocha II</dc:creator>
      <pubDate>Sun, 16 Aug 2020 23:47:06 +0000</pubDate>
      <link>https://dev.to/dmarcr1997/selenium-webdriver-for-automation-god</link>
      <guid>https://dev.to/dmarcr1997/selenium-webdriver-for-automation-god</guid>
      <description>&lt;p&gt;So I recently wanted to create an application to automate the job application process. This project is still a work in progress and was really just meant to be a break from what I have been working on. Using selenium and Monster's easy application process, I got my program to apply to various speed-apply jobs. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;First I imported requests and webdriver from selenium. Then got the monster job URL for software jobs in texas and passed it into my chrome driver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
from selenium import webdriver
URL = 'https://www.monster.com/jobs/search/?q=Software-Developer&amp;amp;where=texas'
driver = webdriver.Chrome(chromedriver_location)
driver.get(URL)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the program logged me in using the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.find_element_by_tag_name("ul a").click()
driver.find_element_by_id("email").send_keys("email")
driver.find_element_by_id("password").send_keys("password")
driver.find_element_by_id("btn-login").click()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Job Application
&lt;/h2&gt;

&lt;p&gt;When I first started this I tried to go through each application and have the program fill in my information and apply. This worked well for one job but the driver was slower than the code and caused some issues. So I decided to just select the speed-apply jobs and apply to these. However, the issue then arose that the page some times had different numbers of jobs so I implemented the solution below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for num in range(0, 50):
    try:
        jobs = driver.find_elements_by_tag_name('h2 a')
        jobs[num].click()
    except:
        driver.find_element_by_class_name('mux-search-results').click()
        jobs = driver.find_elements_by_tag_name('h2 a')
        jobs[num].click()
    try:
        apply = driver.find_element_by_id('speedApply')
        if apply:
            apply.click()
            print(f"applied to job {num}")
    except:
        print(f"job {num}")
        print("Gotta do more")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, I go through 50 jobs(Sometimes). If there are no more jobs the program then presses the more jobs button. Once these results are loaded the program will try to continue through the process. This works for the most part but as of now, I am running into issues with some of the speed applies.&lt;/p&gt;

&lt;p&gt;With this, I have successfully applied for a handful of jobs on Monster using Selenium and python code.&lt;/p&gt;

</description>
      <category>python</category>
      <category>selenium</category>
    </item>
  </channel>
</rss>
