ralphm's blog

Thursday, 10 October 2013

Logitech Ultrathin Touch Mouse

But does it work with Linux?

Logitech is my brand of choice for input devices. Unfortunately, though, Logitech seems to focus on their unifying receiver for most of their stuff, to the detriment of their Bluetooth offering. Every now and then, they do come out with a nice Bluetooth device, usually targetting ultrabooks or tablets. Last month I stumbled upon the new Logitech Ultrathin Touch Mouse (t630). As usual, it is marketed for Windows compatibility, with Linux officially not supported. They do have a second model targetted to Mac users with the t631, but I suspect the only difference is its color.

Fortunately, this device mostly works fine on my Ubuntu 13.04 laptops. Plural, because this tiny mouse can be set up to pair with two devices, switchable with a switch on the bottom. The only problem is that, out-of-the-box, gnome-bluetooth cannot reconnect with the device when it has been powered down or switched back from the other channel. It turns out that Logitech might not be following standards, and requires repairing every time. In my search for similar cases, I found a bug report for another device that has had similar issues, and the solution presented there also works for the Ultrathin Touch Mouse.

The trick is to tell gnome-bluetooth to always send the pincode (0000, as usual) upon connecting. For this, it needs an entry in /usr/share/gnome-bluetooth/pin-code-database.xml like this:

<!-- Logitech Ultrathin Touch Mouse -->
<device oui="00:1F:20:" name="Ultrathin Touch Mouse" pin="0000"/>

I filed a bug report to have this included by default. After adding the entry, add the mouse as a new input device and it should work as expected.

On to the mouse' features. Besides detecting motion with its bottom laser, the surface is a touch pad that can be depressed as a whole. Pressing in the top left and top right corner will trigger the left and right mouse button events (button 1 and 3). To do a middle-click, you have to press in the center of the touch pad, not at the top middle, as you'd expect. Vertical and horizontal scrolling can be done with swipe gestures, respectively up/down and left/right. This will trigger buttons 4 through 7.

On top of that, there are some additional gestures, which Logitech has pictured in a handy overview. First, there is a two-finger left or right swipe for doing previous and next actions. In X11 this will trigger buttons 8 and 9, and Firefox, for example, will respond to move back and forth in a tab's history. The other three gestures generate keyboard events, instead of the usual mouse events. A double-finger double-tap yields a press and release of the Super_L key. In Unity this brings up the dash home by default. Finally there are swipes from the left edge and from the right edge. The former triggers Ctrl_L Super_L Tab, which switches between the two last used tabs in Firefox, the latter Alt_L Super_L XF86TouchpadOff, which doesn't have a default action bound to it, as far as I can tell. Logitech also mentions the single-finger double tap, but that doesn't seem to register any event in the input handler.

The mouse can be charged with via its micro-USB connector, also on the bottom, with a convenient short USB cable in the box. The micro-USB connector on that cable is also angled so the mouse doesn't have to be upright when charging. The battery state is reported to the kernel, but there is another bug in upower that will make batteries in bluetooth input devices show up as laptop batteries.

Having used the mouse for a few days now, I like it a lot. It is really tiny, but not in a bad way (for me). The two-finger swipe gestures are a bit tricky to get right, but I don't really use them anyway. I also tried hooking it up to my Nexus 7, and that works nicely. All-in-all a great little device, especially while travelling.

Using ElasticSearch and Logstash to Serve Billions of Searchable Events for Customers

Another real-time technology

Kicking off the revival of this publication, I recently did a guest post on our use of Elasticsearch at Mailgun. Since I have joined the Mailgun team at Rackspace in May, my primary project was to reimplement the Mailgun customer logs so that we can serve billions of searchable events. Head over to the HackerNews page for some additional details.

Wednesday, 2 February 2011

Activity Streams in practice

What are they doing?

Atom and RSS feeds are typically used to support syndication of existing works, most commonly weblog entries. They are XML documents that provide a common representation that can be consumed by feed readers, unlike the HTML pages for such a work. ActivityStreams is a format for syndicating social activities around the web. Based on the Atom Syndication Format, it tries to provide a feed for activities, rather than existing works. This includes the act of posting a blog entry, but can also express activities typical for social networking sites, like adding friends, liking something or affirming an RSVP for an event.

