Archive

Archive for the ‘Main’ Category

Wishes coming true

January 13th, 2009 No comments

Lately, two of the projects I wanted implemented badly and was thinking about implementing myself have been started by other people:

Let’s hope both produce something usable. And now I’m sort of relieved, since contributing to existing projects is simpler than starting new ones, especially with my limited knowledge on both subjects. Just like I’ve been shown by the second one, since I didn’t know about ELPA yet.

Taming cpan2dist on Ubuntu 8.10

January 4th, 2009 3 comments

cpan2dist is great. Easily one of the examples why people at Debian (and its derivates) absolutely love Perl and CPAN. However, it requires some fiddling to get right and since I’ve just done that today I’d like to write this stuff down for generations to come.

A quick introduction for those who are unfamiliar with cpan2dist: it fetches a Perl package from CPAN and installs it into your system using distribution’s tools. Thus you can resolve possible distribution upgrades painlessly, since every Perl package is also shown in your package management. It’s part of Perl 5.10 distribution and makes native package installation easy.

There are however some catches and the first hurdle comes at the very beginning: distribution-specific packaging is done with plugins and sadly Intrepid does not include the Debian plugin for cpan2dist, CPANPLUS::Dist::Deb. Since you can’t install that one from packages yet (due to lack of CPANPLUS::Dist::Deb, welcome to recursion), you’d have to install it manually — the good thing is, it will be the only package installed manually and it also can be replaced with a packaged one after bootstrapping the whole system. Just run

1
cpanp install CPANPLUS::Dist::Deb

and the first step is done!

Now cpan2dist can be used. Let’s reinstall CPANPLUS::Dist::Deb, this time as a Debian package!

1
cpan2dist --format CPANPLUS::Dist::Deb --buildprereq --install --skiptest CPANPLUS::Dist::Deb

It should give you a sudo prompt at some point, this is because it installs the Debian package already, so you should be done in a couple of seconds.

The options’ meanings (in this order): the desired format of the packages, pre-requisites should be all built, packages should be installed, tests should not be executed before build (time saver) and module CPANPLUS::Dist::Deb is being built.

However, we are not done yet. You’d notice that cpan2dist tries to resolve some dependencies which are provided by basic Perl packages perl, perl-base and perl-modules. These might, but in most cases should not be downloaded and built from CPAN. Luckily, cpan2dist can be provided with an “ignore list”, the downside is that the default one is tiny und thus mostly useless. We’d have to recreate this list from our system:

1
dpkg -L perl perl-base perl-modules | grep \.pm$ | sed 's/^\/usr\/\(share\|lib\)\/perl\/[.0123456789]*\/\(.*\)\.pm$/^\2$/g' | sed 's/\//::/g' > ignorelist

This is my recipe. I get the list of all *.pm files from perl, perl-base and perl-modules and re-create the module name from its path. Every entry becomes a pattern (e.g. ^Test::Simple$) so that module names wouldn’t match as substrings and the whole list is dumped to ignorelist. Now we have to add an --ignorelist ignorelist option to the cpan2dist command line.

This should round it up — if you are lucky, everything goes well and you’d have an installed module as a Debian package. If you have some bad karma on a particular day, you’d end up with some errors, all of which can be solved with some manual package installation and careful reading.

One problem remains though: cpan2dist doesn’t seem to check whether a particular package is available from the archive. But that’s only a small nuisance in an otherwise really useful package.

Private feeds in Google Reader

December 29th, 2008 2 comments

Probably the most requested feature in Google Reader has been support for private feeds. Probably, they think every good web application should support private links (the ones with a random ID attached to it) so that their users can keep control of their credentials — a very sensible thing to assume. Private links can be reset everytime you need it and thus you should be safe. Google also keeps such feeds private, you’d need to get the URL into main Google index to make it appear somewhere. Also, Google needn’t store any passwords for other services, thus reducing possible critisism on itself.

