Piperka blog

Whither Piperka

Let me tell you a story. There was a stone and a pot. And everyone was well fed by the stone soup. I may have skipped over a bit.

Let me talk about motivation, that is, mine, and let me talk about Piperka. I've been running it for over eight years now, which is a long time for doing anything. In many ways, it remains the same that it was from the start, the basic idea was there from the beginning and much of what I have been doing since has been auxiliary stuff or refinements. Besides the ever-so-present need for fixing crawler issues and adding a few thousand comics.

My motivation matters since I'm the only person behind Piperka and nothing much happens unless I do it. And it's not anything as simple as turning a profit, either. I had aspirations of commercial success when I started doing it, but that idea has been laid aside along the years. It's been a great way to practise my coding skills and accumulate proof of thereof. It has helped me get jobs. I can use it to explore techniques that I wouldn't have the opportunity for at my day job. I've been doing it for fun, and out of curiosity to see how people would react, and sometimes in anticipation of positive reviews.

It's been a fun ride, but right now I'm in a bit of an impasse. I've seen less progress last year than what I'd like. I changed jobs a year ago (to a much nicer one) and moved to a city where I can have a social life, again. Both of which have made me to neglect Piperka. I've had less time and when I've had it, I haven't necessarily felt like touching Piperka. Yet I'm not about to abandon Piperka, if only because I use it myself and I couldn't imagine reading web comics without, or with someone else's software. It's frustrating, seeing how Piperka could be better but feeling like I'm being the bottleneck, preventing that from happening.

I've tried. Build and they come, they say. I released Piperka's source code when it became feasible and I convinced myself to take the leap, inviting people to participate, and that's gone nowhere. One thing that I should have done already back then would be to arrange some other point of communication besides emailing me, personally. I've set up a public development mailing list, feel free to join to say what you'd like to see fixed or improved, or just follow along. A blog is fine for (sadly, infrequent) announcements but I hope that a mailing list would lend itself to a more open discussion.

So far, Piperka's story hasn't been that of the stone soup. It's been all me. I could have tried to commercialize it, but that's not the route that I wanted to try to take. I could have made look all serious and rename it as something less whimsical, as something that actually had something to do with web comics, but I didn't want to. Piperka's quirky and odd and so personal that there are days when I feel like taking it down just to avoid having others look at it, and I like it that way. I'm not sure how trying to get others to participate in running a web site would even work. I can release the source code but there will still be only one Piperka, which I control. That's something I can't even try to meaningfully change before the support would be there.

I'll say a few words about Piperka's crawler, comic updates and the database, to give a picture of what's involved in trying to share the burden of maintenance. It's about the plumbing, the hidden part which becomes visible only when it doesn't work properly. I take users' privacy seriously and that alone means that I'm not giving direct access to the database to anyone. I could, in principle, strip it of user data and make the crawler code contained in there available for people, in hopes that I would receive help in maintaining it. I'm not going to do it at this time. First off, I need to be convinced first that releasing the web site's source code was a good idea, even, before I release even more. I don't want to do it only to see nobody care. Maintaining it is unglorious janitorial work which even I find too much like work at times, and I don't expect people to jump in for that. Beyond that, there's the same problem I had with regard to the source code itself. If I made a dump of the data and someone improved on it, then there would be no easy way for someone to send me the fix, nor for me to accept the changes. It doesn't live in a version control system but in a database, and the web comics' archives it tries to reflect is quite an ephemeral bunch. Beyond that, it's not just a matter of fixing the comic archive index, but there are ways that the data is tied to users' settings. For example, when a page needs to be removed from Piperka's index, all the bookmarks need to be bumped down by one page to reflect the change. One future development plan I have is to allow users make annotations on a comic's archive page and that'd only make it more necessary to consider user data when updating the comic data.

What I'd really need to improve on Piperka's crawler would be a better user interface for the maintenance work. I do it all currently on a shell on the server, calling scripts to invoke the crawler or update the database directly via SQL queries. It works and updating a comic, on a comic per comic basis, doesn't usually take all that long. But it could be improved on, and all that effort does add up. I would have saved the time used for that many times over, had I used the time to build a better user interface for the work. There would be another benefit, too, if I had the interface: It would enable me to hand over parts of the maintenance to others.

Ultimately, this is a question of what kind of a site Piperka is. In a sense, its purpose is to stay out of the way. Nobody visits Piperka to see Piperka itself, but to get to read the web comics. But how does it do that, how does it present itself to people and who's working on it behind the scenes. I find myself unsatisfied with how the answers to these stand now, and I'd like to see that change. To put it simply, I want to make running Piperka feel like fun again.

submit to reddit
Mon, 06 Jan 2014 11:22:58 UTC

Piperka Map

