Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Small software released: RA-WebPass

I just re­leased a wee piece of soft­ware, called RA-Web­Pass which is sim­ply a web­page that you can use to change lin­ux sys­tem pass­word­s.

Ba­si­cal­ly, I wrote it to­day out of my frus­tra­tion with cus­tomers ask­ing me "how can I change the pass­word for the FTP server". Ok, this is how you can.

It's sim­ple and does­n't have too many de­pen­den­cies, so it should be rather se­cure, but don't trust me on that, and you need to run it as root, so be very very care­ful.

RA-Web­Pass home page

On a re­lat­ed note: it's quite sat­is­fy­ing to write some­thing in two hours and just re­lease it :-)

CSS/HTML guru advice needed!

Ok, I give up. I need help.

The mag­i­cal some­times-it-­work­s-on-IE-­some­times-­does­n't over­flow:au­to CSS prop­er­ty has kicked my but­t.

It worked un­til a while ago, and now it does­n't.

Can any­one tell me why the grey pre­for­mat­ted thing here has scroll­bars on Fire­fox and Kon­queror, but not on IE?

In the past, I thought that was be­cause it did­n't work in­side ta­bles, but now there are no ta­bles in the lay­out.

So, I am clue­less :-(

UP­DATE Thanks for all the sug­ges­tion­s, it kin­da works now :-)

Spiderman 3 on IMAX

That's the way those movies are meant to be seen.

On mon­day I had my first IMAX ex­pe­ri­ence (the first IMAX in Ar­genti­na opened not long ago).

The rum­ble in my guts in the first big ac­tion scene... hav­ing to move the head to fol­low the ac­tion on the last one... re­al­ly an in­tense cin­e­mat­ic ex­pe­ri­ence.

I liked the sec­ond movie bet­ter, and ev­ery­one seemed a bit tired of their roles, but a fun movie.

If you are go­ing to do pop­corn, you bet­ter do great pop­corn, and that's what Rai­mi does.

A KDE hack: Faster mail searches in kmail, using mairix

Kmail search­es slow­ly.

I have been a kmail us­er for a cou­ple of years, since I set­tled in my own home of­fice with my own com­put­er.

I like the thing.

How­ev­er, it an­noys me that it takes sooooo long to find a mes­sage in my mail­store. Hey, it's on­ly 13000 mes­sages!

So, while I wait for KDE4 to bring all its search­ing good­ness, I de­cid­ed to see if I could hack some­thing quick­ly.

En­ter mair­ix: a mail in­dex­er/search thing.

Con­vinc­ing mair­ix to in­dex all my mail was rather sim­ple (here is my ~/.­mair­ixr­c):

base=/home/ralsina/
maildir=Mail/*...
maildir=.kde/share/apps/kmail/dimap...
omit=Mail/mairix
database=~/.mairix_db

What does it do?

  • It in­­dex­es mail stored at ~/­­Mail and ev­ery­where in my kmail imap fold­er­s.

  • It stores search re­­sults in ~/­­Mail/­­mair­ix and ig­nores its con­­tents when search­ing. The re­­sults are stored as links, so they waste no disk space.

Af­ter run­ning mair­ix so it builds its DB (took about a min­ute, which is less than most kmail search­es) , you can search for things like this:

[ralsina@monty ~]$ time mairix b:bartleblog
Matched 6 messages

real    0m0.232s
user    0m0.012s
sys     0m0.204s

And the re­sult can be seen in kmail, in the mair­ix fold­er:

mairix1.png

How­ev­er, there is a prob­lem. It will work for the first search, but not for the sec­ond one. On the sec­ond search, you get the same con­tent list­ing, but all mes­sages ap­pear emp­ty.

That's be­cause kmail saves an in­dex file of each fold­er. To work around that, I wrote a lit­tle shell wrap­per, kmair­ix:

#!/bin/sh
rm ~/Mail/.mairix* -f
mairix $*

And you use that in­stead of call­ing mair­ix di­rect­ly.

But there are still im­prove­ments to be done. If your kmail is cur­rent­ly dis­play­ing the mair­ix fold­er, search­ing does­n't up­date the mes­sage list.

DCOP to the res­cue! We can switch to the in­box, then back to mair­ix (ad­just as need­ed for your­self):

dcop kmail KMailIface selectFolder /Local/inbox
dcop kmail KMailIface selectFolder /Local/mairix

Miss­ing pieces:

  • How about switch­ing to the kmail win­­dow? Sad­­ly, the kwin DCOP in­­ter­­face seems in­­­com­­plete. Maybe as­sign­ing kmail a hotkey and work from there? Let me know if you have any ideas.

    UP­­­DATE as sug­­gest­ed by An­no He­im­burg: just call kmail.

  • A GUI (of course!) prob­a­bly with a tray icon...

  • A way to au­­to-up­­date the Mair­ix DB when new mail ar­rives. I am think­ing about do­ing it with in­­cron but have not done it yet.

So, here is the fi­nal ver­sion, put it some­where in your path, and use AL­T+F2 to search your mails :-)

#!/bin/sh
rm ~/Mail/.mairix* -f
mairix $*
dcop kmail KMailIface selectFolder /Local/inbox
dcop kmail KMailIface selectFolder /Local/mairix
kmail

BartleBlog live!

I was think­ing: how can I im­ple­ment page pre­views in Bartle­Blog?

The ob­vi­ous way is to ren­der the page and open the lo­cal file. How­ev­er, the page may link or in­clude pieces that are not up­dat­ed yet in the stat­ic ver­sion, so that can give con­fus­ing re­sult­s.

Then it hit me... gen­er­ate the page on the fly and serve it. And do the same for ev­ery­thing else the brows­er asks for.

So, af­ter search­ing for 15 min­utes for the sim­plest python "web frame­work" that let me use the code al­ready in Bartle­blog, and de­cid­ing for Col­u­brid...

Now, this is cute: bartle­blog as a dy­nam­ic web app in 34 lines.

from colubrid import RegexApplication, HttpResponse, execute

from BartleBlog.backend.blog import Blog
import BartleBlog.backend.dbclasses as db
import os, codecs

class webBlog(Blog):
    def __init__(self):
        Blog.__init__(self)
        self.basepath='http://localhost:8080/'
        self.dest_dir=os.path.expanduser("~/.bartleblog/preview")
        if not os.path.isdir(self.dest_dir):
            os.mkdir(self.dest_dir)


class MyApplication(RegexApplication):
    blog=webBlog()
    urls = [
        (r'^(.*?)$', 'page'),
        (r'^(.*?)/(.*?)$', 'page'),
        (r'^(.*?)/(.*?)/(.*?)$', 'page'),
        (r'^(.*?)/(.*?)/(.*?)/(.*?)$', 'page')
    ]

    def page(self, *args):
        path=''.join(args)
        page=db.pageByPath(path)
        self.blog.renderPage(page)
        return HttpResponse(codecs.open(os.path.join(self.blog.dest_dir, path)).read())

app = MyApplication
app = StaticExports(app, {
    '/static': './static'
})


if __name__ == '__main__':
    execute(app)

Contents © 2000-2021 Roberto Alsina