JavaScript

JavaScript Closure Explained

Normally JavaScript functions can’t remember things. They’re just processes that eat inputs and poop outputs. In, out, gone. No trace left in them. If you were to ask them to personally keep count of the number of times they’ve executed, they would stare back at you with blank, sad eyes.

While closure, simply put, is a JavaScript function that carries its own persistent, private variables [1][2].

Continue reading

Standard
OS X

Remapping Keys in Sierra

Because of my use of VIM, ESC is much more useful to me than the more easily accessible CapsLock. I’ve always used Seil to switch them, until it started to fail in the new MacOS, Sierra.

After a bit of search, Karabiner solved my problem wonderfully.

Standard
Thoughts

System Error

99% of learning happens when one adjusts their actions according to feedback. When this airway is blocked, situation can hardly ever improve. And the biggest reason for evading and resisting investigating and learning from errors, is a tendency to take it personally.

As opposed to “take it systematically”.

Continue reading

Standard
Thoughts

Death of KickassTorrent

A couple of days ago, the creator of the most popular torrent sharing site, KickassTorrent, was arrested in Poland, and as of now US is seeking his extradition. After isoHunt’s shut down in Canada, 2013, ThePirateBay’s end in Sweden, 2014… now this. Again.

Continue reading

Standard
Fun Projects, Performance

Huffman Coding Explained

Due to patent issues with newer schemes [1], Huffman Coding remains to be the go-to compression algorithm of the day, being applied in ZIP, JPEG, PNG… and much more.

The core idea of Huffman Coding, is to use shorter codes to represent more frequent characters. As for why we always see a mysterious tree of zeros and ones, well, that’s essentially how computers store anything: with binary codes. Essentially the goal of constructing the Huffman binary tree is: to assign the most frequent characters to the shortest zero/one path, walking from tree root to end of a branch.

tree

How to create such a tree?

Continue reading

Standard