Showing posts with label postgresql. Show all posts
Showing posts with label postgresql. Show all posts

This Week I Learned 2018 - Week 37

Something from the archive or last week post.

If you want to do a YouTube video on tutorial on photography, how should you do it? So far, nothing can top this video. Well choreographed, interesting topic, and relevant demonstration on applying Morandi (a famous 20th century Italian still life painter) colour style in your photography. What impressed me was the tutorial was not focusing on the post-processing but instead stressed on the importance on scene selection and model's clothing choices. Sometimes, you can't simply post process (photoshop) everything.


How easy to setup development workstation in Ubuntu these days? In seconds, if you exclude the time needed to download all the packages. I've been looking into TypeScript, React, and VS Code these days and it's the right time to setup a new development environment through Ubuntu's Snap.
$ sudo snap install node --channel=10/stable --classic
$ sudo snap install vscode --classic
$ sudo snap install --edge typescript --classic

What is the best approach to read a book? Reading with a pencil  (via HN) or also known as marginalia. The idea is simple, you're basically collaborating with the book author by scribbling down your questions, thoughts, and ideas in the free margin space (limited for some books). In other words, purposeful annotations while reading or active reading (suitable for research papers but not some book genres where you read for leisure).  Also, such reading method is not applicable for ebook reader (yes, reMarkable exists but the steep price does not justify it), which still does not provides a good paper experience for doodling.

Is JQuery dead? Not yet but soon, probably within these few years. Reading through the blog post by Github Engineering on removing JQuery from Github frontend, little have I realized that the frontend (JavaScript) have matured enough to deprecate JQuery. What does this indicates? The web have move beyond the dreadful old incompatible Internet Explorer versions, which the main reason of the existence of JQuery project. What next? TypeScript becomes ES Next (maybe?) and the standardization and popularity of custome web components. One thing for sure, old things will be rediscovered, reimplemented, and rehyped again and again, as usual. Same old same old. (ง'̀-'́)ง

How to teach yourself hard things? (via HN) Alternatively, the Richard Hamming tackled this in his The Art of Doing Science and Engineering: Learning to Learn course and Edward Kmett in his Stop Treading Water: Learning to Learn lecture. Furthermore, comments in HN provides us with a few good gems in area of exercising, programming, or physics. However, this is only applicable for those who are discipline, having intrinsic motivationgood quality sleep, and don't get burn out (you will eventually). In short, learning will come naturally if you interested in tackling the problem itself. Time is limited, pick your battle wisely.