At Mediamatic Lab, we've recently gave notifications an overhaul. We had some code scattered around for sending notices to users, like when they received a friend request. We wanted to add a bunch of notifications so that people are aware of what happens in the network of sites, with their profile or works they've created. For example, when someone tags a person as being in a picture, it would be nice for that person to get a message about that. We also have a collection of RFID-enabled Interactive Installations that generate XMPP notifications for our backchannel system. I'll come back on this.

Whenever something happens that you want to send a notification for, there are a couple of things that you want to include in the notification: what happened, when it happened, and which persons and/or things are involved. The concepts of ActivityStreams turned out to coincide with how we wanted the notification to work. It abstracts activities in actors, objects and targets, along with a human-readable text to describe each activity.

A verb is an identifier for the kind of activity that has taken place. A verb takes the form of a URI, much like rel attributes in Atom link elements, or properties in RDF. The most basic verb is post, with the URI http://activitystrea.ms/schema/1.0/post.

An actor is the (usually) person that has performed the activity. Objects are the main persons or things that the activity was performed upon. For example, when I post a picture, I am the actor, and the picture is the object. A target is an object an action was done to. An example could be the photo album my uploaded picture was posted to. Actors, objects and targets usually have a URI, a title and an object type, similar to RDF classes.

Our new notification system does a couple of things whenever a an activity has taken place. It figures out the verb, actor, object and possibly the target and then creates a notification entry. It then calculates the parties that should get this notification in their inbox. This is usually the actor and the owner of the object. A person's profile is always owned by itself, so when the object is a person, that person would get a notification on things happening to them. When a party is not local (i.e. on another site in the federation), the notification is sent to the other site to be processed there. Each person's inbox is viewable as a stream of activities, much like Jaiku or Facebook, and is also published as an ActivityStreams feed (e.g. ralphm's activities. New notifications can then be processed by other modules.

One of them is the Message module, that sends out e-mails for notifications, according to personal preferences. For now, you can choose what kind of notifications you want to receive an e-mail about, by choosing the verbs you are interested in. Examples currently include: friend requests/confirmations, changes to things you own, people liking, linking to, RSVPing (for events), sharing (to Twitter, Facebook, etc) or commenting on things you own, and people tagging you in a picture.

Another module is the Publish-Subscribe module, that provides XMPP Publish-Subscribe nodes for each person, along with a node for all notifications for that site. This allows for applications that use the stream of activities for a person or the whole site, in near-real-time. An example could be a mobile app to track activity for you and/or your friends, or IM notifications much like Identi.ca or Jaiku.

Another possibility is a backchannel. We developed a backchannel system for events we deploy our RFID-enabled Interactive Installations at. A backchannel feed is aggregated from a configurable set of sources, of which the incoming items are formatted into notifications to be put up on a live stream. Every time someone takes a (group) picture with our ikCam, the image is posted on the backchannel, along with a text listing the people in the picture.

On top of that, we also can include tweets by tracking particular keywords and people. We use (and improved) twitty-twister to interact with Twitter's Streaming API from Twisted. I've recently changed the streaming code of twisty-twitter to consume JSON instead of the deprecated XML (with a bunch of tests), and a way to detect unresponsive connections.

With activities now also available as XMPP notifications, the logical step was to consume these for the backchannel as well. We have an office backchannel on a big screen that tracks Twitter for keywords related to Mediamatic and its events, and the notifications from our interactive installations. It now also includes activity on our sites, and this turns out to be a great way to see everything happening in our sites.

So, did it all go smoothly? No. We found quite some things in the ActivityStreams' concepts in combination with anyMeta and our interactive installations that we didn't expect when we started the project.

One of the big ones was Agents. Our interactive installations have their own user accounts to take pictures, process votes, etc. These accounts have special privileges to perform actions like making all people in an ikCam picture contacts in the network. We also have a Physical I-like-it button, which is an RFID reader placed next to a physical object (e.g. a painting) that has a representation in one of the sites. When reading a tag, it creates a like relationship between the holder of the RFID tag and the object. When we just enabled the first enabled the new notifications functionality, a message popped up on the backchannel: ikPoll Agent likes iTea.

That was quite unexpected but quite logical when we thought about it. ikPoll Agent is the user account for the I-like-it button, that is powered by the same software as our more generic ikPoll installations. We defaulted the actor of an activity to the user account performing the action. Although the agent creates a link from the person to the object, the link was not created on behalf of the physical user. So we needed to introduce the concept of Agents, and have that also stored and communicated along with activities. The same action would now yield an entry with the title 'ralphm likes iTea (via ikPoll Agent).

Another was pictures taken with the ikCam. Besides posting the image, all actors are tagged in the picture, the picture is optionally linked to an event and a location. This yields a bunch of notifications, where we would like to have only one: ralphm took a self-portrait. We have started work on compound activities that would have the enclosed activities linked to it and back, a bit like the Atom Threading Extension.. This would allow aggregators like the backchannel only show the umbrella notification.

A final one was our verb link. This was supposed to be a catch-all verb for the activity of creating a semantic link between two things, of which the predicate didn't already have its own verb (like friending, liking, etc.). It now looks like having a notification like 'person A linked to thing B' might need some more information. An e-mail notification at least has the links to respective pages, but that doesn't quite work on a backchannel beamed on a big screen. For now we ignore such notifications for the backchannel, until we have a better solution. It might be that we need to include the link's predicate in the notification, or make links themselves first-class citizens (with their own URI).

Going to FOSDEM and/or the 10th XMPP Summit in Brussels? I'll be talking about this and other topics in my talk on Federating Social Networks on Saturday 5 February.

Thursday, 14 January 2010

Apple Notification Server = Idavoll

Pushing ahead...

Last week, Blaine Cook congratulated me on Idavoll being in Apple Mac OS 10.6 Server, as its Notification Server. I did have contact with Apple's server team ages ago, about them using Idavoll and having added some customizatons, but never knew where it ended up. The list of Open Source projects used in Apple's products confirms the use of Idavoll, and Wokkel, too, as a dependency of Idavoll. Cool!

Idavoll, and thus Notification Server, is a generic XMPP publish-subscribe service, in Python with Twisted. Upon inspection of the code and the differences against the mentioned versions, most of the customizations match those I was already aware of: an SQLite backend, the whitelist node access model and associated member affiliations. The link to Notification Server at the open source list goes nowhere (yet), so I am unsure about the actual license of their additions. I contacted the server team, and will write again if I have more news on this.

At the nice post by Jack Moffitt on Apple's use of XMPP, Kael mentions the presence of more Publish-Subscribe goodness in Calendar Server. This is actually the stuff that uses Notification Server for push notification in iCal. As Jack says, it is truly great to see large corporations like Apple to embrace XMPP like this. I really wish Google Calendar had a similar feature. Now I only get meeting invites through e-mail. Apple's particular use of Publish-Subscribe reminds me of Joe Hildebrand's effort on WebDAV notifications, and I think that there are a lot of applications that could benefit from such push features.

As I touched upon earlier, at Mediamatic Lab, we use XMPP Publish-Subscribe for exchanging things for federation. But we've also built a bunch of interactive installations, most of them dealing with RFID tags we call ikTags. To name two examples, the ikCam takes a (group) picture, uploads it and friends the depicted persons by reading their tags. The ikPoll is a polling station where people can 'vote' on questions with the tag. Typically, there are also publish-subscribe notifications coming out of those interactions, so you can create a live stream of things happening at an event like PICNIC. Combined with the Twitter Streaming API and our own status messages, this creates an entertaining back channel, coincidently powered by Idavoll.

Thursday, 17 December 2009

Jewish Monument Changes

An exercise in semantic web relationships...

Two exciting projects I've been recently working on at Mediamatic Lab are two highly connected sites around the Jewish Community in the Netherlands during World War Ⅱ. The first is one of the oldest sites we have made, the Digital Monument. This site contains verified information on all of the Dutch jews that have died during WWⅡ along with their households, documented posessions and known documents and pictures. It is maintained by a team of editors of the Jewish Historical Museum.

The second is a brand new community site, to complement the Monument by allowing anyone to add new information, pictures and stories on people at the Monument.

The Monument is very impressive, as I learned back at the first BarCamp Amsterdam, hosted by Mediamatic. You will know what I mean if you spend a little as five minutes paging through the site. Today, however, I want to talk about the technology behind both sites.

Data Model Changes

The data in the Monument is highly semantic in nature. People are part of households, as head-of-family, spouse, son or daughter. Or some other relation. Households have a location and lists of possessions. Tied to all of these are supporting documents and pictures. In anyMeta, all of these are modeled as things with edges between them with a certain predicate. A typical household would be modelled like this:

For the community site, however, we wanted to have more direct relationships between people: parent-child relations, sibling relations, partner relations and a more generic (extended) family relationship. As the community also has most things of the monument imported, this meant a change in the data model and a subsequent conversion in the monument.

In anyMeta, (almost) everything is a thing. As such, the predicate on an edge between two things is also represented by a thing. This has traditionally been named role. Like all things in an anyMeta site have a resource URI, the resource URI of a role is the predicate's URI. We try to use existing (RDF) vocabularies as much as possible for this.

For relationships between people, we've used the knowsOf and friendOf properties from RELATIONSHIP, used in FOAF. So this was the first place to look for the desired new predicates. However, this vocabulary does not have a property for expressing a generic extended family relationship. Fortunately, XFN has the kin relationship type, along with child, parent, spouse and sibling. Richard Cyganiak described how to express XFN relations in RDF, so we used that to base our predicates on.

Like RELATIONSHIP, most of the XFN properties are subproperties of the foaf:knows property, and have some hierarchy themselves, too. In anyMeta, we didn't have the concept of subproperties, yet, so we added a new role for expressing subproperty relationships between roles, and introduced the concept of implicit edges. These are edges with a superpredicate of the explicit edge that is being created. For example, the xfn:child property is a subproperty of foaf:knows. Whenever an edge between two people gets created with the child role, another implicit one with the knows role is added, too.

After conversion and with the implicit edges present, the new data model of the example above looks like this:

The blue arrows are the new, derived edges. A spouse edge is made between those people that respectively have a head-of-family and partner relation to the same household (this can be assumed to be correct for this dataset). For person that have a son or daugther edge to a household, a child edge is made from the head-of-family and partner persons (if any) in that household to this person. We haven't (yet) added derived sibling edges, as this relation depends on the parents of both persons, too.

You can also see gray, dashed edges. These are the implicit edges that follow from the property hierarchy. Another thing to notice, is that the biographies are gone. We put the texts in there directly on the persons and households, instead.

Besides the regular pages of all people, households and other things, you can also use our semantic browser to look at the relationships between things. For example, Mozes and his family can be browsed from here.

Sunday, 19 July 2009

Twisted at Mediamatic

How Georgious is Twisted?

Even before I got to work for Mediamatic Lab, Mediamatic was using Twisted. My friend Andy Smith used it for a bunch of projects around physical objects, usually involving some kind of RF tags. Examples include the Symbolic Table and the Friend Drinking Station. From this grew fizzjik, a Twisted based library that implements support for several kinds of RFID readers, network monitoring and access to online services like Flickr and of course anyMeta.

On the other hand, I have dabbled in Twisted for quite a while now, mostly contributing XMPP support in Twisted Words and through the playground that is known as Wokkel. But why go through all that effort, while there are a several different Python-based XMPP implementations out there? And why does Mediamatic use Twisted? Why do I believe Twisted is awesome?

First of all, we like Python. It is a great little language with extensive library support (batteries included), where everything is an object. Much like in anyMeta. It is a language for learning to program, to code small utility scripts, but also for entire applications.

But going beyond that, building applications that interact with different network protocols and many connections all at the same time is a different story. Many approach such a challenge by using preemtive threading. Threads are hard. Really hard. And Python has the GIL, allowing the interpreter to only execute byte codes in one thread at a time.

So in comes Twisted. Twisted is a framework for building networked applications in Python, through a concept known as cooperative multitasking. It uses an event loop that hands off processing of events (like incoming data on a socket or a timer going off) to non-blocking functions. Events loops are mostly known from GUI toolkits like GTK, and so Twisted goes even beyond networking by working with such toolkits' event loops, too. As most network protocol implementations only have a synchronous interface (i.e. one that blocks), Twisted includes asynchronous implementations of a long list of network protocols. For the blocking interfaces that come from C libraries, like databases, Twisted provides a way to work with their threads, while keeping all your controlling code in the main thread. Asynchronous programming does take some getting used to, hence Twisted's name.

So how do we use Twisted? Well, a recent application is our recent RFID polling system. It allows people to use their ikTag (or any card or other object with a Mifare tag), tied to their user account on an anyMeta site, to take part in a poll by having their tag read at an RFID reader corresponding to a possible answer. The implementation involves:

Additionally, we also want to show polling results, so we have a browser talking to a local HTTP server and a listener for XMPP publish-subscribe notifications.

This is quite a list of tasks for something as seemingly simple as a polling stations. But wait: there can be multiple readers tied to a particular poll answer, likely physically apart, a polling question can have maybe 50 answers (depending on the type of poll, like choosing from a collection of keywords) or there could be a lot of questions at one event.

So, back to Twisted. Twisted has HTTP and XMPP protocol support (both client and server-side), can talk to serial devices (like your Arduino board) and DBus (for watching NetworkManager and device events) and provides event loop integration with GTK to also process GUI events and manipulate widgets based on events. Together with Wokkel, it powers the exchange of information in our (and your?) federating social networking sites. In Python. No threads and associated locking. In rediculously small amounts of code. That's why.

Not yet convinced? Add a Manhole to your application server, SSH into it, and get an interactive, syntax highlighted Python prompt with live objects from your application. Yes, really.

XMPP Summit #7 and OSCON 2009

Two great flavors...

I am attending XMPP Summit #7 and part of OSCON 2009, with which it is co-located due the kind folks at O'Reilly. Much like last year, only this time in San José, California. Unlike the European version of the summit last February, we hope to focus more on doing than talking, although there will be plenty of that, of course.

Suggestions were made to do some interoperability testing, along with general hacking sessions. I am bringing my implementation of server-to-server dialback, and a bunch of other protocol implementations in Wokkel to the table. While there are a bunch of other protocol implementations in Python, I think the Twisted approach is so different that I want people to know about the ideas behind it. By introducting them to Twisted through Wokkel should give them at least a glimpse of why I believe Twisted is awesome.

So, nearing the summit I prepared a bunch of examples around the XMPP Ping protocol, as I mentioned before. Additionally I prepared an example echo bot on steroids, which is basically a stand-alone XMPP server that connects to other servers using the server-to-server protocol. It will accept presence subscriptions to any potential account at the configured domain, sending presence and echoing all incoming messages.

Besides the hacking sessions, I planning to discuss publish-subscribe delete-with-redirect, node collections, publish-subscribe in multi-user chats and service discovery meta data. Oh, and we might go on a field trip to discuss Google Wave XMPP-based federation protocols. Then, after the summit, I will hanging out at OSCON until Thursday, for hallway meet-ups on federating social networks with protocols like OpenID, OAuth and technologies like webfinger and pubsubhubbub. I also brought an RFID reader to play with.

Wednesday, 8 July 2009

Wokkel releases

Making crispy sounds...

Today's Wokkel 0.6.2 release is to show case some of the features in the previous 0.6.0 release. Most of the work was part of the things we have been building at Mediamatic Lab as part of a restructuring of how we federate our social networking sites using publish-subscribe.

First of all, I added a preliminary, but functional, implementation of server-to-server support, using the dialback protocol. This complements the router code that went into 0.5.0 and Twisted Words 8.2.0 to make a fully stand-alone XMPP server. Note that it does not implement any client-to-server functionality yet, but this can be added as separate server-side components now.

To show this off, I have created a bunch of examples around the XMPP Ping protocol, for which the protocol implementation itself is also a nice example of how to write XMPP protocol implementations using Twisted Words and Wokkel. Be sure to check out these examples.

The other feature I want to mention is publish-subscribe Resources. They provide an abstraction of (part of) a publish-subscribe service. The protocol parts are handled by Wokkel. This should make it easier to do node-as-code scenarios, by just filling in the blanks of the various methods that are called upon receiving requests from pubsub clients. I'll create some examples for this shortly.

Sunday, 31 May 2009


Pushing it with HTTP...

PubSubHubbub is a protocol and reference implementation for doing publish-subscribe using web hooks, polling in feeds triggered by a ping from the publisher, and POSTing Atom entries to notify subscribers. The notification part is similar to what I've been working on for the publish-subscribe stuff at Mediamatic Lab, where we spiced up Idavoll with an HTTP interface to bridge the gap between XMPP Publish-Subscribe and HTTP speaking entities.

Although I spend a lot of time working on XMPP based publish-subscribe, I understand the reasons for going for a full HTTP-based approach. XMPP can be intimidating for developers of web applications. While the differences between XMPP and HTTP are important (stateful connections, asynchronous processing, etc), the fact that it is different is reason often enough. Hosting facilities don't always offer ways to do XMPP, and there is not nearly enough running code out there to make it easier for people to play with these technologies to spice up their web application with non-IM XMPP functionality. Having platforms like Google App Engine provide sending and handling raw XMPP stanzas as part of the API would surely help.

That said, PubSubHubbub has two separate sides to it, the publishing part and the notification part. There's nothing that prevents a hub to do the publishing part using regular XMPP publish-subscribe. Instead of fetching the Atom Feed over HTTP every time, it could use autodiscovery to find out the publish-subscribe node and upgrade by subscribing to it instead. Similarly, the notification part could send out XMPP notifications. Combined with existing HTTP aggregator, that combination is very similar to how the aggregator for Mimír works.

I'm still not convinced that PubSubHubbub is the answer to the efficient exchange of updates on social objects, but I do think it is a good way to make smaller entities be part of a federation of social networking sites. Likely, we'll see a hybrid approach, to begin with.

Social Web FooCamp 2009

The stuff we did besides throwing Frisbees...

Last month I was fortunate enough to attend Social Web FooCamp at O'Reilly HQ in Sebastopol, CA, a follow up to Social Graph FooCamp in 2008. I can't express how inspiring such events are, being able to have a continuous, in-depth conversation with so many bright minds about so many topics that keep you busy on regular days, and more. I'll give a quick overview of the whole trip, and then go into depth in a series of posts.

My trip started with a visit to friend and former Jaiku colleague Andy Smith, who was kind enough to take me in at Houseku. As soon as I landed on SFO, I got an SMS from him to make a detour to his office. Besides meeting a bunch of Andy's fellow googlers, I got to spend some time with Brett Slatkin talking about PubSubHubbub.

The next day I got a ride to Sebastopol from Edwin Aoki. After a trip full of interesting conversation, we arrived at the O'Reilly offices. Sebastopol was a lot warmer than San Francisco, perfect for camping. Lots of familiar faces, but also a lot of new ones. During the Friday evening, apart from the general introduction, I didn't get to any sessions, but instead spent talking to a bunch of people on XMPP, Publish-Subscribe and the work I am doing on federating social networks under that name Open-CI at Mediamatic Lab.

The next two days were filled with sessions and hallway talk on OpenID, OAuth, different approaches to Publish-Subscribe and inter-site communication, resource and service discovery and service scalability. While most of the topics were similar to last year, I was glad to share what we've done at Mediamatic Lab over the past year, while learning how others have fared. We used these technologies to make a true federation of social networking sites where you can make cross-site relations between people and their social objects. Some of our discoveries there we're shared among the participants, while others had interesting other approaches.

Especially interesting to me was a session on OAuth and OpenID where I could explain how we tried to improve upon the user experience. Both technologies have a bad reputation in this area. With some smart defaults and trust between sites, we could eliminate some of the screens. There was talk about using pop-ups in some situations, either as lightboxes or as new (small) windows. In our experience the former can't be used if you want to do SSL (since you can't validate the address and certificate). The latter was deemed confusing in our user tests. Research is still ongoing, I suppose. The other issue had to do with presenting OpenID providers. We currently use a drop down, but that doesn't scale up very nicely. Logos might work, but in the end has the same issue.

I also got to show Blaine Cook the code I wrote recently to make it easier to write XMPP publish-subscribe enabled services (code-as-a-node), that has been included in the recent Wokkel release. In turn, Blaine shared his thoughts on simple addressing on the web and we got to hash it out with a bunch of people like Brad Fitzpatrick, who also organized the pubsub shootout session. Finally, Eran Hammer-Lahav showed his work on XRD.

I'm pretty sure I forgot to mention a lot of things, but when it comes back to me, I'll write about it some other time.