<?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: COBE Tech</title>
    <description>The latest articles on Forem by COBE Tech (@cobe_tech).</description>
    <link>https://forem.com/cobe_tech</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%2Forganization%2Fprofile_image%2F1142%2F351ade9e-008e-4a05-b691-504070187a71.jpg</url>
      <title>Forem: COBE Tech</title>
      <link>https://forem.com/cobe_tech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cobe_tech"/>
    <language>en</language>
    <item>
      <title>Hands-on React projects for practice</title>
      <dc:creator>Danijel Vincijanović</dc:creator>
      <pubDate>Mon, 23 Sep 2019 20:07:28 +0000</pubDate>
      <link>https://forem.com/cobe_tech/hands-on-react-projects-for-practice-579e</link>
      <guid>https://forem.com/cobe_tech/hands-on-react-projects-for-practice-579e</guid>
      <description>&lt;p&gt;As a JavaScript developer I had a chance to mentor a few people and show them how JS works both on the server and client side. Some of them were beginners and some already quite skilled JavaScript developers. Despite their experience level, in one point of time everyone needed some practical tasks to brush up on skills so that they can be ready when a real project kicks in. &lt;/p&gt;

&lt;p&gt;For that purpose, I've already published some of those tasks that you can pick up and practice. As a sidenote, we're using them as a part of the selection process for an internship or a job.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&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%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/cobeisfresh" rel="noopener noreferrer"&gt;
        cobeisfresh
      &lt;/a&gt; / &lt;a href="https://github.com/cobeisfresh/frontend-tasks" rel="noopener noreferrer"&gt;
        frontend-tasks
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Frontend tasks&lt;/h1&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cobeisfresh/frontend-tasks/tree/movie-api" rel="noopener noreferrer"&gt;Movie API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cobeisfresh/frontend-tasks/tree/shopping-cart" rel="noopener noreferrer"&gt;Shopping cart&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Must read&lt;/h3&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.w3schools.com/js/default.asp" rel="nofollow noopener noreferrer"&gt;JavaScript basics&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://javascript.info/js" rel="nofollow noopener noreferrer"&gt;JavaScript fundamentals&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://bonsaiden.github.io/JavaScript-Garden" rel="nofollow noopener noreferrer"&gt;JavaScript Garden&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://dmitripavlutin.com/7-tips-to-handle-undefined-in-javascript" rel="nofollow noopener noreferrer"&gt;7 Tips to handle undefined in javascript&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Useful resources&lt;/h3&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://github.com/getify/You-Dont-Know-JS" rel="noopener noreferrer"&gt;You Don’t Know JS&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://eloquentjavascript.net" rel="nofollow noopener noreferrer"&gt;Eloquent JavaScript&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://hackernoon.com/prototypes-in-javascript-5bba2990e04b" rel="nofollow noopener noreferrer"&gt;Prototypes in JavaScript&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://scotch.io/tutorials/better-javascript-with-es6-pt-ii-a-deep-dive-into-classes" rel="nofollow noopener noreferrer"&gt;Deep dive into classes&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="http://marijnhaverbeke.nl/talks/es6_falsyvalues2015/#0" rel="nofollow noopener noreferrer"&gt;ES6&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://developers.google.com/web/fundamentals/primers/promises" rel="nofollow noopener noreferrer"&gt;Javascript promises&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.sitepoint.com/javascript-testing-unit-functional-integration" rel="nofollow noopener noreferrer"&gt;Javascript testing&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://bundlephobia.com" rel="nofollow noopener noreferrer"&gt;Bundlephobia&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.javascripting.com" rel="nofollow noopener noreferrer"&gt;Javascript libraries&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=QyUFheng6J0" rel="nofollow noopener noreferrer"&gt;JavaScript VM internals, EventLoop, Async and ScopeChains&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/cobeisfresh/frontend-tasks" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;If you have some tasks that you would like to share with others, please post them in the comment. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you solve task, feel free to send me a link to the solution and I will do my best to give you a constructive feedback!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Is this a €1.000,00 worth Node script?</title>
      <dc:creator>Danijel Vincijanović</dc:creator>
      <pubDate>Thu, 29 Aug 2019 09:09:51 +0000</pubDate>
      <link>https://forem.com/cobe_tech/is-this-1-000-00-worth-node-script-548l</link>
      <guid>https://forem.com/cobe_tech/is-this-1-000-00-worth-node-script-548l</guid>
      <description>&lt;p&gt;So the story begins with one of my favourite &lt;a href="https://www.youtube.com/user/viktorlantos"&gt;Youtube channels&lt;/a&gt;. A few days ago, they've published a new video announcing that they will soon reach their 100k subscriber and on that occasion will give out a &lt;strong&gt;€1.000,00&lt;/strong&gt; voucher which the person can then spend on new  equipment.&lt;br&gt;
