Skip to content

Instantly share code, notes, and snippets.

@mlazowik
Last active May 8, 2022 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlazowik/9ed84c6a2bab06d060673bff75c7c7a3 to your computer and use it in GitHub Desktop.
Save mlazowik/9ed84c6a2bab06d060673bff75c7c7a3 to your computer and use it in GitHub Desktop.
Programming efficiency tips

Working with errors

First, isolate the actual error message. Sometimes it can be buried in hundreds of lines of warnings and unrelated output (c++ templates are notorious for that, things are getting better with colored higlighted output tho, clang usually gives better output than gcc).

Sometimes the best way is to literally search for the word “error” in the output/terminal.

If you don’t (almost) almost immediately know what’s wrong it almost always make sense to copy the error into Google. After copying try to figure out which parts are specific to your code (like function/variable names, specific memory addresses etc.) and remove them before hitting search. This will make results more focused as Google will not try and include your specifics.

Google search operators

Learn google search operators if you don’t know them. Most useful ones are:

  • quotes to search for exact phrases (normally google includes synonyms, different word order, disjoin words etc.)
  • minus to exclude words, example: I want to find a song named get lucky, I don’t remember the artist but I know it’s not the Daft Punk one. I can type get lucky song -daft and immediately get what I need. Sometimes I’ll go through a few iterations of excluding words
  • site: include only specific domain in results, for example scanform site:qed.ai

Quickly navigating search results

When searching, especially for things like compile/runtime errors:

  1. first adjust your query using the operators so that it seems like (from titles and text previews) that results mostly make sense
  2. scroll down through results and click on anything that looks semi-promising while holding ctrl, this will open each result in a new tab while you stay at the results tab. Possibly go over multiple result pages. Adjust how many results you open depending on how promising they look
  3. Switch to the tab with the first result (to not lose the query tab yet)
  4. Glance over the question to see if is related and how much, but not too long
  5. Jump to the few top answers and inspect them, also watch out for highly upvoted comments
  6. If the current page is not helpful close it with ctrl + w, this will close the current tab and show the tab with the 2nd result. Repeat until you find something helpful

With time you’ll be able to discern which results are applicable quicker and quicker, and this way of navigating is a lot faster than opening a result, going back, opening second result and so on

Sign up for new github code search preview at cs.github.com

It’s infinitely better than the current search bar. It can be immensely helpful to find existing usages of some library functions you want to use etc.

Use vs code in browser to navigate github repos

If you want to inspect (part of) github repo in more detail, as in more than just one file, open that repository in github and hit . (dot). This will open the repository in an online version of vs code, you’ll be able to jump to function definition/usage (regular github browser also has jump to definition btw.), use vs code search etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment