<?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: undqurek</title>
    <description>The latest articles on DEV Community by undqurek (@undqurek).</description>
    <link>https://dev.to/undqurek</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%2F222705%2F822e37d5-7e7a-49aa-a0af-bd4ae205b156.png</url>
      <title>DEV Community: undqurek</title>
      <link>https://dev.to/undqurek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/undqurek"/>
    <language>en</language>
    <item>
      <title>Safe &amp; save - Git password under Windows</title>
      <dc:creator>undqurek</dc:creator>
      <pubDate>Tue, 03 Nov 2020 09:58:48 +0000</pubDate>
      <link>https://dev.to/undqurek/safe-save-git-password-under-windows-5bl8</link>
      <guid>https://dev.to/undqurek/safe-save-git-password-under-windows-5bl8</guid>
      <description>&lt;p&gt;When I am looking for how to save may git password I get everywhere a lot of solutions. Sometimes it is necessary to read big amount of descriptions before we are able to use right command. I have decided to prepare this article for people who use Windows with git and want to keep password in safe storage.&lt;/p&gt;

&lt;p&gt;Solution is simple. Just use following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; credential.helper manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It switches git to use Windows Credintial Manager to store passwords in safe way.&lt;/p&gt;

&lt;p&gt;You can check full article on my page too:&lt;br&gt;
&lt;a href="https://dirask.com/posts/Git-save-username-and-password-on-windows-DWEXEj" rel="noopener noreferrer"&gt;https://dirask.com/posts/Git-save-username-and-password-on-windows-DWEXEj&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>opensource</category>
      <category>github</category>
      <category>windows</category>
    </item>
    <item>
      <title>JavaScript built-in &amp; beautify JSON</title>
      <dc:creator>undqurek</dc:creator>
      <pubDate>Fri, 30 Oct 2020 19:47:48 +0000</pubDate>
      <link>https://dev.to/undqurek/javascript-built-in-beautify-json-10bn</link>
      <guid>https://dev.to/undqurek/javascript-built-in-beautify-json-10bn</guid>
      <description>&lt;p&gt;Do you know the best way how to beautify JSON in pure JavaScript?&lt;br&gt;
As answer: now I know?&lt;br&gt;
But in the past it wasn't obvious.&lt;br&gt;
I have used online tools.&lt;br&gt;
Today, I know quick solution:&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;beautifyJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 4 spaces as indent&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Usage example:&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uglyJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;{"id": 2, "name": "Tom", "age": 25}&lt;/span&gt;&lt;span class="dl"&gt;'&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;beautyJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;beautifyJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uglyJson&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;beautyJson&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Online runnable examples: &lt;a href="https://dirask.com/posts/pqqJxp" rel="noopener noreferrer"&gt;https://dirask.com/posts/pqqJxp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tool</category>
      <category>json</category>
      <category>webdev</category>
    </item>
    <item>
      <title>In how many ways can you redirect your web page in JavaScript?</title>
      <dc:creator>undqurek</dc:creator>
      <pubDate>Wed, 20 May 2020 23:09:35 +0000</pubDate>
      <link>https://dev.to/undqurek/in-how-many-ways-can-you-redirect-your-web-page-in-javascript-33ol</link>
      <guid>https://dev.to/undqurek/in-how-many-ways-can-you-redirect-your-web-page-in-javascript-33ol</guid>
      <description>&lt;p&gt;Some time ago I got an idea to count, in how many ways you can make redirect operation from the level of JavaScript code running in the browser?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dirask.com/posts/joza8p" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg50wixs9cwzurb81q7cr.png" width="401" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is known for a long time that, at the very beginning, browsers offered Location API (i.e. window.location object) with JS, that helps to redirect the current page to a completely different one. As an alternative to it, we can look at the existing quirks - yes quirks, you haven't heard yourself! - because that's what I am going to call link creation in order to click on it and redirect our site elsewhere. And I will tell you that I believe that there will definitely be a man who will do it :) because why not ... if it is possible, heh ... It reminds me of my little cat, who instead of going straight, tries to squeeze through a narrow crack, next to it to continue its journey - because cats have this way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dirask.com/posts/joza8p" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdql2fs6lwwsok13wl4a.png" width="397" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before HTML 5 appeared, the developers who designed API put a lot of effort to provide special functions to navigate that was needed - it is the History API (i.e. window.history object). Ok, I know a lot of solutions come from suggested and already implemented solutions in many browsers. &lt;/p&gt;

