This Week I Learned - 2016 Week 43

Last week post or the whole series.

This is one of those week where I become very wordy. ;-)

Previous post was too long when I realized that Blogger don't let me add more than 20 tags. That threshold should be a good indicator for me to stop jotting down the item and move to next week post. Some of these notes below are old items which I haven't have time (lack of discipline) to jot it down in a timely manner (lack of consistency). Don't sweat on this. Reflect, learn, adapt, adjust, monitor, and continue as usual. Although there are some minor hiccups, there is still like 9 weeks to go for this year.

Generating and attached iCal invite through email? It may seems simple as first, but, as usual, it may works for one email client but not for others (we haven't take into consideration of desktop, mobile, and web client). Furthermore, there is iCal and vCal, both are VCALENDAR standard where the former is succesor of the later. Digging deeper, it seems that different email client behaves differently when come to REQUEST METHOD used. The typical troubleshooting procedure is first, make sure you can attach send the iCal correctly through email properly using the email library (using MIME::Lite in my case). Next, read other people code on implementing similar solution. You can may miss out certain API calls or use the library incorrectly.

Testing in Perl. You can go through these articles for a start before you jump in to Test Drive Deveopment (TDD) best practices. Some of the issues I've encountered. First, to compare two different different ordered arrays, `cmp_bag` in Test::Deep is your friend. Second, To simulate delay, instead of using `sleep`, you can use Test::Mocktime's `set_relative_time` to do so. But off course, you will need to learn more tricks about the default standard testing module in Perl, Test::More. Writing a new Perl's module, integrate testing as early as possible

While we on testing. To benchmark the speed of your SQL query, you can disable MySQL query cache. This ensure that no caching is used which may give the wrong impression regarding the speed of the query.

While this is quite old news, two features in Perl 5.10 which I think make a lot of senses. The `defined or` is useful to check if a variable is defined or else use the default value (more examples). And the `state` for declaring a variable as static variable. Useful when you want to implement localized caching.

On Perl again. Check if a substring exists in a string without using Regex through using `index`. I wish Perl have more Object-Oriented way of doing so. Maybe Perl 6 have it?

Note to self. This is very useful. Several alternative ways to monitoring event in Javascript, useful for debugging. My favourite is using the `monitorEvents($0)` method. So simple and straightforward.


While we're on Javascript. Developing a web application with heavy AJAX usages? Well, you have to use `history.pushState` somehow. Why not just switch to Turbolinks?

Storing hierarchical data in database? Adjacent List is the most common and first to use approach when modelling hierarchical tree. However, Bill Karwin's presentation and example and follow up example convinces me of using Closure Table or Bridge Table may be the balance and right approach. This is useful when you're using database system like MySQL that does not supports hierarchical and recursive SQL queries natively.


This Week I Learned - 2016 Week 42

Last week post or the whole series.

Interesting week indeed. It has been a while since I last encountered so many different type of personalities who want or don't want to be a developer.

As usual, what have I learned this week? The usual stuff.

If you're running on GNU/Linux and want a way to manage different Windows OS through Vagrant, you can try this Vagrantfile. Installation and setup is pretty much straightforward, just make sure the Vagrantfile is downloaded. Unfortunately, the login still fail to work.
$ sudo install virtualbox vagrant
$ vagrant plugin install winrm winrm-fs

$ mkdir vagrant_win
$ cd vagrant_win
$ wget https://goo.gl/ATpaEY
$ IE=Win7IE8 vagrant up

Sanic, Python 3.5+ asynchronous web server. The discussion at HN seems rather interesting. While this is nothing new, asynchronous database layer like asyncpg seems rather userful to improve your DB query speed.

Issue with Babun's memory conflict after Windows updates? Try rebasing, not that Git rebasing thought. Cygwin still is the better and prefered choice for Unix experience in Windows. Yes, I know there is Bash on Windows.
1) Exit babun.
2) cmd /c %SYSTEMDRIVE%\Users\%USERNAME%\.babun\cygwin\bin\dash.exe -c '/usr/bin/rebaseall -v'

Customozing HTML's file inputs. Probably the most comprensive guide on different techniques to change the default behavour.