However, not every website supports private links and there we have a problem: I’d like to use a couple of private feeds with Google Reader but can’t. Or better couldn’t, since I’ve made myself a late Christmas present: a Google Reader private feeds workaround!

It’s a small Perl script intended to be running somewhere on your own hosting. What does it do? Not much: given a GUID it fetches an associated website and returns it to the requester. If GUID is not found, nothing happens. If an error occurs, nothing is returned either. So simple. You still have to take care of the feed list though.

I will upload the code and some instructions to the newly created Google Code project shortly. Stay tuned!

Website’s content — which goes where?

December 29th, 2008 2 comments

Yet another blog generator surfaced, called Jekyll. Probably nobody would have noticed, if it wasn’t for GitHub to introduce their GitHub Pages, based on Jekyll. GitHub has been a blogging platform for a while already (see e.g. Homoiconic by Reg), so this seems like making blogging an official feature. Also, this justifies a critical analysis of the concept.

I’ve been following ikiwiki, another site generator, for about half a year now. Actually, it’s a hacker’s dream, blogging with Emacs, storing the whole history in Git, having your site update automagically and being mostly secure because most web-visible content consists of generated static pages. For me, being statical is just a nice add-on, but I really really like the idea of blogging with my $EDITOR instead of some idiotic web-page form (but that’s a completely separate ranting topic). Lack thereof in WordPress is the main reason I’m so lazy about blogging.

However, there is one major flaw, which so far has been exhibited by every RCS-enabled blogging engine I’ve seen: these tools violate MVC. Simple case goes like this: user creates a new blog entry somewhere under posts/2008/12/26/my-blog-post.mdwn, which gets transformed to /posts/2008/12/26/my-blog-post.html by the engine. There might be some derivation, but the principle stands — directory structure in the source is being mapped one-to-one to the web. However, this means that entry’s representation in a URL is directly attached to the content of this entry. Separating concerns, anyone?

Actually, it seems like correct behaviour: put a bunch of content into a storage and let some website generator do its work and present this content to the site visitor. In each blogging system each text is available at several locations: entry’s permalink, month’s overview, tag’s overview, category’s overview, etc. The problem is in our case that a single web-site location for the content is assumed and hard-coded by the author, every other is generated, which is to say the least, inconsistent.

A single blogger can play different roles on his website at the same time: designer, admin, coder, author, editor, usability expert etc. It’s important to remember which role starts when. Putting a text into the system is author’s task, but the editor’s the one to decide where to put it on the website. Depending on situation, there might be several locations, might be just one or even none if content is not to be published until a certain date. But it’s still in the database, it’s its visibility that changes.

Therefore separating concerns in this case requires web-site generation which relies only on content’s metadata and a set of publication rules. The contents of each page on the website could be defined by subroutines returning the entries. For example, if we assume that a list of all articles on a web-page is available (@posts), we could define (pseudo perl code):

  • All posts: "/posts/" => map {$_.summary} sort {$a.date cmp $b.date} @posts
  • All posts for a certain date: "/posts/\d{4}/\d{2}/\d{2}/" => map {$_.summary} grep {$_.date ~= "\1/\2/\3"} @posts
  • An index page: "/" => grep {$_.category ~= "start" } @posts

In this case, it’s irrelevant how these pages are stored, the engine needs to make sure @posts is available and contains everything from a site.

In this context it’d make sense to define permalink strategy too. Taking an ID of an article as its permalink, one could define $permalink = sub { "/id/" . $_.id } to be a canonical generator for permalinks for each article.

What happens if permalinks change? Consider permalinks containing slugs (many people like them). Slugs are mostly auto-generated, so that permalink based off a slug will change if you update the title of your blog post. If it doesn’t, it might not be appropriate for the post anymore and thus misleading for the visitors. You could also change you permalink strategy completely, for whatever reason. If your writing is somehow relevant and linked to on the net, you’ll break a lot of links on other websites. Nobody wants that, but everyone does that every now and then.

