Posts about programming (old posts, page 15)

2008-02-18 10:06

Text-based presentations

There have been a few posts on planet KDE about text-based presentation tools (1 , 2 , 3) and while their solutions are all probably better than mine, I have to say I did something in the area about a year ago.

Since I like restructured text and PyQt that's what it's based on, but you can just use it with vi and a wyse60, if you want.

My project is called Tobogan and it has a working version.

It has a GUI, but let's ignore it for this post about text-based software ;-) and show the text behind it:

Why use Tobogan

(If you are a nerd)

:transitions: from_left,to_left,from_top,to_top,from_right,to_right,to_bottom,fade_out

It's nerd-oriented

It's trivial to display source code, with
proper syntax highlighting.

.. code-block:: python

    from base64 import *
    def myFirstFunction():
          print b64decode ('YnllIHdvcmxkIQ==')

Even for things like shell sessions.
Dammit, I am a nerd, I will try to add every nerd
feature I deem cool.

It does things simply

This is a subtitle?

Wanna show a flickr photo?

.. code-block:: rst

    .. flickr:: myPhotoTitle

How about using to share your files?
And whatever else you can think of, it probably
**can**\  be done.

.. footer:: Smart thing goes here

And here is the result after running on it.


  • If you move the cursor to the top, you will get (broken?) previous/next arrows
  • If you click on the window, you get to the next slide.

I have not touched this in almost a year, and it would need lots of love, but it's not a bad concept, IMVHO.

2008-02-12 12:15

Open with: Google Docs

The eee is small. It has very little storage. So, why should I use dozens of MB on a word processor? Because I get word documents in the mail every once in a while.

In fact, the only word documents I get are error messages from windows users. Here's the procedure every one of them seems to have found to tell me what's inside explorer's error pages:

  1. Capture the screen
  2. Paste it into Word
  3. Mail it to me

I suppose copy&paste of the page contents was too hard. But anyway, I usually manage by having kword or abiword handy, but I was thinking...

I am reading my email. That means I am on the net. That means google docs is right there. And they have a python API! 15 minutes later...

#!/usr/bin/env python

# Create a client class which will make HTTP requests with Google Docs server.
client =
# Authenticate using your Google Docs email address and password.
client.ClientLogin('[email protected]', 'whateveritis')

ms = gdata.MediaSource(file_path = sys.argv[1], content_type = "application/msword")
entry = client.UploadDocument(ms,"tmp_open_with_gdocs/%s"%sys.argv[1])
os.system("firefox '%s'"%entry.GetAlternateLink().href)

Try it, as long as you have firefox, a decent version of python and gdata it should open the doc you pass as first argument on google docs in firefox.

Remember that you need to delete it later if you don't want it, and rename it if you want to keep it with a decent name.

I am not turning it into a real app, but it's good enough for me. Put it in your path and associate it to your .doc files.

A similar thing for .xls is trivial. A script that would handle both, also.

Could please someone take this and make it a real app?

2008-02-09 12:02

rst2pdf: New and improved

My rst2pdf script has had several things happen to it.

  1. It got another guy working on it: Christoph Zwerschke
  2. It's on googlecode now:
  3. Christoph made a number of improvements:
    • bulleted and enumerated list simplified, use same font as text for bullets and numbers
    • links in table of contents work
    • compress literal sections horizontally so that they always fit on the page
  4. I have integrated hyphenation using wordaxe (works only with reportlab 2.1)

The output using hyphenation is really ugly right now (for example, I get a black square instead of an hyphen) but it's a small step forward.

2008-02-05 19:44

Rebelling against insanity: Wicd requires half of GNOME

UPDATE: you can get this program now at google code

I have been using my eee for a while already with a sort of Kubuntu in it.

However, my favourite wireless/wired network management app is wicd, which is a Python/GTK application. Or was, since version 1.4.1 requires python-gnome2-extras.

Which depends on ....

