/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `’: Homebrew must be run under Ruby 2.3! You’re running 2.0.0. (RuntimeError)

brew update
brew install ruby

World’s most spoken languages

World’s most spoken languages, based on # of first-language speakers‬
‪ ‬
‪1. Chinese (Mandarin) 935M‬
‪2. Spanish 390M
‪3. English 365M
‪4. Hindi 295M
‪5. Arabic 280M
6. Portuguese 205M‬
‪7. Bengali 200M
‪8. Russian 160M‬
‪9. Japanese 125M‬
‪10. Punjabi 95M

https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers

What does that mean?

A list of 25 Principles of Adult Behavior by John Perry Barlow

1. Be patient. No matter what.
2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
3. Never assume the motives of others are, to them, less noble than yours are to you.
4. Expand your sense of the possible.
5. Don’t trouble yourself with matters you truly cannot change.
6. Expect no more of anyone than you can deliver yourself.
7. Tolerate ambiguity.
8. Laugh at yourself frequently.
9. Concern yourself with what is right rather than who is right.
10. Never forget that, no matter how certain, you might be wrong.
11. Give up blood sports.
12. Remember that your life belongs to others as well. Don’t risk it frivolously.
13. Never lie to anyone for any reason. (Lies of omission are sometimes exempt.)
14. Learn the needs of those around you and respect them.
15. Avoid the pursuit of happiness. Seek to define your mission and pursue that.
16. Reduce your use of the first personal pronoun.
17. Praise at least as often as you disparage.
18. Admit your errors freely and soon.
19. Become less suspicious of joy.
20. Understand humility.
21. Remember that love forgives everything.
22. Foster dignity.
23. Live memorably.
24. Love yourself.
25. Endure.

https://kottke.org/18/02/a-list-of-25-principles-of-adult-behavior-by-john-perry-barlow

HTTP GET request body

I was developing a RESTful API. When done with the basic select/insert/update, I needed to implement endpoints for batch queries. All of a sudden, I was like, how do I pass in the list of ids? Is there some standards out there?

I was thinking of using POST. That was how I did it back then, simple and easy. But with the REST philosophy, or the http way of things, I wanted to stick with GET.

So… how do I pass in a list of ids? I can use the query string, but there is a limit to the query string or uri. Not small, but not big either.

https://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string

How to represent the params in the query string for, say a list of ids? Turns out the “right” way is: http://our.api.com/Product?id=101404&id=7267261

https://stackoverflow.com/questions/2602043/rest-api-best-practice-how-to-accept-list-of-parameter-values-as-input

The URI gets a bit too long… hard to debug. So… can I send a GET request with a body? Turns out it is possible. My flask app seems to like it, though I had a hard time making that happen with AWS API Gateway and Lambda.

I did some more searches related to using GET with body. It turns out there is a split in opinions. Technically it’s doable, but that’s not what people expect things to work.

https://stackoverflow.com/questions/978061/http-get-with-request-body

For now I take the easy way to use POST with body for multiple params request (possibly a list of 10,000 ids). Sorry to REST that I failed the test.

Thousands comma numeric formatting in psql

select trim(both ' ' from to_char(12345678.49, '999,999,999.99'))

The trim is to take away the white space from the sides.

Ref: https://www.postgresql.org/docs/9.6/static/functions-formatting.html

Deep-copying in JavaScript

Good stuff.

http://dassur.ma/things/deep-copy/

Meltdown and Spectre

Meltdown

Meltdown breaks the most fundamental isolation between user applications and the operating system. This attack allows a program to access the memory, and thus also the secrets, of other programs and the operating system.

Spectre

Spectre breaks the isolation between different applications. It allows an attacker to trick error-free programs, which follow best practices, into leaking their secrets. In fact, the safety checks of said best practices actually increase the attack surface and may make applications more susceptible to Spectre

Which systems are affected by Meltdown?

Desktop, Laptop, and Cloud computers may be affected by Meltdown. More technically, every Intel processor which implements out-of-order execution is potentially affected, which is effectively every processor since 1995 (except Intel Itanium and Intel Atom before 2013).

Ref:
https://meltdownattack.com/
https://github.com/IAIK/meltdown