If we however additionally save a URL and the subroutine which has been used for routing each time then we’d have a redirection permalink list. It could be checked by default if no current page definition matched. This way for each part of your web-site which has been visited at least once, you’d have a routing available and thus, these URLs would not die. This could help our permalinks be at least a little bit more permanent.

So to sum it up: in a perfect world we’d be putting our blog entries under version control in an arbitrary order, making sure our metadata is correct. A rule set would define how the website is built together based on this metadata. Permalinks would not die at the wave of a hand, defining additional views and URL patterns would be as simple as adding a single text line to a file. A couple of HTML templates would round up this whole stuff. A hacker’s ranting would be a little bit easier in a long run…

The games we play…

April 7th, 2008 2 comments

I guess I’m now stuck in the blogging business forever. Previously, none of my friends blogged — some were ignorant, other paranoid or just plain lazy. And now this: an old friend, who literally pinged me for the last eleven years because I’ve been lazy enough not to send a message to good old Riga, pushes me to the edge, demanding a list of games I play. Oh well. Since modern communication is just a matter of trackbacks and comments in a blog, I guess I’ll make this public.

Geez, games… Computer games… I just don’t quite know what to write about them, since I haven’t been playing much in the last seven or eight years, I’ve willingly missed every single gaming fashion in the last decade. I’ve seen and played a bit of "Counter Strike", I’ve seen people playing "Need for Speed" or "Grand Theft Auto", I’ve talked long hours about psychological problems concerning "World of Warcraft" without having played or seen a minute of that, I’ve heard about Lineage and wondered what that might be until I’ve researched and found out it was a russian "WoW" competitor. I’ve been excited about and haven’t played a single minute of "S.T.A.L.K.E.R.", damn, even "DOOM" has been a game I’ve played three years too late. I’m a gaming failure and I admit it. Not that I’m ashamed of it…

It’s just that I find hacking my linux box, creating little scripts and reading a lot of articles and books on computing topics vastly more exciting that gaming. I’ve saved a lot of money by not buying the best graphic accelerator on the market, by not upgrading my workstation to the greatest, by not arguing about 1200dpi mice vs. 1500dpi mice with or without a battle mouse pad. I’m not an energy drink addict. I’m not into battle strategy, neither in "Counter Strike" nor in "Warcraft". I haven’t felt the need to imagine myself being a dwarf with a +8 power hammer. I’ve never been to the coma-drinking festivals called LARP. Sorry, I’m boring. I can spend the whole day and night reading about virtues of classical vs. prototype-based OO, my feed list in Google Reader is at 86 feeds at the moment, 814 entries unread — and most of them are really interesting. In fact, I’ve been going on like this since late 2000 and I’ve got every single job I’ve had since 2002 because of this. I love educating myself, so I’m doing this most of the time.

Coming back to the topic, I’m sometimes tempted to play something. Sadly, my games selection is somewhat limited by my OS, I’d have to reboot to play most of the games, so this is one more reason I’m not an active gamer. But still, sometimes I play and these are my top 3 games I’ve found entertaining recently and actually played long hours (apart from Free Cell, that is ;)):

  1. Prince of Persia This one game — or better, three games since I’m talking about all three modern PoP games — is a masterpiece. The original "Prince of Persia" has taken a lot of time playing it, kids on the block talked about having saved the princess in 20 minutes, about how to kill the reflection prince, about Jafar etc. It was the game at that time, excellent in gameplay and graphics. When the second "Prince" came out, it was a kind of disappointment, as it wasn’t that much better. Still, we played it. The third one, "Prince of Persia 3D" was a extraordinary failure and still, I tried playing it. When "Sands of Time" came out, it was like a legend coming back, stronger than ever. I’ve been telling my friends that this should have been the original "Prince" if we had 3D graphics at that time. Excellent animation, intuitive controls, extraordinary fights, it had it all. Then there was "The Warrior Within", which was just as mindblowing — combining "The Matrix", "Mortal Kombat" and "Prince of Persia" has been pure genius. The same can be told about "The Two Thrones". The game was fun to play, it was difficult enough not to fall asleep, not too hard not to be turned off and long enough to have about two weeks of continuous fun.

  2. Frets on Fire This is a new game on the block and it’s a free (as in speech) "Guitar Hero" clone. Being an extremely simple concept and providing no story at all, it’s still more fascinating than many other games currently on the market. Just play the guitar and enjoy it!

  3. Pro Evolution Soccer Well, this one is pretty simple. I like soccer, I like playing it and I like playing it on my computer. Not that I was good at it, but I still can enjoy it. PES has a hard stand against EA-produced FIFA-branded game series, but it’s nevertheless a simulator with a better game feeling. I’ve actually bought a gamepad a long time ago to play it.

