Jhaampe

October 1st, 2007 by exhuma.twn

About these homes and at the intersections of the roads in this nomadic ‘city’ are the gardens. Each is unique. One may centre around an unusually-shaped stump or an arrangement of stones or a graceful bit of wood. They may contain fragrant herbs or bright flowers or any combination of plants. One notable one has at its heart a bubbling spring of steaming water. Here grow plants with fleshy leaves and exotically-scented flowers, denizens of some warmer clime brought here to delight the mountain-dwellers with their mystery. Often visitors leave gifts in the gardens when they depart, a wooden carving or a graceful pot or perhaps merely an arrangement of bright pebbles. The gardens belong to no one, and all tend them.

Robin Hobb, Assassins Quest.
Great Britain: Harper Voyager, 1998

When rading this passage of this book (which is part of the Farseer Trilogy) I could not help but think about Open Source projects. If you did not had the same thought when reading the text, go read it again. It is a beautiful analogy.

Note: If any directly involved party feels that any copyright claims have been violated by posting this, please leave a comment. I will take this text down if so requested.

Posted in Babble | No Comments »

GPG… anyone?!?

September 24th, 2007 by exhuma.twn

I can sympathize that GPG (a free and toolset to encrypt and sign digital data) has not been used by the wide public in the past. It was complex to set up, the concept of private/public keys was a bit flaky to most people, PGP (not GPG!) costs precious money, and integration with mail clients was not trivial.

With the spreading of Mozilla Thunderbird this has changed drastically however. With enigmail (a mozilla-addon to use GPG with the mail client), things are becoming much easier and accessible. It offers most of the functionalities you wish to see in such a tool. It allows you to create a new private/public key pair, has a simple management tool for keys, and lets you very transparently sign and/or encrypt e-mails.

In my opinion, the main reason why GPG is still a thing for “geeks” or “professionals” is the ignorance (or naiveté) of people about how easy mails can be intercepted. Yesterday I demonstrated somebody this exact fact. And him still being quite computer-literate, he was still baffled that I could show him the text of a mail he sent with his password along the lines (All done with his consent of course). And I do not consider myself a hacker. Just a few minutes of googling, downloading and installing the right tool did it for me. And if I can do this, so can many other people as well. With a little bit more effort, it’s even possible to alter the text of a mail in transit. Needless to say, the emails are stored on somebody else’s server. An this in plain text! Even if the server does support SSL, TLS or whatnot. This only means that the transmission between mail-client and mail-server is secured. Not the storage. And you never know who sit’s behind the screen of that server.

Granted, most of the time, people managing servers like this are most likely geeks themselves, which usually share the concern about security, and thus keep things safe.

Considering this, it can become easy to demonstrate the advantages of mail encryption/signing. And usability is increasing steadily. With the mozilla suit (and thunderbird) now having a user-friendly tool at the ready, people are not yet easily convinced to keep security in mind. Other mail-clients offer easy user-interfaces as well. The KDE-Suite (with KMail and KGPG) had brilliant supoprt for this already a long time ago. And there are more free tools available to make it a user-friendly experience. The Swiss-Army-Knife for a Windows environment would probably be GPGShell. It still resorts to the GPG-Cli application from time-to-time, but it keeps it to a minimum. It also offers easy file-encryption via Windows Explorer shell entries. Another alternative is Evolution, which has built-in supoprt for GPG.

Suffice it to say, there is widespread support for GPG (and PGP) in mail-application across all OS’es. To become more widespread in use, people should be made aware of the risks that are posed by e-mails and how easy it can be made to keep personal information really personal.

Posted in Babble | No Comments »

Calculate the distance between two GPS-Coordinates (ctd.)

September 17th, 2007 by exhuma.twn

And here’s the same thing as plpgsql function for Postgres:

CREATE OR REPLACE FUNCTION lldistance( a point, b point)
RETURNS FLOAT AS $$
DECLARE    x FLOAT;
        dlat FLOAT;
        dlon FLOAT;
BEGIN
   dlat = radians(a[0]-b[0]);
   dlon = radians(a[1]-b[1]);
   x := sin(dlat/2)^2 +
        cos(radians(a[0])) * cos(radians(b[0])) *
        sin(dlon/2)^2;
   RETURN 6367442.5 * (2*atan2(SQRT(x), SQRT(1-x)));
END;
$$ LANGUAGE plpgsql

This results in more accurate distances than simply using

SELECT point1 <-> point2 FROM sometable;

You could also use plpython as function language and copy/paste the earlier post, but plpgsql is more portable.

Posted in Coding Voodoo | 1 Comment »

Calculate the distance between two GPS-Coordinates

