<?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>Forem: Dekel</title>
    <description>The latest articles on Forem by Dekel (@dekel).</description>
    <link>https://forem.com/dekel</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%2F584045%2F0325eb17-b83e-4024-833e-3f7971bad5db.jpeg</url>
      <title>Forem: Dekel</title>
      <link>https://forem.com/dekel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dekel"/>
    <language>en</language>
    <item>
      <title>Last Week I Wrote Some jQuery (and no one fired me 🤓)</title>
      <dc:creator>Dekel</dc:creator>
      <pubDate>Sun, 15 Aug 2021 20:40:42 +0000</pubDate>
      <link>https://forem.com/dekel/last-week-i-wrote-some-jquery-and-no-one-fired-me-3iao</link>
      <guid>https://forem.com/dekel/last-week-i-wrote-some-jquery-and-no-one-fired-me-3iao</guid>
      <description>&lt;p&gt;Short disclaimer - Yes. The title of this post is a bit of a clickbait. Not 100%, but you can definitely read it as one. I’m not your standard full-time employee, so it’s gonna be a bit hard to fire me, but I still decided to write some jQuery code, and everyone was happy with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  So, let’s rewind a bit
&lt;/h3&gt;

&lt;p&gt;I started using jQuery ~15 years ago (around the time it was released). It was the “go-to” for everything you needed to do, and I think it’s safe to assume that almost every website back in the day included the &lt;code&gt;&amp;lt;script src="jquery.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt; line in it. It was even before the days of &lt;code&gt;cdnjs&lt;/code&gt; (where the standard for using jquery became &lt;code&gt;&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt; and all javascript content was served directly from the websites you built without using any cdn).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.jquery.com" rel="noopener noreferrer"&gt;jQuery&lt;/a&gt; was used originally to make it easy for developers to write code that just works. Unlike today, back in the day browsers had different standards and in order for your code to run smoothly (or just work?) on different browsers - there were many things you needed to learn and remember how to do, and some of the standard things that we have today (&lt;code&gt;document.querySelector&lt;/code&gt;) weren’t available (or didn’t work as expected). Using jQuery provided a very easy and standard way to access elements (DOM manipulation), work with events and know that everything will work, regardless of the browser your users used to access your website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cggt4n378h9e8xqn4v6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1cggt4n378h9e8xqn4v6.png" alt="image"&gt;&lt;/a&gt;Photo by &lt;a href="https://pixabay.com/users/pexels-2286921/" rel="noopener noreferrer"&gt;@Pexels&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  jQuery UI
&lt;/h3&gt;

&lt;p&gt;Following the wide usage of jQuery - another lib was released, called &lt;a href="https://jqueryui.com/" rel="noopener noreferrer"&gt;jQuery-UI&lt;/a&gt;. According to the website:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some of the features that jQuery-UI provides are easy to use APIs for &lt;a href="https://jqueryui.com/draggable/" rel="noopener noreferrer"&gt;draggable&lt;/a&gt; elements, which are super easy and can save us a lot of time if we need to handle everything that is related to drag&amp;amp;drop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1s796w40abxlj53kulq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1s796w40abxlj53kulq3.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Back To Last Week
&lt;/h3&gt;

&lt;p&gt;So last week I needed to create the following interface:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A simple page that shows a container (a rectangle with some background image).&lt;/li&gt;
&lt;li&gt;Inside the container we need to display circles (we have a list of the x/y position of each circle).&lt;/li&gt;
&lt;li&gt;Each circle can be dragged, but only on the Y-axis.&lt;/li&gt;
&lt;li&gt;The dragging/dropping can be only inside the container.&lt;/li&gt;
&lt;li&gt;When finished - we need to save (console.log, for now) the new positions of the circles.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since it was a POC I decided it’s best to do “quick-n-dirty” work with jQuery, which eventually took ~3 hours. The jQuery-UI lib with the draggable API saved me a lot of time, and since it was a POC I didn’t really care if it would be written using some up-to-date framework (react/vue).&lt;br&gt;
One of the nice things about the draggable API of jQuery-UI is that the &lt;code&gt;axis&lt;/code&gt; (which gave me a quick solution for the Y-axis only dragging) and the &lt;code&gt;containment&lt;/code&gt; (which provides a way to hold the dragged circles inside the container):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#container span&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;draggable&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;axis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;y&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;containment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;parent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://jsfiddle.net/wrd9mfkz//embedded/result,html,js,css//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The final version also contains an option to upload the image/the dataset (the positions of the circles) and a few more things, but for this post I included this version of the code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;Working with jQuery might not be the first choice of most people (and probably also not my first choice for most projects), but it really depends on which project you are currently working on. Yes, sometimes it’s better to just write vanilla javascript, and in case you need something that is a bit more than ~20-30-40 lines of code and is more complex - it’s probably better to use one of the standard and up-to-date frameworks, but you shouldn’t be afraid to use everything that you have in your disposable to provide fast solutions.&lt;/p&gt;