Apart from these, there are some games I still know from my childhood and which can take any number of hours of my free time. These are the Monkey Island series and Alley cat. Particulary the latter is a gem of arcade gameplay, being the only game known to man that looks great in CGA, running at normal speed even on current quad-cores despite its age (try that with Digger!) and providing a simple, but fascinating aim.

I also remember playing Moorhuhnjagd a lot when it first came out and also a great night spend at a friend’s place playing Mortal Kombat and a Tron clone that whole night. By the way, Armagetron is one great game, the best implementation of the tron-principle I’ve even seen.

That’s about it, there is not a lot more to say about my gaming preferences. Hope you had fun reading this stuff :)

Tags:

Interesting spam

April 6th, 2008 No comments

Spammers are the ones who drive the progress. They are the ones who think of most kicking way to promote their products, we actually should respect them for the quality of their work (marketing, that is) if we weren’t so pissed about it at the same time.

I’ve had some very interesting comments in this blog in the last few days, which are obviously spam (because of the links to "naked celebrities" websites), but they are both filter-proof because of the content and are also reflecting on 90% of blogs’ content. I’ll just leave them uncommented for now, they are glorious by themselves.

It is one of things I can never understand … how people can think that way. It’s so illogical that it can only be based upon moronity.


Computers have already revolutionized the way we live and work. Have they changed the way we think? After reading all posts I think they have. People, why do you write what you hear somewhere, not your own thoughts?


Well this is depressing. Stop writing like that, your posts are spoiling your reader’s mood. Boring.


This blog is simply smashing. In my humble opinion of course. As this post is rather debatable I don’t think all your blog visitors are going to agree with it.

Tags:

21

April 3rd, 2008 No comments

It has been a long time since I’ve last been to sneak previews at the movies. Today I’ve bit the bullet and told myself I had to go, just to vent a bit. I was lucky: out of all possible movies I’ve had "21", which I wanted to see anyway. Of course, it’s a "popcorn" movie, but Kevin Spacey was excellent as always, so it was quite enjoyable. I’m no film critic, so I won’t write a complete review, but it’s a nice movie without much moral preaching, so if you happen to go to the movies, "21" might be a good choice.

However, several topics which has been mentioned but not really analyzed or emphasized in this movie were quite disturbing. It’s mostly about how smart guys who don’t have the money usually don’t stand a chance in this society. The protagonist has been working for five years since he was sixteen to earn his A+ in high school, to get the best grades at MIT, he’s bright, talented and smart and still not good enough for some people, mostly the ones who decide about who wins and who loses by granting or not granting scholarships for those who need it. Being good at what you’re doing is simply not enough in this world. You need to be perfect. Or rich, that’s the second possibility.

Sixteen-year-old spend days and nights learning stuff they won’t need and trying to get a hold of the best grades they can get. Soon you’ll need to provide performance reports from the elementary school just to get a place at a college. Even slightest mistake in your youth, smallest performance loss and you are out. You haven’t been a normal teenager since you’ve been working hard to get somewhere you’ve always wanted to, then you fail a class and you are out. You are weak, you don’t belong here, only the strongest survive. Better luck in your next life.