September 17th, 2007 by exhuma.twn

This function uses the Haversine formula to calculate the distance which takes into account the spherical nature of the earth.
As the earth is not a perfect sphere, this function approximates this by using the average radius.

from math import sin, cos, radians, sqrt, asin

def lldistance(a, b):
   """
   Calculates the distance between two GPS points (decimal)
   @param a: 2-tuple of point A
   @param b: 2-tuple of point B
   @return: distance in m
   """

   r = 6367442.5             # average earth radius in m
   dLat = radians(a[0]-b[0])
   dLon = radians(a[1]-b[1])
   x = sin(dLat/2) ** 2 + \
       cos(radians(a[0])) * cos(radians(b[0])) *\
       sin(dLon/2) ** 2
   y = 2 * asin(sqrt(x))
   d = r * y

   return d

Posted in Python | 1 Comment »

Centering a window on the screen with Qt

September 10th, 2007 by exhuma.twn

Yet another thing that’s not automagic in Qt.
Here’s a python solution:

if __name__ == "__main__":

   app = QtGui.QApplication(sys.argv)

   dw = app.desktop().width()
   dh = app.desktop().height()

   myapp = MainWindow()
   myapp.setGeometry(
         int((dw - (dw - (dw / 2)) * 1.5) / 2),
         int((dh - (dh - (dh / 2)) * 1.5) / 2),
         int((dw - (dw / 2)) * 1.5),
         int((dh - (dh / 2)) * 1.5))
   myapp.show()
   sys.exit(app.exec_())

This will also resize the window, adapting to the desktop size.
Found and adapted from the Qt interest archive.

Posted in Python | No Comments »

Adding Scrollbars to a QFrame in Qt

September 10th, 2007 by exhuma.twn

Many things are very easy to accomplish in Qt. Qt’s designer is a great help with that. But the is no option to simply “enable” scrollbars for a frame. Also, the QScrollArea can nowhere be found in the designer. The solution is actually quite simple:

  1. Add the component you want to be scrollable (QFrame, QLabel, …) in the designer as usual
  2. In the application code:
    1. Create a new QScrollArea
    2. Set the parent of the widget you created in the designer to “None”
    3. Set the widget of the QScrollArea to the widget from step 1
    4. Insert the QScrollArea to you ui

And here’s some example code (boiled down to the essentials):

sa = QtGui.QScrollArea()
self.ui.myWidget.setParent(None)
sa.setWidget(self.ui.myWidget)
self.ui.vboxlayout1.insertWidget(0, sa)

You would probably write this somewhere in you application-constructor right after you call setupUi.

This will insert the scroll area at the top of vboxlayout1 (see the doc for insertWidget). You can of course also use addWidget.

It’s a shame that there’s no direct support for QScrollArea in designer. Maybe we will see it in some future release.

An example for C++ can be found in the Qt Forums.

Posted in Python | 2 Comments »

Speed comparison of various terminals

September 6th, 2007 by exhuma.twn

Terminal speed comparisonI never cared about which terminal to chose. I usually ended up with aterm on non-KDE boxes and Konsole on KDE boxes. This comparison (and the attached comments) is actually quite interesting.

The results were quite surprising 😉

Posted in Linux | No Comments »

Web Provider Fun

August 16th, 2007 by exhuma.twn

Oh yess… rants… I love to rant… and after my adventures of today and reading the last post, I have to dump my thoughts as well. And this one is about one of our web-providers in our oh-so technically advanced country. Or so they claim.
Read the rest of this entry »

Posted in Babble | No Comments »

VIM rc-file

August 10th, 2007 by exhuma.twn

Due to inane network restrictions I am maintaining several copies of my vimrc file. I would syncronize it though other means. Alas, the restrictions not only cover the network. So I have to resort to simply posting it here.

This is not meant to be an explanation of vim configuration file. However, it contains lots of comments, and might prove a good primer/starting-point. Eventually I will also include other modifications I made in my vim-home-folder as they are either used in the vimrc or just plain useful 😉

Read the rest of this entry »

Posted in Babble, Coding Voodoo | 2 Comments »

Ohloh Open Source Statistics

July 26th, 2007 by exhuma.twn

ohlo language statsOholoh is a site that keeps code statistics of open-source projetcs. It’s very interesting to browse though the different projects and look at their metrics.

It can also be a nice incentive to get people do commit on a regular basis, as it adds a sort of healthy competition to the development cycle.

Anyhow…. Great idea, and it already keeps track of quite a number of projects.

Posted in Coding Voodoo | No Comments »

« Previous Entries Next Entries »

Pages

Recent Posts

Categories

Links


Archives

Meta