രണ്ടായിരത്തി ഇരുപത്തിയൊന്ന് പിറന്നിട്ട് ആദ്യം വായിച്ച പുസ്തകമാണ് ഡോ.ഉമാദത്തൻ രചിച്ച “ഒരു പോലീസ് സർജന്റെ ഓർമക്കുറിപ്പുകൾ”. ഒരു സുഹൃത്ത്, അദ്ദേഹം വായിച്ച മികച്ച പുസ്തകങ്ങളേക്കുറിച്ച് എഴുതിയ ഒരു കുറിപ്പാണ് ഈ പുസ്തകം വായനയ്ക്ക് തിരഞ്ഞെടുക്കുവാൻ എന്നെ പ്രചോദിപ്പിച്ചത്. മലയാള പുസ്തകങ്ങൾ ആമസോൺ കിൻഡിലിൽ കിട്ടിത്തുടങ്ങിയതോടെ വായന ഏതാണ്ട് പൂർണ്ണമായും അതിലേക്ക് മാറ്റിയിരുന്നു. പുസ്തകത്തിന്റെ സാമ്പിൾ വായിച്ചു ഇഷ്ടമായതോടെ അടുത്ത വായന ഇതായിരിക്കണമെന്നു തീരുമാനിച്ച് ഒരു കോപ്പി (ഡിജിറ്റൽ) അപ്പോൾ തന്നെ വാങ്ങി വച്ചു. എന്നാൽ ആദ്യ അധ്യായങ്ങൾ സൃഷ്ടിച്ച ആകാംക്ഷ മൂലം വായിച്ചു കൊണ്ടിരുന്ന പുസ്തകം മാറ്റി വച്ച് രണ്ടു ദിവസം കൊണ്ട് വായിച്ച പുസ്തകമാണ് ഇത്.
രസകരമായ രീതിയിൽ , എന്നാൽ ഗൗരവം ചോരാതെ തന്റെ അനുഭവങ്ങൾ വായനക്കാരിലേക്ക് എത്തിക്കുന്നതിൽ ഗ്രന്ഥകർത്താവ് വിജയിച്ചുവെന്നാണ് എന്റെ അഭിപ്രായം. ഇതിൽ വിവരിച്ചിരിക്കുന്ന ഒരനുഭവം വർഷങ്ങൾക്കു മുൻപ് എന്റെ നാട്ടിൽ സംഭവിച്ചതാണ്. അതിന്റെ സത്യാവസ്ഥയും എങ്ങനെ ആ കേസ് ശാസ്ത്രീയമായി തെളിയിച്ചു എന്നും അറിയാൻ സാധിച്ചു.
ഡിജിറ്റൽ പതിപ്പിൽ അക്ഷരപ്പിശക് ഏറെയുണ്ടായിരുന്നത് സുഗമമായ വായനയ്ക്ക് തടസ്സമായി. ഗ്രന്ഥകാരന്റെ പ്രശ്നമല്ലെങ്കിലും പലയിടത്തും എന്താണുദ്ദേശിച്ചതെന്ന് മനസ്സിലാക്കുവാൻ സമയമെടുത്തു. ഈ പോരായ്മകൾ ഒഴിവാക്കിയാൽ, മികച്ച വായനാനുഭവം!
There are only two hard things in Computer Science: cache invalidation and naming things.
Reading this post shared in Hacker News today was thought-provoking. One among the TwoHardThings – naming things – might have an implication on society. Am I right when I say that I have a file named blacklist.yaml which stores all those words which are not allowed in my application?
Happy to see that the Internet Engineering Task Force has a draft working towards fixing such terms in their specification documents. This draft mentions certain commonly-used terms like master-slave, whitelist-blacklist and possible alternatives to make these specifications more neutral in terms of our society. While this draft progresses, I feel that the developers can start bringing changes in some places immediately, starting with renaming a file from blacklist.yaml to blocked.yaml etc.
Post Script: My muscle memory still makes me type git push origin master. Who is the master here? Maybe this should be renamed to trunk as in subversion.
The word “machine” has its origin in the Greek word “makhana” meaning “device”. Initially used to refer mechanical structures built to perform an intended action, the term “machine” in modern times encompass a lot more – automobiles, computers, farm machinery, factory automation systems, robots – the list goes on. At times, reading and learning about those old machines which paved the way for the new and technologically advanced ones is fascinating.
I am not an automobile enthusiast who gets down to the nitty-gritty of every vehicle I drive. Nevertheless, a few vehicle restoration videos I watched on YouTube in recent times inspired me, not as a driver, but as an engineer. In most of these videos, the YouTuber rescue (that’s the word most of them use) and restore a car or a truck which has been abandoned by its owner. Here is one of them I bookmarked:
It is the sheer passion for engineering that drives these folks to search for old vehicles and bring them back to life. Often, the search for a spare part makes them travel miles. One can imagine how satisfied they would be looking at those restored engines moving again. Ain’t they giving rebirth to these old machines?
My thoughts were in conjunction with computers while watching these videos. Does anyone care to bring back vintage computers to life? Even if anyone does, is it worth restoring them considering their sluggishness compared to modern computers? Any decent smartphone we have today has more computing power than old computers and can perform millions of operations in fractions of a second. A restored van from the 1960s can still move at 40 mph, and satisfy the driver with the pleasure of driving a vintage vehicle. But a restored computer from the 1970s – say an IBM 5100 with memory ranging from 16-64KiB – will never satisfy the user now as he/she won’t be able to listen to his/her favourite music album! Once restored, it might be exciting to see something coming upon the screen but that is more or less useless in the modern era.
Moore’s law holds! New computers replace the older ones quickly by adding more computing power, memory, storage etc., thus paving the way for technological innovation in almost every part of our daily life – automobile, modern medicine, home appliances etc. Present-day software is hungry for more computing power, memory etc. to solve harder problems using better faster algorithms. This makes computers obsolete at a faster rate than ever before. Nobody cares to rescue and restore these as we do with automobiles!
I found a few old/vintage electronic devices at my home – a Yashica film camera bought by my father around 30 years back, a Tape Recorder made by Sharp Corporation in the late 1980s etc. Occasionally, I feel like fixing the tape recorder to make it sing again, then comes the bitter realization that I don’t have any cassettes to listen to – they have been replaced by Spotify or YouTube Music installed on my smartphone.
The Active Support component of Ruby on Rails provides a class named KeyGenerator for generating secret keys. This is a wrapper around OpenSSL’s implementation of PBKDF2 (Password-Based Key Definition Function 2) and is commonly used to generate secrets keys for encryption use-cases.
CachingKeyGenerator is a wrapper around KeyGenerator class which helps us to avoid re-executing the key generation process when it is called using the same salt and the key_size. This is helpful because the key generation process is computationally costly. However, CachingKeyGenerator uses an instance of Concurrent::Map to store the generated keys in memory to avoid the re-execution. This is not helpful when the number of keys to be cached is large so that periodic cleanup is required on least recently used ones.
Assume that we are using CachingKeyGenerator to generate unique secret keys for encrypting personal information of our application’s users. This will return the key if it exists in the Concurrent::Map or re-execute the key generation process and cache the key before returning to the caller. When the userbase is huge, it is not practical to store all the generated keys in the memory of application instances. Instead, it would be ideal to perform a periodic clean up of the cached keys to avoid memory hogging.
We will see how we can solve this issue using a new wrapper around KeyGenerator. Instead of Concurrent::Map in CachingKeyGenerator, this implementation will use ActiveSupport::Cache::MemoryStore which, as per the documentation, is Thread-safe and has an LRU based clean-up mechanism built-in:
This cache has a bounded size specified by the :size options to the initializer (default is 32Mb). When the cache exceeds the allotted size, a cleanup will occur which tries to prune the cache down to three-quarters of the maximum size by removing the least recently used entries.
KEY_EXPIRY = 1.day # expire the keys which are older than a day
@key_generator = key_generator
@keys_cache = ActiveSupport::Cache::MemoryStore.new(expires_in: KEY_EXPIRY)
# Returns a derived key suitable for use.
cached_key = @keys_cache.fetch(args.join)
return cached_key unless cached_key.nil?
# cache miss, generate a new key
generated_key = @key_generator.generate_key(*args)
As the default cache size is 32Mb, this helps to avoid memory hogging of our application while providing a cache for frequently used keys.
Recently, I decided to digitise my songbook (lyrics with chords annotated) using the TeX typesetting system. TeX provides amazing packages for typesetting songbooks. Since my collection had mostly Malayalam songs, XeLaTeX was my choice of TeX engine which has better support for non-Roman scripts – like Malayalam, Tamil etc.
There are several TeX packages available for typesetting song lyrics and chord books. I am using the songbook package which is fairly advanced in its features. The following gist is a sample source code for generating lyrics of a famous Malayalam Melody – “തേരിറങ്ങും മുകിലെ”, annotated with the chords.
Munnar, popularly known as “Kashmir of South India”, is a famous tourist destination in the Idukki district of Kerala state. Known for its picturesque hills and Neelakurinji (a shrub with purplish-blue flowers that blossoms only once in 12 years ), it is one among most sought out destinations by the tourists visiting India.
With the mercury levels touching almost zero degrees, snowfall was the main attraction that rallied tourists to Munnar in December 2018. In the meanwhile, I upgraded from 9-year-old Sony a390L DSLR to Sony ILCE-6300 and was planning for short trips to capture landscapes using my new gear. Initial plans were to travel to destinations nearby Bengaluru. As part of this, I toured Shivanasamudra Waterfalls along with 2 of my friends. I will write another post on this trip soon.
On a short vacation to my hometown in January, I decided to drive to Munnar along with my cousins. Munnar town is almost 100 kilometres away from my native, and I knew that it was indeed a poor decision to drive that night. After a long journey from Bengaluru to Hometown, I was tired. My cousins too had a tiring day at work. But the desire to capture the snowfall and the sunrise persuaded me. I promised my cousins to drop them back the next morning as they have to be at the office by 10:00 AM.
With my camera and its accessories, winter clothes and a few bottles of water, we started around 9:00 PM in my car. The plan was to reach the Top Station (around 30kms away from Munnar town) by 5 AM to capture the sunrise. By midnight, we reached Adimali where we stopped to have tea. The temperature had already dropped to 7 degrees. Relying on the time and distance information provided by Google Maps, we decided to take a nap somewhere between Adimali and Munnar. Drive for 3 hours had already taken sleep away from me. My cousins had dived into a deep sleep which left me alone beneath the clear sky of Munnar. I decided to drive slowly to our destination.
Somewhere en route to the Top Station, I spotted an open place where the sky looked so beautiful with a lot of stars. The time was around 2 AM by then. I stopped over there to experiment with astrophotography. I spent almost an hour to figure out how to use bulb mode in my camera and was able to capture the following images.
Around 5 AM, we reached our destination – Top Station – the highest point in Munnar and falls on the Kerala – Tamil Nadu border. Early arrival helped me to find a photo spot and capture the sunrise. We started driving home around 6 AM, as my cousins had to report to their offices for duty. Munnar is a paradise, a must-visit destination for travellers exploring Kerala.