Why Microsoft Word is a better writing tool than LaTeX? Reading through the post by Thorsten Bell on the tools he used to write his book (via HN) reaffirms the mistake I've made when typesetting documents, books, and thesis using LaTeX, ConTeXt, and pandoc. Fancy tools may distract you from doing what matter most, writing itself. If the writing is difficult, we can be sidetracked through fiddling with these tools under the pretense of productive procrastination.That's why, a slow and noisy typewriter (surprise that it's still expensive these days) was such an efficient tool for writing. You can't do nothing else but type or write. Which is why so many distraction-free editors exists in these Interweb days.

Why I still love PostgreSQL after all these years? 100-plus of custome data types (even table and view can be as well) supported in the database itself (via HN). Programming languages can change numerous times for a long maintained systems. Not sure for the database system. Some developers prefer strongly typed programming languages, but they seldom look into database systems with custome data types support.

How do we test web service API through console or command line? (via HN) There are so many choices like Strest, Newman (console version of Postman), shakedown (Bash script), karateDSL, UnRAVL, Artillery, and Tavern (Python-based). Coming from console background, I have preference for shakedown and Tavern due to its simplicity.

To rent or buy a house? HN user isostatic gave a practical answer to this question. Buy if you're investing, having kids, or don't want to be forced to move. Rent if you don't want to maintenance the house.

What is the symptom of midlife crisis in a good way? Extreme athleticism. (via HN) One key point I agree with the writer is that we're preparing for the coming old ages as highlighted in this quote. Interesting days ahead.
...... extreme fitness is less about being young again and more about building yourself up for the years ahead. In other words, getting better at getting older.

This Week I Learned 2018 - Week 05

Last week post or something from the archive.

New week and we're embracing the second month of 2018. The summer (for Southern Hemisphere, summer starts from December 1 till February 28 or 29) wind was blowing gently indicating the near of Chinese New Year. 活了大半辈子,原来南半球的季节正好跟北半球相反,真的是受教了!俗语说,“一年之计在于春,一日之计在于晨”, 自己要好好检讨及规划!

Going through my daily steps count, less activity this week due to sickness. Icy cold drinks during midnight and middle-age guy don't was not a good combination. But luckily we have long vacation, good to catch up with my needed rest and recovery. Comparison of total steps walked as illustrated below. (Yes I know the missing legend) Target for next week is to average out the steps till 5000 steps and above.


Dropsy and the whole body is pineconing? Nothing much we can do besides except humanely euthanize the fish. We lost three this week and unexpectedly the Blue Mable is going down also. The typical treatment is daily water changes combines with aquarium salt, Methylene blue, or Malachite green. We're not sure but I suspicious was due to overfeeding which leads to stress and constipation as well as infection.

When visited enough Aquarium shops, you will learn a thing or two. First, antibiotic powder (yellowish colour, suspect the main ingredient is Sodium Nifurstyrenate) usage was quite common especially expensive tropical fish like Discus (not a fan and seriously, a moving water pancake?!). Second, fish sellers in Market Road packed their fishes in plastic bags treated green water (suspect is Malachite green) and unpack it again in plastic square tank for selling each water in plain water. You can achieve profit if you can sustain the longevity of the fishes until they are sold to the customer.

More conversations breeders. It seems that female Bettas are far more expensive than male and fellow breeders don't want to sell their precious female Bettas to retain their quality breed of lines. Only for those who have financial gains from doing this. I wish more breeders should focus partially on the locally Malaysian Bettas. There is one breeder and I wish him all the best. Wild Bettas found locally may not be that colourful but it's good to breed and increase the population.

You know the play was so good that even the opposite bench players applauded it. This reminded me of Kobe Bryant's baseline reverse dunks. Along with Giannis AntetokounmpoBen Simmons is another NBA player to watch out for in the coming few years. Only time will tell.

Too many blockchain wannabe tech startups in Malaysia. Enough said. The never ending of startups chasing the next hype cycle.

How do you unstaged changes in Git? There are cases where merging or rebasing kind of messed up and you're left with a list of modified files.
$ git stash save --keep-index --include-untracked

Meanwhile, you can clean up your local working repository in Git through interactive mode or Git clean interactive.
$ git clean -di

The list reduction functions in List::Util. Some good examples:
$foo = reduce { $a > $b ? $a : $b } 1..10       # max
$foo = reduce { $a gt $b ? $a : $b } 'A'..'Z'   # maxstr
$foo = reduce { $a < $b ? $a : $b } 1..10       # min
$foo = reduce { $a lt $b ? $a : $b } 'aa'..'zz' # minstr
$foo = reduce { $a + $b } 1 .. 10               # sum
$foo = reduce { $a . $b } @bar                  # concat

More effed up stuff in our beloved MySQL. This time, "SQL Error (1451): Cannot delete or update a parent row: a foreign key constraint fails ....". To quote from the documentation (emphasis added),
If ON UPDATE CASCADE or ON UPDATE SET NULL recurses to update the same table it has previously updated during the cascade, it acts like RESTRICT. This means that you cannot use self-referential ON UPDATE CASCADE or ON UPDATE SET NULL operations. This is to prevent infinite loops resulting from cascaded updates. A self-referential ON DELETE SET NULL, on the other hand, is possible, as is a self-referential ON DELETE CASCADE. Cascading operations may not be nested more than 15 levels deep.

In other words, self-referenced foreign key(s) or recursive deletes doesn't work in MySQL (it WORKS in a PROPER database management system like PostgreSQL). You have to create another new table to link the relationship, something like many-to-many data model. If you needs deep nested hierarchy data structure, use Closure Table.

This Week I Learned - 2017 Week 50

Last week post or something from the archive.

Two more weeks to go and we can start the new year. Meet quite a few talented and inspiring people around. Wish I pick up illustration at a younger age. It never too old to try venture into something totally new.

The Second-system effect, where simple and efficient system was replaced by over-engineered systems due to personal agendas, preferences, and career advancement. The Mythical Man-Month book is within my reach and every time I saw the book cover, it reminded me of the profound insights of Fred Brooks. The Hack story at Facebook done everything correctly and to prevent such effect (Facebook should have just buy Zend last time and replace PHP with Hack instead). Software architecture is more leans towards theoretical, common sense, and management rather than practical hands-on stuff. Most of the recommended reading literature indicate this.

PostgreSQL Exercises. Yup, someone have helped me to check off one item of my bucket list. PostgreSQL should gain more traction and exposure comparable to MySQL. I'm glad someone made some contributions towards that direction. History always repeat itself, this time, unfortunately, the worse (MySQL) is always better.

License compliance. A concept so foreign for so many software house, let alone those startups or companies without even a human resource department.

Not really time management but mission, GTD, energy management, and automation.

Three girls in kitchen by William Gedney via (RD). When times were simpler and photography was manual, constraints, limited, and more humane. Roger May have a good write-up on his photography works.

Embroidery, potential new hobby for the coming new year? Example of a work (screenshot captured and cropped by me) by glazier-heart shown below. Not that hard, you just need patience and tracing ability. What if you combines your masterpiece with sarcasm and cynicism? Surely it going to be an awesome gift. Note to self, remember the Wheaton's Law.


This Week I Learned - 2017 Week 37

The old stuff or last week post?

Slow week but things are moving ahead. More focus and getting more deep work done.


Familiar name that caught my attention while watching the game demo. Glad to see him living his dream and doing what he love. He is part of the team (Ninja Theory) that developed Hellblade: Senua's Sacrifice (watch the development diariesIGN's review, or GamePlayHK's broadcast) is worth checking out. I've wondered, what if I'm more persistent and follow his path?





The Search for Better Search at Reddit. Every initial search implementation starts with default Database's own internal natural language full-text search implementation. For PostgreSQL is Tsearch2 and MySQL is FULLTEXT index.


Different publications have different writing style guides. If you're going to publish to their journals, follow their convention.


When comes to affordable (ahem, cheap) amplifier, Lepai is a well-known brand and the general most people would recommended it as your first amplifier. However, there was confusion about another brand, Lepy or Lvpin, which was initially thought as a clone but actually is the same company but a new name. To differentiate this, Lepai brand is used in US or internationally by Part Express and Lepy brand is used in China or TaoBao. Different name confused and influenced my search effort as I was searching for the wrong brand name. Nevertheless, if you searching for Lepai amplifier in MY, search for "Lepy" keyboard instead.

Even though these are cheap amplifier, the audio amplifier chip (more on this later) and quality of the capacitors will determine the overall sound output and pricing. Some audio enthusiasts with good electronic knowledge will purchase this category of amplifier and upgrade or modify it with better parts.




Tripath TA2020 is interesting audio amplifier chip. IEEE ranked it as one of the microchip that shock the world as it allows consumer grade sound systems to produce higher sound at a lower price. It even created a new amplifier category, Class-T amplifier, which is a proprietary variant of Class-D amplifier.

Entry level amplifier typically based their design on these few variants of Class-D/Class-T amp chips.

(1) Tripath TA2020A/TA2020A+ (20 watt per channel), TA2021, TA2024(15 watt per channel).
(2) Texas Instruments TPA3118 (30 watt per channel).
(3) STMicroelectronics TDA7492PE (45 watt per channel).

Discussion on different audio amplifier brings no benefit if you're not a audiophile or trained ears to notice the subtle differences. For a beginner, start with the cheapest possible amplifier available at your place.





This Week I Learned - 2017 Week 22

Last week's post or the whole series.

Slow week. Lots of pending stuff needs to be cleared off.

One of the best thing in learning, always be the most stupid person in a class and ask a lot of questions. You never know you will learn something new or relearn something old. Or it may reaffirm some beliefs you always held truly to yourself.

#1 If you need to display CJK characters and emojis in MySQL, use 'utf8mb4_unicode_520_ci'. Historically (another good write-up), MySQL support 'utf8mb3', later changed to 'utfmb4', and changed again to 'utf8mb4_unicode_520_ci' (since MySQL 5.7), and lastly 'utf8mb4_0900_ai_ci' (since MySQL 8.0). Sometimes you wonder why you still stuck with the curse of MySQL where there are better solution out there.

`utf8mb4` is the superset of `utf8`. Meaning that the former also includes the later character set.

To show the supported character set in your MySQL installation.

First check your MySQL version.
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+-------------------------+
| Variable_name           | Value                   |
+-------------------------+-------------------------+
| innodb_version          | 5.7.18                  |
| protocol_version        | 10                      |
| slave_type_conversions  |                         |
| tls_version             | TLSv1,TLSv1.1           |
| version                 | 5.7.18-0ubuntu0.17.04.1 |
| version_comment         | (Ubuntu)                |
| version_compile_machine | x86_64                  |
| version_compile_os      | Linux                   |
+-------------------------+-------------------------+
8 rows in set (0.33 sec)

Next list our the available character sets for `utf8mb4`.
mysql> SHOW COLLATION WHERE Charset = 'utf8mb4';
+------------------------+---------+-----+---------+----------+---------+
| Collation              | Charset | Id  | Default | Compiled | Sortlen |
+------------------------+---------+-----+---------+----------+---------+
| utf8mb4_general_ci     | utf8mb4 |  45 | Yes     | Yes      |       1 |
| utf8mb4_bin            | utf8mb4 |  46 |         | Yes      |       1 |
| utf8mb4_unicode_ci     | utf8mb4 | 224 |         | Yes      |       8 |
| utf8mb4_icelandic_ci   | utf8mb4 | 225 |         | Yes      |       8 |
| utf8mb4_latvian_ci     | utf8mb4 | 226 |         | Yes      |       8 |
| utf8mb4_romanian_ci    | utf8mb4 | 227 |         | Yes      |       8 |
| utf8mb4_slovenian_ci   | utf8mb4 | 228 |         | Yes      |       8 |
| utf8mb4_polish_ci      | utf8mb4 | 229 |         | Yes      |       8 |
| utf8mb4_estonian_ci    | utf8mb4 | 230 |         | Yes      |       8 |
| utf8mb4_spanish_ci     | utf8mb4 | 231 |         | Yes      |       8 |
| utf8mb4_swedish_ci     | utf8mb4 | 232 |         | Yes      |       8 |
| utf8mb4_turkish_ci     | utf8mb4 | 233 |         | Yes      |       8 |
| utf8mb4_czech_ci       | utf8mb4 | 234 |         | Yes      |       8 |
| utf8mb4_danish_ci      | utf8mb4 | 235 |         | Yes      |       8 |
| utf8mb4_lithuanian_ci  | utf8mb4 | 236 |         | Yes      |       8 |
| utf8mb4_slovak_ci      | utf8mb4 | 237 |         | Yes      |       8 |
| utf8mb4_spanish2_ci    | utf8mb4 | 238 |         | Yes      |       8 |
| utf8mb4_roman_ci       | utf8mb4 | 239 |         | Yes      |       8 |
| utf8mb4_persian_ci     | utf8mb4 | 240 |         | Yes      |       8 |
| utf8mb4_esperanto_ci   | utf8mb4 | 241 |         | Yes      |       8 |
| utf8mb4_hungarian_ci   | utf8mb4 | 242 |         | Yes      |       8 |
| utf8mb4_sinhala_ci     | utf8mb4 | 243 |         | Yes      |       8 |
| utf8mb4_german2_ci     | utf8mb4 | 244 |         | Yes      |       8 |
| utf8mb4_croatian_ci    | utf8mb4 | 245 |         | Yes      |       8 |
| utf8mb4_unicode_520_ci | utf8mb4 | 246 |         | Yes      |       8 |
| utf8mb4_vietnamese_ci  | utf8mb4 | 247 |         | Yes      |       8 |
+------------------------+---------+-----+---------+----------+---------+
26 rows in set (0.00 sec)

However conversion from `utf8` to `utf8mb4` will encounter these issue of `ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes`. There is a DAMN good guide (ironically better than official documentation) written to resolve that issue and planning for the migration. However, the SQL queries only works for MySQL 5.6.

Meanwhile, this is one good example of writing Perl unit test cases to evaluate `utf8mb4` character set.

#2 Found the solution to my long unanswered question. When writing Bash script, how do we skip certain parameter. For example, we want to skip first parameter but takes the second $2 parameter onward? `shift` my friend. Is a universal concept that I've looked at it almost every day in Perl but never occur to me that this is the same in Bash script as well.

#3 PostgreSQL 10 with examples. The only worthy stuff produced by HP besides the printer. People, embrace the most advanced FOSS database system. Stop playing with MySQL.

#4 Time your console commands but cannot capture the output of `time` to a file? You're not using the command correctly. You should surround it with parenthesis. Either one will work. Depends on how many output files you want to have.
$ (time ls) > outfile 2>&1
$ (time ls) > ls_results 2> time_results

#5 How do you lost 1kg per week or the perfect diet? Both gave the same good advice. It actually make sense without actually starving yourself. The key take here is to first figure out the daily needed calories. Then reduce 500 calories from your food intake and add activities that burn 500 calories as well. The second part make sense. You just don't focus on diet, you should incorporate physical activities as well.

#6 "How do I get started with artificial intelligence?" and "What can I do with AI in my own product or company?" Read this.

#7 The technology stack of craiglist. Surprising, they are using Sphinx Search Server. Thought they might be using Elasticsearch. Why? Based on the comparison on both search servers, Elasticsearch scores way higher than Shpinx. Maybe Sphinx fits the requirement usages in craiglist?

This Week I Learned - 2017 Week 19

Last week post or the whole series.

Slow week but nevertheless, it was an interesting turn of event. Can't wait for more excitements to unfold in coming week. Importantly, never lose focus on your goals over petty things.

#1 One of the best experience shared I've read when comes to employment agreement. Always read the agreement carefully and lawyer up when necessary. Emphasis added by me.
I got sucked into a dispute with a former employer once over intellectual property rights in an employment agreement. They kept trying to sneak in a clause into the agreement in every other paragraph that gave them ownership of, full rights/responsibilities for, and access to, anything I did remotely related to programming or computers outside of work while not on the clock. It was so broad, even my non-lawyer ass knew it was an awful thing. It became a deadlock argument back and forth until I asked if they were accepting liability for any illegal activities I could perform outside of work. Suffice to say those clauses disappeared by CoB the next day in the agreement.
#2 Perl's answers to the Fizz-Buzz question.
#! /usr/bin/env perl
use strict;
use warnings;
use 5.024;

my $t = <>;
chomp $t;

for my $ins ( 0..$t-1) {
    my $limit = <>;
    my $sum = 0;
    map {
        $sum += $_ if ($_ % 5 == 0 or $_ % 3 == 0) 
        } 0..$limit-1;
    print "$sum\n";
}

What interested me is not the solution but the input from the diamond operator (<>) used within this context, which itself is also another interesting story. The diamond operator is useful when writing GNU/Linux console utilities as the operator will work either on standard input or files.

#3 Probably the best sequence diagram to illustrate an HTTP request through CGI. Source from Web Development with Perl.

#4 Why does Google prepend while(1); to their JSON responses? (via HN)

#5 Why you should just use PostgreSQL if you're using Open-sourced database systems? See the number of features (those in green) available. Sigh. Yet we still stuck with MySQL.

This Week I Learned - 2017 Week 18

Last week post or you want to read through the whole series.

Since the prevalent of Internet these days, we're more connected that ever. And yet, we're even more isolated. More and more shopping malls and residential areas are being built especially around the transit stations. Basically all looks the same and people are discourage to travel to another town anymore because everything is available either online or at your nearest malls.

Sick. Down with fever. It has been a while since last time. No one but myself to blame. For people around my age, good rest and food is a way to healthy life. We're not seeking prolonged life but prolonged health.

#1 So, what's your Plan B? Good discussion from the comments. While there is some sort of discrimination against older programmers, but the reality is older programmers may just burn out or bore doing the same mind-numbling stuff over and over again. Yes, the same sh*t but different day. Not everyone have the opportunity to work meaningful projects (yes, subjective view), but most of us just work on some glorified spreadsheet or database skin. You see the same mistakes repeated over and over again from different systems and it's just pointless or bother to raise it up again.

#2 On becoming a low-level programmer. There is a curated list of information especially on the hardware part.. There is also another list of learning the fundamental of computer science. So many things to learn and explore and yet, so little time. Sometimes the reality of life commitments limit our choice on the thing we want to pursuit. I need to finish everything by July before I can start to clear the list from my bucket list. One step at a time. Follow the system.

#3 First, make it work, then make it right, and finally, make it fast. Get the thing to work first before you're thinking about making it right (giving the right name) and optimize it. Fulfill the requirements of the stakeholders first (prototyping) before you're looking into doing it right and fast. Something I need to remind myself constantly as we're often obsess with perfection. What's the point if your build it the right way and fast but does not meet the stakeholder needs?

#4 How to write a REST client in Perl. Most Perl modules have limited documentation, for example, little example on how to use the APIs. This is where PHP (it has been so long since I mentioned something about PHP) really shines. As the language is slowing dying, there are little or no good example on how to start something up fast.

Meanwhile, something rather interesting about Perl. I've seen quite a few Perl codes with subroutines that prepended with ampersand (&) operator. Basically, the ampersand is needed if you're calling a subroutine before its declaration. Off course, there are many other reasons and usages to use the ampersand, but commonly as reference to a subroutine.
&hello;

sub hello {
    print "hello";
}

When using OO with Perl, you will need to instantiate the constructor or method invocation through the arrow (->) operator (a reference). Good examples given below.

Using the arrow notation or virtual method.
my $apple = Fruit->new("apple");
$apple->get_price('usd');

Using the double colons notation or static method.
my $apple = Fruit::new("apple");
Fruit::get_price($apple, "usd");

However, to invoke the method either statically or virtually, you'll need to write the constructor as follow.
sub new {
    my $self  = shift;
    my $class = ref($self) || $self;
    return bless {}, $class;
}

#5 "error: src refspec master does not match any." Silly me. You need to commit something locally before pushing to remote Git server.

#6 Tiny Python Notebook. Definitely not tiny but quite comprehensive guide to Python 3.6.

#7 How to unstage all staged files in Git? It's so easy that the best answer is not upvoted enough.
$ git reset

#8 Postgres Weekly. When come to FOSS database choices for web application for Intranet application, I'm strong opinion that PostgreSQL should be the default choice. Feature like Range Types and others solves quite a lot of issues and save lots of developer-hours. Yes, MySQL has its own usage, but for any business application which involves monetary and strong ACID compliance, it's not a right choice.

This Week I Learned - 2017 Week 07

Last week post or the whole series.

When come to getting new stuff, I really should have a one-item policy. For example, if I'm going to get a new bag, either I sell off the existing bag or donate it out. Otherwise, no point having two bags where you only going to use one. Not only is wasteful, it's also a hassle to store it and clean it as well. Something for me ponder upon when I'm thinking of getting any new stuff.

#1 Six modern keys to wealth. HN user, monodeldiablo describes six possible ways for anyone to accumulate wealth. In essence, you should be competent (both book smart and street smart), persistent (perseverance), and extraordinary lucky (right place, right time, and right people).

Developers are generally book smart but always having difficulties to monetize their projects or technical ability (turn it into a business). The most recent example is JWE, the author and maintainer for GNU Octave is looking for job after 25 years of maintaining the software (I think he is doing a great job since he have been doing it for 25 years but having some financial difficulties these few years). I've made a small contribution to him and being a FSF associate member can help too (just make a note in your monthly contribution). Expect some blog posts on GNU Octave in coming future.

#2 Coroutines in Perl? Use Coro module. More on asynchronous programming in Perl in coming posts. Busy week and I can't seem to allocate any time to look into this. So many things to follow up and so little time.

#3 Prioritize! Prioritize! This reminds me of Stephen Covey's four quadrants approach (similar to The Eisenhower Method) of prioritizing to-do list and time management.

#4 theXeffect subreddit. Fundamental approach to build habits and prevent procrastination. Also known as the "Seinfeld Strategy". Following Bombjoke advice, the steps as follow.
  • Buy a pack of index card. Get the one from Daiso with 5mm grid.
  • Start with Boléro by Maurice Ravel as your background music.
  • Pick a daily habit you want to develop. May I recommend meditation?
  • Write the reasons on why you want to develop the habit on the back of the card.
  • Start now. Do the habit. Once done, mark a big 'X' on the box. If you fail, mark a big 'O'.
  • Continue for 66 days or 2 months. A habit is formed after that period.
The index card by hardcase00 shown below is a good example to illustrate the steps mentioned. Look closely at the card. In order to continue the streak, he have different minimum meditation time ranging from 5 seconds till 15 minutes. Set your goal so low and easy that you don't have any excuses of not doing it. Remember the main purpose is not to focus on how long you can meditate but to develop a habit of daily meditation.



#5 Software developers who started after 35. I have mixed feeling about this. Is good that anyone who are diligent enough can pick up software development skill but Peter Norvig's post on teaching yourself programming in ten years reminded me otherwise. Well, it depends on how you see software development itself. Is it a tool for your to achieve your goal? Or a skill you wish to gain and master? Different people have different motivations.

#6 Is PostgreSQL good enough? (via HN) By far, best written technical post I've read this year. Sad about the font size though. Seriously, who read at such small font size? I've seen quite a few systems which can benefit greatly if they switch to PostgreSQL instead of MySQL. MySQL, being popular and easy to learn doesn't means that it's suitable for all scenarios.There are other requirements where PostgreSQL fits, for example, PostGIS. For a comparison between two to programming languages, MySQL is like dynamic-typed programming language and PostgreSQL is like static-typed programming language. If I'm going to develop any intranet web application which involves critical financial information, my first choice is definitely PostgreSQL.

#7 Goals are for Losers. Passion is Overrated. Provocative opinion but make sense. You need to implement a system or habit to achieve what you want in life. Not passions or goals. Example from the slide is losing 10kg is a goal but eating the right way is a system. To increase the success of what you want in life, use a system approach to acquire more skills which can increase your odd. Summary of this approach. Item #4 is also another good example of systematic approach increasing the success rate of what you want to achieve in life.

This Week I Learned - 2016 Week 52

Last week post or the whole series.

Week 52, the last week of year 2016. ;-)

