<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  
  <title>mutludev</title>
  <subtitle>Notes on development, electronics, and things I find interesting.</subtitle>
  <link href="https://mutlu.dev/feed.xml" rel="self" />
  <link href="https://mutlu.dev/" />
  <updated>2025-05-27T00:00:00Z</updated>
  <id>https://mutlu.dev/</id>
  <author>
    <name>mutludev</name>
  </author>
  <entry>
    <title>How Axios Processes Interceptors Order Matters</title>
    <link href="https://mutlu.dev/articles/how-axios-processes-interceptors/" />
    <updated>2025-05-27T00:00:00Z</updated>
    <id>https://mutlu.dev/articles/how-axios-processes-interceptors/</id>
    <content type="html">&lt;p&gt;If you’ve written any frontend app with authentication, you&#39;ve probably used Axios interceptors. But have you ever thought about the order in which they run? I hadn’t, until I ran into a bug (or maybe a feature).&lt;/p&gt;
&lt;p&gt;While setting up my refresh token logic, I created two request interceptors like this:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;interceptors&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;request&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;refreshTokenInterceptor&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;interceptors&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;request&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;authenticationTokenInterceptor&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;refreshTokenInterceptor&lt;/code&gt; checks if the token is expired and, if it is, fetches a new one from the server and saves it to localStorage.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;authenticationTokenInterceptor&lt;/code&gt; then takes the token from localStorage and attaches it to the request.&lt;/p&gt;
&lt;p&gt;Well, when I tested it, the token was getting refreshed, but the request was still being sent with the old token. After a few &lt;code&gt;console.log&lt;/code&gt;s, I figured out the issue: request interceptors run in reverse order to how they’re defined.&lt;/p&gt;
&lt;p&gt;After a quick Google search, I found this is a known behavior in Axios:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/axios/axios/issues/1663&quot;&gt;https://github.com/axios/axios/issues/1663&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/axios/axios/issues/841&quot;&gt;https://github.com/axios/axios/issues/841&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Axios states that request interceptors are stack-based; they run like popping from a stack.&lt;/p&gt;
&lt;p&gt;I&#39;m still not sure if this is a bug or a feature, but it doesn’t look like it’ll change anytime soon. So next time you add more than one interceptor, keep this in mind.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Git Tips Exclude files locally</title>
    <link href="https://mutlu.dev/articles/git-tips-exclude-files-locally/" />
    <updated>2025-05-16T00:00:00Z</updated>
    <id>https://mutlu.dev/articles/git-tips-exclude-files-locally/</id>
    <content type="html">&lt;p&gt;Recently, I ran into an annoying issue while working on a project. The repository has a configuration file that&#39;s checked into Git, but I need to modify it to suit my development environment. Unfortunately, since the file is tracked, Git constantly flags it as modified. Every time I want to pull new changes, I have to stash and pop my local changes, and it becomes annoying fast.&lt;/p&gt;
&lt;p&gt;Fortunately, Git has a local exclude file that can help. Here&#39;s how to use it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the &lt;code&gt;.git/info/exclude&lt;/code&gt; file in your repository.&lt;/li&gt;
&lt;li&gt;Add the path to the file you want Git to ignore, just like you would in a &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That’s it. Git will now locally ignore changes to that file.
This tip really worked for me, so I&#39;m sharing it here in case it works for you as well, and in case I need it in the future.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Weird behaviors of javascript Primitive Types and Reference Types</title>
    <link href="https://mutlu.dev/articles/weird-behaviors-of-javascript-primitive-types-and-reference-types/" />
    <updated>2023-05-26T00:00:00Z</updated>
    <id>https://mutlu.dev/articles/weird-behaviors-of-javascript-primitive-types-and-reference-types/</id>
    <content type="html">&lt;p&gt;I recently learned a difference between Primitive types and Reference types.
I thought it would be great to write a blog post about this topic.&lt;/p&gt;
&lt;h2&gt;Let&#39;s start with a code snippet&lt;/h2&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; a&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1&lt;/span&gt;

a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Well this looks okay let&#39;s do the same thing with an object&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;token literal-property property&quot;&gt;someText&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; a&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// { someText: &quot;Hello&quot; }&lt;/span&gt;

