Posts

Showing posts from 2017

Mindset

Carol Dweck's book has simple thought: growth vs fixed mindset is the core of learning process, how we face the challenges. Because of simplicity, this thought really feels true. The corollaries of the mindset are huge. Literally - the general path in life we choose when using one mindset or the other. As a father, chapter about praising effort and not the talent in the children is especially helpful (done something very fast and without effort? Then it was too easy for you, let's do something challenging!)

Born A Crime

My first audio book turned out to be amazing childhood stories of south african-born comic Trevor Noah. Totally different experience of a man growing up in different country, sometimes funny, sometimes sad but amazingly true.

Be careful when you cast

There was a bug which indicated itself when something was saved to sqlite and then queried back. It turned out that we were saving int which got bind to int64 but when binding value in query we (tada!) used unsigned int! The catch could be demonstrated with the following small example: #include <iostream> #include <stdint.h> using namespace std; int main() {   int src = 0xFFFFFFFF;   int64_t x = src;   uint32_t req = 0xFFFFFFFF;   int64_t y = req;   cout << "x = " << hex << x << endl;   cout << "y = " << hex << y << endl;   cout << (x == y) << endl; } x = ffffffffffffffff <- what we are saving y = ffffffff <- what we are searching for 0 In here, x and y get literally the same value but after converting to int64, totally different values get saved to the database! Fix? Bind to int - it's 4 bytes and in this case! And maybe use uints/int more consis...

On Writing Well

The new book on my bookshelf, On Writing Well by William Zinsser. Helps clear up the head a lot in terms of writing. Main thoughts: No clutter - just minimal amount of words for what you want to say Rewriting/editorial is not only normal but essential (example with the real manuscript edits is golden) You are writing for yourself in the first place Write for people, with people In detail: Verbs - active, precise, colorful No redundant adverbs or adjectives Contractions are totally fine (I thought not!) He/she is the real problem: use plurals ('they', 'we') or change wording to address What struck me: just "friends" vs "work friends" + "close friends" (no distinction sounds a lot better!) See a lot in common with writing good code - say only what you want to say, no more, no less.

QTCreator for x86

Historically, we were using 32-bit Ubuntu (16.04) for development and all was good... until we discovered that maximum QTCreator version you can officially get (without building from sources  of course) is 3.5.1 ! Which, while not too bad, had some nasty crashes fixed only in the later versions. And only after some time and luck, we discovered that ubuntu-sdk-ide is QTCreator with plugins. What's important, it gets updated for x86, too! (latest version is 4.1.0 for 16.04) see here . As a result,  sudo add-apt-repository ppa:ubuntu- sdk-team/ ppa && sudo apt update && sudo apt install ubuntu-sdk-ide. Solved!

Failure Is Common

Just read the James Altucher's Choose Yourself . Very inspiring piece of work. Inspiring in a sense that many other books are talking about: failure is not only normal but failure is very-very common. Almost-evident wisdom but still it takes to read many-many books talking about this in one or the other fashion (and heck a lot of practice of failing) to really feel that with your own bones. Great book!

Travelling Idea

When I was driving from Los Angeles to San Francisco, I had to find the place or places where to stay for the night. I was wondering if, given the data from all the people travelling this route, it is possible to find the best places to stay considering few parameters you can choose like "Days travelling - Awesome places to see - Cheapest stay on the route". If you want cheapest trip, algorithm will find the optimal route prioritizing this criteria, or if you want just the route people usually take - see it and decide for yourself whether it is what you want. For example, if booking.com has, for example, lots of data of anonimized user IDs, it should be possible to implement something like that, isn't it? Or there is already such a service and I had just totally missed it?

sqlite + multiprocessing?

Just implemented simple test (mostly using examples from the internet). Yes, sqlalchemy+sqlite crashes when more than one thread is trying to access the database file. Need to move to MySQL to have a few processes (like Tornado) access the DB...

Rabin-Karp Algorithm

Random thought: i t turns out that Rabin-Karp is based on quite simple things - first, knowing the hash function and, second, understanding that the previous hash of the substring could be used to calculate the next one (when including next symbol) in O(1) instead of calculating the next hash anew in O(n).

Getting POSIX TZ strings from Olson tzdata

Problem at hand: we are having IOT device which does not have the IANA/Olson tzdata package but we would like users to be able to select their time zones from the list, but not enter the TZ string in form of PST8PDT... After a lot of searching, I could not discover the way of obtaining any sort of the TZ string database which would work for most of the cases. The closest I got was the momentjs  JSON data generated from the old good Olson tzdata but, alas, it was still missing the simple TZ strings. Now it was pretty much evident that solution should still somehow include the Olson database but I did not know how. Final step had come up when I actually have taken a look at the tzinfo file format and discovered that in the current version (v2), the TZ string lies right in the end of each file, conveniently separated by the new line symbols at start and in the end! So the final solution for now is: download latest tzdata build it with zone info compiler (or just zic) ...