Showing posts with label imagemagick. Show all posts
Showing posts with label imagemagick. Show all posts

This Week I Learned 2018 - Week 48

Last week post or read the old stuff instead.

What is this console app that always gave me a conflicting experience every time I use it? ImageMagick. Besides the forking of GraphicsMagick, the use of complex XML format (surprising for a 28-years program at the time of writing) as its configuration settings, it always failed when processing large number of files that exceed its default threshold values. Tweaking it with different settings or disabled it did not resolve the crash issue. Switching to GraphicsMagick yielded the same result. The workaround was convert each image file to PDF in parallel manner and merge all PDF files as single large PDF file.
find . -name '*.jpg' | parallel --progress convert {} {.}.pdf
pdfunite *.pdf scanned_doc.pdf

Does Webpack, Docker Machine, through Virtual Box, and Unix-based host OS work well? No, not really when come to watching changes of files and hot reloading. First, Inotify, the Linux kernel subsystem which notify file changes to application is not and will not be supported in Virtual Box. How about we switch to VMWare? Nope, not supported either. Switching Webpack's watch method to polling have its own issue as well, CPU usage and hot reloading depends on frequency of polling. The key is find the acceptable polling interval. Off course, there are workarounds but not to my liking. If you read carefully, optimal solution using Inotify does not work because the limitation of shared folders through Network File System (NFS) and how file changes event is not communicated between Docker's host and container.

What to consider when designing RESTful API for third parties usage? There are four rules: (1) Use API keys for every request endpoint, (2) Regulate usage through rate limiting using HTTP 429 and API key instead of IP address, (3) Revoke API key if there are usage violation but provides API for client to check rate limits, and (4) Use other means to validate authentication and authorization beside API key.

What are the differences between COALESCE and IFNULL in MySQL? There are several but COALESCE is the preferred choice because (1) It's a standard and should works across multiple DBMS (but do we switch DB that often?), (2) COALESCE support multiple arguments until it can find the first non-NULL value but IFNULL only  support two arguments, and lastly (3) IFNULL is slightly faster than COALESCE. Interestingly, undefined value (1/0) is considered as NULL or missing value.
mysql > SELECT IFNULL(1/0,'yes');
mysql > yes

mysql> SELECT COALESCE(1/0,'yes');
mysql > yes

What is the equivalent of `which` in Windows? `where` as shown below.
C:\where notepad
C:\Windows\System32\notepad.exe
C:\Windows\notepad.exe

This Week I Learned - 2016 Week 36

Last week post or you might want to check out the whole series.

Some findings around the Internet.

XKCD-style graph using Matplotlib? In Ubuntu, you'll need to install these fonts to get the closest possible rendering.
$ sudo apt-get install ttf-mscorefonts-installer fonts-humor-sans
$ rm -rf ~/.cache/matplotlib/fontList.cache

Using Matplotlib without X-server? Switch to Agg backend. Useful when you're rendering image through Docker container.
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

Sigh. Unresolved ImageMagick bug in most recently releases including the LTS, which text conversion still causing core dump. Switching to GraphicsMagick, a fork of ImageMagick did not resolve the issue as command line options have both diverted. My research made me aware that both tools were being used to massively batch process images in a very large scale.

Sometimes, the default Vim configurations/features is good enough without installing buggy extensions. We're relying too much on the external plugins without utilizing the fullest features of Vim itself.

Old time PHP developer switching to Perl? You should read this Reddit's post. The advice given was spot on and correlates with my own personal experience. Nothing against PHP, but in our journey to become a better developer, you'll need to expose yourself to other programming languages and environments. Otherwise you'll end up like those developer who claimed to be a ten-plus years developer but actually doing the same development development work for a year but repeated ten times. I will write another blog post on this in coming future.

"To finish projects on time, start every single step as late as possible" via HN. Full text of all the twitter posts. Catching and provocative statement coming from Tiago Forte, a productivity consultant. Despite the click bait title, HN user, bmh100 interpret his message correctly. Keywords here is "critical path". In other words, is Critical Chain Project Management. Sometimes I wonder is procrastination due to lack of awareness of a task? Or to rephrase it, procrastination is a mindfulness problem? Without awareness, there is no estimation and prioritization, hence the task will be postponed repeatedly or not completed within the time frame?