Why I write automated tests

Leave a comment

Why I write automated tests.

I write automated tests for a variety of reasons. For one they tell me when I break things. Secondly, having automated tests enables me to go fast. I can make changes with confidence. I am free to aggressively refactor my design. And I don’t stress about breaking the important stuff because I know the automated tests are there to back me up. They are like my shield and my armour.

But really, to me, automated tests are about leverage. They allow me to leverage myself in greater ways that wouldn’t be possible if they weren’t there. I can spend less time regression testing. More time adding new features, improving the testing while doing the one other kind of testing that’s really important – exploratory. These are things things the computer can’t do. Only I can.

So for me automated tests are about leverage. They give us a way to leverage ourselves and our teams further, while giving us all back the one thing we crave. Time.

Beautiful code is good method composition

Leave a comment

Was listening to a podcast with DHH on Tim Ferris show and I really like his definition of beautiful code.

Basically said it’s code where all the methods and abstractions in a class are at the same level. Some methods aren’t doing really low level things. Others aren’t too high. They are all at the same level of abstraction.

Good way to describe any nice API.

For example you can do this:

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupDelegates];
    [self setupLayouts];
    [self setupSearchBar];
    [self setupReachability];
    [self displayTracks];

Or you can do this

- (void)viewDidLoad {
    [super viewDidLoad];
    self.searchBar.delegate = self;
    self.collectionView.delegate = self;
    self.collectionView.collectionViewLayout = self.collectionFlowLayout;
    [self setupSearchBar];
    [self setupReachability];
    [self displayTracks];

See the difference? The methods are not all at the same level of abstraction. Which makes the code harder to read.

Permission denied (publickey)

Leave a comment

If you suddenly see this it’s because your the keys you use for ssh are either gone or not know to ssh. If you have them, but they just aren’t registered:

$ ssh-add -l (The agent has no identities.)
$ cd ~/.ssh (to see your keys)
$ ssh-add ~/.ssh/id_rsa (or whatever your key is called)

Also, make sure macOS (10.12+) uses your SSH key’s passphrase from the Keychain automatically

$ chmod 600 ~/.ssh/config # temporarily grant write access to the config
$ echo "Host *\n  UseKeychain yes\n  AddKeysToAgent yes" >> ~/.ssh/config
$ chmod 400 ~/.ssh/config


How to gitignore sub projects

Leave a comment

If you have dirty subprojects (say in a project named core) do this

Screen Shot 2017-01-11 at 1.51.22 PM.png

How to quickly find a PR on github or ghe

Leave a comment

Go to your repos


Click Pull Requests

Screen Shot 2016-12-07 at 12.07.28 PM.png

Click the type of PR you are looking for

Screen Shot 2016-12-07 at 12.07.42 PM.png

Then search

Screen Shot 2016-12-07 at 12.07.51 PM.png

How to git rebase and squash commits

Leave a comment

Find the SHA of the commit you want squash to

Commit: SHA1
Commit: SHA2
Commit: SHA3
git rebase -i SHA3
git rebase -i HEAD^^^

Cntl-v enter visual mode
Select text
c – to delete
Type what you want to appear
Press ‘Esc’ x2
Add a ‘p’ to bottom commit

Edit your file appropriately. Then save.

If you make a mistake

git rebase --abort

If you want to change a commit message

git commit --amend

Two squash two commits together:

git rebase --interactive HEAD~2

Dont reorder. Just take as is and change commit message when done.

Then force push your changes back to branch.

git push --force -n

How to interactive select and replace text in Vi

Leave a comment

Edit file

Screen Shot 2016-03-17 at 2.26.28 PM.png
Cntrl – V to enter Visual block mode

Select the text you want to replace

Screen Shot 2016-03-17 at 2.27.05 PM.png

Press c – to delete

Screen Shot 2016-03-17 at 2.27.36 PM.png
Type what you want to appear

Screen Shot 2016-03-17 at 2.28.02 PM.png
Press esc to see it all magically appear

Screen Shot 2016-03-17 at 2.28.25 PM.png

Altervativly can do a global replace in with with


Older Entries

%d bloggers like this: