<?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: Morten Olsrud</title>
    <description>The latest articles on DEV Community by Morten Olsrud (@hakash).</description>
    <link>https://dev.to/hakash</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%2F106503%2F3067fd6d-b22f-4d02-81ed-d32f3bb6f296.png</url>
      <title>DEV Community: Morten Olsrud</title>
      <link>https://dev.to/hakash</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hakash"/>
    <language>en</language>
    <item>
      <title>Webcam replacement advice needed</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Sat, 04 Apr 2020 19:14:32 +0000</pubDate>
      <link>https://dev.to/hakash/webcam-replacement-advice-needed-5f6m</link>
      <guid>https://dev.to/hakash/webcam-replacement-advice-needed-5f6m</guid>
      <description>&lt;p&gt;Hey there!&lt;/p&gt;

&lt;p&gt;Like most of us, I find myself needing to up the ante equipment wise at the home office. I've landed a nice setup with monitors and a HyperX Quadcast mic, I'm waiting for a mechanical keyboard to land, as well as a nice, ergonomic mouse with extra buttons to minimize shifting hands from mouse to keyboard.&lt;/p&gt;

&lt;p&gt;What I don't have is a nice camera. Sure, we all dream about that HDR 4K 60fps sweetness, but my budget is nowhere near that. I also see that the market is sucked dry for conventional webcams, especially the nicer ones like the Logitech 922, which to be honest, is also a bit pricey.&lt;/p&gt;

&lt;p&gt;I am looking for creative, good alternatives that will work well on Ubuntu 18.04 onwards. &lt;/p&gt;

&lt;p&gt;My own thoughts so far has been to use my mobile phone, as that camera is better than the one in my laptop, but the software solutions I have come across sucks in some way, if they work at all.&lt;/p&gt;

&lt;p&gt;I have also peeked at Action Cameras and Camcorders, but those camcorders get pricey fast. I still have a hope regarding actioncams, but their documentation is often very lacking with regards to supporting live streaming video to a computer over a cable, as in allowing the computer to use the camera as a video source. Another issue I've read about is that many of the actioncams has a lens leaning heavily towards a fish eye view for more snappy action videos.&lt;/p&gt;

&lt;p&gt;Anyone out there have experience with using alternative cameras as webcams for video calls, as well as for screencast recording? Ideally Full HD 1080p @ &amp;gt;=30fps and HDR, but HDR is less important. Cheap 1080p actioncam without pronounced fish eye is possibly my best bet, but impossible to find reading specs in webshops...&lt;/p&gt;

&lt;p&gt;Any suggestions or alternatives? Please share your thoughts and/or setup in the comments.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>help</category>
      <category>discuss</category>
      <category>equipment</category>
      <category>camera</category>
    </item>
    <item>
      <title>Meet Jotr - A note-taking app for the CLI</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Mon, 21 Oct 2019 21:42:46 +0000</pubDate>
      <link>https://dev.to/hakash/meet-jotr-a-note-taking-app-for-the-cli-33ch</link>
      <guid>https://dev.to/hakash/meet-jotr-a-note-taking-app-for-the-cli-33ch</guid>
      <description>&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/hakash"&gt;
        hakash
      &lt;/a&gt; / &lt;a href="https://github.com/hakash/jotr"&gt;
        jotr
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A terminal tool for jotting down tagged notes.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This project is in beta. Help is needed to test it to root out issues that might have escaped me. Documentation and everything needs scrutiny.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you are like me you really hate context switching. Jumping out of a train of thoughts to go fiddle in some GUI when you are in on the deep end in a terminal is really less than optimal.&lt;/p&gt;

&lt;p&gt;Personally I use various apps for taking notes of different kinds, in different contexts, and try to minimize switching out of a context to take or read notes. Partly due to the overhead of the navigation, but also the imminent danger of getting distracted.&lt;/p&gt;

&lt;p&gt;I, and a lot of my fellow developers out there, suffer in various degrees of what I jokingly call "The 'Oooh Shiny!' Syndrome". This is the thing that happens when your eye catches something distracting. This can be a notification, an unrelated, but interesting question on Stack Overflow, some article you scan by looking for something or even urges to suddenly dig into some other tech.&lt;/p&gt;

&lt;p&gt;Sure, most of us have a good grip on this, but let's be honest. When you have a mammoth task of the boring or uncomfortable kind, it's just too easy to start procrastinating.&lt;/p&gt;

&lt;p&gt;Reducing context switching, entering "zen-mode" in all apps that support it, turning on Do Not Disturb where ever possible and so forth is all good tips here. Several members of this community has made detailed posts about this exact topic, earning hundreds of reactions.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Jotr can help a little - a user manual of sorts
&lt;/h2&gt;

&lt;p&gt;Jotr is, as stated above, a note-taking app for the CLI. It allows you to stay in the terminal and avoid visual cues and distractions just to find some previous recorded info, or add some new notes, or "jots" as we coined them.&lt;/p&gt;

&lt;p&gt;It is centred around tags, and each jot you add gets added to one or more tags. Using tags is optional of course, and omitting them will just default the jots to use the "Random"-tag.&lt;/p&gt;

