Thursday, September 10, 2015

What a line of code

I didn't know this line of code (in any language) will make sense but apparently it does:

auto l = [](){};

Look at all those brackets!

I encountered this when reading this blog ("http://blog.3d-logic.com/2014/12/08/c-async-development-not-only-for-for-c-developers-part-i-lambda-functions/").

It's a C++ lambda function and equivalent to this C# code:

Action l = () => {};

In C#, an Action type is a delegate (a function pointer) that returns null. The pair of empty parentheses means there is no parameter for this function. The empty curly braces means it's not doing any operation at all.

So in summary... it's a piece of code that accepts no parameter, doesn't do anything, and returns nothing. Effectively useless. But nevertheless valid code. And quite beautiful too.


Sunday, September 06, 2015

Google Play Books, Chrome, and the Language Issue

I have this one problem with the Google Play Books website (https://play.google.com/books/reader) in Chrome when I'm already reading a book. No matter what I do my Google Chrome browser doesn't seem to recognize it and change the language of the navigational links.

As an example, I had my settings before in Chrome for my languages set to English and Filipino, the Philippines' native language. Just to make it consistent I wanted to see the navigational links (like "Exit", "Return to page X") in English. But for some reason, no matter what I do (clear my Chrome browser's cache several times, restart my Chrome browser several times too, change my Google profile to English, etc) it always reverts to Filipino ("Lumabas", "Malapit ka na sa dulo", etc).

See sample below:

Google Play Books language issue
Before the fix

Upon investigation (when you look at the source of the returned HTML of the navigational portion of the reader page), it shows the following in the HTML tag: , FIL being the language shorthand for Filipino. So the solution is to somehow change it to .

The problem is: How?

After several hours of wasted time and trial and error, it turns out the solution is relatively easy: pass an additional querystring parameter to the URL such that instead of this:

https://play.google.com/books/reader?

you'll have:

https://play.google.com/books/reader?&hl=en.


The HL=EN parameter does the trick and forces your Google Play Books reader page to render all navigational links in English.

I hope this helps those who have the same issue as I do.

Happy (Google Play Book) reading!


What a line of code

I didn't know this line of code (in any language) will make sense but apparently it does: auto l = [](){}; Look at all those bracke...