<?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: Rodion Gorkovenko</title>
    <description>The latest articles on DEV Community by Rodion Gorkovenko (@rodiongork).</description>
    <link>https://dev.to/rodiongork</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%2F318470%2Fdb593203-93cf-4775-ac22-5f99866dac7b.jpg</url>
      <title>DEV Community: Rodion Gorkovenko</title>
      <link>https://dev.to/rodiongork</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rodiongork"/>
    <language>en</language>
    <item>
      <title>Any programming challenges with money prizes?</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Sat, 16 Sep 2023 07:39:20 +0000</pubDate>
      <link>https://dev.to/rodiongork/any-programming-challenges-with-money-prizes-3346</link>
      <guid>https://dev.to/rodiongork/any-programming-challenges-with-money-prizes-3346</guid>
      <description>&lt;p&gt;I remember eons ago there were TopCoder which held contests with some money prizes perhaps twice per month, and sometimes marathon games, which ran longer. Then there also were Google-Ai-Challenges, but they were rare...&lt;/p&gt;

&lt;p&gt;What is happening nowadays? What coding challenges (sites or events) do you know which offer monetary rewards?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Do you code Games?</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Fri, 06 Mar 2020 17:34:18 +0000</pubDate>
      <link>https://dev.to/rodiongork/do-you-code-games-12oc</link>
      <guid>https://dev.to/rodiongork/do-you-code-games-12oc</guid>
      <description>&lt;p&gt;Hi Friends!&lt;/p&gt;

&lt;p&gt;The question is in the title: do you code games, at least sometimes? Sorry, but it is very short post :)&lt;/p&gt;

&lt;p&gt;I can elaborate, however. It's not necessarily about polished-finished games, like silly mobile "jump-jump for the stars" with rich graphics and sound.&lt;/p&gt;

&lt;p&gt;Perhaps you code some basic pen-and-pencil games as an exercise, or even puzzles (not necessarily tic-tac-toe, but similar). Or small logic turn-based ones (like evade zombies, travel the maze etc). Perhaps you spent a week to write the code, then play for 20 minutes and forget about it :)&lt;/p&gt;

&lt;p&gt;Do you put more attention to game logic - or to look-n-feel and sound? What have you coded, please, feel free to share links if you have something at hand!&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>career</category>
    </item>
    <item>
      <title>Personality Swap - new problem based on Futurama episode</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Thu, 05 Mar 2020 17:42:29 +0000</pubDate>
      <link>https://dev.to/codeabbey/personality-swap-new-problem-based-on-futurama-episode-48ip</link>
      <guid>https://dev.to/codeabbey/personality-swap-new-problem-based-on-futurama-episode-48ip</guid>
      <description>&lt;p&gt;One of episodes of Futurama series (&lt;em&gt;Prisoner of Benda&lt;/em&gt;) is about personality-swapping machine - it can exchange two people's bodies, but only once for each given pair.&lt;/p&gt;

&lt;p&gt;This makes quite a problem about returning personalities to their bodies. You may test your algorithmic skills trying to solve it :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.codeabbey.com/index/task_view/personality-swap"&gt;&lt;strong&gt;Personality Swap @ CodeAbbey&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_WgHIs66--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/4D8PmUN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_WgHIs66--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/4D8PmUN.png" alt="Prisoner of Benda"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>challenge</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Tesla Hack shows how far AI is from being really intelligent</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Thu, 20 Feb 2020 21:34:57 +0000</pubDate>
      <link>https://dev.to/rodiongork/tesla-hack-shows-how-far-ai-is-from-being-really-intelligent-235</link>
      <guid>https://dev.to/rodiongork/tesla-hack-shows-how-far-ai-is-from-being-really-intelligent-235</guid>
      <description>&lt;p&gt;Recent &lt;a href="https://www.businessinsider.com/hackers-trick-tesla-accelerating-85mph-using-tape-2020-2"&gt;news&lt;/a&gt; about successful "Hack" of Tesla car. It's system of computer vision / optical recognition catches images of road signs to provide "auto-pilot" function. Researches modified shape of the character in speed limit sign (see picture below) and Tesla misread it as 85 instead of 35, while it seems obvious human brain/eye can't make such a mistake.&lt;/p&gt;

&lt;p&gt;What does it mean?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d2De6btA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/X078xOx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d2De6btA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/X078xOx.png" alt="Image which bewildered Tesla"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are surrounded nowadays bu "smart" things, including smart tooth-brushes and smart toilet-seats. We are made to believe that computer brain nowadays can do wonders.&lt;/p&gt;

&lt;p&gt;But it's not exactly so. Even not close.&lt;/p&gt;

&lt;p&gt;During last 50 years humankind come up with many clever (even whimsical) algorithms which allow computers to outperform human brain in many tasks. Siri can find you nearest toilet or correct spelling of any word. Some "robo-babes" can politely talk to audience - while Boston Dynamics robo-dogs open doors by pressing handles - and this impresses!&lt;/p&gt;

&lt;p&gt;Nevertheless we still have quite vague idea of how the human brain works and learns. We can teach computer to self-learn in some field (e.g. decision making in some game) - or to extract information about "diapers and beer" from sales logs.&lt;/p&gt;

&lt;p&gt;We can teach it letters and digits - but suddenly it appears the underlying algorithm "classifies" them in different, more primitive manner than human. Consider, for example, how dogs recognize other dogs despite being of very different breed, even if never seeing anything alike. Computer (e.g. Neural Network) can't extrapolate knowledge in this way.&lt;/p&gt;