&lt;p&gt;Thinking about what someone will do with your code is not something you should ignore, but if you work on something that is only a POC and you just need to understand if there is a future for that code and someone will actually use it - before over engineer and start a project that will take a week - it’s ok to do something that is “quick and dirty” just to get a feeling and understand how and what to do from here. &lt;/p&gt;

Cover photo by &lt;a href="https://pixabay.com/users/viarami-13458823/" rel="noopener noreferrer"&gt;Markus Winkler @ pixabay&lt;/a&gt;

</description>
      <category>discuss</category>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Let’s Talk About Juniors</title>
      <dc:creator>Dekel</dc:creator>
      <pubDate>Sun, 08 Aug 2021 19:56:39 +0000</pubDate>
      <link>https://forem.com/dekel/let-s-talk-about-juniors-5ahm</link>
      <guid>https://forem.com/dekel/let-s-talk-about-juniors-5ahm</guid>
      <description>&lt;p&gt;Over the last couple of years, I was privileged to work with many juniors. I have mentored, helped, hired, fired, consulted, read CVs, advised friends and colleagues on hiring juniors, and decided it’s time to write down my two cents on the topic.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This post is focused mostly on junior developers, but I’m sure its content can be relevant to other positions as well.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are so many juniors out there. Every year we have thousands of new developers finishing their degrees, whether from universities or colleges and let’s not forget all of the bootcamps, online courses, and self-educated people who just go and learn online. We live in an era where most (if not all) of the learning material is just out there - waiting for people to consume it.&lt;/p&gt;

&lt;p&gt;Juniors are eager to start their careers, but unfortunately, there aren’t many positions for people without any background, and most companies prefer to go with experienced employees (whether seniors or "junior with 2 years experience").&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ro8ou7o603w39ebwzql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ro8ou7o603w39ebwzql.png" alt="image"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@debbieducic" rel="noopener noreferrer"&gt;@debbieducic&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Open Positions
&lt;/h3&gt;

&lt;p&gt;Whenever a new junior position is being published - there are so many candidates that send over their CVs. LinkedIn is one of the main resources for those publications - whether directly on the LinkedIn Jobs section, or posts that people share on their feed. But there are other places as well. Many juniors are members of groups that share those open positions - Telegram groups, WhatsApp groups, Facebook groups, and more. Many people volunteer to find and share new open positions in those groups - just to help other juniors start their journey.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Check out these job ads on LinkedIn:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvy8i353i3alfcpnixo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvy8i353i3alfcpnixo2.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Only 2-3 days, and already more than 200 candidates submitted their CVs to these positions.&lt;/p&gt;

&lt;p&gt;With so many candidates it’s super hard for the managers who are in charge of the hiring process to actually go over each and every CV and give it enough attention. As a candidate - if you really want to be one of the few selected to continue the process - you must find a way to stand-out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fehjh72ecikjnwfn9c8xg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fehjh72ecikjnwfn9c8xg.png" alt="image"&gt;&lt;/a&gt;Photo by &lt;a href="https://pixabay.com/users/geralt-9301/" rel="noopener noreferrer"&gt;@geralt&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Standing Out as a Junior Developer
&lt;/h3&gt;