a&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;someText &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hi&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// { someText: &quot;Hi&quot; }&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This performed unexpected isn&#39;t it?
You will understand why this happens by the end of this post, let&#39;s dive into it.&lt;/p&gt;
&lt;h2&gt;What are primitive and reference types&lt;/h2&gt;
&lt;p&gt;In Javascript, we have 6 primitive types&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;li&gt;undefined&lt;/li&gt;
&lt;li&gt;Symbols (ES6)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;and 3 Reference types&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Object&lt;/li&gt;
&lt;li&gt;Array&lt;/li&gt;
&lt;li&gt;Function&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Primitive types&lt;/h2&gt;
&lt;p&gt;Primitive types stored in a fixed-sized memory,
so exact value of &amp;quot;a&amp;quot; stored in memory,
I think an example would be more helpful here&lt;/p&gt;
&lt;p&gt;We created variable &amp;quot;a&amp;quot;, it placed into memory like this&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/i/78h80kwcycj4ml9ptq9h.png&quot; alt=&quot;Alt Text&quot;&gt;&lt;/p&gt;
&lt;p&gt;then we copied memory value of variable &amp;quot;a&amp;quot; to variable &amp;quot;b&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/i/bicwvzm9a4hrjibwybun.png&quot; alt=&quot;Alt Text&quot;&gt;&lt;/p&gt;
&lt;p&gt;That seems okay let&#39;s see what happens with Reference types&lt;/p&gt;
&lt;h2&gt;Reference Types&lt;/h2&gt;
&lt;p&gt;Reference types are more complex and take up more space compared to Primitive types.
They can&#39;t be stored in fixed memory so they stored in a random location in memory
let&#39;s see it&#39;s diagram&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/i/s97tqad5lqtq6xsdafrb.png&quot; alt=&quot;Alt Text&quot;&gt;&lt;/p&gt;
&lt;p&gt;Notice that the value stored in memory is not the real value itself, its reference to real value.
When we copy the variable &amp;quot;a&amp;quot; to &amp;quot;b&amp;quot; we copy the Memory value (Reference to real object). That&#39;s why they&#39;re called reference values.
When we copy the variable &amp;quot;a&amp;quot; we don&#39;t copy the real value, we copy reference to real value.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/i/v3ygq15ibgw48putrbaw.png&quot; alt=&quot;Alt Text&quot;&gt;&lt;/p&gt;
&lt;p&gt;That&#39;s why &amp;quot;b&amp;quot; is also changed when we change the property of &amp;quot;a&amp;quot;.&lt;/p&gt;
&lt;h2&gt;Source&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;https://github.com/leonardomso/33-js-concepts
&lt;ul&gt;
&lt;li&gt;Section 3. Value Types and Reference Types&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Thanks for reading&lt;/h2&gt;
</content>
  </entry>
  <entry>
    <title>Making git more productive with aliases</title>
    <link href="https://mutlu.dev/articles/making-git-more-productive-with-aliases/" />
    <updated>2020-08-27T00:00:00Z</updated>
    <id>https://mutlu.dev/articles/making-git-more-productive-with-aliases/</id>
    <content type="html">&lt;h2&gt;What is an alias&lt;/h2&gt;
&lt;p&gt;This would be a quick tutorial. If you ever checked your &lt;code&gt;.bashrc&lt;/code&gt; file probably saw the &lt;code&gt;alias&lt;/code&gt; keyword.
Creating alias in bash is like creating shortcut for command so instead of typing &lt;code&gt;git status&lt;/code&gt; you can type &lt;code&gt;gs&lt;/code&gt; and run the same command.&lt;/p&gt;
&lt;h2&gt;Creating new alias&lt;/h2&gt;
&lt;p&gt;Let&#39;s create an alias for &lt;code&gt;git status&lt;/code&gt; command.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your &lt;code&gt;.bashrc&lt;/code&gt; file, you can use any text editor&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;alias gs=&amp;quot;git status&amp;quot;&lt;/code&gt; to end of the file
&lt;ul&gt;
&lt;li&gt;Let&#39;s inspect our code&lt;/li&gt;
&lt;li&gt;&lt;code&gt;alias&lt;/code&gt; - keyword&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gs&lt;/code&gt; - shortcut&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git status&lt;/code&gt; - full command&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Example configuration that i use&lt;/h2&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;gs&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git status&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;ga&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git add -A&quot;&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;gp&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git push&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Ending&lt;/h2&gt;
&lt;p&gt;You can use aliases for every command. So be creative. If you find yourself typing the same command over and over again try making it shorter.
Thanks for reading this post.&lt;/p&gt;
</content>
  </entry>
</feed>