<?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: Selahattin Ünlü</title>
    <description>The latest articles on DEV Community by Selahattin Ünlü (@selahattinunlu).</description>
    <link>https://dev.to/selahattinunlu</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%2F76031%2F1dbb08f5-724e-432d-94b3-31baf5530314.jpeg</url>
      <title>DEV Community: Selahattin Ünlü</title>
      <link>https://dev.to/selahattinunlu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/selahattinunlu"/>
    <language>en</language>
    <item>
      <title>Weekly Update of Me: Week 2 (What I've learned, what did I do and the links I've found)</title>
      <dc:creator>Selahattin Ünlü</dc:creator>
      <pubDate>Thu, 06 Jan 2022 08:46:23 +0000</pubDate>
      <link>https://dev.to/selahattinunlu/weekly-update-week-2-4pg9</link>
      <guid>https://dev.to/selahattinunlu/weekly-update-week-2-4pg9</guid>
      <description>&lt;p&gt;Hi everybody! I've started to share weekly updates of me. You can find following topics inside:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What did I learn previous week?&lt;/li&gt;
&lt;li&gt;What did I do during the week?&lt;/li&gt;
&lt;li&gt;Links that I've found useful&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also reach that contents on my website&lt;br&gt;
&lt;a href="https://www.selahattinunlu.com/weekly-updates/week-2"&gt;https://www.selahattinunlu.com/weekly-updates/week-2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also check the first week using following link:&lt;br&gt;
&lt;a href="https://www.selahattinunlu.com/weekly-updates/week-1"&gt;https://www.selahattinunlu.com/weekly-updates/week-1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy 🥳&lt;/p&gt;


&lt;h2&gt;
  
  
  What I've learned previous week?
&lt;/h2&gt;
&lt;h4&gt;
  
  
  Browserlist on package.json
&lt;/h4&gt;

&lt;p&gt;My friend has realized that one of the website he built was not working well on Safari 12.&lt;br&gt;
He had used Tailwindcss 3 to style the website and Tailwindcss3 targets to Safari 14+.&lt;/p&gt;

&lt;p&gt;So I was looking for a solution to help him and I found of course 😬&lt;br&gt;
The solution was adding "browserlists" into the package.json. Honestly I did not expect it to works&lt;br&gt;
but it did 🥳😅&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"browserslist"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"production"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;0.2%"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"not dead"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"not op_mini all"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"last 3 safari version"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;--&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;solution&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;a href="https://create-react-app.dev/docs/supported-browsers-features/#configuring-supported-browsers"&gt;https://create-react-app.dev/docs/supported-browsers-features/#configuring-supported-browsers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=F2N-evGOcxc"&gt;https://www.youtube.com/watch?v=F2N-evGOcxc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/browserslist/browserslist"&gt;https://github.com/browserslist/browserslist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Manipulate fetched data in react-query
&lt;/h4&gt;