Web framework benchmarks. The Round 10 has one of the best humourous write-up.
The project returns with significant restructuring of the toolset and Travis CI integration. Fierce battles raged between the Compiled Empire and the Dynamic Rebellion and many requests died to bring us this data. Yes, there is some comic relief, but do not fear—the only jar-jars here are Java.
What happens when you rename a branch in Git? Plenty of things. First, you rename it locally. Next, you rename it remotely (is the same as remove the old branch and add a new branch). After that, either you update your upstream URL or checkout a fresh copy of the said new branch. Lastly, you may needs to batch update your commit messages.
$ git branch -m new_name
$ git branch -m old_name new_name
$ git push origin :old_name
$ git push --set-upstream origin new_name
$ git filter-branch -f --msg-filter 'sed "s/foo/bar/"' master..HEAD

The database schema for StackOverflow is publically accessible. I was surprised that it's such a straight forward design and nothing fancy at all. Well, is just a CRUD app with some additional tweaks here and there. However, the ranking formulae is far more interesting when compare to different algorithms used by other popular forum-like sites.

So may ways to iterate through the Perl's array. Implementation 1, 4, and 5 is what I normally used but the 5th method is still my favourite.

Source code syntax higlighter through Javascript? Just found out today, besides highlight.js, there is also Prism.js. The former seems to have more languages support but the later is used for quite a few popular projects.

NBA season going to start soon, maybe is time for me to learn some Statistics through certain API? Can't wait what surprises the 2016/2017 season will give us.

This Week I Learned - 2016 Week 41

Last week post or the whole series.

This is probably the unexpected way or the one-liner new way to purge old Linux kernels. You will need to install byobu (text-based window manager and multiplexer) as the Bash script is part of the package. Why I need to purge the old kernels? Well, I can't upgrade to Ubuntu 16.10 because `/boot` partition don't have enough free spaces.
$ sudo apt install byobu
$ sudo purge-old-kernels

Epoch, the start of a time, is commonly used in computing as a point of reference or date arithmetic. For Unix, the epoch starts from Jan 1, 1970. And I thought that was the standard epoch time used for every Operating System. I didn't realize that for Windows as well as for other platforms, the epoch time was different and it's set to Jan 1, 1601 (represented in FILETIME structure), a few hundres years earlier than Unix epoch time. Why? 1601 is the first year of 400-years cycle of Gregorian calendar.

Conversion between two epoch system times is straight forward using the simple formulae or another approach to calculate the different between two values, which is 11644473600 seconds. (Note that Windows tick is 100-nano seconds interval, which is 10000000). If you have a Windows epoch timestamp (18-digits), use this site to convert to normal date.

Using Git in Windows? Do use the Perforce's P4Merge as git merge tool for the three-ways merging tasks. Learned this while watching how other developer works. You can pick up a lot by watching how others works. Do keep that in mind.

Almost at the end of the year, maybe this is the right time to pick up Golang? Don't like buying Go books, well, someone recommended me to pick up "The Little Go Book".

Looking for beautiful real-time log analyzer? Try GoAccess, which is depends on gwsocket, a RFC 6455 compliant web socket server.. I should install this for my homelab later.

Testing your web application locally but wants to simulate different IP addresses? Try IP Spoofing to simulate HTTP requests

Using testing in C++, use Google Test. Going to try this in coming days if I can get my C++ development environment working.

This Week I Learned - 2016 Week 40

Last week post or the whole series.

My sentiments exactly. See comment below regarding chasing fad in technology development and especially PHP programming language. Do I actually miss PHP? Not really. But I think most of the web development systems still can be solved using PHP-based solutions. Barrier of entry to web development using PHP still the best choice.
Incidentally, this isn't unique to the front-end. I've seen the same thing happen with the SQL->ORM->Mongo->Couch->SQL nonsense, or the myriad of templating engines written for PHP, a language that itself is a templating engine.

Using Node.js? Need a basic system with essential features to bootstrap your system? Look no further than Hackarthon Starter.

The difference between Ponzi, Pyramid, and Matrix Scheme. A lot of young people, especially fresh graduates need to aware and prevent themselves from falling for such scams. The pitch of being your own boss or retire early may sounds too good to be true.

