Random Tips for programmers
This week I wasn't able to continue my writing about MeanJS (relocation takes a LOT of your otherwise free time apparently).
So I've assembled a short list of some tips learned in the past few weeks:
Github's quick file search
When looking for a specific file on a repository that's also stored on Github, it might be easier to search for the files on the website (especially if you're dealing with a lot of different branches, easier than switching between all of them locally).
I've recently learned that there's a quick file search option, that can save you a LOT of time.
On the repository view, simply press "T", you should get the following screen:
For example, searching for main.css:
For extra Shortcuts, here's a small cheat sheet from github:
Learn the powers of git log
and just about every git command is incredibly powerful
I had to review a branch recently after merging it, sadly github doesn't give many tools to filter through commits and I wanted to see what was committed into the branch, without all the merged commits.
The command I ended up using was:
git log --first-parent
That way I only saw the direct commits on the branch, very useful.
If you also want to see what has changed within those commits, simply run:
git log -p -m --first-parent
There is a lot to learn within git log (much like in every command on git).
Event Listener Breakpoints
Let's say you're debugging a relatively complex JS website, and you're trying to grab the event attached to some button.
It has been years since Inspectors (Chrome/Firebug) were able to show coherent Event Listeners, but because of jQuery/Backbone/whatever you are using it's impossible to gather relevant information there (honestly that should be fixed).
In come Event Listener Breakpoints:
The most common event is obviously the 'click' event, that is very useful to track what functions are being called without having to put breaks everywhere.
That's it for this week, I know the post is short but I'm going to try to add some extra time next week to write a coherent post.