You’re Not Loren Brichter

    30 Nov 2012

    A good analysis on why you shouldn’t use the freemium model in the App Store.

    You’re not Loren Brichter. You’re just not. Maybe you’re a genius, and you’ve made an app that’s even better than anything Loren has ever done. That’s nice, but you’re still not Loren Brichter. You didn’t work at Apple on the original iPhone. You didn’t have one of the early App Store successes with Tweetie. You haven’t guest lectured at Stanford. You didn’t earn the reputation he has for building the highest quality stuff, and you aren’t universally adored in the Apple community as an all-around nice guy. You may be all those things some day if you keep working at it like he did, but you’re not there yet, and you’re not getting there this week. If you want to emulate anything about Loren, emulate his commitment to quality, his ability to take advantage of the luck that comes his way, and his focus on the product rather than the profit motive. Don’t emulate his freemium game pricing model. That’s like donning a white suit and thinking you can dance like Travolta. Not going to happen.

    Event Detection

    22 Oct 2012

    This project is my thesis work for my bachelor degree at the Department of Computer Science of University of Turin.
    This is what I worked in the last six months and I am very proud of it.


    What is it?

    A system to detect geotagged events through the analysis of social networks.

    What is an event?

    An event is a large number of tweets and photos geographically close with the same #hashtag.

    How does it work?

    • Geotagged tweets (from Twitter) and photos (from Teleportd) of the last three hours are collected and saved in a database.
    • An algorithm group this points in different clusters, based on theirs hashtag and coordinates.
    • If a clusters has enough points, it’s marked as event.

    Does it really work?

    There are a lot of false-positive, also called “fake events”, so the blacklist of hashtag is continuously growing. But at this time I am satisfied on how my algorithm works.


    The Algorithm

    Just a bit of background

    The algorithm use the map/reduce logic to analyze tweets and photos in MongoDB and to create geolocated events.

    A point is a tweet or a photo, with an hashtag and a geotag.
    A cluster is an event, with a number of points analyzed and a number of neighboring points to analyze.

    Hadoop

    I choosed Hadoop to realize Map/Reduce because it is the most widely used framework for this kind of job and it has large documentation.
    In this way, I don’t care about multithreading and multiprocessing and I leave Hadoop this kind of jobs.

    The algorithm is running on a server with 16 cores and 32GB of RAM. This is my mapred-site.xml if someone cares.

    MongoDB

    After a deep research in many relational and not relational database, MongoDB was my choice. It has a great documentation, a powerful support of geolocated queries and it is very scalable.
    The Mongo-Hadoop plugin let me to integrate it in MongoDB. Its config options are in the file mongo-dbscan.xml.

    Map

    The map function reads the points in input. All points are not visited; this is due to the input query execute in MongoDB from Hadoop.
    If a point has enought points in neighborhood, then a cluster will be emitted and the point is marked as clusterized; otherwise, do nothing.

    function map(P, eps, MinPts)
        if P is unvisited then
            mark P as visited
            NeighborPts = regionQuery(P, eps)
            if sizeof(NeighborPts) < MinPts then
                do nothing
            else
                mark P as clusterized
                prepare the key
                create new cluster C
                C.neighborPoints = NeighborPts
                C.points = P
                emit(key, C)
    

    Reduce

    The reduce function has in input an ‘array’ of clusters with the same key.
    Its job is to aggregate these clusters and to analyze their neighborhood to merge all points into a unique cluster.
    This method can be called much times, virtually every time the map function emits a new cluster with a key equals to another cluster.

    function reduce(key, clusters, eps, MinPts)
        finalC is the final cluster
        for all C in clusters do
            finalC.points = finalC.points ∪ C.points
            for all P in C.neighborPoints do
                if P′ is not visited then
                    mark P′ as visited
                    NeighborPts′ = regionQuery(P′,eps)
                    if sizeof(NeighborPts′) ≥ MinPts then
                        NeighborPts = NeighborPts ∪ NeighborPts′
                    end if
                end if
                if P′ is not yet member of any cluster then
                    add P′ to cluster C
                end if
    

    The iOS App

    Once the server-side system was up and running and the algorithm worked, the last step was to create a client application that lets users to find these events.
    I decided to develop an iOS application, with a bunch of social features to let users not only to view the events, but also to interact with them. For each events is possible to find what are the users that are taking part of it, viewing the last tweets and photos on the map.

    ios


    The Speech

    Here there are the slides of my speech on 19th of October.


    More infos

    The official website of the app and the project is http://eventdetection.marcosero.com/.
    The code of the algorithm and of the iOS app are both on GitHub:

    Programmer Competency Matrix

    09 Oct 2012

    Level 0 of a Software Engineering about source code version control:

    Folder backups by date

    This is awesome.

    Userl

    02 Oct 2012

    Exploring GitHub, often I ask myself: “What’s this user’s favourite language? How does it like to get stuff done?”
    Because of that, I create userl, a tiny Ruby script to scan the repositories of a GitHub user detecting its preferred languages.

    You can quickly install it via RubyGems

    $ gem install userl

    To start to analyze user’s repositories, type

    $ userl marcosero

    and you’ll get this

    +—————————-+———-+———-+—————–+ | marcosero repositories | +—————————-+———-+———-+—————–+ | Name | Stars | Forks | language | +—————————-+———-+———-+—————–+ | Event-Detection | 2 | 1 | Java | | Event-Detection-iOS-App | 1 | 0 | Objective-C | | lifeofadev.eu | 1 | 0 | JavaScript | | Mail-my-IP | 2 | 0 | Java | | msChat | 1 | 0 | Java | | MSMapClustering | 2 | 0 | Objective-C | | newsyc | 1 | 0 | Objective-C | | SnoozeOrStop | 1 | 0 | Objective-C | | SpringBoard-iOS-5.0 | 4 | 3 | Objective-C | | The-Setup | 1 | 0 | Shell | | toSync | 1 | 0 | Java | +—————————-+———-+———-+—————–+ | | 17 | 4 | +—————————-+———-+———-+—————–+ +———————————–+——————————–+ | marcosero languages | +———————————–+——————————–+ | Language | Bytes | +———————————–+——————————–+ | Objective-C | 1597039 | | JavaScript | 96339 | | Ruby | 70642 | | Java | 66165 | | PHP | 5261 | | C | 2844 | | Shell | 2046 | | CoffeeScript | 1244 | | C++ | 706 | +———————————–+——————————–+

    Source code

    Userl is released under the MIT license: do whatever you want, but remember to mention me.

    You can find it on my GitHub: https://github.com/MarcoSero/userl

    MSMapClustering

    02 Oct 2012

    During development of my thesis project (that consists also in an iOS app on which I’ll write when it will be done) I looked for a way to cluster pins inside a map view, like Photos.app does with photos on the map.

    I wanted something like that:

    MSMapClustering

    and I was extremely negatively surprised when I discovered that such a feature wasn’t default.

    For that reason, I developed a reusable component, MSMapClustering, that lets me (and every one else) to create a map view that automatically clusters its pins based on the zoom level.

    The code is freely adaped from an Apple tutorial of WWDC 2010, I’ve packed it into these classes to make a reusable component for my future works.

    You can find it on my GitHub.

    Here’s a quick tutorial on how to use it:

    Structure

    There are three main classes:

    • MSMapClustering, a subclass of MKMapView
    • MSMapClusteringDelegate, the class delegate that conforms to protocol <MKMapViewDelegate>
    • MSAnnotation, a class that conforms to protocol <MKAnnotation>

    Usage

    Include in your project the three classes above and then create your map view and its delegate:

    MSMapClustering *mapView = [[MSMapClustering alloc] init];   mapView.delegate = [[MSMapClusteringDelegate alloc] initWithMapView:mapView];
    

    Add annotations using these methods

    - (void)addMSAnnotation:(MSAnnotation *)annotation;
    - (void)addMSAnnotations:(NSArray *)annotations;
    

    Implement the delegate’s method in the class MSMapClusteringDelegate (obviously!), but pay attention changing methods already inside it.

    If you want, you could set marginFactor and bucketSize parameters in MSMapClusteringDelegate.m.

    • marginFactor: this value controls the number of off screen annotations are displayed.
      A bigger number means more annotations, less chance of seeing annotations views pop in but decreased performance.
      A smaller number means fewer annotations, more chance of seeing annotations views pop in but better performance.
    • bucketSize: adjust this roughly based on the dimensions of your annotations views.
      Bigger numbers more aggressively coalesce annotations (fewer annotations displayed but better performance). Numbers too small result in overlapping annotations views and too many annotations in screen.

    Other Infos

    I included a demo application that shows how to implement this component.
    Please remember that MapKit framework is required.

    Play with it and feel free to ask me whatever you want. Hope it’s useful.