Sid Verma Unnecessary tautology is unnecessary

> Sid's blog: Page 3


Kodi controllers

For the past five years, a Raspberry Pi, running Kodi, has been attached to my TV. The Pi, TV and the software all get updated time to time, but the overall setup has been the same for most of it.

+----+              +----+              +-----+
| TV |----(HDMI)----| Pi |--(USB/DLNA)--| HDD |
+----+              +----+              +-----+

Controllers I’ve used for Kodi over the years -

  • Desktop Keyboards (Wired/Wireless)
  • Wireless Mouse
  • Web Interface
  • Tasker scenes utilizing the web interface API
  • Kodi remote apps (for Android/iOS)
  • Emulated keyboard over SSH
  • VNC
  • Arduino based bluetooth remote
  • Game controllers

Some of these were novelty ones, others were used because of circumstantial needs+availability.

My primary controller is the excellent app Yatse (Lets you browse/play media on the phone itself - much faster than the TV UI). When the phone’s not nearby, or there’s a guest involved, I use a game controller (connected for retroPie anyway).

Last week, I was setting up Kodi (OSMC to be exact) on my old roommate’s Raspberry Pi. While I was installing Yatse on his phone, this other guy present there, who isn’t familiar with the software, doesn’t have any of the controller I know of, starts browsing movies on the TV. I look over, dumbfounded, and see him casually using the TV remote to play around in the UI.

Five years of having a CEC-compatible TV with a CEC-compatible SBC, and it never dawned on me to try the simplest UI possible - The TV remote.

Video - The Monkey Business Illusion by Daniel Simons



Minimalistic npm packages.

A follow up to my previous post, this time we look into some of the lesser known, but widely used javascript packages.

Javascript’s NPM package manager, is one of the biggest and fastest growing package manager out there. As of writing this:

  • RubyGems - 145,675 (25 new packages/day)
  • PyPI - 149,111 (104 new packages/day)
  • Packagist - 191,577 (103 new packages/day)
  • Maven Central - 244,143 (149 new packages/day)
  • npm - 679,009 (508 new packages/day)

Minimalism doesn’t only apply to design, lifestyle and ownership, but also to code. Here are some of the most minimal packages in npm:

is-false

Returns false if the value of a property is either strictly false, or it’s inverse is strictly true.

5 weekly downloads

Let’s take a look at its github repository:

Pretty standard set of files. You’ve got your test cases, test runner config, editor config, lint config, and other necessary files. Let’s look at the code:

Absolute minimalism.

 

is-even

Return true if the given number is even.

27,881 weekly downloads

This was slightly more minimalistic.

 

is-positive-integer

check if a number is a positive integer

173 weekly downloads

Oh, the beauty!*

 

More:

 

* The author has updated the code to a very non-minimalistic monstrosity. But for the sake of this post, we are gonna pretend that the initial commit is where it’s at.



Mathematical operations on objects in javascript.

All of these were executed on Node.js 6.9.1

> [] + []
''

Obviously.

> [] + {}
'[object Object]'

Less obvious, but okay.

> {} + []
0

Huh?

> {} + {}
'[object Object][object Object]'

Oh, fuck off.

I’d rather just add strings to these from now on:

> [] + ''
''
> [] + '1'
'1'
> [] + 'a'
'a'
> {} + ''
0
> {} + '1'
1
> {} + 'a'
NaN

Lol.

Okay, subtraction maybe:

> [] - []
0
> {} - {}
NaN
> [] - ''
''
> [] - '1'
-1
> [] - {}
NaN

FML.

But, my favorite one is this:

> {} - []
-0

Follow-up post: Minimalistic javascript packages