Check out Synapse!

I can’t speak for all Linux users, but over the years I have sadly come to accept that the Linux community is usually sidelined and ignored by most vendors in the first release of any product — be it application software, device drivers or hardware. Even companies that stand on the shoulders of open-source software often treat Linux as a second-class citizen (case in point: Google with Chrome, Apple with Safari and numerous other products).

While there is plenty of Linux-specific software out there as well, most of it is to fill the void left by mainstream vendors. Consider the Instant Messaging world. Google Talk still has no native client for Linux. In fact, there is no really good and well supported chat client on Linux that reliably does voice as well as video chat. Yes, there are ways to make it work, but if they really worked, wouldn’t more people be using them?

A brave soul is making another attempt to change the status-quo. Enter Synapse: a refreshingn take on a Jabber/XMPP only IM client, designed especially for Linux. (Interistingly, Synapse is written using Qt/Mono, both of which are cross-platform, so it could easily run on other platforms as well).

Synapse

Quoting from the introductory blog post:

With all the focus on the web, a lot of people have been dismissing desktop operating systems as nothing more than something required to run a web browser. Unfortunately, Linux, which has suffered from unpolished UI applications for a while, has been hit especially hard by this trend.

Even though there have been lots of exciting advances to the platform (Mono, DBus, Cairo, Gstreamer, KDE4, etc.), few developers focus on supporting Linux, and Linux applications rarely receive the same polish and attention to detail as web applications.

Although it makes me unpopular, I’m not ready to give up on Linux software development. I feel strongly that there’s a place for both web and desktop applications, and exciting opportunities for integration between them.

I like many things about Synapse already:

  • a slick website
  • it uses git (and github)
  • provides packages for Ubuntu and some other distros
  • the app itself is visually interesting

Of course, many things don’t quite work yet (such as the ability to add multiple accounts!). But it definitely looks like a very interesting project, one that I’ll be watching very closely.

Quick note about the formatting issues

If you see some formatting issues with the content here, it is because I have disabled the WP-Dokuwiki plugin temporarily while I investigate some performance issues. In the meantime I am also trying to convert the content to plain old HTML where possible. So please bear with me and drop me a note if something is horribly wrong.

Diving into nPath

A few days ago, Steve posted a concrete example of Aster nPath. Though the example in the above mentioned post was called “straightforward”, I think that for people unfamiliar with nPath syntax, it could have been a little difficult to digest in one glance. It certainly wasn’t immediately obvious to me. So I’ll try to break down the query in that post into little bits and hopefully clarify the syntax further.

First, some context. Here is the problem that Steve posed:

For example, suppose we are interested in the optimization of our website flow in order to retain and engage visitors driven to us by SEO/SEM. We want to answer the question: for SEO/SEM-driven traffic that stay on our site only for 5 or less pageviews and then leave our site and never return in the same session, what are the top referring search queries and what are the top path of navigated pages on our site? In traditional data warehouse solutions, this problem would require a five-way self-join of granular weblog data, which is simply unfeasible for large sites such as Myspace.

And here is the nPath query that answers the above problem (taken from Steve’s post):


SELECT entry_refquerystring, entry_page || “,” || onsite_pagepath as onsite_pagepath, count(*) as session_count

FROM nPath(
ON ( select * from clicks where year = 2009 )
PARTITION BY customerid, sessionid
ORDER BY timestamp
PATTERN ( ‘Entry.Onsite+.OffSite+$’ )
SYMBOLS (
domain ilike “mysite.com” and refdomain ~* “yahoo.com|google.com|msn.com|live.com” as Entry,
domain ilike “mysite.com” as OnSite,
domain not ilike “mysite.com” as OffSite
)
MODE( NONOVERLAPPING )
RESULT(
first(page of Entry) as entry_page,
first(refquerystring of Entry) as entry_refquerystring,
accumulate(page of Onsite) as onsite_pagepath,
count(* of Onsite) as onsitecount_minus1
)
)
WHERE onsitecount_minus1 < 4
GROUP BY 1,2
ORDER BY 3 DESC
LIMIT 1000;