It has been a long way since the beginning of the whole TWIL series. I've reached my goal of writing at least 52 posts this year, I managed to hit 58 posts. Now what? Should I continue this TWIL series? Yes, indeed I should. There is no harm but benefits by continue this ritual. Maybe I should try different approaches and more diversify topics in my posting. Yearly reflection post should come later.

This Arduino project to calculate speed or to implement digital speedometer seems interesting and fun. It was quite a surprise but if you understand fundamental mathematics, it all seems easy and approachable.

Using Pandoc with different fonts and rendering engines. Below command will list out all the available fonts in your system.
$ fc-list : family | cut -f1 -d"," | sort

PostgreSQL 9.6 new features with examples (PDF) via Lobsters. All software release notes should accompany by details example on any features being updated or introduced. I have mentioned numerous times that I miss PostgreSQL a lot.

Discussion on C++17. Now I can understand why C++ is still not that suitable for Operating System development but more for application development which needs performance and full memory management.

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 04

In case you miss out, last week post.

#1 Shōwa Genroku Rakugo Shinjū (official site). Caught my attention with its unique and mature story line. Definitely way different from the regular shounen action anime. Basically a story about the journey of an apprentice rakugo storyteller. The fast paced dialogues and art style reminded me of The Tatami Galaxy (Reddit discussion).

