Open Source Content Management Framework

Planet Midgard

Composer solves the PHP code-sharing problem

Posted on 2011-11-02 00:01:06 GMT.

In PHP we've had a lousy culture of code-sharing. Because depending on code from others as been tricky, every major PHP application or framework has practically had to reimplement the whole world. Only some tools, like PHPUnit, have managed to break over this barrier and become de-facto standards across project boundaries. But for the rest: just write it yourself.

But now Composer, and its repository counterpart Packagist, promise to change all that. And obviously new conventions like PHP's namespacing support and the PSR-0 standard autoloader help.

Composer is heavily inspired by NPM which has built a strong culture of code-sharing and easy deployment in the Node.js community.

Easy for users

With Composer, managing dependencies in your project is very easy. Simply create a composer.json file where you state your dependencies, and let the package management system worry about the rest.

Packages that are registered with packagist.org are obviously easiest to depend on, but you can also state packages coming from custom repositories (like your company's internal version control system), or PHP extensions that you need.

Here is for example the composer.json from the Midgard PHPCR provider:

{
    "name": "midgard/phpcr",
    "type": "library",
    "require": {
        "php": ">=5.3.0",
        "ext-midgard2": ">=10.05.5",
        "phpcr/phpcr": ">=2.1.0-beta1"
    }
}

With this file, Composer knows that our PHPCR provider runs only on PHP 5.3 or newer (as it uses namespaces), and that it needs the Midgard PHP extension and the PHPCR interface classes to be available.

Now installing the project is easy:

$ wget http://getcomposer.org/composer.phar 
$ php composer.phar install

How about autoloading? Traditionally PHP required you to manually include or require all files you wanted to use in your code, with the possibility to write an autoloader to handle it automatically when you call an undefined class. But managing these autoloaders is also a chore.

Composer helps here too, by automatically generating an autoloader that will be able to load your own code, and the code from all your dependencies. So you can get rid of your own autoloaders and include statements, and just include the Composer-generated autoloader in your code:

require 'vendor/.composer/autoload.php';

After this all the classes you've stated your application needing will be available.

Easy for developers

While ease-of-installation is important, it isn't enough to build an ecosystem. The other thing that has to be easy is publishing code. Basically: if you've written a piece of functionality in PHP that you could see yourself using in another project, it should be effortless to publish it as a library.

This is where approaches like PEAR mostly failed, by making it too cumbersome to define your packages, to build them, and to upload them to the repository.

With Composer this is very easy. You again define a composer.json for your package, and push that to your project's Git repository. Then just register the Git repository URL with packagist.org.

After this Packagist will spider your repository and make it available as a package.

Publishing new versions is very easy: simply keep your composer.json up-to-date, and tag your releases in Git.

Where are we now?

It is still early days for Composer, and the project is being worked on at a hectic pace. However, it is already good enough for managing dependencies to modern, PSR-0 compatible libraries.

What I would like to see happen next is support for custom package roles and autoloaders. This would allow us to handle more specific cases, like for example installation of Midgard MVC components and their non-namespaced autoloading needs. After that we should be able to get rid of our custom installer code and just join the Composer crowd.

But if your code is already fully namespaced, this is a great time to get started with Composer.

DNode: Make PHP and Node.js talk to each other

Posted on 2011-10-31 11:50:50 GMT.

If you've been following my blog, you might have noticed that lately I've started doing quite a lot of Node.js development alongside PHP. Based on conversations I've had in various conferences, I'm by far not alone in this situation - using Node.js for real-time functionality, and PHP (or Django, or Rails) for the more traditional CRUD stuff.

Both environments have their strong points. Node.js is very fast and flexible, but PHP has a lot more mature tools and libraries available. So in a lot of projects it is hard to choose between the two. But now you might not have to.

Enter DNode

DNode is a remote method invocation protocol originally written for Node.js, as the name probably tells. But as the protocol itself is quite simple, just sending newline-terminated JSON packets over TCP connections, implementations have started popping up in other languages. You can talk DNode in Ruby, Perl, Python, Java, and now PHP.

I started working on the PHP DNode implementation in the Symfony CMF hackday in Cologne a week ago, and got it into a running stage on a train ride from there to Paris. The implementation isn't yet complete, but works already quite well.

With DNode you can expose Node.js functions to be available on PHP, and PHP class methods to be available on Node.

Like most Node.js functionality, DNode works asynchronously. So instead of waiting for return values you supply a callback function that will be called when the method completes.

PHP as client

Here is a simple DNode service for Node.js:

var dnode = require('dnode');
var server = dnode({
    zing: function (n, cb) { cb(n * 100) }
});
server.listen(7070);

This creates a DNode service running in TCP port 7070 that provides one method: zing that multiplies the value given to it by 100 and sends the result to the callback provided.

Calling this with PHP is easy:

// Connect to DNode server running in port 7070 and call 
// Zing with argument 33
$dnode = new DNode\DNode();
$dnode->connect(7070, function($remote, $connection) {
    // Remote is a proxy object that provides us all methods
    // from the server
    $remote->zing(33, function($n) use ($connection) {
        echo "n = {$n}\n";
        // Once we have the result we can close the connection
        $connection->end();
    });
});

Now just start the server:

$ node simple/server.js

And run the client. As you can see from the PHP code above, once we get the result the client will end the connection automatically:

$ php examples/simple/client.php 
n = 3300

Because only simple TCP connections and JSON packets are used, this is quite fast. Here are time results for the client on my MacBook Air:

real    0m0.064s
user    0m0.050s
sys     0m0.010s

PHP as a server

PHP can also act as a DNode server. You instantiate the DNode class and pass it the object you want to expose via DNode. All public methods of the object will be made available to the DNode clients:

// This is the class we're exposing to DNode
class Zinger
{
    // Public methods are made available to the network
    public function zing($n, $cb)
    {
        // Dnode is async, so we return via callback
        $cb($n * 100);
    }
}

// Create a DNode server
$server = new DNode\DNode(new Zinger());
$server->listen(7070);

This DNode service will obviously be visible for both Node.js and PHP clients.

Bidirectional communications

A DNode client can also expose methods to the server. In this example the server provides functionality for converting temperatures from Celsius to Fahrenheit, but actually gets the current Celsius temperature by asking it from a client.

Server:

// This is the class we're exposing to DNode
class Converter
{
    // Poll the client's own temperature() in celsius
    // and convert that value to fahrenheit in the supplied 
    // callback
    public function clientTempF($cb)
    {
        // The other side of DNode connection is exposed via
        // $this->remote proxy object
        $this->remote->temperature(function($degC) use ($cb) {
            $degF = round($degC * 9 / 5 + 32);
            $cb($degF);
        });
    }
}

// Create a DNode server that listens to port 6060
$server = new DNode\DNode(new Converter());
$server->listen(6060);

Client:

// This is the class we're exposing to DNode
class Temp
{
    // Compute the client's temperature and stuff that value
    // into the callback
    public function temperature($cb)
    {
        $degC = rand(-20, 50);
        echo "{$degC}° C\n";
        $cb($degC);
    }
}

$dnode = new DNode\DNode(new Temp());
$dnode->connect(6060, function($remote, $connection) {
    // Ask server for temperature in Fahrenheit
    $remote->clientTempF(function($degF) use ($connection) {
        echo "{$degF}° F\n";
        // Close the connection
        $connection->end();
    });
});

Then just start the server:

$ php examples/bidirectional/server.php

And run the client:

$ php examples/bidirectional/client.php 
28° C
82° F

The same will obviously work with a Node.js client:

$ node bidirectional/client.js 
23° C
73° F

Installing DNode

dnode-php can be installed using the Composer tool. You can either add dnode/dnode to your package dependencies, or if you want to install dnode-php as standalone, go to the main directory of its repository and run:

$ wget http://getcomposer.org/composer.phar 
$ php composer.phar install

You can then use the composer-generated autoloader to access the DNode classes:

require 'vendor/.composer/autoload.php';

Some DNode examples can be found from the examples folder. They are compatible with the similarly-named examples from Node.js DNode.

Contributing

php-dnode is developed under the MIT license in GitHub. If you're interested in it, please watch the repository and send issues or pull requests.

Where is the future for openness in mobile?

Posted on 2011-10-03 17:53:42 GMT.

These are tough times for fans of open mobile environments. Android is less and less open, Symbian was closed again, HP stopped making webOS devices, and now Intel abandoned MeeGo to work with Samsung and operators instead. So, what is the community to do?

One option is to follow the lead of the big companies, hoping that Tizen works, or that Google again sees the benefit of working with others in the open.

The other is to take the matters in our own hands. There is precedent for this. Much of early Linux activity came from the efforts of the community, not on the initiative of corporate interests. And there have been OpenMoko and Mer, the latter an attempt to make a fully open version of Nokia's Maemo environment, suspended when MeeGo promised to bring the same benefits.

Well, now Mer is back.

mer-400.jpg

The goals for Mer align pretty well with what the community would need:

  • To be openly developed and openly governed as a meritocracy
  • That primary customers of the platform are device vendors - not end-users.
  • To provide a device manufacturer oriented structure, processes and tools: make life easy for them
  • To have a device oriented architecture
  • To be inclusive of technologies (such as MeeGo/Tizen/Qt/EFL/HTML5)
  • To innovate in the mobile OS space

There have also been some other invitations to new potential homes for the community, ranging from openSUSE to Debian.

It will be interesting to see how this works out. But whatever we as a community do, we should ensure we look at more than just licensing.

Business analytics with CouchDB and NoFlo

Posted on 2011-09-21 17:52:53 GMT.

The purpose of business analytics is to find data from the company's information systems that can be used to support decision making. What customers buy most? What do they do before a buying decision? What are the signs that a customer may be leaving?

For the last month we've been working in Salzburg to build such a system, the Intelligent Project Controlling Tool needed for running large collaborative research projects like IKS. Since the design we went with can be reused for other business analytics needs, I wanted to write a bit about it.

But first, here is how our system looks like:

Proggis displaying IKS project plan

Where does the data come from?

There are many ways to gather business data. Often the information systems already contain the data needed. But it may also be hidden in a jungle of spreadsheets. Or maybe some data is simply not available, and has to be filled in manually.

Handling all these cases in one system is a tricky question. To solve it, we went with a two-layered strategy:

  • All data used for analytics is stored as Linked Data in a CouchDB system
  • NoFlo workflows are used for gathering data from the diverse sources and convert it to the format needed

In IKS's case, much of the data was available in a series of spreadsheets. With these, we built the necessary workflows for first converting the spreadsheets into XML with Apache Tika, and then extracting the information from them in a sensible subset of JSON-LD.

Because IKS is a collaborative project, information needs to be gathered from a diverse group of partner organizations. Some of them have systems that provide the needed APIs (like Basecamp, which we use), and we can just periodically import the data. But with many we decided on a simple data interchange approach: spreadsheets handled over email.

In this approach, user files a data request into the system. This gets picked up by NoFlo, which sends an email with the appropriate spreadsheet template to the partner. Then it starts waiting for a reply. When a reply arrives, it extracts the data from the attached spreadsheet and imports it to the system.

Our NoFlo processes are mostly initiated by the CouchDB change notification API. We keep them running persistently using forever Node, so whenever some operation needs to be run it happens nearly immediately.

Ensuring data consistency

With any automation, and especially with the email-based data interchange, things can go wrong. Because of this we tag all data that we receive with its origin, whether it was some automated operation or an imported spreadsheet. These origins are called execution documents. Users can browse all completed workflow executions and see what data came in from them. These can then be either accepted or rejected.

This way if some partner accidentally sends faulty data, or something else breaks, the incorrect information received can be easily removed. CouchDB's versioning capabilities help here.

Analyzing the data

CouchDB is built on top of the concept of map/reduce. Here you can modify and combine the data in lots of different ways using simple JavaScript functions. In our case we elected to write all our CouchDB code in CoffeeScript for simplicity. For example, here is the reduce function in CoffeeScript that counts totals of time planned, time used, and time left per task or partner in a project:

(keys, values, rereduce) ->
    roundNumber = (rnum, rlength) ->
        Math.round(parseFloat(rnum) * Math.pow(10, rlength)) / Math.pow(10, rlength)
    data =
        planned: 0.0
        spent: 0.0
        left: 0.0

    if rereduce
        for reducedData in values
            data.planned += reducedData.planned
            data.spent += reducedData.spent
        data.left = data.planned - data.spent
        return data

    for doc in values
        if doc['@type'] is 'effortallocation'
            data.planned += roundNumber doc.value, 1
        if doc['@type'] is 'effort'
            data.spent += roundNumber doc.value, 1
    data.left = roundNumber data.planned - data.spent, 1
    return data

If you figure out a new way to look at the data you have, simply write the needed map and reduce functions and save them into the database. CouchDB will then run them against existing data and produce numbers.

Data visualizations

Numbers are good, but to really see the information buried in them you need some visualizations. For this we decided to follow the CouchApp idea where the user interface code is stored in the database together with the data itself. This way no application servers are needed, and you can take the whole system with you just by replicating the database. Think of the possibility of doing some analysis on your company while flying to a meeting!

The visuals are in our case provided by JavaScript InfoVis Toolkit, a nice, MIT-licensed interactive graph library.

CouchDB views handle the number crunching, then CouchDB list functions process the numbers into the format needed for visualization. This leaves only a minimal amount of work for the client side.

For consistency our application has been built with CoffeeApp, so all the database and user interface code is in CoffeeScript.

In a nutshell

Any business analytics system dealing with moderate amounts of data can be built following this approach.

Simple architecture for a business analytics system

This way you have a business analytics environment that is easy to extend with more data when it becomes available. New analysis can be done by writing reasonably simple map/reduce functions, and CouchDB's replication capabilities allow you to take the system and data with you.

Using JSON-LD for the data storage makes a lot of sense, as this way the relations between different pieces of information are easy to handle. And using URIs for data identifiers means you can easily mash up information coming from different sources together.

The two-layered approach of using NoFlo for data imports, and CouchDB for analysis also allows for clean separation of concerns. In our case, I did the workflow part of things, and Szaby built the visualizations.

VIE 2.0 is starting to emerge

Posted on 2011-09-21 15:01:28 GMT.

VIE is a JavaScript library that makes RDFa-annotated entities on web pages editable. We started the work towards the next major version of it, codenamed Zart (for Mozart) in a Salzburg IKS hackathon couple of weeks ago.

VIE

Yesterday I merged the Zart codebase into the VIE repository. This blog post describes some of the improvements it brings.

VIE now has an instance

For VIE 1.x users the first visible change (and probably the only necessary API change) is that now VIE needs to be instantiated before being used. Singletons are evil, and so we are not a singleton any longer.

So, for existing VIE code, you need to:

var vie = new VIE();
// and then any traditional VIE calls, like:
var entities = vie.RDFaEntities.getInstances('div.article');
console.log("There are " + entities.length + " RDFa entities in your articles");

The VIE 1.0 API can be disabled by passing a setting when instantiating VIE:

var vie = new VIE({classic: false});

Services and VIE

The other big change in VIE is that now the API has been built in a service-oriented manner. This means that for example reading and writing RDFa is just a service you can enable and disable at will.

The benefit here is that we can easily add support for other formats and capabilities without having to touch VIE internals. Thanks to the schema.org situation, Microdata is getting more use, and so at some point we'll probably add a service for it.

Registering and accessing services is easy:

// Instantiate VIE
var vie = new VIE();

// Pass the service instance and a name you want to use for it
vie.use(new vie.RdfaService, 'rdfa');

// Call a method from the service using the name
// this one would give us the RDF subject of the
// element matched by the jQuery selector
vie.service('rdfa').getElementSubject('div.article');

An immediate benefit here is that we can have two RDFa parsing implementations. If you have problems with our own custom jQuery-based RDFa parser, then you can use the more strict rdfQuery powered implementation instead:

vie.use(new RdfaRdfQueryService, 'rdfa');

Using deferreds

For the new main VIE API we created a sort of a Domain-Specific Language for handling semantic entities. A core part of it is that now all operations utilize jQuery's Deferred objects. With them you can attach different callbacks to the results of your operation, and they will fire either when the operation completes, or immediately if the operation has already been run.

This gives a lot of flexibility in using the API, and allows us to provide same API for services that deal with the DOM, and services that talk to external APIs like Stanbol.

For example, parsing RDFa from a given DOM element (provided with a jQuery selector) happens like this:

vie.load({
        element: 'div.article'
    }).
    from('rdfa').
    execute().
    done(function(entities) {
        console.log(entities);
    });

The chain here is: operation (in this case, load), from service (rdfa), execute operation, then when done, do callback.

With the RDFa service we register Backbone Views for the elements our entities came from, so just like with VIE 1.x, they will update automatically when you change the contents of your entities. But manual writing is also available in case you need it. Here is how it works:

vie.save({
        element: 'div.article',
        entity: someBackboneModel
    }).
    to('rdfa').
    execute().
    done(function() {
        console.log("Saved!");
    });

In addition to done, which fires if the operation succeeds, you have fail for failed operations, and then which fires regardless of success or failure.

Accessing external services

The new VIE is not just about RDFa. In addition to working with the entities you have on a page, you can also access external repositories of semantic information, like DBpedia.

For example, to find out everything that Wikipedia knows about Salzburg, you could run:

vie.use(new vie.DBPediaService, 'dbpedia');
vie.load({
        entity: '<http://dbpedia.org/resource/Salzburg>'
    }).
    using('dbpedia').
    execute().
    done(function(entity) {
        console.log("This is what we know of Salzburg");
        console.log(entity);
    });

In browser usage these calls to external services are subject to cross-domain AJAX limitations. A way to work around those is to set up a proxy, and tell the DBpedia service to use that. To do this, pass the proxy URL to the service when instantiating:

vie.use(new vie.DBPediaService({proxyUrl: 'http://localhost:8080'});

With this, all the factual information from Wikipedia will be at your disposal. The size of every city, the height of every mountain. Birthdates and places of birth for famous people. Your web app can do quite a bit with this information.

Finding entities from text

Apache Stanbol is a semantic engine that can extract all kinds of entities from text documents. It can be used for auto-tagging and other things.

Here is how you can use it with VIE:

vie.use(new vie.StanbolService, 'stanbol');
vie.analyze({
        element: 'div.article'
    }).
    using('stanbol').
    execute().
    done(function(entities) {
        console.log("We got the following enhancements for article content");
        console.log(entities);
    });

Stanbol can tell you what a piece of content talks about. People mentioned, places, concepts. It will also give you the language of the text.

Moving forward

The new version of VIE is still under heavy development. Most of the thngs work, but some details may still change. It is a good idea to start taking a look at it now, but before a beta release at least, VIE 1.0 is the recommended tool to use.

If you already use VIE 1.0 for making your content editable, VIE 2.x will give you a lot of additional power. Enhancements, data queries, namespace handling, and much more.

Thanks to Szaby and Sebastian for helping to make this happen!

Another django cms base

Posted on 2011-09-13 10:35:00 GMT.

Cooper-cms, a really simple cms built with django that probably suitable for company site. It has testimonial, team, content and blog (offcource :) ) modules. I know its not fancy as django-cms but it will suit for some simple company site though https://bitbucket.org/avenpace/cooper-cms

GObject Introspection is coming to Node.js

Posted on 2011-09-12 00:27:13 GMT.

GObject Introspection (GIR) is a way to create automatic bindings to GNOME libraries for various different programming languages. I've written before about the benefits of bringing GIR to PHP, and now it seems something similar is happening on Node.js.

node-gir has been written by Tim Caswell, with help from Sebastian Wick and Piotr Pokora.

I've been following the progress for a while, and today, during a flight from Helsinki to Salzburg, I was finally able to open a Midgard repository connection with it. The API still is a bit weird, and lacks support for the asynchronous nature of Node, but those will hopefully change soon. Quick example:

var Midgard, gir, config, mgd;
gir = require("../gir");
gir.init();
Midgard = gir.load("Midgard");
Midgard.init();

// Use a local SQLite database file
config = new Midgard.Config();
config.__set_property__("dbdir", __dirname);
config.__set_property__("dbtype", "SQLite");
config.__set_property__("database", "midgard");

// Open connection to the database
mgd = new Midgard.Connection();
if (!mgd.__call__("open_config", config)) {
    console.error("Failed to open connection");
    process.exit();
}

node-gir is being developed on GitHub if you want to lend a hand or try it out. To build it, run npm install and you should be able to run the code examples.

Having GIR support for Node would make it a full-fledged GNOME environment, and mean that there would be proper GObject Introspection in all three major JavaScript runtimes - SpiderMonkey, JavaScriptCore and V8. And this way GNOME JavaScript developers could also utilize the wealth of existing Node.js modules.

Embrace and extend

Posted on 2011-09-11 23:14:02 GMT.

I'm getting worried about Google. Long one of the champions of the open web alongside Mozilla, the rise of social networking silos and the app economy seem to have scared them. And like any scared organism, they lash out.

Many of their plans to make web competitive against native development environments are good, there is indeed much to improve in the stack. But what I'm uneasy with is the unilateral way they go about it, preferring "big reveals" and post-facto standardization instead of the open conversation that built most of the Internet we have today. This is not the way to collaborate.

Consider some of their recent efforts:

  • SPDY, a protocol to replace HTTP which Web is built on. Currently only supported by Chrome, which uses it to talk to several Google services
  • Dart, their JavaScript-killer which recently surfaced through a leaked email
  • Microdata and Schema.org that seek to replace last ten years of semantic web development with a spec cooked up by couple of big vendors in secret

These - together with WebSQL, NaCl, WebM and WebP - mean that Google has active efforts to replace practically every layer of the web (except HTML itself) with something of their own design.

The way all of these were introduced bears strong reminders of how Microsoft tried to embrace, extend, and extinguish the web in late 90s. That period brought horrors like ActiveX and the awful, unkillable IE6. Though, for the sake of fairness, it also brought us XmlHttpRequest which was the enabler of the AJAX revolution.

Google's new technologies may end up being beneficial for web developers, but they also threaten to fragment the platform. After all, as the competition in the "post-PC" space heats up, the competitors are unlikely to embrace Google's extensions of the web stack. That would be a loss to all.

Brendan Eich, the original author of JavaScript comments on Hacker News:

So "Works best in Chrome" and even "Works only in Chrome" are new norms promulgated intentionally by Google. We see more of this fragmentation every day. As a user of Chrome and Firefox (and Safari), I find it painful to experience, never mind the political bad taste.

Ok, counter-arguments. What's wrong with playing hardball to advance the web, you say? As my blog tries to explain, the standards process requires good social relations and philosophical balance among the participating competitors.

Google's approach with Dart is thus pretty much all wrong and doomed to leave Dart in excellent yet non-standardized and non-interoperable implementation status. Dart is GBScript to NaCl/Pepper's ActiveG.

Disclaimer: I've been a long-time fan of many of Google's services, and have visited some of their offices a few times. I like the company. Which is exactly why I'm so concerned about this unilateral approach at standards. I am also involved in some standards processes through the IKS Project.

Using LinkedIn for more business

Posted on 2011-09-08 09:57:00 GMT.

Using online forums can really generate business.

I have been quite lazy from time to time on social networks. Just being there was enough for me.

But is it really?

No one connects  with you just like that. You have to be commited to make something fo a tool. As an example. Just beacuse you install Word on your computer you wont get tons of documents. You still have to write them ...      

So i decided some time ago to make somthing out of my profile. Make it more interesting to people. People should want to connect with me when reading it.

Here are some small ways on how to get more out of your LinkedIn profile:


1. Connections
If you connect with more people on LinkedIn you spread your message better. Even if its a person that wont buy your product or sell you something at the moment. The person will se your updates a
nd posts. This can lead to business in the future.

2. Groups

You can get alot of connection in participating in groups. Groups that targets your business area. It can generate leads, give you new information and it also says some on what kind of person yo
u are and what you work with. (My own profile for example is mostly about systems administration and offshoring industry)

3. Search engines
LinkedIn scores quite high on search engines. By keeping a good and updated profile with information on what you are doing will do good in promoting you and your company as a product.    

4. Cross post content
All your articles and updates you write should be cross posted across several networks. Facebook, LinkedIn, Twitter and more. That way your content is exposed to a broader audience and will make some points on all the search engines.

5. Building a good profile and what it can do for you.

Your profile on LinkedIn is almost like your CV. It tells your visitors who you are and what you have accomplished workwise. It show your publications, your work history and recomendations from
others.

In this way a good profile demonstrates knowledge and professionalism in a whole new way. It could generate more business for you by exposing you to wider audience. In the end it will make people more eager to connect with you and contact you for your services.

Final words.

I know forums because it comes with my work some. But i have never really USED them i just have an account and log in from time to time.

But now when i update them on a regular basis and really tend to them. It gives me new customers and a wider network. Securing a vital business for my company. It pays of in the end.

Why the tablet form factor is winning

Posted on 2011-09-05 15:30:31 GMT.

The press is writing a lot about a "post-PC ecosystem" these days, and while many dismiss tablets as simple toys, I think the world of computing is undergoing a major shift. Tablets may not be good for writing, but they are good, probably better than PCs for a lot of other things. And it turns out, people want to be doing these other things.

MG Siegler from TechCrunch has a great post on the subject:

...I’ve been trained over time to think that the traditional PC is the way to do these things whether it’s for work or play. That’s simply not true. The tablet form factor is so. much. better. when you don’t have to do an excessive amount of typing. And during downtime, when I use a computer like a more regular human being, I’ve found that’s often...

Computing is changing. That’s just about the most obvious statement ever. We’ve been seeing this for years with the rise of the smartphones. But traditional computing is changing as well. As in, people are abandoning PCs for these newer devices. And this will keep happening.

My experience conforms with this. I rarely use my laptop outside of the work context of writing code, instead preferring to use the tablet with its great ergonomics, portability and long battery life. On some of my previous trips I noticed that already more than half of people sitting in airport lounges use a tablet instead of a laptop. Not bad for a product category that has existed in a mainstream manner for less than two years. Nokia's internet tablets blazed the trail years earlier, but were never marketed outside the geekdom.

Now, much of the attention in the tablet world has been focused on the couple of platforms that are winning in popularity, and therefore have most of the apps. But regardless of how well Apple and Google play their cards, the post-PC world will be a multiplatform one.

About a week after I got my webOS-powered TouchPad, HP went and killed the product. Yet this hasn't made the device useless. As Paul Rouget recently found out, as long as you have a good browser, your device will be relevant.

Some people can't or don't want to use Native Apps. Because their phones don't have Apps, or because there is just no good Apps for what they want to do, or because, well, because they don't need to...

While in the Western world we were looking at Apple bringing pretty Apps in an expensive device, in the Eastern world, Opera was bringing a working web browser to all the existing devices.

This is the big opportunity for free software to remain relevant in an environment of highly-locked devices. Much of the web already runs on free components, and by using the web as a universal runtime we can bypass almost any platform restrictions. As Paul Graham wrote back in 2001, no one can break web applications without breaking browsing.

The world of publishing is starting to understand this. Their revenue models can't take the heavy control that vendors like Apple imposes, and so Amazon's Kindle is a web app, and so is Financial Times. That "Next year HTML5 will replace native apps" is the new "Next year will be the year of Linux on the desktop" is already a Twitter joke, but there is certainly some movement in this direction. And interestingly, the Linux desktop is actually becoming more web-savvy and touch-friendly.

There are clearly sweet spots for something to be a web app, or for it to be a native application. Similarly, there are different situations where tablets will be the appropriate tool, and where PCs are. The tablet context will be more like this:

tablet-breakfast.jpg

Than this:

ipad-workstation.jpg

The heavy lifting is a better fit for a system designed for that. As Steve Jobs said, the PC will be the truck.

Nemein and Infigo merge to create a digital agency focused on web and mobile

Posted on 2011-09-02 11:15:37 GMT.

Yesterday the contracts were signed to acquire Infigo as part of Nemein. Infigo, is a consulting company focused on mobile development and web using open source tools. You'll probably at least know their CTO, Jerry of the USB finger fame.

Even in the ten years of history of our company this is quite a significant move - it allows us to combine Nemein's traditional expertise on content management with Infigo's mobile offerings. As smartphones and tablets are becoming popular, more and more services we build will have a mobile element, which is now easier with lots of in-house expertise.

This also means more focus on the interplay between the Midgard content repository, NoFlo workflows, Node.js and Symfony web services, and mobile applications built in Qt.

nemein-infigo.jpg

Petri Rajahalme (with me in the photo) will be the CEO of the merged company, and I will focus on leading the R&D efforts.

python-oauth2 hack

Posted on 2011-08-21 13:13:00 GMT.

When you are using python-oauth2 from simplegeo on your Google App Engine instance, you'll get some exception that cause by "ImportError: No module named httplib2" Yes, apparently httplib2 are not supported by GAE and instead they oblige you to use google.appengine.api.urlfetch.fetch instead So I hack python-oauth2 to use google.appengine.api.urlfetch.fetch You can found my python-oauth2 fork on

Flow-based programming for PHP

Posted on 2011-08-18 13:07:34 GMT.

You may have seen my earlier post about NoFlo, the flow-based programming tool I've written for Node.js. It allows you to do quite cool stuff, like a visually controlled web server:

NoFlo-powered web server

Yesterday Igor Wiedler published Evenement, a PHP port of the EventEmitter class from Node.js. As NoFlo builds quite heavily on EventEmitter, I decided to see how far the PHP port could be taken.

As result, there is now PhpFlo, a flow-based programming environment for PHP.

Example of how to define and run a flow (you can also use a JSON format for this):

// Add nodes to the graph
$graph = new PhpFlo\Graph("linecount");
$graph->addNode("Read File", "ReadFile");
$graph->addNode("Split by Lines", "SplitStr");
$graph->addNode("Count Lines", "Counter");
$graph->addNode("Display", "Output");

// Add connections between nodes
$graph->addEdge("Read File", "out", "Split by Lines", "in");
$graph->addEdge("Read File", "error", "Display", "in");
$graph->addEdge("Split by Lines", "out", "Count Lines", "in");
$graph->addEdge("Count Lines", "count", "Display", "in");

// Kick-start the process by sending filename to Read File
$graph->addInitial($fileName, "Read File", "source");

// Make the graph "live"
$network = PhpFlo\Network::create($graph);

The flow consists of processes, or instances simple "black box" components that have their own defined input and output ports. Program logic is defined by making connections between them. Here is a simple component that reads the contents of a file:

namespace PhpFlo\Component;
use PhpFlo\Component;
use PhpFlo\Port;
class ReadFile extends Component
{
    public function __construct()
    {
        $this->inPorts['source'] = new Port();
        $this->outPorts['out'] = new Port();
        $this->outPorts['error'] = new Port();

        $this->inPorts['source']->on('data', array($this, 'readFile'));
    }

    public function readFile($data)
    {
        if (!file_exists($data)) {
            $this->outPorts['error']->send("File {$data} doesn't exist");
            return;
        }

        $this->outPorts['out']->send(file_get_contents($data));
        $this->outPorts['out']->disconnect();
    }
}

I hope people find this system useful. If you're interested in FBP, then J. Paul Morrison's book is a good place to start.

And if you're in FrOSCon, feel free to come and chat with me :-)

Symfony2 for Midgard Developers

Posted on 2011-08-16 17:18:49 GMT.

We hosted a full-day Symfony2 workshop for some of the Finnish Midgard developer community today. As I've written before, Midgard is now transitioning to Symfony2 as our PHP web framework of choice, and this workshop was organized to support that.

Subjects discussed included:

  • Symfony2 as a central PHP ecosystem
  • Basic ideas behind Symfony2
  • Introduction to PHP namespaces
  • Installation with Symfony Standard Edition
  • Running Symfony2 with AppServer-in-PHP
  • Creating a new Bundle
  • Templating in Symfony2
  • Routing in Symfony2
  • Using the Midgard content repository with Symfony2
  • Running MidCOM components inside Symfony2

You can also find the Pinpoint sources for the tutorial from GitHub. I'll try to keep them updated for future use.

Some notes from Desktop Summit 2011

Posted on 2011-08-11 16:18:35 GMT.

As usual, Desktop Summit 2011 has been a lot of fun. I've been to most of the GUADEC and aKademy free desktop events in the past few years, but this was the first time I didn't give a talk. Even that way, it was definitely worth spending a week in Berlin.

While much of the corporate involvement around the desktops has evaporated through some recent events, this seems to have given the developers lots more creative freedom. I've seen many very promising concepts from both communities.

Here are some things that happened during the week:

  • The roadmap for Midgard to become closer to the JCR specification solidified, including a reasonably good plan on backwards compatibility
  • We published the first version of GICR, generic Content Repository interfaces for GObject. Midgard will probably be the first project to implement them, but we hope others will follow. It'd be a great fit for GNOME Documents, among other things
  • The project to replace our own PHP frameworks with Symfony2 continued by implementing the MidCOM compatibility layer that will allow Midgard1 web applications to be run in the new environment
  • My work on the NoFlo flow-based programming tool got some positive attention and interest. Still lot of stuff to do
  • We at Nemein co-sponsored the GObject Introspection hackfest. GIR is important for bringing GNOME libraries to new environments like scripting languages and the web
  • Lots of ice cream got eaten. I think it will be fair if I stay out of next year's deathmatch and focus on coaching ;-)

Tomorrow back to Helsinki for a week, then onwards to FrOSCon and Salzburg...

django realtime currency rate

Posted on 2011-08-09 23:33:00 GMT.

Its been a really long time since I post something here For some dumb reason, I forgot my blogger login/password :hammer: Anyway, since I'm now heavily work with django stuff Here are some django related projects that hopefully can benefit anyone who need it * django-currency_rate, simple django app that can give you realtime currency rate base on http://themoneyconverter.com. Owh its even
Designed by Nemein, hosted by Kafit