libart-2.0-2 (>= 2.3.18), libaspell15 (>= 0.60), libatk1.0-0 (>= 1.13.2), libbonobo2-0 (>= 2.15.0),
libbonoboui2-0 (>= 2.15.1), libc6 (>= 2.6-1), libcairo2 (>= 1.4.0),
libfontconfig1 (>= 2.4.0), libfreetype6 (>= 2.3.5), libgconf2-4 (>= 2.13.5),
libgda3-3, libgdl-1-0, libgdl-gnome-1-0, libgksu1.2-1 (>= 1.3.3), libgksu2-0 (>= 1.9.6),
libgksuui1.0-1, libglade2-0 (>= 1:2.6.1), libglib2.0-0 (>= 2.14.0), libgnome-keyring0 (>= 2.19.6),
libgnome2-0 (>= 2.17.3), libgnomecanvas2-0 (>= 2.11.1), libgnomeui-0 (>= 2.19.1),
libgnomevfs2-0 (>= 1:2.17.90), libgtk2.0-0 (>= 2.12.0), libgtkspell0 (>= 2.0.2),
libice6 (>= 1:1.0.0), libnspr4-0d (>=, liborbit2 (>= 1:2.14.8),
libpango1.0-0 (>= 1.18.2), libpng12-0 (>= 1.2.13-4), libpopt0 (>= 1.10), libsm6,
libstartup-notification0 (>= 0.8-1), libx11-6, libxcomposite1 (>=1:0.3-1),
libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3 (>= 1:4.0.1), libxi6, libxinerama1,
libxml2 (>= 2.6.29), libxrandr2 (>= 2:1.2.0), libxrender1, zlib1g (>= 1:,
python-support (>= 0.3.4), python (<< 2.6), python (>= 2.4), python-gtk2,
python-pyorbit, python-gnome2-desktop

In short: a 87MB download. That can't be good. In fact, there are almost no changes from 1.3.1 which didn't require all that! Except for one change that makes all the difference on a eee PC: vertical resizing to under 400px. :-(

So, because I am who I am, I did this:


It's a replacement for wicd's and Only needs PyQt4 which I already had and depends on:

libc6 (>= 2.6-1), libgcc1 (>= 1:4.2.1), libqt4-core (>= 4.3.2),
libqt4-gui (>= 4.3.2), libstdc++6 (>= 4.2.1), python-central (>= 0.5.8),
python (<< 2.6), python (>= 2.4), python-sip4 (>= 4.7), python-sip4 (<< 4.8)

See a difference there?

Took me about 3 hours to hack together, and works (except for wired config, the prefs dialog, static IP and scripts) but the hard work is done.

If anyone wants a copy, just ask. I expect KUbuntu could use something like it?

2007-12-28 12:46

Thinking in 800x480: Web browsing

I am still anxiously waiting for my Asus eee (still a week to go or so), and I was thinking about web browsing in the 7", 800x480 screen.

Yes, you can do the usual things, go to full screen mode, whatever, but for many sites, 800 pixels is just too narrow.

You can make pages fit better in a limited width by reducing the font size. A good 8pt font is probably readable on that screen, since you will be pretty close to the screen.

However, that does nothing for layouts that are pixel-based, and for the size of images.

However, after reading about Qt 4.4's support for webkit and widgets in QGraphicsView, I started thinking... that's doing it wrong.

What you want in limited screen space is text in the usual size and the page in a smaller size.

So, my idea is:

  • Make the font larger. Say, 12pt.
  • Render the page in a webkit widget that's 1200x720 pixels.
  • Put the widget in a QGraphicsScene, and reduce it 33%.

The result? a 800x480 web page view that contains the whole page.

Of course you should be able to change all these parameters with a single control. Is the page too wide to see in 800x480 with 8pt fonts?

Then try 1000x600 with 10pt fonts, and reduce it to fit the screen.

Still too wide? Then try 1200x720 and a 33% reduction.

Possible tips:

  • Should work better with aliased fonts, since the size reduction should make antialiased fonts too blurry. A wide, open font will look better,
  • The scrollbars will look squashed, I expect. Probably checkboxes and radio buttons will look funky. Here, more advanced wizardry is needed.

Of course it would have to be tested, but I am willing to bet this will work better than other alternatives. If I had a working PyQt 4.4 I would try to do it myself ;-)

2007-11-30 09:29

Qmail public domain? Cool!!!!

According to Slashdot, at least.

That means there can be a real community project to integrate all the patches floating around!

That means qmail will stop sucking without need for manual labour!

I am just thrilled by this.

2007-11-28 15:51

If you are a qmail user: read this

  • If you don't know what qmail-spp is, please check it out. It makes qmail much much better.
  • If you know qmail-spp, then maybe my plugin collection will be handy for you.
  • My most useful plugin is probably ipthrottle, which you can use to make overeager IPs connect less often.
  • The version currently in SVN will autoblock those IPs for a configurable amount of time if you are using ipsvd which is like tcpserver, only much better.
  • I really need someone to help me test the SVN version, which should be way, way better than the releases on the page.
  • The SVN repo is at googlecode

2007-11-28 14:01

Rethinking Linux Configuration: Part I

I have said Linux sucks. Here's my new project: Make it suck less, one bit at a time.

And I start with one of the big chunks: configuration.

Part I in a longish series (I expect 5 parts at least).

2007-11-23 21:23

My seal of approval!

The KDE project is relicensing some code. There is a tool to verify if any SVN account holder is blocking the relicensing of some file.

Hey, looks like I was!

I don't expect to have any actual code there since I have not editd those files in perhaps 6 years, but it costed me nothing to approve it ;-)

2007-11-23 17:32

Wanted: C programmer

Checking on my semi-dead projects, I found that one was almost finished but I had forgotten about it: rater

In order to make it really useful, however, I need a C programmer that can turn this python program:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from socket import *
serverHost = 'localhost'
serverPort = 1999

s = socket(AF_INET, SOCK_STREAM)
s.connect((serverHost, serverPort))
print "Sending: ",' '.join(sys.argv[1:])
s.send(' '.join(sys.argv[1:])+"\n")
data = s.recv(1024)
sys.exit(int(data.split(' ')[0]))

Into a nice function that never fails and never leaks memory (of course, it should return instead of exit, this is just example code ;-).

If that's done, I can release rater as a useful tool, which should find a home in many qmail installations (and maybe other uses).

Contents © 2000-2019 Roberto Alsina