Reporting ActiveSupport::Duration in concise human readable formats
by Syed Aslam in Rails · 2 min read
Convert ActiveSupport::Duration objects to concise human readable formats like '2h 30m 45s' with locale support.
Thoughts, Stories, and Ideas
by Syed Aslam in Rails · 2 min read
Convert ActiveSupport::Duration objects to concise human readable formats like '2h 30m 45s' with locale support.
by Syed Aslam in Javascript · 2 min read
There are situations when you want to use an object or an array as a key. Unfortunately, JavaScript objects allow only strings are keys. With ES6, JavaScript gives us a second type of object called a WeakMap that allows objects as keys.
by Syed Aslam in Ruby · 2 min read
In Ruby we can create module functions for named methods that may be called with the module as a receiver, and these functions also become available as instance methods to classes that mix in the module. There are multiple techniques to achieve this in Ruby, but the simplest and best known are Module#module_function and extend self.
by Syed Aslam in Ruby · 2 min read
Ruby supports magic comments (interpreter instructions) at the top of the source file, mostly known for setting a source files' Encoding. But there is more you can do.
by Syed Aslam in Rails · 1 min read
Accessing the headers sent by clients in rails spits out both headers along with other environment variables. This adds a bit of inconvenience if you want to process only the external headers.
by Syed Aslam in Git · 2 min read
This is one hard to find out there so here it is. How to remove an updated file from a pull request whose content is changed but is out of the scope for this pull request. Now you want to remove the file from the pull request without deleting the file itself, not delete the file itself, but just revert the inclusion of this file in the pull request because, if you delete the file, then that deletion becomes part of your changeset, which is not what you wanted at all.