#2 Mobile Suit Gundam: The Origin (official site). Probably the next anime series I like after the Mobile Suit Gundam: The 08th MS Team in Gundam franchise. Love the old school animation and original characters design. For some amusement, there is a good discussion on the worse Gundam protagonist.

#3 Social media friends are mostly fake (Reddit discussion). Agree with one of the comment. There is a distinctive difference between a contact and real friends. You should treat all social network as contact list for networking purpose, nothing more and nothing less. Real friends should be interacted through physical life.

#4 Empanada. So this is "Mat Salleh" (Portuguese to be exact) name for Malaysia snack called "karipap" or "curry puff". Knowing this makes me craving for the Empanada, especially those large one with filling of sweet potatoes, chicken meat, and curry spice.

#5 The Bookbinder. Remember before you submit your final thesis or dissertation you need to bind it with fabric or fake leather cover and gold foil lettering or seal? The video illustrates the step-by-step process to do it.

#6 How to create and apply patch in Git. Till today, I still can't remember how to do it properly.

#7 Conversational Commerce (HN discussion). I've noticed that the Social Network is slowly being replaced by Social Messaging. Are we going to the days where ICQ/AIM and IRC were once popular?

#8 PostgreSQL Query Plan Visualization (HN discussion). The most aesthetic visualization of PostgreSQL's execution plan for a SQL statement through the EXPLAIN command (more explanation on its usage). Which is also inspired by another tool explain.depesz.com. Unfortunately both are web-based tool where sometimes not applicable if you've sensitive SQL queries that should remain confidential.