&lt;p&gt;And so, in 2020, most of breaking news about using AI, ML, NN or GA anywhere from automotive industry to crime investigation generally has strong smell of marketing. Still those algorithms are clever math functions and methods which astonishingly can achieve goal in many cases - and surprisingly fail in many other cases!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So don't be easily fooled by hype-words. We still have very long way to make machines "clever" in general sense of word. Though still it seems possible.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D3jwB3b9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thumbs.gfycat.com/GleamingZealousFiddlercrab-size_restricted.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D3jwB3b9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thumbs.gfycat.com/GleamingZealousFiddlercrab-size_restricted.gif" alt="Hapless robot"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>try Scheme instead of JavaScript for UI</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Thu, 20 Feb 2020 17:23:29 +0000</pubDate>
      <link>https://dev.to/rodiongork/try-scheme-instead-of-javascript-for-ui-1836</link>
      <guid>https://dev.to/rodiongork/try-scheme-instead-of-javascript-for-ui-1836</guid>
      <description>&lt;p&gt;&lt;em&gt;In this tutorial we'll try create animation&lt;br&gt;
&lt;a href="https://codeabbey.github.io/js-things/bunny/index.html"&gt;LIKE THIS&lt;/a&gt; (Bunny image bouncing inside rectangular DIV) - using funny language Scheme instead of JavaScript.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why trying Scheme?
&lt;/h2&gt;

&lt;p&gt;Besides being fun and with curious syntax, it greatly influences your coding style. It is &lt;strong&gt;very hard to write bad code&lt;/strong&gt; in Scheme/LISP because&lt;br&gt;
you'll get lost in the heaps of parentheses. So it makes you arranging code in small and clever functions (we call it "decomposition").&lt;/p&gt;

&lt;p&gt;Also, if you go in depth, it teaches a lot about functional programming, especially with its list data types.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Scheme
&lt;/h2&gt;

&lt;p&gt;Scheme is functional language with &lt;strong&gt;very&lt;/strong&gt; simple syntax. It is one of main branches of LISP - which is the oldest language still being used widely enough. (Fortran is older, but not used that much nowadays) If you heard of &lt;code&gt;Clojure&lt;/code&gt;, &lt;code&gt;Guile&lt;/code&gt;, &lt;code&gt;Common Lisp&lt;/code&gt; - you know they are variants.&lt;/p&gt;

&lt;p&gt;It looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;alert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all language constructions are simply made of list elements inside parentheses, or round brackets, i.e. &lt;code&gt;( ... )&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;all function names and operators are put immediately after opening bracket&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So our example simply calculates sum of &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt; and shows it with browser alert box (it is for browser version, of course)&lt;/p&gt;

&lt;p&gt;We will use Scheme implemented in JS, called &lt;a href="https://www.biwascheme.org/"&gt;BiwaScheme&lt;/a&gt; - as we want it for UI tasks. You can try the expression above in the interpreter on this page.&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's start - Page Setup
&lt;/h2&gt;

&lt;p&gt;I'll do everything in single html file, for clarity - though you can split it later, of course. Let's make &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; of the bunny inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"field"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Heeey, I'm Bouncing Bunny!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"bunny"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://codeabbey.github.io/js-things/bunny/bunny2.png"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add some coloring and form (you may see, final demo fits any window, but for now let's use fixed size of the &lt;code&gt;DIV&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;gray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;#field&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;cyan&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;640px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;480px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;#bunny&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At last let's add some stub for script with &lt;code&gt;Scheme&lt;/code&gt;. You see, we use &lt;code&gt;biwascheme.js&lt;/code&gt; (release from the site mentioned above) in &lt;code&gt;src&lt;/code&gt; attribute and the code itself inside tags (which is a bit unorthodox) - but that's not the only method. This code will find &lt;code&gt;H1&lt;/code&gt; element and set its color to &lt;code&gt;red&lt;/code&gt;, just as we can do it with jQuery:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://codeabbey.github.io/js-things/biwascheme.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h1&lt;/span&gt;&lt;span class="dl"&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;color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put all three snippets into file and check if it works.&lt;br&gt;&lt;br&gt;
You should see &lt;a href="https://codeabbey.github.io/js-things/bunny/step1.html"&gt;&lt;strong&gt;something like this&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Variables and Bunny positioning
&lt;/h2&gt;

&lt;p&gt;Global variables are not very good in functional code, but the task of animation is also not very "functional" one, so let's add &lt;code&gt;X&lt;/code&gt; and &lt;code&gt;Y&lt;/code&gt; to mark current position of the bunny. This and all the following should be put inside &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; stub we created above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we also would like to have some auxiliary variables - to hold &lt;code&gt;field&lt;/code&gt; and &lt;code&gt;bunny&lt;/code&gt; DOM objects - and also for sizes of the field (while sizes of bunny are not calculated before image is loaded, we'll work around this). For such things we have several simple functions which are not in standard &lt;code&gt;Scheme&lt;/code&gt;, but were added in &lt;code&gt;BiwaScheme&lt;/code&gt; for interoperability with JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;field&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getelem&lt;/span&gt; &lt;span class="s"&gt;"#field"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;fieldW&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;element-width&lt;/span&gt; &lt;span class="nv"&gt;field&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;fieldH&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;element-height&lt;/span&gt; &lt;span class="nv"&gt;field&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;bunny&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getelem&lt;/span&gt; &lt;span class="s"&gt;"#bunny"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At last let's add function for setting coordinates of the Bunny - and add test-call to it, to check it works. It works just by assigning &lt;code&gt;top&lt;/code&gt; and &lt;code&gt;left&lt;/code&gt; styles of the &lt;code&gt;bunny&lt;/code&gt; element we got above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bunnyMove&lt;/span&gt; &lt;span class="nv"&gt;left&lt;/span&gt; &lt;span class="nv"&gt;top&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;set-style!&lt;/span&gt; &lt;span class="nv"&gt;bunny&lt;/span&gt; &lt;span class="s"&gt;"left"&lt;/span&gt; &lt;span class="nv"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;set-style!&lt;/span&gt; &lt;span class="nv"&gt;bunny&lt;/span&gt; &lt;span class="s"&gt;"top"&lt;/span&gt; &lt;span class="nv"&gt;top&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bunnyMove&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This code doesn't have a lot of observable changes compared to previous step - but the bunny should be off the center line to prove coordinates and moving works really.&lt;br&gt;&lt;br&gt;
&lt;a href="https://codeabbey.github.io/js-things/bunny/step2.html"&gt;&lt;strong&gt;See here how it should look, please&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Timer and Movement
&lt;/h2&gt;