&lt;p&gt;Install it using &lt;code&gt;npm i -g jotr&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding data
&lt;/h3&gt;

&lt;p&gt;You can add jots using a full terminal editor that's built-in, or add them using a &lt;code&gt;git commit -m "Some message"&lt;/code&gt; style, to reduce context switching even more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;jotr js node react &lt;span class="nt"&gt;-c&lt;/span&gt; Node is awesome to serve React-driven pages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This one-liner gives you the jot &lt;code&gt;Node is awesome to serve React-driven pages&lt;/code&gt; connected to the tags &lt;code&gt;js&lt;/code&gt;, &lt;code&gt;node&lt;/code&gt; and &lt;code&gt;react&lt;/code&gt; tags. Quotes are optional as long as you don't use characters with special meaning in the shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading data
&lt;/h3&gt;

&lt;p&gt;To list all your jots you can use &lt;code&gt;jotr -l&lt;/code&gt; or &lt;code&gt;jotr --list&lt;/code&gt;.&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;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;-l&lt;/span&gt;
Your jots so far:
js:
  - Node is awesome to serve React-driven pages
node:
  - Node is awesome to serve React-driven pages
react:
  - Node is awesome to serve React-driven pages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, when you get a lot of jots, listing them all becomes tedious and unruly. For this situation you can list only certain tags:&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;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;-l&lt;/span&gt; js
Your jots tagged with js:
js:
  - Node is awesome to serve React-driven pages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you cant remember the exact tag, you can search or grep with &lt;code&gt;jotr -g [search term]&lt;/code&gt; or &lt;code&gt;jotr --grep [search term]&lt;/code&gt;:&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;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;-g&lt;/span&gt; node
Your jots matching node
js:
  - Node is awesome to serve React-driven pages
node:
  - Node is awesome to serve React-driven pages
react:
  - Node is awesome to serve React-driven pages
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you want to know what tags exist, you can use &lt;code&gt;jotr -t&lt;/code&gt; or &lt;code&gt;jotr --tags&lt;/code&gt; to list them:&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;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;-t&lt;/span&gt;
The tags currently registered:
js
node
react
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Altering, deleting or editing your jots
&lt;/h3&gt;

&lt;p&gt;The data storage of Jotr is file-based, and uses a simple YAML-format to save the data ordered by the tags. As of yet, Jotr does not support editing or deleting single jots, but a new, more complex storage-format is being considered to support this.&lt;/p&gt;

&lt;p&gt;Until then Jotr does give you an option to edit the file-storage directly by using the &lt;code&gt;jotr --edit&lt;/code&gt;. This loads up the entire YAML-file in the internal editor for your editing pleasure. I urge you to do an export (se below) before you manually edit the YAML-file, as a corrupt YAML-file will not function correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Purge and export
&lt;/h3&gt;

&lt;p&gt;Naturally you can export your data to a YAML or JSON file:&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;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;--export&lt;/span&gt; mynotes.yml
&lt;span class="nv"&gt;$ &lt;/span&gt;more mynotes.yml 
js:
  - Node is awesome to serve React-driven pages
node:
  - Node is awesome to serve React-driven pages
react:
  - Node is awesome to serve React-driven pages