Postgresql 9.3 Installation in Ubuntu 13.10

Since the usual PostgreSQL’s Personal Package Archives (PPA) has been deprecated in favour of a newer APT repository, is times for me to switch the repository and upgrade my installation to the latest-greatest version.

Surprisingly, there is a quicker and convenient way to install or upgrade your PostgreSQL. Let’s start with this method first.

Download the shell script, make it executable, and run it.
$ wget http://anonscm.debian.org/loggerhead/pkg-postgresql/postgresql-common/trunk/download/head:/apt.postgresql.org.s-20130224224205-px3qyst90b3xp8zj-1/apt.postgresql.org.sh
$ chmod +x apt.postgresql.org.sh
$ sudo ./apt.postgresql.org.sh

Remember, don’t simply download any shell script from the Net without actually peeking it source. One interesting thing I learned from the script is there are many ways to determine the code name of your Ubuntu/Debian distro. The simplest way is using lsb_release.
$ lsb_release -cs
saucy

Search for the latest available PostgreSQL versions, which as shown below is version 9.3.
$ apts ^postgresql-9.? | sort -r | head -n 1
postgresql-9.3-slony1-2 - replication system for PostgreSQL: PostgreSQL 9.3 server plug-in

Let’s us install the latest version, 9.3 and along with PgAdmin, the administrative tool.
$ sudo apt-get install postgresql-9.3 pgadmin3