&lt;p&gt;But what's new about this new API that Location API doesn't have?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dirask.com/posts/joza8p" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvogx2gimom4ay38mq48e.png" alt="New power?" width="175" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;heh, ok, I will explain briefly:&lt;/p&gt;

&lt;p&gt;The History API allows us to navigate without reloading the page. But wait..., someone well versed in the subject could ask me the question: what does the History API have common with a redirect? This is a redirect for which we need to change the content by own logic in own way - which does not change the fact that the URL is changed in the browser's address field after the operation. After refreshing the page, the page associated with the new address will be load. Modern Front-end frameworks such as Angular, React, VUE, etc. use this technique. It is only covered by the Routing API provided by various types of routing modules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Location API
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dirask.com/posts/joza8p" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6g70fcl5nx292dc3c62j.png" alt="Location? yes, but this is about the website address, not the server physical location :P" width="349" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It provides 3 basic approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;location.assign('&lt;a href="http://my-new-url.com'" rel="noopener noreferrer"&gt;http://my-new-url.com'&lt;/a&gt;)&lt;br&gt;
navigates to the indicated page,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;locartion.href = '&lt;a href="http://my-new-url.com" rel="noopener noreferrer"&gt;http://my-new-url.com&lt;/a&gt;'&lt;br&gt;
it is nothing more than an alternative approach to the assign() function,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;location.replace('&lt;a href="http://my-new-url.com'" rel="noopener noreferrer"&gt;http://my-new-url.com'&lt;/a&gt;)&lt;br&gt;
removes the current page from the history of browsed pages and inserts a new entry with opening the link - overwriting actual link in history,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;okay there are still:&lt;br&gt;
location.hostname, location.pathname, location.search, e.t.c.&lt;br&gt;
but they only change a specific part of the URL so I skip it :)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this API we can redirect our website to any link - even with other origin.&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="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

    &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://dirask.com/about&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;//location.assign('https://dirask.com/about');&lt;/span&gt;
    &lt;span class="c1"&gt;//location.href = 'https://dirask.com/about';&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The technical version of the article can be found &lt;a href="https://dirask.com/posts/JavaScript-how-to-redirect-to-another-web-page-d1bNM1" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;How such an API can be used for? I think a cool and simple example could be redirect operation to the https version of my page if needed.&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="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;Page content...&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  History API
&lt;/h2&gt;

&lt;p&gt;It gives you the ability to reload pages faster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dirask.com/posts/joza8p" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcrnhfy6rqzrj8wz9wj22.png" alt="A small-big thing! I am sure that this feature is very useful for many developers - some of them access it directly" width="347" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It provides the 2 most important functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;history.pushState(state, title, url)&lt;br&gt;
adds another entry to the navigation history, changing url,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;history.replaceState(state, title, url)&lt;br&gt;
replaces the current entry in the navigation history, changing url,&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where noteworthy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;url argument is the address that will be displayed in the URL field of the browser without causing the page to reload - the "small" limitation is the fact that we can only navigate within the same domain!!! and later need to overload the page content with own logic...&lt;/li&gt;
&lt;li&gt;state and title arguments are described in the MDN documentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After refreshing our website, the source code will be loaded from the current URL - normal scenario of page loaging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Link and simulated click action
&lt;/h2&gt;

&lt;p&gt;And now it's time for quirks offered by the link itself and the click() function. Maybe I will show it on an example:&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;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"link"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://dirask.com"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;click&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;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to navigate, use just Location API.&lt;/li&gt;
&lt;li&gt;When we want to reload only a certain part of the page and speed up on loading time, History API will be appropriate - so do the frameworks listed above.&lt;/li&gt;
&lt;li&gt;Link + click - at your discretion :)
for target="_blank" attribute a good browser will block the operation. Without an attribute a lot of most popular pages will manage it like google ;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once again, I invite you to the technical version of the article &lt;a href="https://dirask.com/posts/JavaScript-how-to-redirect-to-another-web-page-d1bNM1" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Alternative version of this article is available &lt;a href="https://dirask.com/posts/In-how-many-ways-can-you-redirect-your-web-page-in-JavaScript-joza8p" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>redirect</category>
      <category>webbrowser</category>
    </item>
  </channel>
</rss>