&lt;p&gt;There are so many ways to make sure that your CV gets the right attention, but regardless of the design/colors/fonts/professional photo/cleanliness - here are a few things that can help you stand-out and make sure that your CV does not get skipped accidentally:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;LinkedIn profile is a must.&lt;/li&gt;
&lt;li&gt;Add some intro paragraph about yourself - what is the type of position you are after, what are your strengths, how would the company benefit from your experience if they take you.&lt;/li&gt;
&lt;li&gt;Make sure to include a link to your GitHub account.&lt;/li&gt;
&lt;li&gt;Have some interesting repositories in your GitHub account.
Projects that you worked on (and not the standard "to-do list"; that is probably one of the most-common projects for juniors).&lt;/li&gt;
&lt;li&gt;A portfolio is great, if you can have one. Definitely not a must, but at the end of the day - you want to show that you are better than the other CVs in the pack, and a decent portfolio is indeed a way of showing that you are better.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Why put so much attention to the CV?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9s6dj5lh1jb0chek7zhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9s6dj5lh1jb0chek7zhz.png" alt="image"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@brandsandpeople" rel="noopener noreferrer"&gt;@brandsandpeople&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Think of it this way - I’m hiring a junior, and I’m getting 200 CVs. Let's assume that half of them contain GitHub accounts, and the other half doesn’t. Unfortunately - I have only one position, and I must skim very quickly over all of those CVs. Whether it’s intentional or not - CV that does not contain a link to a GitHub account, where I can actually go and read some code - gets lower priority. Out of the half that does have GitHub accounts - I will be able to read some code and understand which is better and worth my time to actually call the candidate and check if we can move on to the next steps.&lt;br&gt;
Eventually - you as a candidate should help the hiring person focus on your CV and move it up the stack. It’s your job to stand-out.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Are The Benefits in Hiring Juniors?
&lt;/h3&gt;

&lt;p&gt;This question is something that you hear from so many managers. Assuming your company has enough money to hire only seniors - why would you hire juniors at all? It’s no secret that sometimes you hire juniors because their salary is lower. No one would say otherwise. But salary is not everything. There are many other reasons to hire juniors as well:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Juniors have less experience, but they can come with fresh perspectives.&lt;/li&gt;
&lt;li&gt;Hiring juniors requires you to spend time on mentoring - which is good for everyone. You might have a small team and consider promoting someone to a team-lead - putting them developer in charge/mentor for 1-2 juniors (without officially giving a title) is a great way to check if it can work in the future.&lt;/li&gt;
&lt;li&gt;With great power comes great responsibility; you can (and should) make your team of juniors better with time - making you a better team lead/manager, in the process.&lt;/li&gt;
&lt;li&gt;Seniors are hard to find. It’s a fact. Hiring seniors is a long process and during that time - juniors can help you grow your business.&lt;/li&gt;
&lt;li&gt;Juniors are eager to show they are worth it. They are eager to learn and motivated to be part of the team and start working on "real world" problems.&lt;/li&gt;
&lt;li&gt;There are always tedious tasks. Even if way say that everything in our company is super interesting and nothing is boring - eventually - there will be something that our seniors will prefer not to do (and will be super interesting for a junior that never did it before).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Finding The Right One
&lt;/h3&gt;

&lt;p&gt;Like every process - finding the right junior can take time. It's not only about finding the most brilliant one, or the one that has the best grades, but it's also about finding the one that you can motivate, mentor, direct and grow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e4pln4xjawyxdk5j16y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e4pln4xjawyxdk5j16y.png" alt="image"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@benjaminsweet" rel="noopener noreferrer"&gt;@benjaminsweet&lt;/a&gt;&lt;/p&gt;




Cover photo by &lt;a href="https://unsplash.com/@goian" rel="noopener noreferrer"&gt;Ian Schneider @ unsplash&lt;/a&gt;