Force-directed graph algorithms are fun. Imagine a collection of particles, each repelling each other much like electrical charges do. Add springs between some of the particles, and let them all bounce around until they attain a rest position.

Hence, Piperka Map. I've modelled user data as a force-directed graph and put it available on a map page. The bigger the circle, the more readers it has. Relative closeness means that the comics have common readers. I've deliberately de-emphasized the exact subscriber count from the map. Mouse wheel zooms and the map can be panned by dragging. Clicking a comic opens up controls, where you can open up the comic's info page or, if you are logged in, subscribe to a comic. The quick search dialog is available on the map.

I've added links to the map from comics' info pages and from users' profiles. There's the option of highlighting another user's comic picks. Only comics with readers get a place on the map.

The map viewer code is my own and I haven't paid all that much attention to cross browser compatibility. It's built using SVG, which can require more support from a browser than some other technique. It works best on Chrome, with some glitches on Firefox and I've no idea how IE copes though I'm certain nothing below version 10 would work. The map is a snapshot from today, but I'll enable daily updates later on. I may yet alter the algorithm in ways which would change its layout. This isn't something where there would be some intrinsic right way of doing this, but it's all determined by aesthetics. As for my graph layout program itself, I'm considering releasing it as an independent project.

I suppose Piperka's subscriber data is pretty challenging from a data mining perspective. Most people read xkcd and any algorithm would find that out first. I may yet write about the current related comics algorithm, the one that is still labelled as "experimental". It, too, involves graphs but in a more abstract sense and something alike Gaussian blur from image processing. It's my original work, which rarely is a good endorsement for something like this. I may replace it with something yet, but for now, it stays.

Piperka Map was inspired by Ruslan Enikeev's The Internet map. When I saw it, I got immediately the idea that I had similar data in my hands and wanted to do something similar. With the amount of data I had, I could well do it all with plain old CPU code. Kudos to AMD for my FX-8350 which dutifully crunched numbers during my numerous attempts at getting something sensible looking out. The first thing I did was to make my code run in parallel.

This all doesn't have much to do with catching comics' updates. Then again, Piperka isn't necessarily about that only. It was interesting so I wanted to do it.

submit to reddit
Sat, 26 Oct 2013 17:11:25 UTC

Getting social

I'm introducing a few social networking features to Piperka. Never fear, none of this will affect you unless you choose to use them. I've found myself checking out the comics' lists of readers, to see if can spot familiar names, and I thought that there's a case for making that kind of information more prominently available.

You can now follow other users. That means that comics that they read get hilited (currently, with a small "F" letter) in the listings, and there's a new profile privacy setting, protected, which lets other users see your comic picks once you give them the permission.

When you follow another user, they (and only they) can see a link back to you on their followers page, unless your profile is set as private. This means that with the private setting, you can only follow public profiles. Following is an asymmetrical relation, so being followed doesn't mean that you need to reciprocate. Permissions to view a profile are separate from the followee status. Having a permission but no followee status just means that the profile is visible but it won't be hilited.

Private profiles are as hidden as ever. Trying to see them makes Piperka neither confirm or deny that the user exists. Viewing a protected profile without a permission lets you ask to see their profile. I've made all the existing profiles either private or public and new users will get protected as their default setting.

I'm still going to work on how Piperka lets you access this information and on the presentation, but the basic ideas should be in place already. I'll see first whether anyone else cares to use this feature besides me.

I may do some data mining on the relationship data and show the results publicly. Nothing that would identify any single user. Basically the same thing I do with the comic subscription data, or would do if that part still wasn't pretty underdeveloped. I won't be giving anything sensitive to any third parties and I hope that you already expected that of me.

As an aside, singular they is weird.

submit to reddit
Mon, 15 Jul 2013 20:53:15 UTC

The story so far, 2013

It's been a while. I've purposefully not tried to stick to any update schedule, but I guess I could have written something earlier, already. So far, there have been two larger, yet not all that visible changes to Piperka this year.

But before I go into that, I should tell of an old bug. I redid the account and login handling code two years ago. After that, the new account creation code discarded the user's email instead of storing it. Please go check your account information page and check that you have an email address there. You'd need it for password recovery.

The rest of this post is going to get, unavoidably, more technical. In March, I introduced support for banner uploads. Prior to that, they were submitted as plain old text links. It worked, but it was a rather ungainly way of doing it. The comics have banners submitted more frequently now, so it seems that it solved a problem. I had to clean up quite a bit of old code to make that work, starting with how I was calling Mason. And since I'm using AJAX submits instead of plain old Web 1.0 submits, I had to use File API. I opted for simpler code and just tell older browsers that banner uploads are not supported.

