Category Archives: Articles in english

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
# …

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 …

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.

iOS 4 Simulator crash (when installed to custom folder)

just downloaded and installed the iOS 4 SDK and as my root OS X partition is rather (too) small, I put it into a custom location /Users/Developer.Snowleopard/.

This causes the iPhone Simulator to crash and compiling gives an error like:

ibtool failed with exception: Interface Builder encountered an error communicating with the iPhone Simulator. If you …

XCode: missing “deprecated” warnings

when developing for long-term use, you want to use APIs that aren’t likely to be removed soon, a.k.a. “deprecated”.

So, don’t use downward compatible calls below a point you really aim for.

XCode helps with compiler warnings about “deprecated” calls – if “Project -> Edit Project Settings -> GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS” is set:

But be careful, this complains e.g. …

Automatic gzip compression for Apache2 Webservers

after failing and failing again in the last months, I finally got it with the help of http://www.debian-administration.org/articles/137

The .htaccess configuration
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript
requires Apache’s mod_deflate enabled via
$ a2enmod deflate
Module deflate installed; run /etc/init.d/apache2 force-reload to enable.
Check the result with http://www.gidnetwork.com/tools/gzip-test.php

Caution: There seems to be an If-Modified-Since/Last-Modified HTTP 304 bug in mod_deflate, …