Create and setup a local user account.
$ echo $USER
kianmeng

$ sudo -u postgres createuser --superuser $USER
$ sudo -u postgres psql
postgres=# \password kianmeng
postgres=# \q

$ createdb $USER

Finally, install the sample booktown database.
$ cd /tmp
$ wget http://www.commandprompt.com/ppbook/booktown.sql
$ sudo -u postgres psql -f booktown.sql template1

$ psql
psql (9.3.3)
Type "help" for help.

kianmeng=# \c booktown
You are now connected to database "booktown" as user "kianmeng".
booktown=# \dt
                 List of relations
 Schema |         Name          | Type  |  Owner
--------+-----------------------+-------+----------
 public | alternate_stock       | table | postgres
 public | authors               | table | postgres
 public | book_backup           | table | postgres
 public | book_queue            | table | postgres
 public | books                 | table | postgres
 public | customers             | table | postgres
 public | daily_inventory       | table | postgres
 public | distinguished_authors | table | postgres
 public | editions              | table | postgres
 public | employees             | table | postgres
 public | favorite_authors      | table | postgres
 public | favorite_books        | table | postgres
 public | money_example         | table | postgres
 public | my_list               | table | postgres
 public | numeric_values        | table | postgres
 public | publishers            | table | postgres
 public | schedules             | table | postgres
 public | shipments             | table | postgres
 public | states                | table | postgres
 public | stock                 | table | postgres
 public | stock_backup          | table | postgres
 public | subjects              | table | postgres
 public | text_sorting          | table | postgres
