Development

Useful XCTest Keyboard Shortcuts

Here are some helpful keyboard shortcuts that can help you run your unit tests much more quickly To run all tests: CMD + U To run whichever test your text caret (those blinking thing) is currently in: CTRL + Alt + CMD + U To run the last test that you have ran: CTRL + Alt + CMD + G

Using Go Dep to Manage Dependencies

dep is a dependency management tool for golang. If you have done any software development before, dep is similar to npm, pod or pip. In simple words, it is a package manager to manage your project’s third party libraries. How to install it There’s a few ways to install dep. Personally I prefer to install it with Homebrew $~ brew install dep Initializing a project with dep To initialize it in your go project, go to your project directory and run the following

How to Change Git Branch Name

A quick one. Here’s how to change your git branch name: If you want to rename of your current local branch: git branch -m new-branch-name If you want to change the name of a different local branch git branch -m old-branch new-branch-name That’s it. Bye.

Set Default Git Push Behaviour

I tend to forget that I have to specify the current branch name when pushing it to a remote. For example: $~ git push or like this $~ git push -u origin Either way, these commands tend to fail when I haven’t yet set the upstream branch. git will return an error similar like this: fatal: The current branch develop has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin <INSERT BRANCH NAME HERE> To avoid this, I have to set the upstream branch name explicitly first before pushing it to the remote repository.

zsh a Default Terminal Shell

I prefer zsh over bash as my everyday shell. Unfortunately zsh is not the default shell on macOS. To make it as a default shell for your machine, simply do the following: 1. Install zsh Make sure zsh is available on your system. If not, install it with brew. $~ brew install zsh $~ which zsh /usr/local/bin/zsh #output 2. Set zsh as default shell To set is as default shell, run the following in your terminal:

Diff So Fancy

I find it quite hard to make sense of the output from git diff. Let’s just say that it is somewhat off-putting. diff-so-fancy is an open source project to solve this problem and help make your diff much less uglier. Installation There are a lot of ways to install it but I prefer to install all my tools with Brew. So run the following in your terminal: $~ brew install diff-so-fancy Configuration To use diff-so-fancy, you have to set it up globally.

Viewing Diff Since Latest Git Pull

To view the changes between your latest git pull $~ git pull origin $~ git diff @{1}.. @{n} means the n-th previous value of HEAD. You can refer the official docs on reflog Shortnames for more. p/s: I am currently trying to dissociate myself from becoming too dependent on SourceTree for daily git operations.

On Writing Unit Tests

I would consider that I am a beginner at unit testing but these days, I started writing it much more frequently and I am quite proud of it. I noticed that it actually helps me to notice regression early on and as well as helps me to understand how the components work together. I also learned ‘the hard way’ how hard it is to start writing unit tests for an existing project that have 0 unit test.