Monday, December 29, 2014

Git Tip of the Year: Find the Most Recent Common Commit

Okay, you're working on a branch called 'awesome' and you want to know what's the most recent common commit of branch 'awesome' and 'master'.

Just run this:
$ git merge-base awesome master
d931216adebf441dc7431f1a073baed8b4a1b20a
And you'll get the SHA1 of the most recent common commit.

Friday, December 26, 2014

IntelliJ Tip of The Year: Rectangular Select

Okay, you want to select a rectangular area in your favorite IDE?

If your favorite IDE is made by IntelliJ here's what you can do:
  1. Hold an  ⌥ (Option) key and do your usual select of the area.
  2. Enjoy yourself.
Here's a video:

Wednesday, December 24, 2014

Github Tip of the Year: Shortcuts for Searching

Github has two great shortcuts that can change your life.

1. Let's say you're browsing the bootstrap repository and you want to find a file named tooltip.js
Press T (yeah, that's the character T on your keyboard).
Boom!
You've activated the File Finder:



Just type tooltip and enjoy yourself:


You can exit the File Finder by pressing Escape.

2. Let's say you're browsing the bootstrap repository and you want to search for a string "awesome".
So, you need to click on a search box and start typing, right?
Nope, just type S (yeah,  that's the character S on your keyboard).
Boom!
The search box is focused now!
Just type awesome into it and press Enter.


Isn't Github awesome?

Sunday, December 21, 2014

PyCharm Tip of the Year: Switch to the Previous File

This tip applies to any IntelliJ product.

Press ⌘-E (slow motion instant replay: Command-E). The popup window containing the list of recent files will appear:


Just press Enter to switch to the previous file. In this example that'll be a file pydrill.css.

To sum it up: to switch to the previous file in IntelliJ press ⌘-E followed by Enter.

Thursday, December 18, 2014

Git Tip of the Year: Switch to the Previous Branch

Okay, you're working on a branch called 'awesome'. You switch to a branch 'master'. You merge 'awesome' into 'master'

How do you switch back to 'awesome'?
Use git checkout - to switch to the previous branch.
# suppose we're at the branch 'master' now
$ git checkout -
Switched to branch 'awesome'
# now let's go back to master
$ git checkout -
Switched to branch 'master'
Yeah, that's pretty similar to a good old cd -.

Git Tip of the Year: Aliases

If you want to use the "git st" instead of the "git status" then you've come to the right place.

If you want to use the "git co" instead of the "git checkout" then you've come to the right place.

If you want to use the "git ci" instead of the "git commit" then you've come to the right place.

Just run this commands:
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
And you're done:
$ git ci --allow-empty -m "nice, we can commit with 'git ci' now"
Yay, we've just made a subversion out of git!

Monday, December 15, 2014

Alfred Tip of the Year: Run Command in the Terminal

First things first. This tip is for the powerpack. Come on, it's only £17!

Okay, fire up Alfred, type ">" followed by the terminal command:
This will open the Terminal and run the command "say Hallo".

If you want to use iTerm2 instead of the Terminal (who wouldn't?), no problem: Alfred Preferences -> Features -> Terminal -> Application:


Just choose an iTerm2 in the dropdown menu and you're set.


only £17 only only £17£17

Wednesday, December 10, 2014

PyCharm Tip of the Year: Multiple Cursors

Multiple cursors is the best thing to happen to text editing since ed.

Here's how to use them in PyCharm. Two simple rules:

  1. To add a cursor, hold an  ⌥ (Option) key and click on a place where you want to add a cursor.
  2. When done with multiple cursor editing, press Escape and you'll be left with a single cursor.

Here's a short video illustrating this feature:

Note: in this particular use case Rename Refactoring is definitely superior to Multiple Cursors. Still a great feature.

Saturday, December 6, 2014

IPython Tip of the Year: %timeit

Let's say you have written an amazing python function called amazing_function and you want to measure its speed.

Forget about manually importing time, and looping n times. Use:
  1. IPython
  2. IPython magic function %timeit:
$ ipython
In [1]: %timeit amazing_function('some', 'arguments')
100000 loops, best of 3: 13.4 µs per loop

Wednesday, December 3, 2014

Mac Tip of the Year: Find a Menu Item by its Name

Let's pretend that you forgot how to reopen closed tab in Chrome. All you remember is: the menu item is called "reopen something".

1. Hit ⌘? (slow motion instant replay: Command-Question mark). This shortcut activates help search field.
2. Type "reopen" in search box. It's quite logical: the command we're looking for have something to do with reopening, thus searching for "reopen" is pretty reasonable.

3. Select "Reopen Closed Tab" in search results:

4. Tada!

⌘? is a great way to find menu items by name. By the way, it works with every application.