What kind of crazy world are we living in? We are supposed to perform like machines from our childhood on, work 70-80 hours per week and then probably just die at the age of 50 — you’d be too old for anything anyway by then. If you don’t want this — well, it’s your choice, but your chances in this world are pretty slim then.

I’m actually one of those who worked hard for what they are. I’m 25 and I’ve been self-training for the last 14 years. I’ve learned a lot, I’m at least a bit gifted, not a genius, but still someone with "good potential". I didn’t have good grades, mostly because I’m lazy and had to work in my free time to earn at least some money for some decent life. I’m actually quite content with the life I have and which will follow: I’ll probably have a decent job, which will get me the money I need for life, family, wife, kids, I’ll have it all. I won’t be the greatest, I’ll just be a quiet good one.

But it’s sad to realize that many of extremely talented guys and girls might not get a life they are worth just because they haven’t been to the best college, haven’t had the best grades, haven’t got the money, hadn’t worked since they were eight or just had bad luck. This whole system is flawed, it’s taking from the poor and giving to the rich. Or at least making it really difficult to talented people to prove their talent.

Sometimes I really hate this world.

Tags:

Thousand ways to make your life harder

March 8th, 2008 1 comment

Just a couple hours out of Lisp world I begin to miss things. It’s a bit paradox, since I didn’t even really use Lisp or any its libraries, but I’ve learned enough about them (and I still know nearly nothing!) to miss features and in some cases simplicity and expressiveness.

Right now, I’m equally excited about learning Pylons and frustrated about so-called template engines. In some weird way, PHP is a template engine too, so I’ll take it as an example to support my point.

Web development could be easily described as masochism since the amount of things you need to know for basic development is enormous. You can’t just go with HTML, CSS, JavaScript (and some theory on HTTP and browser implementations with regard to caching), they are just the basics which could be enough for a simple “home page”, but you’d need a server-side programming language to do some data-crunching.

This language of choice would produce HTML for user’s browser to render, filling pre-defined fields with data, so basically, you’d be converting some HTML template into pure HTML containing your data using your programming language. If you make this language simple enough for small manipulations, you’d get SSI, or you could also make it a full-blown language, in which case you get PHP. Depending on the drugs you take (or not), you might also end up with ASP, ColdFusion or even XSLT but the main principle stays the same and it’s not the point here (this is not a PHP rant ;))

Now the one thing I don’t understand: every single Python templating engine (with one brave exception) uses a PHP-like embedded syntax which is “almost, but not quite, entirely unlike” Python (thanks to Douglas Adams for the excellent expression). It includes things like this:

1
2
3
  % if action == "list":
    <% return '' %>
  % endif

So I’m supposed to learn yet another language with slight deviations to some other language I’m writing the rest of my project in. Seriously, this sucks and it’s highly error-prone. Not to mention the negative karma I’d be producing closing each and every single HTML tag in the template.

Yes, this is still a lot better than writing HTML by hand in PHP (that is, without any frameworks) or in Perl. But this is still a way to make programmer’s job harder and less fun. I’d like to quote Slava Akhmechet on this occasion:

I like HTML in the same way I like PDF - as a document serialization format that does a reasonable job and that I never want to modify by hand. This is one of the main reasons I started Weblocks framework - I never wanted to write a line of HTML again. Ironically, I ended up writing a lot of HTML and learning more about its quirks, accessibility issues, and CSS hooks than I ever wanted to, but I finally ended up with a high level user interface definition language embedded into Common Lisp. Finally, HTML is out of my life, for good. Being lazy does pay off.

Writing HTML is tedious and Slava is right there saying that HTML should be treated like some binary format and not written by hand. It’s entirely possible that it’ll become something like assembly language for the web in a couple of years and only a small group of people will still have to write it manually. We are not there yet, but we could at least make sure that writing HTML happens painlessly, and by “painless” I mean “in the currently used language”.

Common Lisp programmers mostly use CL-WHO for this, which is designed to help the programmer and using Lisp constructs inside CL-WHO expressions makes their life even easier:

