For example, a library I'm using didn't do a thing the way I wanted. No problem - just patch in the way I wanted it to work by replacing the functions on the object's prototype... Swizzling ftw.
@bigzaphod my colleague made a thing so you can add the diff you want to apply to that library in your git repo, and then apply that diff automatically when installing dependencies: https://github.com/ds300/patch-package
@bigzaphod Me: "Let me do some of these math calculations in the web UI in JavaScript I'm sure it will be fine."
Me 5 minutes later: "Well that was my dumbest idea ever."
@bigzaphod If you're not doing horrifying things with a language's type system, are you even programming?
@bigzaphod This is where someone says something smug about Lisp.
@bigzaphod I do a lot of work with dates, this has been a life-saver:
Date.prototype.stdTimezoneOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1);
var jun = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
}
Date.prototype.isDstObserved = function() {
return this.getTimeZoneOffset() < this.stdTimezoneOffset();
}
Added an easy check to the Date method to check if the location observes DST. Super handy!
I'm sure there's no possible way this will bite me in the ass later.