That's a lot of money! Especially if you're, like me, living in Croatia. We're talking about approximate 20% more than an average monthly salary here.&lt;/p&gt;
&lt;h2&gt;
  
  
  Plot
&lt;/h2&gt;

&lt;p&gt;I must admit, after I heard the announcement I was immediately hooked. I paused the video and started thinking of ways to become that 100k subscriber and win the voucher. What I figured out next is that manually checking the number of subscribers and waiting for the right moment to hit the subscribe button won't bring me any luck. I needed a machine to do that work for me if I want to be faster than others.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/RRerwvHrb0nxm/source.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/RRerwvHrb0nxm/source.gif" alt="Fast as machine" width="320" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a short brainstorming session I came up with an easy solution and the only thing I needed was &lt;a href="https://developers.google.com/youtube/v3"&gt;Youtube API&lt;/a&gt; and a little bit of Node. Solution is pretty straightforward: we had to know how many subscribers the channel has so when it reaches its 99.999 subscriber we would need to subscribe.&lt;/p&gt;
&lt;h2&gt;
  
  
  Challenges
&lt;/h2&gt;

&lt;p&gt;If you're already thinking about implementation then you know that we'll need &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval"&gt;&lt;code&gt;setInterval&lt;/code&gt;&lt;/a&gt; or &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout"&gt;&lt;code&gt;setTimeout&lt;/code&gt;&lt;/a&gt; so we can repeatedly check the number of subscribers.&lt;/p&gt;

&lt;p&gt;The only limitation we have here is &lt;a href="https://developers.google.com/youtube/v3/getting-started#quota"&gt;YouTube Data API quota usage&lt;/a&gt;. We get default quota allocation of 10.000 units per day which means that each request will cost us some units. &lt;/p&gt;

&lt;p&gt;In our case, if we want to get a number of channel subscribers we need to do a request to &lt;code&gt;https://www.googleapis.com/youtube/v3/channels?part=statistics&lt;/code&gt; and that request will cost us 3 units. You can calculate your quota cost using &lt;a href="https://developers.google.com/youtube/v3/determine_quota_cost"&gt;Youtube Quota Calculator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If we check the subscribers count every second we'll drain our quota by running our script for 55 minutes which is just not enough; we want our script to run longer so that we don't miss out on our chance. The only solution for this limitation is to use a different interval delay depending on the number of subscribers. That means that we'll perform requests more frequently as the number of subscribers approaches 100k. In the beginning we'll start with one request per hour and then we'll get all the way down to 300 milliseconds.&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Check the solution in this repo below and try it out.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/davinci2015"&gt;
        davinci2015
      &lt;/a&gt; / &lt;a href="https://github.com/davinci2015/youtube-subscriber"&gt;
        youtube-subscriber
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Youtube Subscriber&lt;/h1&gt;
&lt;p&gt;If you want to know why this repo was created read &lt;a href="https://dev.to/cobe_tech/is-this-1-000-00-worth-node-script-548l" rel="nofollow"&gt;this story&lt;/a&gt; about €1.000,00 voucher.&lt;/p&gt;
&lt;h2&gt;
Installation&lt;/h2&gt;
&lt;p&gt;Clone repository&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ git clone https://github.com/davinci2015/youtube-subscriber.git&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;cd into directory&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ &lt;span class="pl-c1"&gt;cd&lt;/span&gt; youtube-subscriber&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Install NPM dependencies&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ npm install&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
Configuration&lt;/h3&gt;
&lt;p&gt;Before running the script you should update variables inside of &lt;code&gt;config.js&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Update following variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;channelId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;client_secret&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;client_id&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Run the server&lt;/h3&gt;
&lt;p&gt;After updating config variables you can run server and let him do the magic.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ node main.js&lt;/pre&gt;

&lt;/div&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/davinci2015/youtube-subscriber"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h2&gt;
  
  
  Twist
&lt;/h2&gt;

&lt;p&gt;After I've finished with the implementation, I continued watching the video where they announce their bounty. In that moment I knew I f***** up. It was never about being the 100Kth subscriber, it was about visiting their social profiles and participating in the prize game where the winner will be randomly chosen.&lt;/p&gt;

&lt;p&gt;So here I am, with a published script and without a €1.000,00 voucher. But let's look at the bright side  - at least I've learned something new and maybe, in the future, this script helps someone actually win the voucher, who knows. &lt;br&gt;
Until then, happy coding!&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>youtube</category>
      <category>api</category>
    </item>
  </channel>
</rss>