1
2
3
4
5
6
7
8
9
10
11
(with-html-output (*http-stream*)
  (:table :border 0 :cellpadding 4
   (loop for i below 25 by 5
         do (htm
             (:tr :align "right"
              (loop for j from i below (+ i 5)
                    do (htm
                        (:td :bgcolor (if (oddp j)
                                        "pink"
                                        "green")
                             (fmt "~@R" (1+ j))))))))))

This is expressiveness I wish to have, this is what I’ve been missing about an hour ago. Luckily, there is one exception in the world of Python template engines, which looks almost like CL-WHO and it’s called Brevé. Even its syntax is like Lisp and it looks like this (more complicated example including inheritance):

1
2
3
4
5
6
7
8
9
10
11
inherits ( 'index' ) [
    override ( 'content' ) [
        h1 ( class_="main" ) [ c.title ],
        p [
            'This page doesn't exist yet.',
            a ( href=h.url_for ( action='
edit', title=c.title ) [
                '
Create the page.'
            ]
        ]
    ]
]

Well, even now I’d still have to know a bit about HTML, but that’s necessary evil right now and I can at least program everything in Python syntax. Not having to enter closing tags by hand could be one single killer feature in Brevé for me. It will (hopefully) make my life easier and that will account for a lot of motivation.

e-books done right

February 28th, 2008 No comments

Just some impressions from the russian e-book market. Russia is what is called “a reading country”. Books are everywhere and are also cheap, so that most people can afford buying books just for the pleasure of reading. Because of that there is no need to buy “only the good ones”, like in Germany.

And then of course there is book piracy. I would rather call this process “popularization”, but sadly “piracy” still fits it. Since copyright enforcement has been unknown in Russia until recently, an insane amount of books has been digitalized and put into “e-libraries”, special portals for text files, either with or without categorization. Books were provided for people to read, not for any kind of profit — most e-libraries started as private collections.

Digitalization has also been the real deal: a book has been dissected, scanned, OCRed, proof-read etc. Since many books had not been available everywhere, e-libraries became one of the first sources for e-books and books in general. Since the rise of PDAs e-reading became even more popular — downloading books was a snap. It have been Russians who proposed FictionBook, an open XML-based e-book format, which became the de-facto standard for the modern e-libraries.

Someday the copyright holders came after e-libraries. The reaction has been as expected: the books have been removed at first notice, so that court and extreme costs could be avoided. Not every author did complain however, since many people bought paper versions of the books after they’ve read them on their PC — to own the ones they liked. E-books were more like a complete preview version. But the whole situation was still unbareable, since e-libraries had an uncertain legal base, their owners could receive subpoenas etc. Everybody wanted just one thing: e-libraries had to stay, the problem was how to do this right.

The solution has evolved and was as simple as it gets: biggest e-libraries founded a company, which signed contracts with authors willing to have their books online legally and also to get payed for that. There has been no changes in distribution channels (e-libraries), no changes in text format (FictionBook, text, HTML, Word, RTF, RocketBook, PalmDoc, Java etc. still were possible). The only three things that has changed were the price for the books of these particular authors, the quality and the availability date of the books. The price has been set to about a tenth of the retail paper version (e.g. 20 roubles vs. 230 retail paper version), available on the release day directly from the publisher. There is no DRM either, and the best thing is: all these books can be read online for free! If you want to pay for a download, there is a wide selection of payment methods available, from text messages to credit cards. Every downloaded book also stays available online for free in your virtual bookshelf.

This was the only possible solution on russian market. I think this is also an example to follow for every other country, since it’s a win/win situation.

Intelligent reddit filter

February 28th, 2008 No comments

You actually don’t need a sophisticated recommendation engine to get the information you might be interested in. Or rather, you do, but it is built upon neuronal networks, not social ones. Here’s how my (untuned) version works:

  1. Subscribe to Reginald’s blog and del.icio.us feed
  2. Repeat for every other technical blogger you like and learn from

Sorry, Reg :) On a more serious note: trust and credibility matters, no matter what others say.