mokacoding

unit and acceptance testing, automation, productivity

Espresso

An espresso is a small coffee, sometimes taken as a quick break.

The espresso posts on mokacoding are short super focused post, mainly a way for me to share interesting little findings, and dump information I might forget.

Enjoy ☕️.



How to set default values in Swift compiler-generated initializers

You can get the Swift compiler to generate an initializer with default values for your structs, if you're willing to put up with a bit of mutability.

How to rename a file in Vim

There are many ways to rename a file in Vim. Here's three.

How to remove trailing whitespaces from all files in a folder

Here's a shell command to trim all the trailing whitespaces in all the files of the current folder.

How to add co-authors to a Git commit

How to check if macOS app is notarized

How to reverse a file in the terminal

How to verify your SSH private key password

How to check if array contains element with block in Ruby

Symbolic links in Git

Here's how to track symbolic liks in a Git repository, in a way suitable for teams.

Quick beforeSuite and afterSuite behaviour

A look at how beforeSuite and afterSuite behave in the Quick testing framework, and the dangers of using them

Quick beforeEach and afterEach behaviour

A look at how nested beforeEach and afterEach behave in the Quick testing framework.

Unless.swift

Porting Ruby's unless operator into Swift via a function.

Lessons learned working on danger-switlint selective linting

A little post to share some things I learnt while working on a PR for danger-swiftlint to allow selective linting.

Setting Up Firebase Without Using CocoaPods

A guide on how to configure your Xcode project to use Google Firebase without using CocoaPods.

Cloud 66 Postfix Deploy Hook

A deploy hook to configure Postfix every time a Cloud 66 stack is built

Strong Opinions Loosely Held

Strong opinions loosely held, and other cornerstones for a winning mindset

Writing your own Swift "if let"

An exercise to understand Swift's optional type: reimplementing the if let functionality

How to make Swift methods unavailable

A quick post showing how to use the Swift availability attribute to mark objects and functions as unavailable.

NSDateFormatter format for JSON dates

How to configure NSDateFormatter to work with JSON API dates.

"Functional Core, Reactive Shell" Resources

Links from my "Functional Core, Reactive Shell" talk

How to update all plug-ins for the latest version of Xcode and Xcode-beta

An handy script to update all Xcode plug-ins to be compatible with the latest version of Xcode and Xcode-beta.

How To Fix Fabric Crashing On Startup When Installed Via CocoaPods

If you are experiencing crashes with a version of Fabric and Crashlytics installed via CocoaPods chances are you are missing required information in the Info.plist. This post shows how to solve this issue.

How to use a double slash in xcconfig files

A short post showing how to use a double slash in xcconfig files, for example to write URLs like https://mokacoding.com

Opening a PR to Bitbucket from the terminal

A simple script you can run to open a PR on BitBucket for your current branch.

How to update an Xcode plug-in for the latest version of Xcode

A simple command to run in your terminal to make sure you can use your favourite plugins on the latest version of Xcode

Hacker News Button

How to add an Hacker News button to your blog

Injecting environment variables from a file with xargs

How to provide environment variables stored in a .env file as an input for a command execution without having to export then, with a deep look at the shell commands used.

How to use Homebrew in CI

A quick guide on how to safely use Homebrew in CI.

The best free RSS reader app ever: IFTTT + Pocket

By using the powerful automation provided by IFTTT we can make deliver the latest posts of your favourite blogs to Pocket. This is the most powerful RSS reader ever, and it is free.

How to display relative line numbers in NERDTree

Vim's relative line numbers are great for jumpin around files, and once you get used to them you want to enable them everywhere. Here's how to have NERDTree use relative line numbers

How to always use the latest Simulator with Xcodebuild

There is a simple keyword you can use in the destination option of an xcodebuild command to always run the most recent Simulator version.

How to install Xcode Command Line Tools without GUI or Xcode

Here's a little script that will allow you to install the Xcode Command Line Tools without having to install Xcode, nor having a logged GUI. This can come pretty handy in automated scripts or when provisioning virtual machines.

AFNetworking custom response serializer to add error information

How to implement a custom AFNetworking response serializer to read the failure response data and populate the callback error with it.

How to have multiple iTunes Connect accounts, and submit apps

Swift array of characters from String

How to get an array of single characters String from a multiple characters String. From foobar to [f, o, o, b, a, r].

How to reuse the last parameter in a terminal command

When typing a shell command it is possible to reuse the last argument of the previous call without having to type it. Let's see how.

Packaging an ipa with Swift files from the terminal

If you are having problems with xcodebuild failing to export your apps with either Swift or Watch Kit support here's the solution, with a handy custom script.