(23 rows)

booktown=#

PostgreSQL, the Poor Man's Oracle

Via HN. Good to hear that ARIN have successfully migrated their database from Oracle to PostgreSQL. Not sure if they are using the plain vanilla or commercialized version.

PostgreSQL is the most under-appreciated and unknown open-source database. While more features were added, they've lost the popularity game to MySQL for two main reasons. Lack of Windows support in the earlier version and availability from web hosting provider. I wish more people would add PostgreSQL into their technology stack consideration instead of just MySQL.

VARCHAR and TEXT in PostgreSQL

There is not performance between varchar and text datatype in PostgreSQL. The use of varchar and text are interchangeable. To quote the PG doc (bold emphasis by me.),
"Tip: There is no performance difference among these three types, apart from increased storage space when using the blank-padded type, and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead."
Further discussion at Reddit.

PostgreSQL Installation in Ubuntu

It has been a while since I last use PostgreSQL professionally and I really miss it a lot. The newly 9.1 installation really brings back all the memories and it's quite sad that I can't remember how to use psql anymore. To make the situation worse, I am now stuck with the horrors, stupidity, and the numerous WTF of maintaining old legacy applications developed using The Shitty Toy Db (TSTD)* with no referential integrity. All this crap using this TSTD makes me long for PostgreSQL even more.

* To be fair to TSTD, if you configure it correctly, is not that bad.

Step 1 : Installation
$ sudo add-apt-repository ppa:pitti/postgresql
$ sudo apt-get update

$ sudo apt-cache search postgresql-9.1 
postgresql-9.1 - object-relational SQL database, version 9.1 server
postgresql-9.1-dbg - debug symbols for postgresql-9.1
postgresql-client-9.1 - front-end programs for PostgreSQL 9.1
postgresql-contrib-9.1 - additional facilities for PostgreSQL

$ sudo apt-get install postgresql-9.1 postgresql-9.1-dbg postgresql-client-9.1 postgresql-contrib-9.1

Step 2 : Setting up your own database account
$ echo $USER
foobar

$ sudo -u postgres createuser --superuser $USER

$ sudo -u postgres psql 
postgres=# \password foobar
Enter new password: 
Enter it again: 
postgres=# \q

$ createdb $USER
$ psql

Step 3 : Have fun.
Step 4 : Profit ?!