Category Archives: development

Rank sql(ite) text search results

When searching for text snippets in sql databases you might want to rank the results according to “how good did it match”. And: the ranking shouldn’t make the query slower.

Let’s take a simple example using the LIKE operator. (I know, FTS does a better job, but let’s stick to like for now).

Assume the search …

Ruby: Simple Fast Fourier Transform

by far not as powerful as the Fastest Fourier Transform in the West but maybe sometimes useful for a quick data analysis or de-noising. Reads stdin and writes to stdout.

Algorithm taken from Meyberg, Vachenauer: Höhere Mathematik II and ported to plain ruby myself.
< ![CDATA[
#!/usr/bin/env ruby
require ‘complex’

class Array
# DFT and inverse.
#
# Algorithm from
# …

Vortrag: Index Suche mit CoreData und SQLite

Gestern gab’s einen Mini-Vortrag von mir bei den CocoaHeads München:

CoreData (iOS) ist nur mit Tricks dazu zu bringen den Index bei Textsuche zu benutzen,
SQLite Full Text Search (FTS) ist der Hammer.

Die Folien dazu.

AlcoCalc iPhone App online!

Hurra! Vor einigen Tagen ist die erste Version des Promillerechners im erschienen. Die App merkt sich was Du wann getrunken hast und schätzt nach der Widmark Formel grob den aktuellen und fallenden Promillewert ab:

.

High-Res UIImage remote load

Loading UIImages automatically in high-resolution works fine for locally stored images – but if you want to fetch them via remote URL you have to code yourself.

A simple, blocking but backward compatible (iOS >= 3.0, maybe even 2.0 but untested)  implementation could look like this:
@implementation UIImage (MRORemote)

// add the @2x filename suffix
+(NSURL *)url2x:(NSURL …

High-Res Artwork Management Automation

The iPhone4 comes with a super high-res display and to leverage that encourages App Developers to provide all artwork twofold – once “normal” and once in double resolution named equally with a “@2x” suffix.

To ease my designers’ life and avoid confusion (and designers are easily confused I found) I ask them to provide the …

Upgrade iOS SDK 4.0 -> 4.1 with custom location

again, for my custom install location I need to prepare:

cleanly uninstall and remove cruft:
$ dir=/Users/Developer.SnowLeopard
$ sudo sh $dir/Library/uninstall-devtools
$ sudo rm -r $dir/*
$ sudo mv /Developer /Developer.deleteme

then do the custom-location install and
finally restore some hotfix softlinks:
$ dir=/Users/Developer.SnowLeopard
$ sudo ln -s $dir/Platforms /Developer/Platforms
$ sudo ln -s $dir/SDKs /Developer/SDKs
$ sudo ln -s $dir/Applications/Xcode.app /Developer/Applications/Xcode.app

Not removing the cruft …

Vortrag: Parser mit Ragel

Parser mit Ragel – komplizierte Grammatiken und rattenschnelles XML.
Warum Parser bauen?
Was spricht gegen Ad-Hoc Parsing (a.k.a. Gefrickel)?
Quelltext Impression
Wie komme ich drauf?
Anschnallen: Die Bausteine
Beispiel: SVG Path Parser
Beispiel: XML Parser
Ausblick: Zustandsautomaten
Vielen Dank

Die Folien vom Vortrag am 22. September bei den CocoaHeads München.

UILabel with a (custom) CGFont

UILabel’s font property accepts UIFonts – but strange enough there’s no way to get a custom loaded CGFont (from a ttf or otf file) converted into such an UIFont. You’re stuck with the iPhone’s pre-installed fonts – at least when you have to support iOS 3.0 devices.

After googling a bit and searching Stackoverflow I found …

Develop with iOS 4 SDK on an OS 3.0 Device

After upgrading to iOS 4.0 SDK, iPhone OS 3.0 is no longer a valid “Base SDK”. Naively switching to iPhone 3.2 prevents deployment to a 3.0 device.

But such “Project -> Edit Project Settings” work out fine:

“Deployment Target” hint found here.