I've been asked sometimes what was interesting I did during my 5+ years of mobile development. So here's the list of some of them:

Mobile stuff

Objective-C, C, JavaScript, a tiny bit of Java and, of cource, Swift. CoreData & pure SQLite as databases.

Hardware connectivity

  • remote controlling TVs & Set-up boxes (reverse-engineered the private protocol with Wireshark)
  • MFi: connectivity to Bluetooth devices (Game controllers & custom made)
  • Bluetooth LE connectivity
  • getting data from in-car hardware data sensors (ProtoBuf over WiFi TCP & UDP)

Mobile payment

  • Payment Library for 3rd party developers & Client App (with ability of White-labeling)
  • Shopping apps with payments, loyalty points (BroadLeaf, Magento, etc)
  • Apps for Merchants

Security

  • TV guide App with Live encoded streaming, EPG, etc
  • Media sharing app with high security (SSL, 3-way sertificates, custum algoritms using OpenSSL)

Other

  • VoIP SIP apps, Asterisk, Avaya (server side setup & client side coding)
  • Location based apps
  • Porting iOS apps to Mac
  • OpenSource projects & libraries
  • One of first committers to CocoaPods
  • Cross platform development: PhoneGap, Titanium, Marmelade
  • runtime-hacking, reverse-engineering, benchmarking, performance optimizatios

Web services

PHP, Ruby on Rails, Node.JS and a bit of Python. MongoDB, MySQL, Redis and others as databases.

  • REST APIs
  • Location services: GeoJSON, storage, search & retrival
  • custom CMSs
  • high load apps (with autoscaling on Amazon)
  • data re-structuring, streaming & proxying
  • custom CaptivePortal with Authentication & Authorization for connecting Facebook, user data, RADIUS (in cloud), WiFi access-points & mobile devices (WISPr)

Most of projects I did myself, some of them with another developer. I'll add more when I'll remember :)

Questions?

So I've made a few more JavaScriptCore VS Native benchmarking on iOS7. All the code is available at xslim/iJSPlayground.

Smaller numbers are better.

JSON parsing

As simple as using JSON.parse(string):

- (void)benchOCParser {
    NSError *error = nil;
    id parsedData = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
    XCTAssertNotNil(parsedData, @"Should not be nil");
}

- (void)benchJSParser {
    JSValue *func = context[@"parser"];
    JSValue *res = [func callWithArguments:@[jsonString]];
    NSDictionary *parsedData = [res toDictionary];
    XCTAssertNotNil(parsedData[@"name"], @"Should not be nil");
}

Result:

:Name                   :Total(s)  :Avg.(s)  
-[x test_benchOCParser] 0.02302    0.00023    (1/100)
-[x test_benchJSParser] 0.08478    0.00085    (1/100)

Yep, Objective-C is faster. Let's do more interesting:

Object mapping: Mantle VS JS

I've wrote my simple mapper that maps json to objects and has ability to specify key-to-property mapping. No relationship.

So you want to use of 3-rd party web services that require API keys, but also make your app available to opensource? Can be done. For example, if you'r using Heroku, you can put your secret keys as Environmental variables:

$ heroku config:set KEY_MAPBOX=xxx.yyy
$ heroku config
=== my-app Config Vars
KEY_MAPBOX:    xxx.yyy

Now, you can use it in Node.js app with key = process.env.KEY_MAPBOX. But what about time when you develop your app? Setting it via bash's export is not fun, so to help with this, ther's a small npm module node-env-file. It uses .env file to pull the variables if they are not set:

env(__dirname + '/.env') if fs.existsSync(__dirname + '/.env' )

I'll make a short walk thru how I've built a simple Web-service (proxy) with Node.js that might be usefull for developers who are started playing with it.

The source code for the app is available on xslim/img.mrt.io

Hello world? No, dump Readme

We'll use Express.js for our routes. Check that your package.json contains express as a dependency in dependencies section and install them with npm install. Create README.md file with some content. Next, create an app.js and fill with usefull code:

