Quick Tips Tutorials
Quick git Commit Searching
While I love GitHub for the way it presents git repository information to me, I've been trying hard not to rely so much on GUI web apps and desktop apps, instead looking to use command line equivalents. You see that in my recent shell posts, including
IFRAME contentWindow is null
I like clean code so I do what I can to avoid unwanted JavaScript global variables. I initially thought that
keys(window)
would give mewindow
property leaks but that didn't work because browsers returned different results, so I moved on to using anIFRAME
to compare default...Get Global Variables with JavaScript
JavaScript globals are considered bad. And as a contributor to the MooTools project, I've heard this on a daily basis for the better part of a decade. MooTools got knocked for extending natives but also for placing objects in the global space, like
Browser
and$$
. I find...Git Update Commit Message
One of my faults as a professional developer is that my commit messages aren't always as descriptive as they could be. Sometimes I even notice a spelling error in them. Bleh -- that's not cool, man. When I do catch that my last commit message isn't good...
Detect if a Document Has Loaded with JavaScript
If you follow me on Twitter, you've probably noticed me whining about ChromeDriver. For some reason it seems as though tests run before the document has properly loaded, leading to transient test failures and loads of frustration. I thought the best way to avoid these problems was...
Git Undo Last Commit
I'm a massive fan of git; it's super powerful and easy to use, especially when it comes to branching. The biggest sin I commit when using git is adding files and then committing them...to
master
branch instead of a feature branch. Oops. Certainly don't want that. If you've done agit...
Get and Set Environment Variables in Node.js
One of the best ways to use sensitive information in open source repositories without hard-coding the information within publicly available repositories is setting environment variables. Set the environment variables on the server, retrieve them by key within your application. When using Node.js, you can retrieve environment variables by key from the
process.env
object: There...Detect Error Type with JavaScript
JavaScript error reporting and catching is important and will only get more important as our web applications become more feature rich and powerful. I have never used
try/catch
blocks in depth -- I usually just catch exceptions for stuff that's usually known to cause problems. Remember this one from the IE6...Serve a Directory with Node.js
As I mentioned in Serve a Directory with Python, sometimes you need a directory to be "served" instead of loading the
file://
location within your browser. In the past I would mess around with MAMPStack and swapping outhttpdocs
directories, but there are better tools these...Merge Arrays with JavaScript
Merging arrays is a fairly common occurrence. I remember when I worked a lot with PHP I would use
array_merge()
all the time. I found myself merging arrays often when handling form submission. JavaScript has a simple, native function for merging arrays (concat
) but it produces a new array.