Swisscom Phonecalls

(Version française disponible ici)

Here in Switzerland the major telco (Swisscom) has an option to let you see your last 20 answered and missed calls on your account webpage.

Not wanting to log in every time I want to check if I missed a call, I wrote some scripts and that fetches the content of my account web page and display them on an iOS app.

The names are fetched from the iPhone address book, and the iPhone receives a notification via Prowl when a call is missed.


Or perhaps all this was an excuse to write some code during the holidays. Who knows.

I can’t make this app an official app because:

  • I need the Swisscom credentials to access the portal and I wouldn’t trust a stranger and give them access to my account. As you do.
  • The process of fetching the list of calls is not an officially approved method and may break (and did) when Swisscom changes the layout of the page.
  • The iOS app can also retrieve the owner of an unknown number via a call to the (more or less the official swiss white pages site). Of course, the API endpoint is not official nor public. Please be nice and don’t abuse this unofficial endpoint.

So I made the source available on GitHub:

For Swisscom

Oh, if you work for Swisscom, or know someone who does, ask for a method to fetch this data with a secure login option. That would be great, because I could make this app available via the AppStore.

Or Swisscom could add this feature to their official app. PLEASE.

Or Swisscom could hire me to implement this feature in their official app. I’m a freelance developer and I’m available!

Some tech details

On the server a Perl script fetches the data (via cron) from the Swisscom and stores the numbers in a MySQL database (any DB would work).
The iOS app calls a PHP script on the server to access the data: the PHP scripts fetches the data from the database and returns a JSON object.

Have fun!

PS: of course I can wait to return home and check my calls on my phone, but where’s the fun? 😉

I wrote this app 2 years ago and I still use it.

(this is a longer version of the original post)

Using WordPress Jetpack with Nginx and Varnish

I need to manage a few WordPress sites and I wanted to add the Jetpack plugin so I can manage all sites from a account. After having installed the Jetpack plugin, trying to manage my site from fails with this error:
Screen Shot 2015-07-03 at 23.25.44

Watching the Varnish log, I tried the same call made by with curl. The endpoint /xmlrpc.php is called via POST, and curl gave me another hint:

<?xml version="1.0" encoding="UTF-8"?>
 <value><string>parse error. not well formed</string></value>

The error -32700 is not really useful, but a search on DuckDuckGo gave me the solution:

Add this line to the beginning of the wp_config.php file of your site:


And voila, it works.

Almost everybody seems to agree on Varnish being the problem, but the solutions given did not work for me. Just in case, the solutions mentioned were to tell Varnish to ignore the calls to /xmlrpc.php.

Detect Touch outside a view

There are tasks that are not so simple (for me) to do on iOS. One of them is to detect a tap outside a view, for example to dismiss a modal dialog.

So, for reference, here’s how I implemented it.

First: you present a modal sheet using:

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion

In your interface, declare an UITapGestureRecognizer

@property (nonatomic, strong) UITapGestureRecognizer *gesture;

Then, in your implementation:

- (void)viewDidAppear:(BOOL)animated
    [super viewDidAppear:animated];
    self.gesture = [[UITapGestureRecognizer alloc] 
      initWithTarget:self action:@selector(handleTap:)];
    self.gesture.numberOfTapsRequired = 1;
    self.gesture.numberOfTouchesRequired = 1;
    self.gesture.delegate = self;
    [self.gesture setCancelsTouchesInView:NO];
    [self.view.window addGestureRecognizer:self.gesture];

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
      shouldReceiveTouch:(UITouch *)touch
    CGPoint point = [touch locationInView:nil];

    UIWindow *mainWindow = [[[UIApplication sharedApplication]
        delegate] window];
    CGPoint pointInSubview = [self.view convertPoint:point 
    if (!CGRectContainsPoint(self.view.frame, pointInSubview)) {
        [self close:self];
        return NO;
    return YES; // handle the touch

- (void)handleTap:(UITapGestureRecognizer *)gestureRecognizer
    if (gestureRecognizer.state != UIGestureRecognizerStateEnded) {
    // Handle the tap if you want to

#pragma mark - Close modal
- (IBAction)close:(id)sender
    self.gesture.delegate = nil;
    [self.view.window removeGestureRecognizer:self.gesture];
    [self dismissViewControllerAnimated:YES completion:^{

That’s it. It could be easier.

Here’s a link to a Gist on GitHub, easier to read.

Convert & Split FLAC files

I had some .flac files that needed to be converted for iTunes, but I couldn’t find a standalone app for OSX, so using my CLI-fu, I managed to do the job.

For reference, this is how I proceeded (you’ll need Homebrew for this).

Install the following packages:

  • cuetools (to print the breakpoints from a cue or toc file)
  • shntool (to split a single-file album image to a file-per-track album)
  • flac (to read .flac file format)
  • ffmpeg (to do the conversion)
  • id3v2 (to read and write id3 tags)
  • mmv (to change the name of files, see below)

mmv is not really needed, but this tool is invaluable, you should use it.

brew install cuetools shntool flac ffmpeg mmv id3v2

First, split the flac file in tracks:

cuebreakpoints album.cue | shnsplit -o flac album.flac

Add the tags to the tracks album.cue split-track*.flac

Rename the files (why? because!)

mmv 'split-track??.flac' "Track#1#2.flac"

Concert the .flac files to mp3 VBR

(for FILE in Track*.flac ; do ffmpeg -i "$FILE" -codec:a libmp3lame -qscale:a 1 "`basename "$FILE" .flac`.mp3" || break; done)

You can now import the *.mp3 files in iTunes.

I couldn’t find a way to convert the .flac files to .m4e AND keep the metadata so I used mp3. If anyone knows a way, let me know. I also read that the ffmpeg aac converter wasn’t as good as iTunes, so I don’t think it’s really worth it.

UIAutomation, nice to meet you

I wrote an app for a museum and it needs to run for a very long time without crashing. Unfortunately, it crashed after a week. (I had 3 days to write the app, and almost no time to test it. Yes, we developers always have an excuse!)

So I had a look to UIAutomation. What a revelation! I wrote a script to test my app and I was able to remove some leaks from my app, but I needed something more hard-core to test my app.

I searched the internets using DuckDuckGo, my favorite searching tool for the last year. I searched for “UIAutomation Monkey” because, being an old Macintosh developer, I remembered of the infamous “Monkey Lives” feature of the early Macs.

I quickly found “UI AutoMonkey” by Jonathan Penn.

Seeing this script clicking frantically is really fun, and helped me find some unexpected bugs.

I was able to let it run for around 6 hours, without crashing and memory usage stays constant. So far so good.

I will install the new app next week, we’ll see how it behaves.


  • I couldn’t run the test for more than 6 hours, Instruments used 10G of memory and wasn’t showing me the memory usage of my app;
  • ARC is cool, but I feel I lost control of my app;
  • Writing an app that needs to run 24/24 without ever restarting is stressful.

Start VPN when waking up

On my Linode server (great company and service BTW), I had setup a VPN for me, but after upgrading to Ubuntu 14.04, I had no time to reinstall it.

So yesterday, I grabbed a free account on NoLimitVPN (because NSA and Google, you know) and I’ve been using it without any problems. (I’m no expert in security, but since NoLimitVPN is managed by a french company and their VPN is hosted on in the Netherlands, I expect a minimum of privacy).

The only problem I had was that the VPN doesn’t connect automatically when my Mac wakes up. DuckDuckGoing (what’s the official or usual verb ?) (because I don’t use Google anymore), I only found AppleScripts running in background and connecting the VPN. Since I don’t want something running in the background on my old and faithful iMac, I looked for alternatives.

This is the solution I’ve set up on my Mac:

To start the VPN (named “VPN”, duh), I use a terminal command

scutil --nc start VPN

Instead of this AppleScript (found on StackOverflow)

tell application "System Events"
    tell current location of network preferences
        set myConnection to the service "VPN"
        if myConnection is not null then
            if current configuration of myConnection is not connected then
                connect myConnection
            end if
        end if
    end tell
    return 120
end tell

To start the VPN when waking up, I use SleepWatcher (a tool I use to pause ArqBackup when my Mac wakes up) and I put this line in my ~/.wakeup file:

scutil --nc start VPN > /dev/null 2>&1

Voila, problem solved.