Alright, so lets see whats going on here. It is important to always keep the big picture in mind — nPath scans groups of (sequential) rows at a time, searching for user specified patterns. Thus, the first thing that we need to specify is exactly what rows will nPath be operating on. This looks pretty much like a regular SQL query:


ON ( select * from clicks where year = 2009 )
PARTITION BY customerid, sessionid
ORDER BY timestamp

Next, we must specify what is it that we are looking for, or the search pattern. The search pattern is unimaginatively specified via the PATTERN clause:


PATTERN ( ‘Entry.Onsite+.OffSite+$’ )

The pattern description looks very much like any regular expression. The above pattern will find groups of rows where the first row matches “Entry”, followed by one or more “Onsite”s and ending with one or more “Offsite”(s). Next, we need to define what “Entry”, “Onsite” and “Offsite” mean. This is done via the SYMBOLS clause:


SYMBOLS (
domain ilike “mysite.com” and refdomain ~* “yahoo.com|google.com|msn.com|live.com” as Entry,
domain ilike “mysite.com” as OnSite,
domain not ilike “mysite.com” as OffSite
)

A row denotes an “Entry” if the corresponding page is on the domain mysite.com and the referer domain was one of the popular search engines. This makes sure we are not counting clicks from other links on mysite.com. “OnSite” and “OffSite” have similar descriptions.

Once we have identified the pattern and the symbols that make up the pattern, we can do some processing with them. Among other things, nPath allows you to dynamically control the columns of the output. These are specified via the RESULTS clause. Columns can be specified via existing column attributes, or using SQL/nPath aggregates:


RESULT(
first(page of Entry) as entry_page,
first(refquerystring of Entry) as entry_refquerystring,
accumulate(page of Onsite) as onsite_pagepath,
count(* of Onsite) as onsitecount_minus1
)

Finally, we can specify exactly what columns from the output we want to view, and how we want to view them. This is specified just like a regular SELECT clause, which operates on the output of an nPath query instead of regular SQL tables:


SELECT entry_refquerystring, entry_page || “,” || onsite_pagepath as onsite_pagepath, count(*) as session_count

And thats about it as far as the functionality of the query goes — there is of course some more syntactic sugar for specifying other constraints such as GROUP BY and ORDER BY. There is a LOT more to nPath than this, but hopefully it gives you some idea of the capabilities of this extremely powerful construct.

How to simulate Compiz’s screenshot plugin in KDE4

I used to run Compiz with KDE 3.5 and I quite liked that setup. Compiz was fast, highly (a bit too much, perhaps) configurable, and came with a great set of plugins. One of my favorite plugins was the screenshot plugin — basically it allowed me to capture arbitrary regions of the screen with a simple mouse+keyboard combo. This was particular useful when writing blogposts to demonstrate something on the desktop, when filing bug reports (to visually show what was going wrong), when telling webmasters what was wrong with their website (it makes everyone’s life easier if the screenshot only captures the problematic space on the page, not the entire window) and so on. The key strength of the plugin was that it was so easy to invoke, and the captured regions automatically got saved as PNGs to a pre-determined folder. Neat.

Unfortunately, with KDE4, I am no longer running Compiz since kwin (KDE’s native window manager) has built-in support for compositing now. KDE4 is great (especially with 4.2) but I still missed the screenshot plugin very much. I couldn’t find any equivalent plugins for KDE4, so I was on the lookout for a workaround. It turns out, there is one. Here is what you do:

  • Go into System Settings -> Input Actions
  • Create a new global shortcut (right click)
  • Bind a convenient shortcut — I use Super+S or Meta+S
  • For the command/URL, enter ‘kbackgroundsnapshot –region’ without the quotes, of course

And there you go — now you can simply press Super+S anywhere, anytime and the mouse cursor will change to a cross-bar. Once you have selected the region to capture, hit enter to save the picture, escape to cancel the action. By default the pictures are saved to your Desktop folder, and are named ‘snapshotX.png’ where X is some number. Here’s a screenshot that I just took:

kbackgroundsnapshot

What makes this work is the little-less known program (like so many other hidden gems in KDE) ‘kbackgroundsnapshot’. It is essentially ksnapshot, but it is supposed to run in the “background”, meaning that it doesn’t show the regular dialog box that ksnapshot shows. Useful for scripts and such.