&lt;p&gt;We use react-query most of our projects in &lt;a href="https://swiftmade.co"&gt;Swiftmade&lt;/a&gt;. I was looking for a way to manipulate the data already fetched&lt;br&gt;
without refetch. I've found this solution: &lt;a href="https://react-query.tanstack.com/reference/QueryClient?utm_source=pocket_mylist#queryclientsetquerydata"&gt;https://react-query.tanstack.com/reference/QueryClient?utm_source=pocket_mylist#queryclientsetquerydata&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;queryClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useQueryClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{...};&lt;/span&gt;
&lt;span class="nx"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setQueryData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;query-key-here&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What did I do during previous week?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I was working on the projects in &lt;a href="https://swiftmade.co"&gt;Swiftmade&lt;/a&gt;. We've completed redesigning of Wrkland's website. It's not released yet 😬&lt;br&gt;
I'm looking forward to share it here when it's released. 🥳 We had built a booking system for them last year. You can check it out for now &lt;a href="https://booking.wrkland.com"&gt;https://booking.wrkland.com&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Apart from my daily tasks, I've built a side project in a day 😅&lt;br&gt;
I was using a service to share my all links in a single page. But it's gone I don't understand why 🥺&lt;br&gt;
Then I've decided to built a simple one instead. 🥳&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://heremylinks.com/selahattin"&gt;https://heremylinks.com/selahattin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://heremylinks.com"&gt;https://heremylinks.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;I've published a new programming tutorial for my Turkish audience (Let's build a Twitter Clone 👀)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=b2k6MoC3YNU"&gt;https://www.youtube.com/watch?v=b2k6MoC3YNU&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://calendly.com/"&gt;https://calendly.com/&lt;/a&gt; - Easy scheduling ahead&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://supabase.io"&gt;https://supabase.io&lt;/a&gt; - Open source Firebase Alternative (Btw I've used supabase's database for heremylinks)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.refactoringui.com/"&gt;https://www.refactoringui.com/&lt;/a&gt; - Great tips on UI/UX&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://error404.fun/"&gt;https://error404.fun/&lt;/a&gt; - Royalty free illustrations for pages&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://invoice-generator.com"&gt;https://invoice-generator.com&lt;/a&gt; - Invoice generator&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?utm_source=pocket_mylist&amp;amp;v=0zmYHn82cY8"&gt;https://www.youtube.com/watch?utm_source=pocket_mylist&amp;amp;v=0zmYHn82cY8&lt;/a&gt; (Fastest way to deploy a database)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devjournal</category>
      <category>writing</category>
      <category>webdev</category>
      <category>learning</category>
    </item>
    <item>
      <title>How to wait for a container to be ready?</title>
      <dc:creator>Selahattin Ünlü</dc:creator>
      <pubDate>Sun, 04 Aug 2019 13:19:26 +0000</pubDate>
      <link>https://dev.to/selahattinunlu/how-to-wait-for-a-container-to-be-ready-2ld9</link>
      <guid>https://dev.to/selahattinunlu/how-to-wait-for-a-container-to-be-ready-2ld9</guid>
      <description>&lt;p&gt;Originally published on my &lt;a href="https://blog.selahattinunlu.com/2019-08-04-how-to-wait-for-a-container-to-be-ready"&gt;blog&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;First of first, I don't have many experiences on Docker. I'm just trying to dockerize one of my side-project and I thought can learn about Docker. Although I did not deploy it yet, it seems great to use it in development at least. Anyway, let's talk about the main subject.&lt;/p&gt;

&lt;p&gt;If you've worked with Docker before, you know that some containers might depends on to the others. For example, your backend applications might depends on to the MongoDB (just like in my case). In this case, backend application must wait until the mongo container is runned. &lt;/p&gt;

&lt;p&gt;There are a couple of ways to set that dependencies in your configuration files. &lt;code&gt;depends_on&lt;/code&gt; is one of them, and I was using it in my application. Everything were working perfectly at the beginning but today I've encountered with a problem! My application was not connecting to the MongoDB. But how? It was working last week and I did not do anything! What the hack?&lt;/p&gt;

&lt;p&gt;Then, I've checked the logs and realized that the MongoDB was being ready to wait connections after my backend application is run! But I had used &lt;code&gt;depends_on&lt;/code&gt; configuration! I've done a quick google search and understood the problem. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;depends_on&lt;/strong&gt; only cares about if the container is run or not. So, does not matter whether mongodb is ready for connections. Aha! It's so sensible. How could docker knows if it's ready or not?&lt;/p&gt;




&lt;h3&gt;
  
  
  The Solution
&lt;/h3&gt;

&lt;p&gt;I've searched the solution as well and found a couple of solutions. I'm gonna tell you the best one for me.&lt;/p&gt;

&lt;p&gt;The solution is &lt;strong&gt;wait-for-it.sh&lt;/strong&gt; &lt;a href="https://github.com/vishnubob/wait-for-it"&gt;Here is the repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a bash script to wait on the availability of a TCP host and port. You can find that description at its repository 'It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers.'&lt;/p&gt;

&lt;h4&gt;
  
  
  How to apply the solution
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I've copied &lt;code&gt;wait-for-it.sh&lt;/code&gt; file into my app folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then add those lines into Dockerfile:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;COPY wait-for-it.sh /usr/wait-for-it.sh
RUN &lt;span class="nb"&gt;chmod&lt;/span&gt; +x /usr/wait-for-it.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;And the final step, I've changed application command in docker-compose.yml:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;app:
    container_name: backend
    restart: always
    build: &lt;span class="nb"&gt;.&lt;/span&gt;
    volumes:
        - .:/usr/src/app
        - /usr/src/app/node_modules
    ports:
        - &lt;span class="s2"&gt;"3030:3030"&lt;/span&gt;
        - &lt;span class="s2"&gt;"9229:9229"&lt;/span&gt;
    depends_on:
        - mongo
    &lt;span class="nb"&gt;command&lt;/span&gt;: bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"/usr/wait-for-it.sh --timeout=0 mongo:27017 &amp;amp;&amp;amp; npm run dev"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all! My backend application waits until mongodb is ready for connections. End of the story! :)&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Throttle and Debounce</title>
      <dc:creator>Selahattin Ünlü</dc:creator>
      <pubDate>Wed, 17 Jul 2019 06:48:10 +0000</pubDate>
      <link>https://dev.to/selahattinunlu/throttle-and-debounce-2918</link>
      <guid>https://dev.to/selahattinunlu/throttle-and-debounce-2918</guid>
      <description>&lt;p&gt;I think they are so cool techniques to prevent running a function too many times. There is a little difference between them and it confused me before thinking about it.&lt;/p&gt;

&lt;p&gt;When I started to think about it (it was today, because I needed to use them), it started to seem easy to know what I need to use.&lt;/p&gt;

&lt;p&gt;First, we need to decide what we want to do. &lt;/p&gt;

&lt;p&gt;If we want to make &lt;strong&gt;limitation&lt;/strong&gt; on a function which runs every time when an event occurred, we can use the &lt;strong&gt;throttle.&lt;/strong&gt; We can use the throttle to decrease the number of calls. Let's imagine you're running a function when the mouse is moved. So, every time the function will run.&lt;br&gt;
You might want to limit it to run every 2 seconds. The function will run only every 2 seconds while the mouse is moving.&lt;br&gt;
You limited it and decreased the number of calls.&lt;/p&gt;

&lt;p&gt;If we want to &lt;strong&gt;defer&lt;/strong&gt; a function call until an event is completed, we need to use &lt;strong&gt;debouncing&lt;/strong&gt;. There is a quick example of it. Let's imagine you want to make a search box that will give the suggestions according to the text to the user. Will you make a query in your database when the user hit to the keyboard every time? Of course, no! Because it'll hurt your database, right? You need to defer making query until the user stopped typing. You can say, make a query when if the user won't type anything in  500ms. It's &lt;strong&gt;debouncing&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Throttle&lt;/strong&gt; will run after every &lt;strong&gt;X&lt;/strong&gt; time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debounce&lt;/strong&gt; will run only once when an event is done.&lt;/p&gt;




&lt;p&gt;There is also a great demo to fully demonstrate how they work.&lt;/p&gt;

&lt;p&gt;You can check it out: &lt;a href="http://demo.nimius.net/debounce_throttle"&gt;Throttle - Debounce Demo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
  </channel>
</rss>
