Keolo Blog

Podcasts for iOS and Mac Developers

If you run a podcast about iOS or Mac programming not listed here, get in touch. I will add it to the list.

Setting up Git on a new Mac

Now you are ready to go! You can use Git in Xcode and in the terminal.

Great Mac Apps

This is a list of some of my favourite apps:

macOS Versions

10.14 Mojave 2018-10-24 Requirements
10.13 High Sierra 2017-09-25 Requirements
10.12 Sierra 2016-09-20 Requirements
10.11 El Capitan 2015-09-30 Requirements
10.10 Yosemite 2014-10-16 Requirements
10.9 Mavericks 2013-10-22 Requirements
10.8 Mountain Lion 2012-07-25 Requirements
10.7 Lion 2011-07-20 Requirements
10.6 Snow Leopard 2009-08-28 Requirements Last version capable of running PowerPC applications
10.5 Leopard 2007-10-26 Requirements
10.4 Tiger 2005-04-29 Requirements Last version capable of running Mac OS 9 applications
10.3 Panther 2003-10-24 Requirements
10.2 Jaguar 2002-08-23
10.1 Puma 2001-09-25
10.0 Cheetah 2001-03-24

Useful Terminal Commands

Line Breaks

macOS and Unix \n LF line feed ASCII 10 ASCII 0x0A
Mac OS 9 Classic \r CR carriage return ASCII 13 ASCII 0x0D
Windows \r\n CRLF carriage return, line feed ASCII 13 10 ASCII 0x0D 0x0A

How to Repair a Corrupted SQLite Database

SQLite files can sometimes become corrupted if the application crashes at the wrong time.

When this problem occurs, all queries fail with “disk image is malformed” or SQLITE_CORRUPT.

In this situation, you can try to dump and recreate the database using the following commands:

sqlite3 FileName.sqlite
.output Dump.sql
sqlite3 Repaired.sqlite
.read Dump.sql

How to Repair a Corrupted PostgreSQL Database

If PostgreSQL fails to start with these errors:

LOG:  could not read from log file 0, segment 73, offset 0: No such file or directory
LOG:  invalid primary checkpoint record
PANIC:  could not locate a valid checkpoint record
LOG:  startup process (PID 1169) was terminated by signal 6: Abort trap
LOG:  aborting startup due to startup process failure

You can try to repair the database cluster using this command:

pg_resetxlog -f /ClusterPath

Then start PostgreSQL again. If it starts properly, you can dump the database and recreate a new one.

PostgreSQL Snippets

Mac Startup Key Combinations

AppleScript GUI Scripting

AppleScript is sometimes useful for automating repetitive tasks on macOS.

But some applications are not scriptable or provide just a few scriptable commands.

In these cases you can use GUI scripting. GUI scripting works with any application. It simulates mouse clicks and key presses.

For example, open AppleScript Editor (in /Applications/Utilities) and type:

tell application "System Events"
	tell process "TextEdit"
		set frontmost to true

		keystroke "Hello"

		click menu item "Print…" of menu 1 of menu bar item "File" of menu bar 1
		repeat until sheet 1 of front window exists
		end repeat
		keystroke "5"
	end tell
end tell

If it doesn’t work, make sure GUI scripting isn’t disabled: quit AppleScript Editor, open System Preferences, click Security & Privacy, click Privacy, click Accessibility, make sure the AppleScript Editor checkbox is selected, quit System Preferences, open AppleScript Editor again.

Useful commands include:

Introduction to Homebrew

Homebrew is a package manager for macOS. It allows you to install various open source software.

It is really easy to use. Here is a quick summary:

You can also check the list of available packages on Braumeister.