Cross-platform command line arguments syntax

I’m rewriting Moderator.swift (yet another command-line argument parser), and with Swift now being available for both OS X and Linux (Ubuntu) it should support a syntax which enables applications to fit in on both platforms.

POSIX* is I think the closest thing to a standard for this, so it will be the basis, with some modifications (The Python documentation also has some good insights).

* OS X is POSIX compliant and so is Linux (mostly).

Read More

New theme and new host

Did not post anything last week, as I have been busy moving the site over to BlueHost and setting up a new theme. All because I wanted Swift code highlighting, and WordPress.com doesn’t support that. This of course took a lot longer than anticipated, but it’s finally done and if I do say so myself the new theme is simpler and easier to read. So all in all it was worth it.

Making a Numeric Type in Swift

Fabián Cañas demonstrates something similar to mixins in Swift (for operators):

By defining types (and protocols) around capabilities, and writing functions that target those capabilities, we end up with cleaner and remarkably reusable code when compared to implementing functionality targeting a specific type. The bulk of our final implementation has nothing to do with distances, time intervals, apples, oranges, or anything else. It reads more like a set of statements of fact that any future programmer could adopt if they so chose.

Swift: Associated Types

Russ Bishop has a clarifying post about Swift protocols and generics:

Type parameters force everyone to know the types involved and specify them repeatedly (when you compose with them it can also lead to an explosion in the number of type parameters). They’re part of the public interface. The code that uses the concrete thing (class/struct/enum) makes the decision about what types to select.

By contrast an associated type is part of the implementation detail. It’s hidden, just like a class can hide its internal ivars. The abstract type member is for the concrete thing (class/struct/enum) to provide later. You select the actual type when you adopt the protocol, not when you instantiate the class/struct. It leaves control over which types to select in a different set of hands.

But I do think he is too harsh on the functional programming hipster kids.

Adding an XCode project to Git

When creating a new project in Xcode it is best to leave the “Create Git repository” box unchecked because it will immediately add all files to Git, including those that are specific to you and are of no interest to anyone else. Instead you can run this script from the project folder, which will add only the files that should be under version control:


#!/bin/bash -x

# create the ignore file
cat > .gitignore <<_EOF_
# Xcode
#
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control?
#
# Pods/
_EOF_

git init
git add .
git commit -m 'Initial commit'

TextSmith – an application for writing

In The ultimate word processor, I described my ideal application for writing. Here is a much more thorough description of its key features and basic workflow:

http://blog.nottoobadsoftware.com/textsmith/

It’s a bit hard to classify, but here goes:

  • Integrated Writing Environment:
    Like the Integrated Development Environments (IDE) programmers use, it tries to provide writers with all the tools they need, and lets them adapt it to their workflow.
  • Semantic Text Editor:
    It lets you describe what the text means as opposed to how it looks.
  • Word Processor:
    This term is normally used for Word, OpenOffice, Pages etc, but these are more page layout applications than literally “word processors”. TextSmith, with its various plug-ins for importing, transforming and exporting text, can literally perform “word processing”.

But the best description is probably just “Writing Application” (as in; an application for writing).

How to import voice memos into Things

I usually write new ideas into the Things app on my iPhone straight away, but sometimes it’s better to just dictate into the Voice Memo app instead of typing. Here’s how you automatically add those voice memos to the Things inbox:

  1. Add the folder /Users/<your username>/Music/iTunes/iTunes Music/Voice Memos to Hazel.
  2. Enter these settings:

    Here is the script:

    tell application "Things"
       set props to {name:"Voice memo"}
       set newToDo to make new to do with properties props
       set notes of newToDo to "[filepath=" & POSIX path of theFile & "]TITLE[/filepath]"
    
    end tell
    

Now, every time you make a voice memo on the iPhone and connect it to your computer a note titled “voice memo” with a link to the sound file will be added to the inbox in Things.

If you don’t have Hazel you can achieve the same thing by setting up a folder action on the voice memos folder. But you will have to modify the script.

Updated the main website. Because less is more.

I have finally updated my main website. I wanted to make it as simple and clean as possible, just like the app itself. It seems most websites try to cram as much text and images as possible onto the pages, making them a chore to read. I’m hoping to avoid that, while still providing enough information. So if anyone notices anything important that is missing, please let me know. Except for a support page, I will add that when I get back from vacation.

My Dream Gadget: A Really Big iPod Touch

My idea of the perfect device would essentially be an iPod touch with a screen the size of an A4 sheet of paper. It would be brilliant for surfing the web and reading e-books and PDF’s. Anyone who’s tried to do that on an iPhone or an iPod touch would appreciate not having to scroll for every paragraph. And in addition to running iPhone apps it should be able to remote control a Mac. Just imagine sitting in the living room and using Front Row on this thing. Not to mention playing an adventure game. Only problem is with a touch-screen that big it would probably end up costing as much as a desktop computer. So we probably won’t see it for a couple of years.

But eventually it will be made. It’s just too obvious and idea for it not to.

Naming things

As is evident from the name of this blog (and the name of my open source project mySettings),  I’m not particularly good at naming things. So if anyone can come up with a better name for this blog, then please let me know. I only called it NotTooBad Blog because it fits in with the name of my website, NotTooBad Software (a name I am satisfied with).