Sunday, November 30, 2014

Mac Tip of the Year: Read your SSH Key Out Loud

If you feel lonely, you can make your Mac to speak to you.

Fire up the terminal and type:
say hello
say command, ahem, says things. It can even read your private SSH key out loud (warning: this is not very secure, someone can eavesdrop you private key):
cat ~/.ssh/id_rsa | say
Or your home directory:
ls | say
Even the cliboard content:
pbpaste | say

Wednesday, November 26, 2014

Mac Tip of the Year: Draw Graphs

Imagine a situation. You're surfing web on your Mac and suddenly you feel an urgent need to draw a graph of the function y = x * x.

These things happen.

Ok, start the built-in Grapher application. It'll ask you for the graph type:


Select "Default" and click "Choose". The graph window will appear.

Type in: y = x ^ 2 and press "Enter". Done:


Now you can continue surfing web.

Sunday, November 23, 2014

iTerm2 Tip of the Year: Open an URL

Let's say there is some URL in your iTerm session that you want to visit:


Hold the ⌘ key and click on the URL. iTerm2 will open the new browser tab with your URL.

Thursday, November 20, 2014

Mac Tip of the Year: Dictionary

Let's say you're reading Ulysses on your Mac and you've stumbled on an unknown word. These things happen, you know. Just do a three-finger tap on an unknown word and enjoy its definition:



It also shows you a snippet of the relevant Wikipedia article.

Heresiarch, huh?

Monday, November 17, 2014

Golang Tip of the Year: fmt.Errorf

So, you want to create an error from the format string in golang.
That's easy, right?
import (
  "errors"
  "fmt"
)
err := errors.New(fmt.Sprintf("my %s error", "awesome"))
About 4000 golang projects  do errors.New(fmt.Sprintf(...

Don't do it, there is a better way:
import (
  "fmt"
)
err := fmt.Errorf("my %s error", "awesome")
You're welcome.

Friday, November 14, 2014

iPhone Tip of the Year: Typing Period

Let's say you're answering a text message on your iPhone and you want to type a period.

So, you need to switch to the symbol keyboard and tap on a period, right?

No. There is a better way.

To type a period on your iPhone just press space twice.
Slow motion instant replay: p r e s s  s p a c e  t w i c e.

You're welcome. Period.

Tuesday, November 11, 2014

Localhost Tip of the Year: Wildcard Subdomains

There comes a time in life when you just need to have the wildcard localhost subdomains.

/etc/hosts won't help you.

Yes, you can roll out bind, named, and whatever else. But there is a simpler and good-enough solution.

Use vcap.me instead of localhost.
vcap.me is a public name (owned by VMWare, so it's pretty solid) that resolves into 127.0.0.1.

But wait, there is more. *.vcap.me also resolves into 127.0.0.1.

> nslookup whatever.vcap.me
Non-authoritative answer:
Name:    whatever.vcap.me
Address:  127.0.0.1

Now you have it: a wildcard domain that resolves into 127.0.0.1.

*.vcap.me

Saturday, November 8, 2014

Mac Tip of the Year: Insert Unicode Characters

Want to insert ⌘, ⇧, or some other weird character on Mac?
Press ⌃⌘Space (slow motion instant replay: Control-Command-Space) and the pop-up window will appear:


It has several character categories. Click on the icons in the bottom row to choose a category.

Emojis:


Panda emojis:

Strange-looking symbols:

And so on.

To insert a character/emoji in the text - just click on it.

Also, when pop-up window is active, you can start typing to search for a character by its name:



⇧⌫↑
I am very sorry.

Wednesday, November 5, 2014

Alfred Tip of the Year: Calculator

Alfred is an amazing application. It's a great app launcher. Everybody knows that.

More importantly, Alfred is the best calculator in the world. Not many people know that.

Here's how to use Alfred as a calculator. Let's say we want to calculate 120 * 0.72:

  1. Press ⌘Space to run Alfred (your Alfred launch shortcut may be a little different)
  2. Type 120 * 0.72 into Alfred search box
  3. It's 86.4. Done: 





 
 Optional: to copy the result of the calculation to the clipboard, press Enter or ⌘C

Monday, November 3, 2014

Python Tip of the Year: pip install --editable .

Let's say you're developing an application in Python. Being a good citizen you've created a file setup.py that describes your application.

Kind of like this:
from setuptools import setup

setup(
    name='yourapp',
    author='Your name',
    version='0.0.1',
    description='Your app',
    packages=['yourapp'],
)
When developing an application you often want to install it into system/virtualenv site-packages directory. At the same time you don't want to run python setup.py install after every time you make a change. There is a simple solution.

Just cd into directory containing setup.py and run pip install --editable .

Slow motion instant replay: pip install --editable <period>. Trailing period is important.

Now your application is installed into site-packages via symlink (kind of) and you don't need to reinstall it after making a change. Just edit your code and site-packages will magically have a new version of your application.