</description>
      <category>discuss</category>
      <category>100daysofcode</category>
      <category>career</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Tagged Template Literals - The Magic Behind Styled Components</title>
      <dc:creator>Dekel</dc:creator>
      <pubDate>Sun, 01 Aug 2021 08:11:48 +0000</pubDate>
      <link>https://forem.com/dekel/tagged-template-literals-the-magic-behind-styled-components-2f2c</link>
      <guid>https://forem.com/dekel/tagged-template-literals-the-magic-behind-styled-components-2f2c</guid>
      <description>&lt;h3&gt;
  
  
  Intro &amp;amp; Background
&lt;/h3&gt;

&lt;p&gt;If you have some experience with React, you probably came across &lt;a href="https://styled-components.com/"&gt;styled-components&lt;/a&gt;. In the last few years, the concept of css-in-js became more popular, and there are multiple libraries that are available for us to use. styled-components is one of them, but you can also find &lt;a href="https://emotion.sh/docs/styled"&gt;Emotion&lt;/a&gt;, &lt;a href="https://formidable.com/open-source/radium/"&gt;Radium&lt;/a&gt;, &lt;a href="https://cssinjs.org/"&gt;JSS&lt;/a&gt;, and more. In this post I'm &lt;strong&gt;not going&lt;/strong&gt; to cover the pros and cons of traditional stylesheet files vs. styled-components, and instead - I'm going to focus on tagged template literals - the "magic" that let us use the &lt;code&gt;styled-components&lt;/code&gt; syntax.&lt;/p&gt;

&lt;h3&gt;
  
  
  styled-component basics - a quick reminder
&lt;/h3&gt;

