A programmer’s nit-picks

Programmers are notoriously nit-picky. We have opinions, stances, and preferences on just about everything and tend to get into frivolous (and often heated) arguments and discussions about our nit-picks. Compiled language vs. interpreted language? Nit-pick! Tabs vs. spaces? Nit-pick! Braces on same line or new line? Nit-pick!!!

In fact, programmers are so passionately nit-picky we invented a process to force our nit-pickyness onto others when they contribute code to our open source projects: code reviews! We even prefix some of our comments with β€œNit:” for emphasis! (Do understand I am using hyperbole here. Code reviews are a good thing and I am grateful for them.)

Lately I have been reading the book RailsSpace (1st edition website) to expose myself to the Ruby programming language, Ruby on Rails, and MVC. I am not actually running any of the code, simply reading the book, code and all. It has been rather interesting and I may have to write a post on the experience when I finish it.

Continue reading “A programmer’s nit-picks”

Watch what you name your form inputs!

I came across this little snafu yesterday while working on my capstone, which I was able to reproduce in all the major browsers.

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form submit</title>
<form method="get">
<label><input type="checkbox" name="random-check"> Random check box</label><br>
<button name="submit">Submit the form!</button>
var Qform = document.querySelector("form"),
Qsubmit = document.querySelector("button");
Qsubmit.addEventListener("click", function(e) {

view raw
hosted with ❤ by GitHub

If your form has any form of <input> or <button> with a name attribute of “submit” (name="submit"), it will override the <form>‘s JavaScript .submit() method and throw an error when you try to call it (as I do in the same code above)!






Internet Explorer 11

Changing the attribute’s value to anything else, even “form-submit”, will prevent the method from being overwritten. So be aware of what you name those inputs! They could introduce some pretty nasty bugs! It took me a bit to track this down because it was behavior I did not expect!


Android version fragmentation needs fixing

If you own a smart phone, tablet, “phablet” or follow the tech industry at all, you will have heard this one word used over and over again in a ton of blog posts (including this one), news articles, and pretty much anything else you can think of:


In the context of phones, tablets, and the like, fragmentation is defined in a basic form as:

Fragmentation is the result of many generations of smartphones or tablets running various versions of the same operating system.

While fragmentation has been primarily used in reference to Android and iOS, it is also present in Windows, Mac OS X, and Linux operating systems, though it is not near as severe there as it is in mobile devices. Further, fragmentation does not occur solely in the core of an operating system (arguably the worst kind), it can occur to any form of software. For example, Niels Leenheer wrote an excellent article on Android web browser fragmentation.

Continue reading “Android version fragmentation needs fixing”

Notepad in HTML5 and JavaScript

On the morning of 10 October, I tired of working on my capstone and had finished contributing a patch to an open-source project, I decided I needed a small, fun, project to quickly create as a change of pace. A few minutes later, either inspirational or pure randomness stuck: recreate Windows Notepad.

Continue reading “Notepad in HTML5 and JavaScript”

WordPress – Load enqueued JavaScript in async or defer

Lately I have been working with WordPress, creating a complete website (even original theme) with it for my college capstone. Generally, things have been fair but there have been some things I have wanted to write a rant-y blog post about (but will not because I value my readers too much πŸ™‚ ). One of those things is loading JavaScript into a site.

According to the documentation, wp_enqueue_script is “the recommended method of linking JavaScript to a WordPress generated page.” So as a good developer I have used this for loading my JavaScript. Aside from the rather crazy parameter order and defaults, I was quickly irked by the inability to load scripts asynchronously. After much searching though the WordPress docs and various programming sites, I came across the following article which uses a simple hash to denote async scripts, use the clean_url hook to filter all external URLs for JavaScript files (although file extensions are only hints) and add the async HTML attribute. However, the function was a bit too naive and limited for my taste (what if I wanted to defer a script?), so I wrote my own function using the basic idea of that snippet, which is the topic of this article. πŸ™‚

Continue reading “WordPress – Load enqueued JavaScript in async or defer”

JS – Smooth scrolling without jQuery

You know what link anchors are, correct? They are used to jump between different sections of the same page. Quite often when a link anchor is clicked, the page smoothly scrolls to the desired location. However, smooth scrolling is not the native behavior. No, the native behavior for link anchors is to instantly jump between sections, which can be jarring and unpleasant. That is why many developers smooth it out using jQuery scripts like this one.

I too enjoy it when anchor links smoothly scroll, but for the last few months I have on a “jQuery fast” and it has severely limited my smooth scrolling options. Smooth scrolling is impossible to recreate with CSS transitions, I have had limited success using requestAnimationFrame, and fun scroll-to-top buttons like Elevator.js are not appropriate. I have really been in the dark on filling the hole left by removing jQuery.

Continue reading “JS – Smooth scrolling without jQuery”

Where in the world is LEGO Island?

For years, one question has lingered in the minds of many LEGO fans, a seemingly simple question with an unresolved solution: “Where in the world is LEGO Island?”

For those who are not aware, LEGO Island is the very first computer game published by The LEGO Group, predating LEGO Star Wars: The Video Game by 8 years. For many older LEGO fans, LEGO Island is considered the LEGO video game, surpassing even TT Game’s latest offerings.

Continue reading “Where in the world is LEGO Island?”

PHP – Calculate your age

Back in 2014 I wrote a JavaScript tutorial on calculating your age. Today, we are going to be exploring the same thing but in PHP!

Calculating the difference between two dates is much easier in PHP thanks to the DateTime family of classes introduced to the standard library in PHP 5.2.0. They provide built-in methods for timezones, date comparison, and date difference, just to name a few things. Because they abstract all the hard work for us (like good APIs ought to do), we will be putting them to use in this tutorial. If you are one of those poor souls who have to use an even older version of PHP (and I am so, so sorry about that. I hope you are paid well.), it would not be hard to port the JavaScript tutorial and replace the UTC calls with calls to date() (I recommend using “j”, “n”, and “Y”). You might also require running date_default_timezone_set("UTC"); before that depending on your server configuration.

On to the code! πŸ˜€

Continue reading “PHP – Calculate your age”