Sometimes the documentation written for a certain API, Data::ICal was so confusing that you have to resolve to searching source code written by others using the same API itself at here, here, here, and here. Can't blame the API author as the standard itself, RFC 5455 is as confusing and complicated.

Google Interview University (via HN). Instead of working for a company, why not strive to work with great people instead? Google is so big and not every team is equal. Agree with one of the comment, this is a good compilation of resource for computer science study. Which reminds me again of the Programmer Competency Matrix. Instead of focusing on the computer science stuff, why not focusing on building stuff? Someone needs to read the interview of famous programmers on their background.

Getting older but still enjoy working as a programmer? Read Reflections of an "Old" Programmer, especially the comments from the blog post itself, HN, and Reddit. The main question here is how do you age gracefully as a programmer? Lifelong learning, especially the fundamentals (the core of computer science, not latest greatest fad frameworks), as those things never changed. I blogged about this last year, during my career detour as a non-programmer role, still technical though.

Didn't realize that to use PowerTop properly, first you will need to calibrate it after installation to collect measurement data. The whole process will take a while and networking will be disabled during that period.
$ sudo apt-get install powertop
$ sudo powertop --calibrate
$ sudo powertop --auto-tune

Besides that, you can turn off unwanted running services to save a bit more battery.
$ service --status-all

Upgrade to LXD 2.3 failed to due a spelling bug in bridge network upgrade script. Fixing the bug manually and restart the installation process again.
$ sudo apt-get install -f

However, new container created don't have a default network bridge. Re-enable this resolved the issue.
$ lxc network attach lxdbr0 test-alpine
$ lxc restart test-alpine

This Week I Learned - 2016 Week 39

Last week post or the whole series.

The month of October have started. As we're closing in to the end of year 2016, I've still have long list of pending items to follow up. Sometimes, is best to take break, reflecting on the current situation, and re-prioritize your short and long term goals. Nevertheless, there is one thing for sure, regardless the outcome, discipline is one sure way to get closer to what you want to achieve.

Interesting stuff I've learned this week.

Few days back, I've managed to finish the book Modern Perl. I bought and starting reading the book on 25th June and finished it by 30th September. It took me roughly 98 days to wrap up the whole book page by page (not a good strategy according to How to Read a Book). My impression? Not a beginner book and not quite a suitable book for any developer switching from other languages. It's more like a reference book on how to code according to the Modern Perl convention. The correct sequence of Perl books to read are as follow:

Language FundamentalsReferences
Learning Perl
Intermediate Perl
Mastering Perl
Programming Perl / the "Camel book"
Modern Perl

While we're in the discussion on book. I'm quite disappointed with Eloquent Javascript. Someone suggested that I should look into `You Don't Know JS` book series instead. Maybe I should try it out instead. It's currently the next item in my reading list.

Again, on Javascript. There is an annoying behaviour of using Array with Object. Seriously? I was caught surprised by this.

On a related note, the popularity of Javascript leads to an issue of Same-origin policy where it's not permitted to request a resource from different domain. The Cross-Origin Resource Sharing (CORS) is a specification to resolve this. Solution exists for different popular web servers with support from different web browsers. For example, how to resolve this matter in Cloudfront.

Life as a Middle-Aged Geek (via HN). The advantage of being a middle-age developer is you probably know what you want or don't want out of your life. As time is catching up and you have plenty of life commitments elsewhere, if better you should constantly review and revise your own life goals. While ageism is an ongoing issue with technology sector, the Old Geek Jobs site was created for those developers whose are (35 and beyond). Or you can be an indie hacker instead?

Look-and-say sequence. Quite an interesting integer sequence, useful when you want to setup a new Wifi password but at the same time, want to confuse the hell of your users.

TLD used for local development? Mine is still using `.dev` but you must be aware that `.dev` is a generic Top Level Domain (gTLD).

Differences between Ansible's `command` and `shell` usages and when to use it. It seems I need to rewrite most of my dotfiles' steps. Didn't realize that `ansible-lint` actual exists.

What are the software stacks or cool tools used in the startup scene?

How to hire a programmer? While technical skills is a crucial requirement, cultural fit and attitude are equivalent important as well. But, as the article mentioned, nothing is guaranteed.