var express = require('express'),
    app = express(),
    http = require('http'),
    fs = require('fs');

app.get("/", function(req, res, next) {
  fs.readFile('README.md', function(err, data) {
    res.writeHead(200, {"Content-Type": "text/plain"});
    res.end(data);
  });
});

app.listen(process.env.PORT || 3000);

Now after running node app.js and visiting the http://localhost:3000/ will give you a dump of your README.md file (Real example). Cool, huh?

As you might know since iOS 7, Apple included JavaScriptCore framework, that gives ability to almost write apps in Java Script. So I did a small trial and it seems to work.

We'll use XCTest for a playground.

First, let's try logging something

#import <JavaScriptCore/JavaScriptCore.h>

- (void)testConsoleLog {
    JSContext *context = JSContext.new;

    // Add logging support
    [context evaluateScript:@"var console = {}"];
    context[@"console"][@"log"] = ^(NSString *msg) {
        NSLog(@"JS: %@", msg);
    };
    [context evaluateScript:@"console.log('message!');"];
}

Now let's do some simple benchmarking:

Her's my personal comparison on different static maps apis. As Example, we want to show a road map image for Enkhuizen (lat: 52.70468296296834, lon: 5.300731658935547), with a zoom 13, using a free account and having nice map style.

Google Maps

Google Maps

  • Pros: Google-style maps
  • Cons: Max size limit (640x640)
  • Limitations: 25 000 views per day

Mapbox

Mapbox Map

Uses nicely-styled OpenStreet maps

  • Pros: Very clean API
  • Cons: Reversed lat & lon in request
  • Limitations: 3000 map views per month (???)

Nokia Here Maps

Nokia Here Map

Supports 2 endpoints - short Nokia m.nok.it (probably deprecated), and a more modern Here image.maps.api.here.com/mia/1.6/mapview which require api keys.

  • Pros: Has a "Map-in-map view"
  • Cons: Not common for people
  • Limitations: 2500 views per day

Any better solutions?

It's quite hard to find information how to work with GeoJSON. And some information provided in the library documentation is quite hard to understand. So her's a few code blocks that can help someone combine GPX, GeoJSON, MongoDB, Node.js and Mongoose.

Disclamer: I'm new to Node.js and CoffeeScript, so feel free to comment my mistakes or code improvements.

GPX to GeoJSON

We will use a Node.JS library togeojson for this.

npm install togeojson --save
npm install jsdom --save

Imagine we will upload a GPX file and convert it after to GeoJSON

togeojson = require 'togeojson'
fs = require 'fs'
jsdom = require('jsdom').jsdom

# Later on

app.post '/routes/upload', (req, res) ->
  file = req.files.file
  if file
    console.log "Uploaded " + file.originalFilename + " to " + file.path

    fs.readFile file.path, (err, data) ->
        gpx = jsdom(data)
        converted = togeojson.gpx(gpx)

        # Send back converted
        res.send converted
  else
    res.send 400

Storing GeoJSON in MongoDB

A presentation I did about a year ago about free & open source tools to produce diagrams from textural description. Check the following presentation:

For a recent website project I was working on, I needed to implement maps. With Google Maps as my first choice, I began to search for some specific examples. While Google has a nice API reference, the examples they provide are not that obvious. Than I came across a book Google Maps JavaScript API Cookbook written by Alper Dincer and Balkan Uraz (Packt Publishing) that provided the information I needed.

google-maps-book

Hosting a Jekyll site on GitHub Pages is cool but a bit limited. You can't use ruby code. But you can use Liquid template tags.

So her's a few hacks how to make a tag management for your blog:

Tag cloud

A solution to show a tag cloud that can be ound in the net, and modified to suit my needs:

  <ul class="tags">
{% for tag in site.tags %}
    <li style="font-size: {{ tag | last | size | times: 100 | divided_by: site.tags.size | plus: 70  }}%">
        <a href="#{{ tag | first | slugize }}">
            {{ tag | first }}
        </a>
    </li>
{% endfor %}
  </ul>