The second, more recent, change is a bit fancier. I made the listing pages (top, browse and profile) navigation use AJAX calls and History API. The (un)subscribe buttons use AJAX now, too. It was remarkably easy to leave the old code path in place for browsers without working History API support. All I needed to do was to not add event hooks to the navigation links and let the old links work as is. By my rough testing, it looks like I made page load time drop by 25% and the page loads won't flash content anymore. I suppose I could further squeeze a pageful of comics to MTU, but that's a project for some other day.

Both changes introduced some bugs that some of you ran into and thankfully told me about. They have been fixed.

I solved a few annoying bits along the way and got to practise some HTML5 techniques. If I had to work on invisible parts of Piperka, I suppose that making the crawler errors easier to manage would have been better used time. But my whim took me here.

If you're interested in even more details than this, then I should remind you that Piperka's source code is available. Of which not all that many people are aware, even those who have contacted me about technical matters. I ought to add a link to a page about the source code to Piperka's templates.

submit to reddit
Mon, 27 May 2013 19:28:04 UTC

Behind the scenes: bookmarking

I updated the bookmarking code on Friday and it looks like that went smoothly. The front end interface is pretty much unchanged and most of what I did for that part was to touch up the messages. Pretty dull and it's something that just works. But the back end has been rewritten, fixing up a lot of old cruft and making my life easier all around. The best patches are those that remove the most lines. Since I don't have anything new to tell about this feature (it still works, just more so), I'll write about something old instead.

As I planned it originally, Piperka wasn't going to even keep a table of all the archive pages of a comic. Piperka got its start as a refinement of my personal comic grabbing scripts. You can find such programs on freshmeat.net, if you like. For that use, I only needed to store the last known page. But, add more users to that, who will have a different number of unread pages waiting for them, and the leap to just putting all the comic's pages in a table wasn't all that big. Using that stored information the other way around, to recognize which comic and which page it was, came naturally after that. It was just a too obvious a use to miss. But I didn't exactly plan on having it as an feature.

Truth to be told, not much of the initial Piperka was planned. I just started coding and features fell into place. I was surprised at having people trying to feed a comic's home page to the bookmarking code, but it made sense to add that.

Piperka stores archive pages in three parts. There's a common base containing the protocol, "http://", domain and a part of the path, and a tail, which is something like ".html" or just empty. The content part contains the variable part, be it a date, a number or something else. It does other preprocessing too, like strip out the protocol and any initial "www." from the URL. That would fail if somebody hosted different comics under "www.mycomic.com" and "mycomic.com".

My first version of bookmarking was as simple as (sorry for the raw SQL):

SELECT cid, ord FROM comics JOIN updates USING (cid) WHERE url=url_base||name||url_tail
Simple, declarative, and utterly inefficient. Postgresql had no idea from that about what I was really trying to do and it couldn't use any indices. Lookup time was at around a second. Wholly inadequate, and I soon replaced this first version.

The next version of the code lived in a perl module. The biggest update was that it used the domain in the given URL to match with the corresponding comic before trying to match the specific page. To deal with multiple comics residing under the same domain, I added special cases to the code, where they would add a bit more to the initial part of the string used to match with a comic. I had to update that special case code by hand if I had new comics using the same domains and it eventually grew to be tens of lines long. Another weakness of the code was that it was unable to handle comics that have identical initial parts up until the variable part. Try feeding, for example, "http://www.meetmyminion.com/?p=" as a bookmark to see how it currently handles that case.

I thought, at that point, that I'd need some persistent data structure to store the initial parts, automatically separated to tell apart the comics with similar domains and initial paths. I wrote a daemon to handle bookmark requests. I was never quite happy with that approach, and it had some bugs that I never got around to fix. Worst of all, it had a habit of sometimeseating all memory until OOM killer reaped it. I had the web server code restart it if it wasn't running when it was needed, but it was still a problem. And I had to manually tell it to refresh its index whenever I made a change to a comic's entry.

My latest change threw out the daemon code. No more RPC and socket handling, it's all done as PostgreSQL procedures now. No more code maintaining an index in its own process, but instead just use PostgreSQL's own indices. They can do matches based on the initial part of a string just fine, and it can do its job in a few milliseconds. As usual, it's the approach I should have taken in the first place. I'm not sure if I would have come up with it if I had just read PostgreSQL's fine manuals a bit more and not just enough to get started. Perhaps, perhaps not. It's been seven years and I'm sure I have developed as a coder along the way. Pretty often the best design choice has been to not start coding, yet.

One other thing which got removed with this change was the code that offered support for using Piperka without registering as a user. That never worked as well as with using accounts and I suspect that it has been broken ever since I added the CSRF protection. I don't know if anyone ever used that at all. I'm thinking of adding an option for logging in with OpenID, which would (hopefully) lower the barrier for anyone to try Piperka out. Not that I'd expect that to matter all that much, but it'd still be a nice feature. There'd be no need to come up with a password for Piperka if I added that.

submit to reddit
Sun, 07 Oct 2012 18:11:12 UTC