&lt;span class="nv"&gt;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;--export&lt;/span&gt; mynotes.json
&lt;span class="nv"&gt;$ &lt;/span&gt;more mynotes.json 
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"js"&lt;/span&gt;:[&lt;span class="s2"&gt;"Node is awesome to serve React-driven pages"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;,&lt;span class="s2"&gt;"node"&lt;/span&gt;:[&lt;span class="s2"&gt;"Node is awesome to serve React-driven pages"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;,&lt;span class="s2"&gt;"react"&lt;/span&gt;:[&lt;span class="s2"&gt;"Node is awesome to serve React-driven pages"&lt;/span&gt;&lt;span class="o"&gt;]}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Done with your list? Want to purge it? Sure:&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;$ &lt;/span&gt;jotr &lt;span class="nt"&gt;--purge&lt;/span&gt;
Are you sure you want to purge all data? &lt;span class="o"&gt;(&lt;/span&gt;y/N&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Still with me? Great!&lt;/p&gt;

&lt;p&gt;As you can see, you can easily stay in the terminal, jotting down things to remember, drafting commands or even use it as a multi-item clip-board.&lt;/p&gt;

&lt;p&gt;Personally I see it as a good tool for remembering commands, settings, flags or even miniature scripts, easily called up where ever you are in the file system.&lt;/p&gt;

&lt;p&gt;Sure, Jotr does not support synching across devices, but as a SysOps or DevOps tool, this can be positive, as you keep the data only in your profile, locally on the machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bonus
&lt;/h3&gt;

&lt;p&gt;Did you know that the core of Jotr is built to be embedded in other systems as a library? Check out the repo to learn more about this. Click on the "library" link.&lt;/p&gt;

&lt;p&gt;Thank you so much for your attention!&lt;/p&gt;

&lt;p&gt;I'll catch you later with updates, tips, trick or other tidbits.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;-Morten&lt;/p&gt;

</description>
      <category>notes</category>
      <category>cli</category>
      <category>terminal</category>
    </item>
    <item>
      <title>Meet Termit - A NodeJS based terminal editor</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Mon, 21 Oct 2019 13:10:23 +0000</pubDate>
      <link>https://dev.to/hakash/meet-termit-a-nodejs-based-terminal-editor-5024</link>
      <guid>https://dev.to/hakash/meet-termit-a-nodejs-based-terminal-editor-5024</guid>
      <description>&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/hakash"&gt;
        hakash
      &lt;/a&gt; / &lt;a href="https://github.com/hakash/termit"&gt;
        termit
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      The TERMinal edITor - embeddable CLI editor
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I've finally come around to make some improvements on this project, and as far as I can test, it functions as intended.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core functionality
&lt;/h2&gt;

&lt;p&gt;Termit is, as the title states, a terminal editor based on NodeJS. This means it is installable with &lt;code&gt;npm i -g termit&lt;/code&gt; and runnable from anywhere with &lt;code&gt;termit&lt;/code&gt; or &lt;code&gt;termit some-file.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It is heavily influenced by Nano, so some aspects of the user experience is similar, as well as some key-bindings.&lt;/p&gt;

&lt;p&gt;If you want a simple terminal editor that simply allows you to edit your files, and the system already has Node installed, then you can use this. It is of course  a heavier choice than Nano, Pico, Vim or similar if you install Node for this alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embedding
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;But wait! There is more!&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Termit also supports being embedded in other applications. By simply requiring and instantiating it with voluntary options, you can use this to let the users have a multi-line input area in the CLI that supports copy-paste, returning content on save with or without saving to file.&lt;/p&gt;

&lt;p&gt;To support additional actions or content-extraction on save, Termit support pre-save hooks in a similar way that Express uses middleware. You add your callback/middleware to the stack and as with the Express-middlewares, if you do not explicitly call &lt;code&gt;next()&lt;/code&gt;, you abort the chain.&lt;/p&gt;

&lt;p&gt;This comes in handy if you want to extract the content to the parent application, without letting Termit touch the file-system. Follow the link up-top to the repo to see some simple code-samples for setting this up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testers wanted!
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Hear ye! Hear ye!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I feel the terminal has reached a level of stability and maturity where it is ready to start testing it in real-world scenarios, and since I am alone on this project, I need the help of the creatively and/or mischievously inclined people here. &lt;/p&gt;

&lt;p&gt;First of all mangle it, test it, use it and see if it will break under some weird environments that I won't be able to test myself.&lt;/p&gt;

&lt;p&gt;The documentation needs a review as well, and I know the code needs all kinds of testing. I'm planning on implementing testing of the current feature-set, with all the necessary refactoring to achieve that. The reason it's not there already is quite simply time and a need to understand how to test terminal-manipulations. Any tips on that is much appreciated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future
&lt;/h2&gt;

&lt;p&gt;Not many plans here yet, besides the testing-bit mentioned further up. I feel I need to get some feedback from actual users on any pain-points or short-comings.&lt;/p&gt;

&lt;p&gt;One thing I know I want to investigate, is "compiling" is as a standalone package installable via Chocolatey, Homebrew or similar. The compiling would remove the need for NodeJS to be pre-installed, but I fell that it would never compete with Nano or similar, so I might not bother. &lt;/p&gt;

&lt;p&gt;The embeddable aspect is possibly the most interesting feature, and the direction that would benefit most from gaining more features and making it more useful to other projects as the core editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  The End
&lt;/h2&gt;

&lt;p&gt;Well, thanks for your time, and your help! I hope you like it, even if you don't see the point of it. It was an interesting challenge really.&lt;/p&gt;

&lt;p&gt;Use the comments below to express first-impressions and general comments, and if you have any issues with it, please open an issue on GitHub. PR's are of course welcome as well.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;-Morten&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>editor</category>
      <category>termit</category>
      <category>helpwanted</category>
    </item>
    <item>
      <title>Swapping two numbers, w/o a temp variable</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Mon, 14 Oct 2019 18:28:54 +0000</pubDate>
      <link>https://dev.to/hakash/swapping-two-numbers-w-o-a-temp-variable-5fc1</link>
      <guid>https://dev.to/hakash/swapping-two-numbers-w-o-a-temp-variable-5fc1</guid>
      <description>&lt;p&gt;Todays post will be a short one, but one that covers a really simple algorithm that still might stump you in an interview setting if you don't have a background in math, or if you haven't been doing code puzzles on your spare time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting the feel of it
&lt;/h2&gt;

&lt;p&gt;Let's start with the easier version, just to get a feel for the task.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Write an algorithm that swaps two numbers.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ok, that is easy enough. In pseudocode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The numbers
a = 1
b = 2

// Let's swap
c = a   // c == 1
a = b   // a == 2
b = c   // b == 1

// result
a == 2
b == 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Ok, we just store the value of &lt;code&gt;a&lt;/code&gt; in temporary storage &lt;code&gt;c&lt;/code&gt;, set &lt;code&gt;a&lt;/code&gt; to the value from &lt;code&gt;b&lt;/code&gt;, and then set &lt;code&gt;b&lt;/code&gt; to the former value of &lt;code&gt;a&lt;/code&gt;, now found in &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Upping the ante
&lt;/h2&gt;

&lt;p&gt;Let's remove the &lt;code&gt;c&lt;/code&gt; from the algorithm, not allowing temporary storage...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Write an algorithm that swaps two numbers, without using extra storage.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Wow, that one is a bit trickier. We can't use any more storage, but we need to swap the numbers. Luckily this involves numbers, and we can leverage math to help us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The numbers
a = 1
b = 2

// lets swap
a = a + b   // 1 + 2 = 3 =&amp;gt; a == 3, b == 2
b = a - b   // 3 - 2 = 1 =&amp;gt; a == 3, b == 1
a = a - b   // 3 - 1 = 2 =&amp;gt; a == 2, b == 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Ok, we first set &lt;code&gt;a&lt;/code&gt; to be the sum of both numbers. Then we set &lt;code&gt;b&lt;/code&gt; to be the result of subtracting it from the sum, making it be the former value of &lt;code&gt;a&lt;/code&gt;. Lastly we set &lt;code&gt;a&lt;/code&gt; to be the result of subtracting the former value of &lt;code&gt;a&lt;/code&gt;, now stored in &lt;code&gt;b&lt;/code&gt;, from the sum, still stored in &lt;code&gt;a&lt;/code&gt;. This results in &lt;code&gt;a&lt;/code&gt; getting &lt;code&gt;b&lt;/code&gt;s old value.&lt;/p&gt;

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

&lt;p&gt;Until I learned this trick the hard way myself in a coding quiz, I was baffled by this question, simply because I have been "trained" to think too much about variables, code, loops and other constructs, and too little in the math-department. This made me attempt to find clever ways of solving it using code, rather than the much simpler math.&lt;/p&gt;

&lt;p&gt;I hope you can get some value from this little tip, saving you from the feeling of inadequacy that I felt. Getting stuck on quizzes like this, that are truly simple to solve, but that we tend to overcomplicate, really does not help us manage the impostor syndrome that most of us experience at times.&lt;/p&gt;

&lt;p&gt;Good luck with your interviews!&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;-Morten &lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>interviewquestion</category>
      <category>numberswap</category>
    </item>
    <item>
      <title>Randomizing arrays</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Sat, 12 Oct 2019 21:43:35 +0000</pubDate>
      <link>https://dev.to/hakash/randomizing-arrays-94k</link>
      <guid>https://dev.to/hakash/randomizing-arrays-94k</guid>
      <description>&lt;p&gt;A little while back I had to make a card game in the browser. As with all card games, there is a need to shuffle the cards. &lt;/p&gt;

&lt;p&gt;"Great!", you might think. "Sounds easy enough! Just call the &lt;code&gt;.randomize()&lt;/code&gt; or &lt;code&gt;.shuffle()&lt;/code&gt; method on the array.", is a normal plan and assumption... until you realize your language of choice does not implement such a feature for you.&lt;/p&gt;

&lt;p&gt;I ran into this issue and needed to find a solution. Luckily for me, I had recently played around with some algorithm challenges and remembered an algorithm called the "Knuth shuffle", after the great Donald Knuth. &lt;/p&gt;

&lt;p&gt;To be fair, he was the one popularizing the algorithm, but the current version, adapted for computers, was made by Richard Durstenfeld, based on the works of Frank Yates and Ronald Fisher, the Fisher-Yates shuffle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The algorithm - in plain English
&lt;/h2&gt;

&lt;p&gt;The goal of the algorithm is to provide a sufficiently pseudo-random shuffling of the given array for most use-cases, though not for cryptography.&lt;/p&gt;

&lt;p&gt;Typically the algorithm starts at the last element, working towards the first, picking a random element of the elements preceding the current element. This way we keep track of already shuffled elements in an easy and non-complicated way.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given the index &lt;code&gt;i&lt;/code&gt; and that &lt;code&gt;i &amp;gt; 0&lt;/code&gt; is true, then take a random number between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;i-1&lt;/code&gt; inclusive. Let's name this &lt;code&gt;r&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next we need to swap the elements using a temporary storage.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In temporary storage &lt;code&gt;t&lt;/code&gt;, store the randomly picked element: &lt;code&gt;t = array[r]&lt;/code&gt;. In the randomly picked index location &lt;code&gt;array[r]&lt;/code&gt;, store the current index element &lt;code&gt;array[i]&lt;/code&gt;: &lt;code&gt;array[r] = array[i]&lt;/code&gt;. Lastly set the current index location to the randomly picked element stored in &lt;code&gt;t&lt;/code&gt;: &lt;code&gt;array[i] = t&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, if &lt;code&gt;i&lt;/code&gt; is still larger than &lt;code&gt;0&lt;/code&gt;, do it all again.&lt;/p&gt;

&lt;h2&gt;
  
  
  The algorithm - in JavaScript
&lt;/h2&gt;

&lt;p&gt;This algorithm works in most, if not all, languages, as it is language agnostic, but some languages has this type of functionality built in, and that might be an even better solution if you want good statistical spread.&lt;/p&gt;

&lt;p&gt;Anyhow, JavaScript was where I encountered the need, so here it is, fleshed out with comments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tmp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&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="mi"&gt;3&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="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Start at the last index (length - 1),&lt;/span&gt;
&lt;span class="c1"&gt;// loop while i is bigger than 0,&lt;/span&gt;
&lt;span class="c1"&gt;// decrement i with one for each pass&lt;/span&gt;
&lt;span class="k"&gt;for&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;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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="nx"&gt;i&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="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the random number&lt;/span&gt;
    &lt;span class="nx"&gt;rand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Store the randomly picked element in the temp variable&lt;/span&gt;
    &lt;span class="nx"&gt;tmp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;// Set the randomly picked index to be current element&lt;/span&gt;
    &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="c1"&gt;// Set the current index to be the randomly picked element&lt;/span&gt;
    &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tmp&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;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Now as you see, this algorithm is actually quite efficient as well. It uses only one pass of the array to do its job, which means it runs in &lt;code&gt;O(n)&lt;/code&gt; in Big-O notation. It also doesn't use any additional arrays, or shifting of arrays, which means that the only real overhead it has, is the storage for the temporary value and the random value.&lt;/p&gt;

&lt;p&gt;Here is another piece of trivia for you, the Fisher-Yates shuffle was created in 1938 and converted to computers by Durstenfeld in 1964. The conversion also reduced the run time from &lt;code&gt;O(n²)&lt;/code&gt; to &lt;code&gt;O(n)&lt;/code&gt; as we see here.&lt;/p&gt;

&lt;p&gt;Well, I for one enjoyed writing this, and I hope you enjoyed reading it. Leave a comment below if you use other algorithms for this use case or just want to share some other insight or comment on this.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;-Morten&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>arrayshuffle</category>
      <category>javascript</category>
      <category>random</category>
    </item>
    <item>
      <title>The simplest way to mimic HTMLEncode in your browser</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Fri, 11 Oct 2019 21:21:07 +0000</pubDate>
      <link>https://dev.to/hakash/the-simplest-way-to-mimic-htmlencode-in-your-browser-17g4</link>
      <guid>https://dev.to/hakash/the-simplest-way-to-mimic-htmlencode-in-your-browser-17g4</guid>
      <description>&lt;p&gt;I was working on a simple textarea based input field with a preview-feature the other day and got to a point where I wanted to render the HTML written in the textarea as written, not parsed as HTML. I was mildly surprised to see that JavaScript did not have it included by default, unlike PHP and most other server-side languages.&lt;/p&gt;

&lt;p&gt;Looking into the issue I discovered a trove of plugins and modules for solving the matter, but that felt a bit heavy handed for my use case. I wanted something simple, fast and really small.&lt;/p&gt;

&lt;p&gt;Doing some more research and playing around, I discovered someone who used built-in features of the browser to sole the problem, in a most ingenious way using jQuery. That library was totally unneeded for the job though, and I present to you the "vanilla" version.&lt;/p&gt;

&lt;p&gt;Behold:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;htmlEncode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&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;el&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="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&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;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&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;And the inverse:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;htmlDecode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&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;el&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="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&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;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&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;Be aware though that this encodes everything HTML-related, so if you are using this on a Markdown-source, you will break your block-quotes. &lt;/p&gt;

&lt;p&gt;Thank you for your attention!&lt;/p&gt;

&lt;p&gt;-Morten&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>encode</category>
      <category>decode</category>
    </item>
    <item>
      <title>100% Pure HTML/CSS Page Navigation - No JavaScript Required</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Sat, 13 Oct 2018 08:15:07 +0000</pubDate>
      <link>https://dev.to/hakash/100-pure-htmlcss-page-navigation---no-javascript-required-2em5</link>
      <guid>https://dev.to/hakash/100-pure-htmlcss-page-navigation---no-javascript-required-2em5</guid>
      <description>&lt;h1&gt;
  
  
  Build a page navigation system using only HTML and CSS
&lt;/h1&gt;

&lt;p&gt;This is a little trick I've acquired over the years, and for most use cases it works wonders in keeping my code clean, lean and free from unnecessary JavaScript. &lt;/p&gt;

&lt;p&gt;Imagine a Single Page Application or a page showing and hiding panels, modals etc. without reloading the page. Clicking on one of these triggers will alter the content of the page. &lt;/p&gt;

&lt;p&gt;Traditionally this was done using jQuery or some home made JavaScript functions altering the styles or classes on the elements in question. Setting a class with &lt;code&gt;display: none;&lt;/code&gt; to hide or &lt;code&gt;display: block;&lt;/code&gt; to show them are classics, along with setting that style directly on the elements.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Well, there is no need to do it so complicated at all.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;Take a look at this HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;...
&lt;span class="c"&gt;&amp;lt;!-- Just a typical nav-element with a list of links --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#page1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Page 1&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#page2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Page 2&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
    ...
    &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#page5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Page 5&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
...
&lt;span class="c"&gt;&amp;lt;!-- 
    All the divs with the content you want to serve. Notice page1 sits last. 
    This is important for the CSS to work.
--&amp;gt;&lt;/span&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;"page2"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"page"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;[some content]&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&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;"page3"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"page"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;[some content]&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&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;"page5"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"page"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;[some content]&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&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;"page1"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"page default"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;[some content]&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;Here we have the &lt;code&gt;nav&lt;/code&gt; element with it's links, and the &lt;code&gt;div&lt;/code&gt;s with their content. Notice the ID of the DIV is the same as the anchor link. One important thing is placing the first page, or rather the div with the content you want to be shown when no link is clicked yet, last.&lt;/p&gt;

&lt;p&gt;And here is the important parts of the CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* This hides all pages */&lt;/span&gt;
&lt;span class="nc"&gt;.page&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* This displays the first page */&lt;/span&gt;
&lt;span class="nc"&gt;.default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* This displays the page corresponding to the one you clicked on */&lt;/span&gt;
&lt;span class="nd"&gt;:target&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* This hides the default page when another page is clicked */&lt;/span&gt;
&lt;span class="nd"&gt;:target&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="nc"&gt;.default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&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;Or condensed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.page&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;:target&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="nc"&gt;.default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.default&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;:target&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&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;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Now, the CodePen I've embedded below contains CSS and HTML not displayed in this example, but that's just to make it "pretty" and has nothing to do with the actual function of the nav. Just the layout. Try it out before we unveil the secret sauce, and a caveat.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/canis1980/embed/WaEXZz/?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Unveiling the secret
&lt;/h2&gt;

&lt;p&gt;The first part of this secret is the links. The &lt;code&gt;href&lt;/code&gt; contains only hashed identifiers  like the ones you use to jump up and down a page. The hash in a URL gets picked up by CSS using the &lt;code&gt;:target&lt;/code&gt; pseudo-selector, allowing us to use that to change the style of the element who's ID is equal to the hash in the URL.&lt;/p&gt;

&lt;p&gt;The second part is how we use the selectors to hide the default page. Since we are placing that last, we can use the sibling selector to target all elements with the class &lt;code&gt;.default&lt;/code&gt; that comes after the element who is targeted. &lt;/p&gt;

&lt;p&gt;Now the caveat is that unless the page is structured or laid out in such a way that the top of the "pages" are also at the top of the browser, the page might jump. Some CSS/HTML only hacks can be done by using container DIVs that holds the ID and are positioned with &lt;code&gt;top: 0px;&lt;/code&gt; and contains the actual content DIV pushed down with margins, or some other similar approach. &lt;/p&gt;

&lt;p&gt;Hope you enjoyed!&lt;/p&gt;

&lt;p&gt;Oh, and if you have other approaches to do SPA and similar type navigation without JavaScript, please share in the comments.&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>navigation</category>
      <category>tips</category>
    </item>
    <item>
      <title>Spring Boot Dependency Injection with Autowiring... wut?</title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Thu, 11 Oct 2018 08:56:42 +0000</pubDate>
      <link>https://dev.to/hakash/spring-boot-dependency-injection-with-autowiring-4kk4</link>
      <guid>https://dev.to/hakash/spring-boot-dependency-injection-with-autowiring-4kk4</guid>
      <description>&lt;p&gt;I've been trying to catch up on Java now, doing advanced courses on Coursera featuring graph-theory, data structures and algorithms and all that stuff. Then I went on to do some hands on, practical &lt;em&gt;"How To"&lt;/em&gt; type tutorials, and as long as one follows the instructor, all goes well. &lt;/p&gt;

&lt;p&gt;The problem arises though, when I try to add some features or new data to the application. All through the tutorials the instructor adds all these &lt;code&gt;@Autowired&lt;/code&gt; properties all around, but I can't seem do grok how they are actually populated. I am not even sure &lt;em&gt;where&lt;/em&gt; in the app the values for these are initialized or marked or whatever to be used as the value to be magically inserted by the framework. &lt;/p&gt;

&lt;p&gt;I do understand that the Spring Boot framework does the magic under the hood using dependency injection, but now &lt;em&gt;how&lt;/em&gt; to utilize that magic on purpose and control it.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>explainlikeimfive</category>
      <category>java</category>
      <category>spring</category>
      <category>autowiring</category>
    </item>
    <item>
      <title>Meet NanoQueue and the Schema Dependency Principles </title>
      <dc:creator>Morten Olsrud</dc:creator>
      <pubDate>Sun, 07 Oct 2018 21:50:48 +0000</pubDate>
      <link>https://dev.to/hakash/meet-nanoqueue-and-the-schema-dependency-principles--1e9f</link>
      <guid>https://dev.to/hakash/meet-nanoqueue-and-the-schema-dependency-principles--1e9f</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This project is currently in stable alpha and needs use cases and contributions to start growing. &lt;/li&gt;
&lt;li&gt;The name "Schema Dependency Principles" is very much a woking title.&lt;/li&gt;
&lt;li&gt;This article will also give the backdrop for the ideas presented, so the tldr is: &lt;em&gt;Modular code is cool, dependencies is not. Depend on information schemas, not classes or named modules!&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;NanoQueue is an idea that came to me when working on a microservice based concept for the municipal sector here in Norway. It is heavily influenced by the message driven architecture we worked on and is in itself not the real answer to any problems like many frameworks claim.&lt;/p&gt;

&lt;p&gt;NanoQueue is a minimalistic message broker and module registry for your browser. It is currently implemented in less than 70 lines of JavaScript, including white space lines, curly braces and the works.&lt;/p&gt;

&lt;p&gt;The mission NanoQueue is on is to help modularise your code and split your pages into smaller, self-contained components with minimal outside dependancies. I believe in the principles of building apps using the appropriate pieces, like a jigsaw puzzle, rather than buying into gigantic, heavy frameworks that solve all your problems, creates new issues you never knew you had and sucks up mobile data on a scale never seen before. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's face it, the Land of Front-End is a place of magnificent wonder and unspeakable horrors, all at once.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The mission
&lt;/h2&gt;

&lt;p&gt;The concept I collaborated on sprung out from the need to get Master Data Management in check, and we soon uncovered a growing pile of troubles related to that. Some of the troubles we saw was vendor lock-in of our data, incompatibilities between systems needing to share data and the sheer complexities of the ginormous monoliths available to the public sector.&lt;/p&gt;

&lt;p&gt;We quickly discovered that killing the monoliths was the most viable way forward, but splitting the monolith into a myriad of microservices that were still tightly coupled and relied heavily on each other smelled funny to us. At this time microservices was the new holy in the cloud sphere, and even Docker was not really a thing yet, or just in it's early infancies.&lt;/p&gt;

&lt;p&gt;After some more work on this, we concluded that the dependencies of a service should lie in it's needed data, and what data it spits out. In a message driven architecture this is possible as the services never directly talk to each other. They only publish and subscribe to topics, queues or message types on a common message broker. Even the dependency for the broker can be somewhat loosened by using standard protocols like AMQP.&lt;/p&gt;

&lt;p&gt;This lead us to the core of the concept: &lt;em&gt;&lt;strong&gt;Depend upon an information schema published in standardised messages, not services or modules.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The key benefit is that you can replace any part with another part that consumes and produces at least the same schemas. There was of course a lot more to the meat of the concept, but this is the core of it, and the core I'm trying to take with me into the front-end space.&lt;/p&gt;

&lt;h2&gt;
  
  
  But front-end?
&lt;/h2&gt;

&lt;p&gt;Yes, this core principle can be just as valuable on a web page with many components sharing data and events, relying on something to happen or data to be fetched, even user actions. &lt;/p&gt;

&lt;p&gt;Now, this is not an attempt to attack, devalue or reason agains using tools like Redux, React, Vue, Angular and similar, as they are all great tools in their own way and area, and they absolutely solve a lot of problems. They can however be quite complex, and are often used just because that is what is being done.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In many cases all your component needs is to be notified of changed relevant data, relevant events or even requests for jobs done.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  State
&lt;/h3&gt;

&lt;p&gt;A component should care about and handle its own state, and share changes in its state with others who depend on that data as well. It should only change the state when something internal happens, and when it receives messages with new or updated data it cares about, that something internal should happen to process that data and possibly influence the state.&lt;/p&gt;

&lt;h3&gt;
  
  
  UI components
&lt;/h3&gt;

&lt;p&gt;All components should know how to change its own appearances based on messages received or internal events like user actions on the component itself. UI components should only care about displaying data or interactive elements, and mostly be ignorant to how that data is retrieved or what happens because of the interaction. &lt;/p&gt;

&lt;p&gt;Some exceptions here is internal actions in the component that need to happen in response to the interaction, like changing a colour, checking a checkmark or other types of UI changes to indicate to the user that they did interact with the component.&lt;/p&gt;

&lt;h3&gt;
  
  
  Non-UI components
&lt;/h3&gt;

&lt;p&gt;These components are typically the ones maintaining some master data records, being the current truth to resolve disputes or what have you. They also do the background tasks like talking to a server, managing sessions, cookies, local storage and such, perform computations, translations, conversions, parsing or other type of short or long-running tasks that are request based in nature. Acting as a middleware for incoming data, automatically parsing etc. before emitting the result, would also be a great application.&lt;/p&gt;

&lt;h2&gt;
  
  
  NanoQueue's role
&lt;/h2&gt;

&lt;p&gt;The part NanoQueue can play, and other brokers like it, is the central hub that handles the passing of the messages. Like I stated in the introduction, NanoQueue does not really solve the problem, but it facilitates the solution. &lt;/p&gt;

&lt;p&gt;What I hope to see, is that we can build a community effort to creating standardised message schemas for specific types of messages. &lt;/p&gt;

&lt;h3&gt;
  
  
  A simple example
&lt;/h3&gt;

&lt;p&gt;Let's take a component that displays a user profile. It needs data like the username, display name, e-mail, profile picture and similar. Some profiles are naturally more complex than others, but for this example, we'll keep it simple and assume that the extra data can be supplied in "schema extensions" or similar.&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;username:&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s2"&gt;"some_dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;email:&lt;/span&gt;&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="s2"&gt;"some_dev@email.some-dev.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;display_name:&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"Some Dev 👨‍💻"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;profile_picture:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://some-dev.com/pic.png"&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;p&gt;This data could be requested using a topic like &lt;code&gt;general.user.profile.request&lt;/code&gt; or something similar. This structure lends itself to easily parse the topic for specificity increasing for each dot, and makes looking up stuff in a dictionary really easy. It is also somewhat the standard in at least some server side message brokers.&lt;/p&gt;

&lt;p&gt;The component that knows how to handle requests for a user profile, will do just that, get the profile from the server if it does not already have the data, and return it through another message, for example using a topic like &lt;code&gt;general.user.profile&lt;/code&gt; to make the data available to everyone wanting that data.&lt;/p&gt;

&lt;p&gt;Some mechanisms for ensuring only the sender receives the response could easily be implemented using contract-bound callbacks, component generated one-off topics like &lt;code&gt;general.callback.[some unique id]&lt;/code&gt; which is given in the request as the callback address. To ensure only the requester can subscribe to the replies, NanoQueue would need a little feature extension, but this should be relatively trivial.&lt;/p&gt;

&lt;p&gt;Now, the messages themselves would possibly look something like the following:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The request:&lt;/strong&gt;&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;publish_topic:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"general.user.profile.request"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;data:&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;user:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some user id"&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;callback_topic:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"general.callback.123456789"&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;p&gt;&lt;strong&gt;The public response:&lt;/strong&gt;&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;publish_topic:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"general.user.profile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;data:&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;username:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some_dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;email:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some_dev@email.some-dev.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;display_name:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Some Dev 👨‍💻"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;profile_picture:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://some-dev.com/pic.png"&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;p&gt;&lt;strong&gt;And the private response:&lt;/strong&gt;&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;publish_topic:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"general.callback.123456789"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;data:&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;username:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some_dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;email:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some_dev@email.some-dev.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;display_name:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Some Dev 👨‍💻"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;profile_picture:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://some-dev.com/pic.png"&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;h2&gt;
  
  
  Bonus feature
&lt;/h2&gt;

&lt;p&gt;As an added bonus feature, NanoQueue supports taking the role as the module registry. If you have a dependency which is a module, not a schema, or want to separate the HTML from the JavaScript code as much as possible, you can have the modules self-register with NanoQueue when they load, for example using self executing anonymous functions ( immediately invoked anonymous function is another name I've seen) to load the module when the script loads.&lt;/p&gt;

&lt;p&gt;You can then access the modules using their name:&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;myModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_Q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myModule&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;This also saves you from clobbering the window-object with loads of modules and random variables. You have one place to find your data and dependencies. Only NanoQueue needs to be globally accessible through the window object.&lt;/p&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I have not gotten so far in this project, but the broker works. The concept is formulated, but not implemented. NanoQueue lives in a repo on GitHub:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/hakash" rel="noopener noreferrer"&gt;
        hakash
      &lt;/a&gt; / &lt;a href="https://github.com/hakash/nanoqueue" rel="noopener noreferrer"&gt;
        nanoqueue
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Minimal Pub/Sub Message Broker for messaging between components on a page
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;NanoQueue&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;Minimal Pub/Sub Message Broker and Module Registry for messaging between components on a page. See &lt;a href="https://nanoqueue.dittdesign.com/example1.html" rel="nofollow noopener noreferrer"&gt;https://nanoqueue.dittdesign.com&lt;/a&gt; for a live example usage.&lt;/p&gt;




&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Introduction&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;NanoQueue is a minimalistic messaging broker and module registry for decoupling modules and components on webpages.&lt;/p&gt;

&lt;p&gt;NanoQueue registers itself in the global &lt;code&gt;window&lt;/code&gt; object as &lt;code&gt;NanoQueue&lt;/code&gt; and with the short form &lt;code&gt;_Q&lt;/code&gt;. Accessing the framework is as simple as &lt;code&gt;window.NanoQueue&lt;/code&gt;, &lt;code&gt;window._Q&lt;/code&gt; or in its simplest form, just &lt;code&gt;_Q&lt;/code&gt;.&lt;/p&gt;

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

&lt;p&gt;NanoQueue is mainly used for sending messages between components, allowing you to have a simple way to make sure hard-to-reach components get their status updates. You can also register multiple components to subscribe to the same topics, allowing you to very easily send the same info to many receivers at once.&lt;/p&gt;

&lt;p&gt;This architecture is well known in the cloud native, microservices and scaling spaces as a "Publish/Subscribe" architecture, or as a message driven architechture.&lt;/p&gt;

&lt;p&gt;Working…&lt;/p&gt;
&lt;/div&gt;


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


&lt;p&gt;I'm guessing the standardised message schemas and the whole concept should have it's own space somewhere, and possibly some tooling to validate the schemas. &lt;/p&gt;

&lt;p&gt;I am open for suggestions and comments, contributions and collaborators who can help me shed some light on the concept and spread the word.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>discuss</category>
      <category>messagebroker</category>
      <category>modular</category>
    </item>
  </channel>
</rss>