&lt;p&gt;So now we need to setup something like &lt;code&gt;setInterval(...)&lt;/code&gt; to change coordinates over time and update bunny position. Final example uses &lt;code&gt;requestAnimationFrame&lt;/code&gt; instead, but let's go on with timer now for simplicity. &lt;code&gt;BiwaScheme&lt;/code&gt; includes simple analog of &lt;strong&gt;setInterval&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;set-timer!&lt;/span&gt; &lt;span class="nv"&gt;updatePosition&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;set-timer!&lt;/code&gt; specifies delay in seconds (so it is 0.05, i.e. 50ms - 20 frames per second). We are going to call &lt;code&gt;updatePosition&lt;/code&gt; function on timer ticks. But we need to add it of course:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;updatePosition&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bunnyMove&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we see that syntax for defining function is the same as for variable - we just assign lambda-function (with no arguments) to the &lt;code&gt;updatePosition&lt;/code&gt; variable. Scheme also has simplified syntax for the same, as you can see in &lt;code&gt;bunnyMove&lt;/code&gt; definition.&lt;/p&gt;

&lt;p&gt;Add these snippets to the end of your script and see - bunny should start moving, though ignoring bounds of the field.&lt;br&gt;&lt;br&gt;
&lt;a href="https://codeabbey.github.io/js-things/bunny/step3.html"&gt;&lt;strong&gt;Look here for example, please...&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Regard Borders and Speed-up
&lt;/h2&gt;

&lt;p&gt;To make Bunny respect borders of the field, we'll need to teach it changing direction. For this we should add something instead of &lt;code&gt;1&lt;/code&gt; to its&lt;br&gt;
coordinates. Let's create variables for vertical and horizontal speed, and use it in &lt;code&gt;updatePosition&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="c1"&gt;; put this below x, y definition&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;vx&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="nv"&gt;vy&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;; and later...&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;updatePosition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;vx&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="nv"&gt;vy&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bunnyMove&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we just need to check inside the &lt;code&gt;updatePosition&lt;/code&gt; for following conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if bunny reaches bottom, i.e. &lt;code&gt;y &amp;gt;= field_height - bunny_height&lt;/code&gt; - then switch &lt;code&gt;vy&lt;/code&gt; to negative&lt;/li&gt;
&lt;li&gt;if bunny reaches top, i.e. &lt;code&gt;y &amp;lt;= 0&lt;/code&gt; - then switch &lt;code&gt;vy&lt;/code&gt; back to positive&lt;/li&gt;
&lt;li&gt;make two similar checks for &lt;code&gt;x&lt;/code&gt; coordinate
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scheme"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;define&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;updatePosition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;fieldH&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;element-height&lt;/span&gt; &lt;span class="nv"&gt;bunny&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;vy&lt;/span&gt; &lt;span class="mi"&gt;-2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;fieldW&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;element-width&lt;/span&gt; &lt;span class="nv"&gt;bunny&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;vx&lt;/span&gt; &lt;span class="mi"&gt;-2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;vy&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;vx&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;vx&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;set!&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt; &lt;span class="nv"&gt;vy&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;bunnyMove&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note that we call function to calculate bunny size every time. This is workaround because we couldn't get it until bunny image is loaded. Of course it could be done in more clever way, but let's keep it simple.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Surprisingly, that's all! Now bunny should bounce of all 4 borders.&lt;br&gt;&lt;br&gt;
&lt;a href="https://codeabbey.github.io/js-things/bunny/step4.html"&gt;&lt;strong&gt;Look how it works in the last example&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So we see, &lt;code&gt;Scheme&lt;/code&gt; looks not too bad when dealing with &lt;code&gt;JavaScript&lt;/code&gt; tasks! I can't tell for sure how good it is with larger programs - I just decided to try it myself.&lt;/p&gt;

&lt;p&gt;The "final" version of the code, linked at the beginning of this post, is slightly advanced - adapting to various screen sizes and using &lt;code&gt;requestAnimationFrame&lt;/code&gt; and time deltas. You may study it, but probably it is too obvious and you even know how to do this better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I hope that even if you won't write much in LISP/Scheme - you still can try it for amusement, and to learn a bit more about different programming languages!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading that far and Happy Coding!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>javascript</category>
      <category>functional</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I award free Certificates at CodeAbbey, Ask Me Anything!</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Wed, 19 Feb 2020 15:24:46 +0000</pubDate>
      <link>https://dev.to/rodiongork/i-award-free-certificates-at-codeabbey-ask-me-anything-3eej</link>
      <guid>https://dev.to/rodiongork/i-award-free-certificates-at-codeabbey-ask-me-anything-3eej</guid>
      <description>&lt;p&gt;In the fall of 2013 I started building my small web-site with programming problems - &lt;a href="https://www.codeabbey.com"&gt;CodeAbbey&lt;/a&gt;. Soon it become obvious that most users fall off after solving from 5 to 20 tasks - but few are &lt;strong&gt;very persistent&lt;/strong&gt;, doing over 100 and sometimes reaching the top.&lt;/p&gt;

