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”
I see this mistake way more often than I should. Someone adds an event listener with an anonymous function callback to an element (like a button) then puts it in a a function that may get called multiple times. While this very common setup may seem harmless, it can create some serious issues.
The problem is this setup will add multiple listeners to the element, a new one each time the function is called, meaning three calls will add three listeners, then when the event is triggered the callback will be run three times. This JSFiddle demo clearly shows the scenario in action.
Continue reading “JS – Avoid duplicating addEventListener()”
I came across this little snafu yesterday while working on my capstone, which I was able to reproduce in all the major browsers.
If your form has any form of
<button> with a
name attribute of “submit” (
name="submit"), it will override the
.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!
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”
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.
According to the documentation,
defer a script?), so I wrote my own function using the basic idea of that snippet, which is the topic of this article. 🙂
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”