Quite a while back there was a xkcd post showing the complete map of optimal tic-tac-toe moves. Ever since seeing it I've wanted to create an interactive version of this that would show a visualisation of the game tree for each possible move, and here it is! You can try it online or check out the source code repository. It runs in a web browser and the code is TypeScript.
mpatric.com
A while ago I needed to allow users to enter a monetary value into a text input in an iOS app. There seem to be a few approaches to doing this, such as:
- Use a text field with a full keyboard and validate what the user entered, or only accept numeric input and a period or comma character
- Use a text field with a numeric keypad, but don't allow minor units (cents/pence) as there is no period or comma character available on this keypad
- Use spinners
To me, none of these options gives a good user experience; I find the best approach is what many ATMs do, which is to allow you to enter only the digits, but have a fixed decimal separator. So, to enter '123.45' you would type 1-2-3-4-5; to enter '18.00' you would type 1-8-0-0; and so on.
In this post, I am going to do this in iOS with a text input and a numeric keypad. The Objective-C code for this is available on github.
If, like me, you have iOS projects that use custom table cells in table views, you may have noticed that when rebuilding the projects for iOS7, table cells are always rendered with a white background, which means if your custom table cells have their own background you may not see it. The solution to this problem can be found in the UITableViewCell Class Reference:
A while back I was searching for a way to launch applications on selected file(s) in the Mac OS X Finder using Hotkeys. This is different from launching the default application (Cmd-Down, Cmd-O or Double-Click the mouse) for a file as I sometimes want to launch different applications on the same file types - like a 'Right Click-Open With' using a mouse, or dragging a file onto an application in the dock or in the applications folder - but with fewer clicks and (more importantly for me) without using the mouse.
For example, I want the currently selected file(s) in the finder to be opened with TextMate when I hit Shift-Cmd-T, to be opened with 0xED when I hit Shift-Cmd-X and to be opened in VLC when I hit Shift-Cmd-V. I have managed to get this working and find this to be a great time saver, so I thought I'd share it.