&lt;p&gt;So I started awarding free Certificates for solving certain amount of tasks (now 145 - &lt;a href="https://www.codeabbey.com/index/wiki/certificates"&gt;read more&lt;/a&gt;). They have unique numbers so they could be checked at user's profile page - or added to LinkedIn by link. Depending on skill some people reach this in a month while others in a year or two...&lt;/p&gt;

&lt;p&gt;It appears, people like them - even so that some tried to cheat :) Though it is annoying to verify pretenders' solutions manually, I'm on the other hand usually feel very pleased by such devotion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I don't mean you need immediately join us :)&lt;/strong&gt; As these certificates are just funny things and not recognized officially by any University or Company, of course. I just have come to boast a bit, since I'm somewhat proud of this idea of motivating people anyway!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here is example of certificate for some outstanding colleague:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FGUKOuoJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zpnxyx2bkv7dxpn9lax8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FGUKOuoJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zpnxyx2bkv7dxpn9lax8.png" alt="Wenting Cai certificate at CodeAbbey"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ama</category>
    </item>
    <item>
      <title>Finding best post time on DEV (improved version, with PHP)</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Wed, 19 Feb 2020 14:30:35 +0000</pubDate>
      <link>https://dev.to/rodiongork/finding-best-post-time-on-dev-improved-version-with-php-4ag1</link>
      <guid>https://dev.to/rodiongork/finding-best-post-time-on-dev-improved-version-with-php-4ag1</guid>
      <description>&lt;p&gt;I explained recently how we can find the hour of the day, in which more posts here at DEV are created. &lt;a href="https://dev.to/rodiongork/detecting-dev-peak-hours-via-api-bash-study-1e5a"&gt;That post&lt;/a&gt; was rather exercise in bash.&lt;/p&gt;

&lt;p&gt;Let's try to figure out &lt;strong&gt;at what hour of the day it is better to publish post to get better chance of reaction and comments&lt;/strong&gt; - for this I'll refine the code and do this in &lt;code&gt;PHP&lt;/code&gt; this time. &lt;code&gt;Python&lt;/code&gt; may be better when whimsical analytics is necessary - but in this case I prefer &lt;code&gt;PHP&lt;/code&gt; for its simple functions to retrieve and parse json.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;As a brief reminder - we can fetch random articles from DEV API in JSON format and analyze various fields here, extracting time of creation etc. Upon retrieving many articles we can judge at what time there are more users on site. The API link for articles is&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/api/articles/"&gt;https://dev.to/api/articles/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What improvements
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Let us use &lt;strong&gt;hour of publishing&lt;/strong&gt; rather &lt;strong&gt;hour of creation&lt;/strong&gt; (i.e. when users first see the article).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's not just count how many articles are published in given hour, but add bonus points for articles having enough reactions or comments.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Let's start
&lt;/h2&gt;