&lt;p&gt;Let's take the following simple syntax for example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/en9vg"&gt;
&lt;/iframe&gt;
&lt;br&gt;
The &lt;code&gt;StyledDiv&lt;/code&gt; in the example above is actually a React component that returns a &lt;code&gt;div&lt;/code&gt; block with the css of &lt;code&gt;color: red; font-weight: bold;&lt;/code&gt;.&lt;br&gt;
Well... kind of. Actually - it's a bit more complicated than that. The output of the above is a div with specific css class-names having the above css definitions inside:


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;br&gt;&lt;br&gt;
Some of you are probably using this without giving it too much of a thought. If we take a closer look we can see the usage of the backtick (&lt;code&gt;`&lt;/code&gt;) right after the &lt;code&gt;styled.div&lt;/code&gt;.&lt;br&gt;
This syntax in Javascript is called &lt;strong&gt;Tagged Template Literals&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Template Literals
&lt;/h3&gt;

&lt;p&gt;Let's start with &lt;code&gt;Template Literals&lt;/code&gt;, and then move on to the more interesting concept.&lt;br&gt;
In javascript - template literals are strings that can contain expressions within them:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;As you can see from the example above - expressions can be variables, but are not limited to them:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We can use either variable or function inside a template literal, and the value that will be used is basically the string representation of the expression:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now that we understand the power of template literals - it's time to move on to tagged template literals - or just tagged templates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tagged Templates - Whats the fuzz?
&lt;/h3&gt;

&lt;p&gt;With tagged templates, we have the power to parse the template literal ourselves using our own "home-made" function.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Note that in the example above - the variable &lt;code&gt;strB&lt;/code&gt; contains the string &lt;code&gt;String A&lt;/code&gt; (and not &lt;code&gt;String B&lt;/code&gt; as you might expect).
&lt;h4&gt;
  
  
  Let's break it down
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;The function &lt;code&gt;funcA&lt;/code&gt; returns the string &lt;code&gt;String A&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;By using the function &lt;code&gt;funcA&lt;/code&gt; as a tagged template - we completely ignored the string that was sent, and we just return something else.&lt;/li&gt;
&lt;li&gt;We can use it with an empty string, and the output will be the same.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Check it out:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Advanced features
&lt;/h3&gt;

&lt;p&gt;The function we use in a tagged template can return everything that we want - we are not limited to only return strings:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Building tagged templates have an option to also accept variables that can be used:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The first argument is a special object, which behave as an array and provides access to all the "native strings" in the original string that was passed to the tag-template function (&lt;code&gt;strings[0]&lt;/code&gt;, &lt;code&gt;strings[1]&lt;/code&gt;, &lt;code&gt;strings[2]&lt;/code&gt;), alongside a &lt;code&gt;raw&lt;/code&gt; property, which allows you to access the original raw strings.&lt;/p&gt;

&lt;p&gt;The rest of the arguments are the expressions that we used inside the template literal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Time to build - let's start with something basic
&lt;/h3&gt;

&lt;p&gt;Now that we know a bit more about template literals it's time to move on to some more complex examples.&lt;br&gt;
We already know that template literals don't have to return strings, so how about creating a simple example of a tagged template that returns a react component with the relevant style?&lt;br&gt;
We will start by creating a simple div example to just wrap our text with some styling on it:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The tagged template is the following code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
The full example is available here:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/oz3oo"&gt;
&lt;/iframe&gt;


&lt;blockquote&gt;
&lt;p&gt;Check out the helper functions (the &lt;code&gt;cssObjFromStr&lt;/code&gt;). we are going to focus on it in the next example.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Using props in the component
&lt;/h3&gt;

&lt;p&gt;The basic example gave us a nice intro, but what about the component's props? We use them all the time in React, and losing them is not an option. Moving to the next example, we will add the option to also use props as part of our component that we would like to style:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We will use the &lt;code&gt;onClick&lt;/code&gt; prop on the div element.&lt;br&gt;
The full example is here:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/n6q3q"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Using props in the template
&lt;/h3&gt;

&lt;p&gt;Props are not only relevant to the components, but also to the template itself. We want to use the props of the component inside the template itself - colors, elements behavior, and more.&lt;br&gt;
To do this we will need to pass the props from the &lt;code&gt;&amp;lt;Div...&amp;gt;&lt;/code&gt; to the &lt;code&gt;cssObjFromStr&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;But this is not enough.&lt;br&gt;
Let's assume that we use the &lt;code&gt;&amp;lt;Div&amp;gt;&lt;/code&gt; element with the property &lt;code&gt;textColor="blue"&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The issue we face here is that the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; component (inside the &lt;code&gt;cmp&lt;/code&gt;) will get the &lt;code&gt;textColor&lt;/code&gt; property, which is not a valid property of a &lt;code&gt;div&lt;/code&gt; element.&lt;br&gt;
A specific solution can be to extract the &lt;code&gt;textColor&lt;/code&gt; from the &lt;code&gt;props&lt;/code&gt;, and pass the rest of the properties down to the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Working example can be found here:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/eeeef"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The styled-components solution is a bit more elegant (and much more generic) - all props that start with &lt;code&gt;$&lt;/code&gt; are considered "private props" and will not pass down to the actual jsx component.&lt;br&gt;
We will use the same concept, but in our example, we will use the _ (underscore) to create private props.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Full working example can be found here:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/vjffb"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;


&lt;p&gt;The styled-component library contains much more than that, with the entire built-in HTML tags, wrapped-components, classes and inheritance (instead of inline-style), global themes and more, however styled-components is just an example of how to use the tagged template literals, which is eventually "just" a native javascript feature as of ECMAScript 2015 (also known as ES6).&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

Cover photo by &lt;a href="https://pixabay.com/users/geralt-9301/"&gt;Gerd Altmann @ pixabay&lt;/a&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Setup a new mac (for devs [and others]) 💻</title>
      <dc:creator>Dekel</dc:creator>
      <pubDate>Sun, 25 Jul 2021 08:17:36 +0000</pubDate>
      <link>https://forem.com/dekel/setup-a-new-mac-for-devs-and-others-4d88</link>
      <guid>https://forem.com/dekel/setup-a-new-mac-for-devs-and-others-4d88</guid>
      <description>&lt;blockquote&gt;
&lt;h3&gt;
  
  
  "Got a new macbook🥳! What should I install now 🧐?"
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm getting this question every couple of weeks from friends and colleagues, and every time I'm sending them instructions on what and how to install in order to setup their environment to make their experience better.&lt;/p&gt;

&lt;p&gt;There are many tools/apps/configurations that you can use to make your life easier and your experience better with your mac.&lt;/p&gt;

&lt;p&gt;So I decided to finally write everything down and share it (instead of copy&amp;amp;paste emails/whatsapp/slack/discord messages).&lt;/p&gt;

&lt;p&gt;Here is my basic setup and recommendations for others.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key repeat &amp;amp; delay
&lt;/h3&gt;

&lt;p&gt;Change the key repeat and repeat delay - this is usually the first thing I'm changing:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9pumsm9qex5wahe9qhy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9pumsm9qex5wahe9qhy.png" alt="image" width="500" height="160"&gt;&lt;/a&gt;&lt;br&gt;
You can find it under &lt;code&gt;System Preferences -&amp;gt; Keyboard&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;And if you like the red arrows - keep on reading&lt;/em&gt; 😉&lt;/p&gt;
&lt;h3&gt;
  
  
  Screenshots to clipboard
&lt;/h3&gt;

&lt;p&gt;By default, screenshots are saved to your desktop. To change this - click &lt;code&gt;⌘+shift+5&lt;/code&gt; and under the "options" menu set the "save to" to "Clipboard".&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To capture an area use &lt;code&gt;⌘+shift+4&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To capture the entire screen use &lt;code&gt;⌘+shift+5&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;⌘&lt;/code&gt; is the &lt;code&gt;command&lt;/code&gt; key. You can find it left to your &lt;code&gt;space&lt;/code&gt; key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'll start with some general tools that just make my life easier:&lt;/p&gt;
&lt;h3&gt;
  
  
  Rectangle
&lt;/h3&gt;

&lt;p&gt;Rectangle is an open-source tool that gives you the ability to easily move the windows-apps around your desktops using your keyboard (left-half / right-half / top / bottom etc)&lt;br&gt;
&lt;a href="https://rectangleapp.com/" rel="noopener noreferrer"&gt;https://rectangleapp.com/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frx86fko6w3zm7ck1invi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frx86fko6w3zm7ck1invi.png" alt="image" width="249" height="358"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Monosnap
&lt;/h3&gt;

&lt;p&gt;Monosnap is a tool to edit your screenshots. They have both paid and free versions (for personal usage).&lt;br&gt;
Remember the red arrows? This is what you want:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqj4r9pt9cz48ccndesc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqj4r9pt9cz48ccndesc5.png" alt="image" width="500" height="263"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://monosnap.com/" rel="noopener noreferrer"&gt;https://monosnap.com/&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Homebrew
&lt;/h3&gt;

&lt;p&gt;This is the de-facto package manager for macos (as a developer - most of the packages you need you can install using homebrew).&lt;br&gt;
Open your terminal (cmd + space) and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  AltTab
&lt;/h3&gt;

&lt;p&gt;Personally, I don't use this tool, but many of my friends like it, so I decided to keep it on my list.&lt;br&gt;
If you moved from Windows to MacOS - AltTab is probably your friend - it brings the power of Windows's "alt-tab" functionality to your Mac.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0f6s5io49e0x1rrhigi2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0f6s5io49e0x1rrhigi2.png" alt="image" width="550" height="331"&gt;&lt;/a&gt;&lt;br&gt;
(Image from &lt;a href="https://alt-tab-macos.netlify.app/" rel="noopener noreferrer"&gt;AltTab's website&lt;/a&gt;)&lt;br&gt;
Install using brew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install alttab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  iTerm2
&lt;/h3&gt;

&lt;p&gt;iTerm2 is a replacement for the standard macos's terminal (and is so much better).&lt;br&gt;
Now that we have homebrew installed we can use to install iterm2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install iterm2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  iTerm2 configuration:
&lt;/h4&gt;

&lt;p&gt;There are many settings that you can change in iterm2, here are a few that in my opinion are a must:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Disable the bell:
iTerm2 Preferences -&amp;gt; Profiles -&amp;gt; Terminal -&amp;gt; Notifications -&amp;gt; Silence Bell&lt;/li&gt;
&lt;li&gt;Set iterm to jump over words on option+left/right arrow and move to begin/end of line with cmd+left/right arrow.
iTerm2 Preferences -&amp;gt; Profiles -&amp;gt; Keys:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;  1. ⌥← (option + left arrow) - set action to "Send Escape Sequence" - Esc+ &lt;code&gt;b&lt;/code&gt;&lt;br&gt;
  2. ⌥→ (option + right arrow) - set action to "Send Escape Sequence" - Esc+ &lt;code&gt;f&lt;/code&gt;&lt;br&gt;
  3. ⌘←(cmd + left arrow) - set action to "Send Hex Code" - value is &lt;code&gt;0x01&lt;/code&gt;&lt;br&gt;
  4. ⌘→(cmd + right arrow) - set action to "Send Hex Code" - value is &lt;code&gt;0x05&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Oh My Zsh 😱
&lt;/h3&gt;

&lt;p&gt;oh-my-zsh is a framework for managing zsh configurations. zsh is the default shell on macos these days.&lt;br&gt;
There are hundreds themes and plugins and you can configure almost everything inside.&lt;/p&gt;

&lt;p&gt;Lets start by installing oh-my-zsh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need fzf for fuzzy search (some plugins need it):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install fzf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Themes:
&lt;/h4&gt;

&lt;p&gt;There are &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes" rel="noopener noreferrer"&gt;so many oh-my-zsh themes&lt;/a&gt; that you can use. I like &lt;code&gt;intheloop&lt;/code&gt;, but you can try others and find the one that you like the most.&lt;br&gt;
To set the relevant theme open your &lt;code&gt;~/.zshrc&lt;/code&gt; file and change the value of &lt;code&gt;ZSH_THEME&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ZSH_THEME="intheloop"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Plugins:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;zsh-autosuggestions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install zsh-autosuggestions
echo "source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" &amp;gt;&amp;gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;zsh-syntax-highlighting&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install zsh-syntax-highlighting
echo "source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" &amp;gt;&amp;gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;zsh-yarn-autocompletions&lt;/strong&gt; - not in brew, so we need to install it manually:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download the mac zip/targz file from the release age: &lt;a href="https://github.com/g-plane/zsh-yarn-autocompletions/releases" rel="noopener noreferrer"&gt;https://github.com/g-plane/zsh-yarn-autocompletions/releases&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Extract it&lt;/li&gt;
&lt;li&gt;Run the following: &lt;code&gt;./install.sh $ZSH_CUSTOM/plugins&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Once installed - add it to your &lt;code&gt;plugins&lt;/code&gt; section in the &lt;code&gt;~/.zshrc&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins=(
# some plugins
yarn-autocompletions
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an important step - to allow running this file you need to set some permissions.&lt;br&gt;
Open Finder, go to &lt;code&gt;~/.oh-my-zsh/custom/plugins/yarn-autocompletions&lt;/code&gt;, hold the shift key, right-click on the &lt;code&gt;yarn-autocompletions&lt;/code&gt; file, click &lt;code&gt;open&lt;/code&gt; (while holding the shift-key).&lt;/p&gt;

&lt;p&gt;By default - oh-my-zsh comes with many other plugins. You just need to enable them. The complete list can be found in your &lt;code&gt;~/.oh-my-zsh/plugins&lt;/code&gt; folder, and you can just edit your &lt;code&gt;~/.zshrc&lt;/code&gt; file and add them as part of the plugins config.&lt;/p&gt;

&lt;p&gt;Here is a good list to begin with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins=(
# other plugins
aws
git
npm
yarn
zsh-interactive-cd
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Fuck
&lt;/h3&gt;

&lt;p&gt;The Fuck is a great tool that corrects errors in previous console commands.&lt;/p&gt;

&lt;p&gt;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;➜ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master


➜ fuck
git push --set-upstream origin master [enter/↑/↓/ctrl+c]
Counting objects: 9, done.
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To install just run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install thefuck
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do you think I'm missing something? Let me know in the comments.&lt;/p&gt;




Cover photo by &lt;a href="https://unsplash.com/@cgower" rel="noopener noreferrer"&gt;Christopher Gower @ unsplash&lt;/a&gt;

</description>
      <category>productivity</category>
      <category>tutorial</category>
      <category>macos</category>
      <category>developers</category>
    </item>
  </channel>
</rss>
