Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about programming (old posts, page 14)

Any regex wizard reading this?

If so, what is the C POSIX regex (y­ou know reg­comp & friend­s) equiv­a­lent of this python reg­u­lar ex­pre­sion:

re.compile(r'^([a-z][a-z0-9_\-\.]*)=', re.IGNORECASE)

Be­cause it sure is­n't this:

regcomp(&re,"^([a-z][a-z0-9_\-\.]*)=",REG_ICASE)

I have been play­ing with it for two hours and am bored :-)

Playing with literate programming

I am us­ing ra-­plu­g­ins as a toy to do things I nev­er both­ered in oth­er project­s.

I am do­ing unit-test­ing. And now... some lit­er­ate pro­gram­ming!

Ok, not much, and not very well, but at least I am play­ing with Lp4all which is a nice, sim­ple tool to gen­er­ate nice HTML from slight­ly wik­i-­marked sources.

You can see some lit­tle things in my code here. My vere­dict so far? A nice way to keep the code doc­u­ment­ed in a fash­ion that ocasi­nal browsers can fol­low.

The main thing miss­ing is au­to­mat­ic cross-ref­er­enc­ing.

In gen­er­al, I am find­ing that this (and unit test­ing) helps me ex­press ex­plic­it­ly to my­self what the heck I am try­ing to do, and see if the code ac­tu­al­ly does it. Which is a re­al­ly good thing.

Itching.

Ok, the SPF im­ple­men­ta­tion sit­u­a­tion is kin­da pa­thet­ic.

There seems to be ex­act­ly one main­tained C im­ple­men­ta­tion. And it's win­dows-on­ly.

  • lib­spf's we­b­site seems to have dis­­ap­­peared

  • lib­spf2's not RFC-­­com­­pli­ant (ver­i­­fied for 1.2.5) and their is­­sue re­­port­ing sys­tem bounces.

So, I have tak­en the most com­pli­ant one I found whose code I can ac­tu­al­ly fol­low (that would be the python one) and am reim­ple­ment­ing it in C (us­ing bstr­lib and lib­d­jbdns).

It will prob­a­bly not come to a good end, but hey, it may work ;-)

To the other three guys (or gals)....

... who own a HP Jor­na­da 720 and are us­ing Opie on it and they have the span­ish/lat­in-amer­i­can key­board­... here is your keymap.

I will write some­thing about how to get Lin­ux go­ing right on it soon, but here's the sta­tus re­port, 48 hours in.

This ba­by (un­named yet) has:

  • 32MB of RAM

  • 1 GB of Flash

  • Wifi (802.11b pcm­­ci­a) + IR­­DA + Eth­er­net (pcm­­ci­a) + Any­thing once I find a 16-bit pcm­­ci­a-USB card (any­one has a spare and wants to re­­cy­­cle it? ;-)

  • De­­cent bat­tery life (6 hours use with wifi, 9 with­­out)

  • A key­board

  • A de­­cent screen (640x240)

  • A de­­cent Lin­ux-based GUI (Opie)

  • A some­what er­rat­ic touch­screen

So, what can I do with it:

  • Email

  • Web brows­ing ( With Kon­­queror good­­ness )

  • Pro­­gram­ming (Python, even PyQt2!). They key­board and screen are sur­pris­ing­­ly de­­cen­t.

  • eBook read­­ing. This is the most im­­por­­tant one. In my work, I spend a lot of time wait­­ing. Wait­­ing for the train to ar­rive, for the trip to end, for some­one to come to a meet­ing, for the wait­­er to bring my meal, for stuff to com­pile, for stuff to down­load­­... maybe I wait 3 hours a day. So I read. And this screen (long and some­what thin) is quite spec­­tac­u­lar for read­­ing. Opie-read­­er is pret­­ty good.

  • MP3 and Video play­er (haven't used it yet). I have stream­ing TV at home, cour­tesy of Cher­ryTV (check the links at the left­­). This should work great when Rosario wants to see Mon­te­cristo and I'd rather see Penn & Teller's show.

  • Gen­er­al PIM stuff. Al­though I tend to keep that stuff in my head and my phone.

The bad side:

  • The bizarre screen as­pect ra­­tio con­­fus­es many con­­fig­u­ra­­tion di­alogs.

  • Al­­most no game works un­­less you ro­­tate the screen.

  • The key­board con­­fig­u­ra­­tion took a while, and is not per­­fect yet ( I can't make dead­­_a­­cute work for some rea­­son)

  • The ex­­tra but­­tons don't work (ex­ter­­nal au­­dio recorder, and alarm light-but­­ton)

  • I can't find a way to bind the func­­tion keys to apps in Opie

  • The re­set but­­ton does­n't work (it's now a hang but­­ton)

  • Sus­pend is not re­al­­ly sus­pend on Lin­ux (for un­avoid­able hard­ware rea­­son­s), so it spends bat­tery when sus­pend­ed (may last 12 hours or so, I think).

  • The on­­ly way to re­al­­ly turn it off is to take out the bat­tery (not as bad as it sound­s).

  • If you do that, it takes about one minute to boot.

So, I am us­ing it more as a lap­top (although a re­al­ly, re­al­ly small one, with very, very good bat­tery life :-) than as a PDA.

The small mem­o­ry and CPU means I can't run very de­mand­ing stuff, but I nev­er seem to do that, any­way.

And of course, the re­al­ly bad thing: it's so much fun to hack with, I have trou­ble work­ing!

All in al­l, a great toy, lots of fun, and rather use­ful.

rst2rst gets tables!

My Re­struc­tured Text to Re­struc­tured Text con­vert­er can now han­dle ta­bles!

If you don't un­der­stand a word of what I just wrote... well, skip this. It's re­al­ly quite es­o­ter­ic.

I man­aged with­out lin­ear pro­gram­ming by the usu­al route: make it ug­ly but func­tion­al. Ba­si­cal­ly, I overdi­men­sion things bad­ly.

Here's the source table:

+-------+---------------------------+
| f2,c1 | f2,c2 longer longer still |
|       +---------------------------+
| f3,c1 | 1. a                      |
| f3,c1 |                           |
| f3,c1 | 2. b                      |
+-------+---------------------------+

Here's what rst2rst gen­er­ates:

+-------+---------------------------+
|       |                           |
| f2,c1 | f2,c2 longer longer still |
|       |                           |
| f3,c1 |                           |
| f3,c1 |                           |
| f3,c1 |                           |
|       |                           |
|       +---------------------------+
|       |                           |
|       | 1. a                      |
|       |                           |
|       | 2. b                      |
|       |                           |
+-------+---------------------------+

Se­ri­ous­ly non-op­ti­mal, but it is func­tion­al, un­til a braver soul im­proves the al­go­rith­m.

It can't han­dle ta­ble head­ers cor­rect­ly, but oth­er than that, it works just fine.

Up­date: It now sup­ports all the RST ta­ble syn­tax, AFAIK.