&lt;p&gt;Main loop of the script is like this - we get top article ID from env this time (you've seen we can take it from API itself instead - but now I want some manual control). Then we pick some random articles with ids between this one and &lt;code&gt;32000&lt;/code&gt; earlier. Some of them do not exists (perhaps were removed). Others we can count:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="nv"&gt;$max&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'MAX'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 263822&lt;/span&gt;
&lt;span class="nv"&gt;$url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://dev.to/api/articles/'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$max&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;32000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;file_get_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$url&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// sending HTTP get to API&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$resp&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="s2"&gt; - error&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;$json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;json_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$resp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$pub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;published_at&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// not created_at!&lt;/span&gt;
    &lt;span class="nv"&gt;$hour&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$pub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// date format is 2020-01-02T11:22:33Z&lt;/span&gt;
    &lt;span class="nv"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="s2"&gt; -&amp;gt; &lt;/span&gt;&lt;span class="nv"&gt;$hour&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&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;This code will print article IDs we have tried - and either hour of publishing, or word &lt;code&gt;error&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's add an array of flags to mark which IDs we have already tried, so we don't repeat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//... and in the loop&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$max&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;32000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;$seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And counters for every hour:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$hours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//... and inside loop&lt;/span&gt;
    &lt;span class="nv"&gt;$hours&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$hour&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;At the end we can print out results (you can do pretty chart of course):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$hours&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Ok, the code will work. You can try it and see distribution of article publishing hours. But that's not exactly what we want!&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus for reactions and comments
&lt;/h2&gt;

&lt;p&gt;Now we add 1 point for every article published in given hour. Let's add 1 bonus point if that article has over 5 comments, for example - and another 1 bonus point if that article has at least one comment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;    &lt;span class="nv"&gt;$cmn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;comments_count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$rct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;positive_reactions_count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;$hours&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$hour&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$cmn&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$rct&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Of course you can change these thresholds and assign different bonus values. I won't spoil you fun of doing this small research yourself - but in general you can get distribution similar to one shown above.&lt;/p&gt;

&lt;p&gt;Good luck and happy coding to everyone! Thanks for reading that far!&lt;/p&gt;

</description>
      <category>php</category>
      <category>tutorial</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>Loop detection - Google interview question</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Tue, 18 Feb 2020 20:53:58 +0000</pubDate>
      <link>https://dev.to/rodiongork/loop-detection-google-interview-question-2h17</link>
      <guid>https://dev.to/rodiongork/loop-detection-google-interview-question-2h17</guid>
      <description>&lt;p&gt;My friend (really former student) wrote me about interview he had recently - as I understand for "intern QA" position at some of Google departments (probably Adwords/Adsense but not sure). One of the questions puzzled him the most, though I think it was more due to slight panic, rather than difficulty. Here I'll share this question and then put few details he told about interview itself for those curious.&lt;/p&gt;

&lt;h2&gt;
  
  
  Detecting Loop in Numeric Sequence
&lt;/h2&gt;

&lt;p&gt;It was a kind of brief "practical exercise" after long "theoretical part". Fellow was proposed to write small snippet of code in Python or Java (languages he manifested to know).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Suppose, we develop function, which on every call yields some number (it is ok to think of it as of random generator) - and we need to check how many calls we can do until sequence starts to repeat.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I.e. we want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;make sure sequence won't enter loop (repetitions) too soon;&lt;/li&gt;
&lt;li&gt;if possible, tell at which step it enters loop and how many steps loop take.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some "fake" example of such function was provided (it was not remembered well, but by his recollections I reconstructed it as von Neumann random generator with improvement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="c1"&gt;# some starting value, e.g. 1776
&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="n"&gt;nn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1917&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;next_num&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now what my friend was proposing and their objections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Let us create &lt;code&gt;dict&lt;/code&gt; and put every value &lt;code&gt;x&lt;/code&gt; into it, and after each call check, if new &lt;code&gt;x&lt;/code&gt; is in this dict already. (they pointed out the state of sequence depends on &lt;code&gt;w&lt;/code&gt; either - but this is rather minor detail)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's do the same, but use tuples &lt;code&gt;(x, w)&lt;/code&gt; as keys of our &lt;code&gt;dict&lt;/code&gt;. (they  said it works for &lt;code&gt;n = 100&lt;/code&gt; but he should increase to &lt;code&gt;n = 10000&lt;/code&gt; - his program was not ending)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;He said program is not finishing because of too large number of iterations. However they explained it is about &lt;code&gt;nn&lt;/code&gt; iterations and so would end in a few minutes unless something bad happens.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After some thought he understand &lt;code&gt;dict&lt;/code&gt; becomes very large (up to 100 mln elements here) - and process takes all memory and (as I suppose, hits the swap and performance degrades greatly).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;He offered to save memory, by replacing tuples with &lt;code&gt;w * nn + x&lt;/code&gt; and using &lt;code&gt;bitset&lt;/code&gt; instead of &lt;code&gt;dict&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;They agreed it is workaround, but said with &lt;code&gt;n = 100000&lt;/code&gt; or more program anyway may eat up all memory. I thought it may too long to calculate to be reasonable anyway - but then thought, this could be rewritten in &lt;code&gt;Go&lt;/code&gt; or &lt;code&gt;Java&lt;/code&gt; with 10 mln iterations per second speed - so running time may be about hour, not too long to be "unreasonable".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So he was told though he did well enough, they expected solution which won't depend on having gigabytes of memory.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is your opinion? I think I understand what they mean. My idea is described in the end of this post.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  About Interview
&lt;/h2&gt;

&lt;p&gt;This happened in Google office in Canada (haven't asked where exactly but perhaps it could be googled), this fellow moved here with his parents year ago and completed education here or something like this. They had some Google employees visiting their college (?) and telling about possible internship or something like this. I believe there was some application process and eventually he was invited for interview.&lt;/p&gt;

&lt;p&gt;Interview had the following parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;many questions about languages he said he know (Java, Python) - though only about standard libraries and syntax, no tools, frameworks etc&lt;/li&gt;
&lt;li&gt;few very shallow questions about other technologies, mainly SQL and HTML - i.e. checking "general understanding" about them&lt;/li&gt;
&lt;li&gt;logic puzzles (I believe at least some are well-known, e.g. "how to put digits on two dice so that any day number between &lt;code&gt;01&lt;/code&gt; and &lt;code&gt;31&lt;/code&gt; could be represented)&lt;/li&gt;
&lt;li&gt;practical exercise (single question, as described above)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm not sure about order of all other parts, but he said they, besides exercise, took somewhat over 1 hour and then exercise was the last and he spent "almost hour" on it solely.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;He haven't shared anything about interview results yet - I suppose he have no response still.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My idea
&lt;/h2&gt;

&lt;p&gt;Here it is, encoded in ROT13 (google to decode if you don't know it) - just to avoid you seeing it unintentionally and spoiling your fun.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Jr arrq gb fgber pheerag (j,k), gura eha sbe x vgrengvbaf, vs jr qba'g rapbhagre gur fnzr, jr fgber arj pheerag (j,k) naq eha sbe x*2 vgrengvbaf, naq fb ba - fb jr qba'g eryl ba qvpg ohg gel qrgrpgvat ybbc ol fvatyr "fgngr", vg znl gnxr gjb gvzrf zber vgrengvbaf, ohg jr fnir gvzr ba trggvat evq bs qvpg.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>challenge</category>
      <category>career</category>
      <category>beginners</category>
      <category>puzzle</category>
    </item>
    <item>
      <title>Ads or Donations - what you prefer to gain money with your site?</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Sun, 16 Feb 2020 06:39:18 +0000</pubDate>
      <link>https://dev.to/codeabbey/ads-or-donations-what-you-prefer-to-gain-money-with-your-site-797</link>
      <guid>https://dev.to/codeabbey/ads-or-donations-what-you-prefer-to-gain-money-with-your-site-797</guid>
      <description>&lt;p&gt;After you get, say, your first steady 1000 daily pageviews with your web-site, you become curious - is there a way to make some profit from it?&lt;/p&gt;

&lt;p&gt;At least to return money paid for hosting, domain name etc.&lt;/p&gt;

&lt;p&gt;If you have some experience in this - please share! If not - welcome to read about mine :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mgG0qSG_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n8iqoyvs1wkqslsgdguv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mgG0qSG_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n8iqoyvs1wkqslsgdguv.png" alt="Survey about Ads"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;results of survey about ads - people either hate them or block them&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Approach tried - Ads from Google
&lt;/h2&gt;

&lt;p&gt;So I started thinking about &lt;a href="https://www.codeabbey.com"&gt;CodeAbbey&lt;/a&gt; - my hobby web-site with coding exercises - after about a year and half after its start.&lt;/p&gt;

&lt;p&gt;I read about &lt;strong&gt;Google Adsense&lt;/strong&gt; and after some efforts added small ad banner to top-right corner, shown on most of pages. I just didn't want to annoy my users with something larger. However even with this I found that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;only about half pageviews load ads - obviously many people use ad-blockers!&lt;/li&gt;
&lt;li&gt;my users are of specific category - mostly techies and many of them studying - who don't pay much attention to ads at all&lt;/li&gt;
&lt;li&gt;some ads are quite inappropriate, silly or embarrassing, especially on mobile (so I switched them off on mobile);&lt;/li&gt;
&lt;li&gt;in total, return is small - in best times it generated about 10-15 bucks per month (with hosting currently about 13 per month);&lt;/li&gt;
&lt;li&gt;during last one or two years ads have become even more silly and their revenue dropped to about 7-8 per month.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's just ain't no good! Of course Google Adsense proposes "to improve your revenue" by putting large (half-screen) ads on pages, but I feel it will look like "damned boolsheet" for our users. And we value our users more than few bucks, right? :)&lt;/p&gt;




&lt;h2&gt;
  
  
  Considering Donations
&lt;/h2&gt;

&lt;p&gt;So currently I'm thinking about turning off ads at all and switching to donations. I previously had few occasional transfers from some kind people - notably one fellow affectionately sent me $100 after he have impressed his opponent while being interviewed for some developer job - by showing his profile at my site and explaining solution of some advanced tasks.&lt;/p&gt;

&lt;p&gt;I've tried survey about people's feeling and it seems to be favorable:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dQb_VvNv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8b439jglys4w5oseoldk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dQb_VvNv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8b439jglys4w5oseoldk.png" alt="donations survey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However there seem to be several things to care about yet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;seemingly I need "business"-type account at paypal - correct me if I'm wrong&lt;/li&gt;
&lt;li&gt;and as I'm going to send some small gifts (mugs, t-shirts) in case of too generous donations - it is important to get notified timely - and arrange some way of asking people for their postal address&lt;/li&gt;
&lt;li&gt;and obviously it is important to come up with some design for any gift postcards, mugs or t-shirts - and find out where to produce them and how to pack them.&lt;/li&gt;
&lt;li&gt;last but not least, I'm sure I'll need to figure out how to properly pay taxes according to our local laws (taxes from normal salary in our country are deducted automatically and we never need to care of this).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;So I'm still working to this switch. If you have any advice - please share!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>money</category>
      <category>web</category>
    </item>
    <item>
      <title>Detecting DEV peak hours via API (bash study)</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Sat, 15 Feb 2020 19:23:19 +0000</pubDate>
      <link>https://dev.to/rodiongork/detecting-dev-peak-hours-via-api-bash-study-1e5a</link>
      <guid>https://dev.to/rodiongork/detecting-dev-peak-hours-via-api-bash-study-1e5a</guid>
      <description>&lt;p&gt;It may be interesting, when there are more people reading &lt;a href="https://dev.to"&gt;DEV&lt;/a&gt; - for example, perfect timing is important for those who is obsessed with idea to get more likes and comments, right? :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xR2GtKLy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/38e1wjz0d912jde7o7go.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xR2GtKLy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/38e1wjz0d912jde7o7go.png" alt="Distributions of random posts at dev.to by hour of creation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;example of histogram produced as result of experiments described below&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's do a simple exercise of collecting stats - for example from &lt;code&gt;DEV&lt;/code&gt;, though this could be used for most similar sites and forums. I will use &lt;code&gt;bash&lt;/code&gt; for amusement, and because it is useful to know more about it. Though you can easily do all steps in other language (Python or PHP will suit best in my opinion). You may briefly refer to my previous post about &lt;a href="https://dev.to/rodiongork/bash-for-project-euler-really-4jnh"&gt;coding projecteuler problem in bash&lt;/a&gt; if you are not well acquainted with this popular linux command line processor.&lt;/p&gt;

&lt;p&gt;Plan is like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;few words about DEV API at all&lt;/li&gt;
&lt;li&gt;getting max id (or total amount) of articles&lt;/li&gt;
&lt;li&gt;getting about 100 random articles before this id&lt;/li&gt;
&lt;li&gt;collecting their publication hours&lt;/li&gt;
&lt;li&gt;and making small chart of it&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Few words about DEV API
&lt;/h2&gt;

&lt;p&gt;This wonderful site has REST API - simply urls which return JSON with data about articles, users, comments etc. A bit of documentation could be found &lt;a href="https://docs.dev.to/api/"&gt;here&lt;/a&gt; but it is quite incomplete. Luckily, we can also refer in the source code, particularly &lt;a href="https://github.com/thepracticaldev/dev.to/tree/master/app/controllers/api/v0"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Root for API is at &lt;code&gt;dev.to/api&lt;/code&gt;. For example, let's look at endpoint listing articles...&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting total number of articles
&lt;/h2&gt;

&lt;p&gt;Open the link &lt;a href="https://dev.to/api/articles"&gt;https://dev.to/api/articles&lt;/a&gt; in your browser. You'll see JSON, obviously - array containing articles data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&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;type_of&lt;/span&gt;&lt;span class="dl"&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;article&lt;/span&gt;&lt;span class="dl"&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;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;261930&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="dl"&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;An Open...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="c1"&gt;//...&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/*... another article data*/&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note, we have several latest articles returned. And each has numeric &lt;code&gt;id&lt;/code&gt;, so seemingly now DEV hosts over &lt;code&gt;200k&lt;/code&gt; articles.&lt;/p&gt;

&lt;p&gt;Now I want to make request from command line, which will return me just this number. I do requests with &lt;code&gt;curl&lt;/code&gt; tool. Try running following commands, one by one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://dev.to/api/articles/

curl https://dev.to/api/articles/ | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'(?&amp;lt;=\"id\"\:)\d+'&lt;/span&gt;

curl https://dev.to/api/articles/ | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'(?&amp;lt;=\"id\"\:)\d+'&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1

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



&lt;p&gt;What's happening? The first line is very simple - &lt;code&gt;curl&lt;/code&gt; fetches json data from API endpoint - and dumps them to console. Second line redirects this output to &lt;code&gt;grep&lt;/code&gt; tool, which applies regular expression to find all &lt;code&gt;"id"=1234567&lt;/code&gt; fragments and prints only numeric ids, one per line (a bit about it further). The third line applies yet another command to the produced list of ids - &lt;code&gt;head&lt;/code&gt; just takes several top lines (one in this case).&lt;/p&gt;

&lt;p&gt;What this regular expression means? Look at the end, we search for sequence &lt;code&gt;\d+&lt;/code&gt; which means "digit, repeated 1 or more times". Before this fragment should be something enclosed in &lt;code&gt;(?&amp;lt;=...)&lt;/code&gt; pattern, called "look-behind". I.e. we shall find only those digits, which are preceded by &lt;code&gt;\"id\":&lt;/code&gt;, though this prefix is not included into "matching" part.&lt;/p&gt;

&lt;p&gt;So at last let's put this single top id number into variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl https://dev.to/api/articles/ | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'(?&amp;lt;=\"id\"\:)\d+'&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Commands inside &lt;code&gt;$(...)&lt;/code&gt; are executed and their output is stored into variable &lt;code&gt;total&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting single article by ID
&lt;/h2&gt;

&lt;p&gt;Now we are going to fetch about 100 random articles. For this we are going to take random number with &lt;code&gt;$RANDOM&lt;/code&gt; function, subtract it from max &lt;code&gt;id&lt;/code&gt; and fetch specific article by this id.&lt;/p&gt;

&lt;p&gt;To get article by id we just add this id to the link used above, e.g.&lt;br&gt;
&lt;a href="https://dev.to/api/articles/123456"&gt;https://dev.to/api/articles/123456&lt;/a&gt; - note here we get not array, but single object describing an article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type_of&lt;/span&gt;&lt;span class="dl"&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;article&lt;/span&gt;&lt;span class="dl"&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;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;123456&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;//...&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;created_at&lt;/span&gt;&lt;span class="dl"&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;2019-06-13T14:31:50Z&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The object includes creation timestamp, we'll use it bit later. For now let's complete the code which fetches 100 articles at random:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; 100 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;random_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;$RANDOM&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
    &lt;span class="nv"&gt;atext&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-sf&lt;/span&gt; https://dev.to/api/articles/&lt;span class="nv"&gt;$random_id&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$random_id&lt;/span&gt;&lt;span class="s2"&gt; - ok"&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$random_id&lt;/span&gt;&lt;span class="s2"&gt; - FAIL"&lt;/span&gt;
    &lt;span class="k"&gt;fi
done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We don't use received text yet - just print out whether article could be loaded or not. Some fails with 404 (which could be checked manually) - seemingly they were saved to draft and never published or deleted afterwards.&lt;/p&gt;

&lt;p&gt;If you want run this snippet right now, I recommend changing &lt;code&gt;100&lt;/code&gt; to &lt;code&gt;10&lt;/code&gt; for test purposes - otherwise it may take significant time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Collecting timestamp data (hour)
&lt;/h2&gt;

&lt;p&gt;So we have json for every article in &lt;code&gt;atext&lt;/code&gt; variable. Let's extract &lt;code&gt;created_at&lt;/code&gt; or more precisely the hour part of this field only. Instead of &lt;code&gt;grep&lt;/code&gt; let's try &lt;code&gt;sed&lt;/code&gt; - another cool default command, just for practice. It works like this, let's redirect curl output to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://dev.to/api/articles/246755 | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'s/.*created_at\"\:\".{11}(..).*/\1/'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;sed&lt;/code&gt; just does substitution by regexp. Regexp is made so that it captures whole document (thanks to &lt;code&gt;.*&lt;/code&gt; at start and end) with &lt;code&gt;created_at\"\:\".{11}(..)&lt;/code&gt; fragment inside. In this fragment we skip quotes, semicolon, then 11 symbols (like &lt;code&gt;2020-01-02T&lt;/code&gt;) and capture two symbols with parentheses. We use the value of the first (and only) captured group with &lt;code&gt;\1&lt;/code&gt; reference to replace whole string. So output is like &lt;code&gt;20&lt;/code&gt; - i.e. hour part.&lt;/p&gt;

&lt;p&gt;We add such line in our script (under &lt;code&gt;if&lt;/code&gt;) in the form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;hour&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$atext&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'s/.*created_at\"\:\".{11}(..).*/\1/'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

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



&lt;h2&gt;
  
  
  A kind of histogram
&lt;/h2&gt;

&lt;p&gt;Now we want to collect results into array. Let's initiate array with 24 zeroes - and we'll increment the element corresponding to given hour on every article found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;0..23&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;0&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="c"&gt;# creates 24 zeroes&lt;/span&gt;
&lt;span class="c"&gt;# ... and below in the loop&lt;/span&gt;
result[&lt;span class="nv"&gt;$hour&lt;/span&gt;&lt;span class="o"&gt;]=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$hour&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I will leave to yourself to figure out how to pretty-print histogram, like one shown at the beginning of the article. Simplified code, as a shell file could look like one below. It simply prints counters for every hour:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nv"&gt;arts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;curl https://dev.to/api/articles&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="nv"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$arts&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oP&lt;/span&gt; &lt;span class="s1"&gt;'(?&amp;lt;=\"id\"\:)\d+'&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1&lt;span class="sb"&gt;`&lt;/span&gt;

&lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;0..23&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;0&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; 100 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;random_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;$RANDOM&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
    &lt;span class="nv"&gt;atext&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-sf&lt;/span&gt; https://dev.to/api/articles/&lt;span class="nv"&gt;$random_id&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
        &lt;span class="nv"&gt;hour&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$atext&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'s/.*created_at\"\:\".{11}(..).*/\1/'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="nv"&gt;hour&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$hour&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s/^0//'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;((&lt;/span&gt; result[hour]++ &lt;span class="o"&gt;))&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$random_id&lt;/span&gt;&lt;span class="s2"&gt; - ok, &lt;/span&gt;&lt;span class="nv"&gt;$hour&lt;/span&gt;&lt;span class="s2"&gt; (&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt;  &lt;span class="c"&gt;# remove leading zero&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$random_id&lt;/span&gt;&lt;span class="s2"&gt; - FAIL"&lt;/span&gt;
    &lt;span class="k"&gt;fi
done

for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;0..23&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[i]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is rather introductory material. You may at once see several things to improve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we should check that randomly chosen pages have no repeating ids&lt;/li&gt;
&lt;li&gt;requests are taking few seconds and often fail, so it would be better to learn running them in parallel&lt;/li&gt;
&lt;li&gt;most active hours probably are not determined by just the hours when articles were created - probably it is better to regard only those articles, which have enough comments and likes&lt;/li&gt;
&lt;li&gt;we can also use authorization for API (don't know yet if this affects speed).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading so far, and excuse me for bash - probably further experiments with API I'll publish using PHP/Python!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>webscraping</category>
      <category>webdev</category>
      <category>bash</category>
    </item>
    <item>
      <title>Is DEV skewed to web-dev mainly? Are you in for something else?</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Thu, 13 Feb 2020 16:47:59 +0000</pubDate>
      <link>https://dev.to/rodiongork/is-dev-skewed-to-web-dev-mainly-are-you-in-for-something-else-47n8</link>
      <guid>https://dev.to/rodiongork/is-dev-skewed-to-web-dev-mainly-are-you-in-for-something-else-47n8</guid>
      <description>&lt;p&gt;Hi Friends!&lt;/p&gt;

&lt;p&gt;I enjoy being here, at &lt;code&gt;dev.to&lt;/code&gt; for some time already. By and by I start wondering - is it really so, that most posts here are about web-dev (and even more so - many of them about frontend, UI) - or it's just a kind of hallucination?&lt;/p&gt;

&lt;p&gt;Drop a note, if not secret, if your interests are in programming-related but different fields, e.g.:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mobile development&lt;/strong&gt; - I really don't see that many posts like "Is Kotlin the best for Android development" or "Have you heard about yet another cross-platform tool for iPhones and Android both".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Computer Science&lt;/strong&gt; - I've seen here such tag, but usually it is used along with some introductory level stuff only, like "Learn about Stack and List in 2020" which looks amusing :)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Embedded Development&lt;/strong&gt; - where are all those discussions like "Forget about your Arduino and start doing it with STM32 like a pro".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Competitive Programming&lt;/strong&gt; - and all those who knew what is Facebook Hackercup, Google Code Jam, TopCoder and CodeForces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Whatever I may forgot&lt;/strong&gt; which is not about web-dev - popular branches of Data-Science and Data-Engineering, some Scientific-related programming, Robotics etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;P.S. Be sure I don't mean it is wrong to be more dedicated to web-dev. It is the field where zounds of projects are nowadays, so it is quite ok. I'm just curious. Thanks! :)&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>meta</category>
    </item>
    <item>
      <title>Hacking Random Generator (linear congruential generator)</title>
      <dc:creator>Rodion Gorkovenko</dc:creator>
      <pubDate>Wed, 12 Feb 2020 20:56:05 +0000</pubDate>
      <link>https://dev.to/codeabbey/hacking-random-generator-linear-congruential-generator-1mpi</link>
      <guid>https://dev.to/codeabbey/hacking-random-generator-linear-congruential-generator-1mpi</guid>
      <description>&lt;p&gt;New problem: &lt;a href="https://www.codeabbey.com/index/task_view/cracking-lcg"&gt;Cracking "LCG" Random Generator @ CodeAbbey&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Default random generators in some languages (&lt;code&gt;Python&lt;/code&gt;, &lt;code&gt;PHP7&lt;/code&gt;, &lt;code&gt;JavaScript&lt;/code&gt;) switched to XorShift or Mersenne Twister. However in others - most notably, &lt;code&gt;Java&lt;/code&gt; and linux/posix &lt;strong&gt;rand&lt;/strong&gt; used in &lt;code&gt;C/C++&lt;/code&gt; - it still uses linear congruential generator in very simple form:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X_next = (A * X_cur + C) % M
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The new problem at CodeAbbey is dedicated to exercise of hacking such generator. I.e. about predicting next results after observing few first ones.&lt;/p&gt;

&lt;p&gt;This both helps to get better understanding of modular arithmetic - and to remember that default random generators shouldn't be used for hashing or encrypting sensitive data - or building online casinos :)&lt;/p&gt;

</description>
      <category>security</category>
      <category>computerscience</category>
      <category>challenge</category>
      <category>codeabbey</category>
    </item>
  </channel>
</rss>
