Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about python (old posts, page 67)

I would be a sellout, but there's not much demand.

For Sale Portobello Mkt
For Sale Portobello Mkt by Jason Jones, under a CC-by-nc-sa license.

It would be nat­u­ral to any­one who does­n't know me to be­lieve I live a life of lux­u­ry, in­ter­na­tion­al trav­el and ex­ot­ic plea­sures 1 but there is a small thing I am kin­da ashamed of:

I hard­ly ev­er got paid to code.

Re­al­ly! Most of the mon­ey I live on has ab­so­lute­ly noth­ing to do with what­ev­er you read about on my blog.

I make my liv­ing do­ing things like in­stalling As­ter­isk in call cen­ter­s, or con­fig­ur­ing MySQL repli­ca­tion, or con­fig­ur­ing VP­Ns us­ing as­sort­ed piece-of-crap routers and by all means if you need that kind of work done, please con­tact Net Man­agers we are freaky good at it and charge rea­son­able rates.

But while I like that kind of thing 2 I like oth­er things bet­ter. I like pro­gram­ming much more than I like con­fig­ur­ing As­ter­isk!

Then again, I am not a re­al­ly great pro­gram­mer. I am just about an av­er­age coder, ex­cept that I am faster than most.

And late­ly, an in­ter­est­ing phe­nom­e­non has tak­en place.

How much mon­ey I earned thanks to my first 14 years of open source and free soft­ware de­vel­op­men­t? $0 3

How much mon­ey have I earned in the last year of FLOSS de­vel­op­men­t? $500 (and it is bound to be more than that soon).

To a first-­worlder that may seem like peanut­s, but down here in the land of cheap beef, that's... about 100 pounds of good meat! Or 10 nice din­ners in fine restau­rants for me and my wife. 4

I am won­der­ing, is this part of a trend? Have oth­ers been re­ceiv­ing more ap­pre­ci­a­tion in the form of mon­ey late­ly?

In any case, it's a great feel­ing when a work of love (and trust me, noone does some­thing for 14 years for free if he does­n't love it) is ap­pre­ci­at­ed.

Just in case: this does­n't mean you have to pay me to get a bug fixed, or to get a fea­ture im­ple­ment­ed. How­ev­er, it does mean that if you like or use any of my pro­grams and want me to feel good about the time I spent writ­ing them... well, you can just send me a nice email, I will be just as hap­py. Re­al­ly!


1

I do!

2

And I do like it! It's like a grownup's ver­sion of Lego.

3

I did get boxed SuSE CD sets for a while but I ac­tu­al­ly lost mon­ey on them since I had to pay tax­es.

4

To all those who have con­trib­uted I send my sin­cer­est ap­pre­ci­a­tion, and trust me that all this mon­ey has been wise­ly in­vest­ed on hav­ing fun, cheap chi­nese gad­getry and choco­late mousse.

Virtualenv and friends (video)

I am one of the speak­ers in the cy­cle of open python lec­tures at La Tribu in Buenos Aires, and here is the one where I speak about vir­tualen­v, build­out, nose, hud­son and oth­er things.

Long video!

Quick hack: rss2epub -- it does what it says.

One of my favourite things about Aran­du­ka as a project is that it's an end­less source of smal­l, lim­it­ed side project­s.

For ex­am­ple, Aran­du­ka is now close to be­ing able to sync my book col­lec­tion to my phone. But... what if what I want to read on the train is not a book but, say, a blog?

Well, blogs pro­vide their con­tent via a feed. And A feed is a col­lec­tion of HTML pieces glued in­to a struc­ture plus some da­ta like au­thor and such.

And there's a great mod­ule for pars­ing them, called feed­pars­er. And I have writ­ten not one, not two, not three, but four RSS ag­gre­ga­tors in the past.

So, how about con­vert­ing the feed in­to some­thing my phone can han­dle? [#] Would it be hard to do?

Well... not re­al­ly hard. It's most­ly a mat­ter of tak­ing a smal­l, sam­ple ePub doc­u­ment (cre­at­ed by Cal­i­bre) writ­ing a few tem­plates, feed­ing it the da­ta from feed­pars­er and zip­ping it up.

For ex­am­ple, this is this blog, as an ePub and here's FBRead­er read­ing it:

Share photos on twitter with Twitpic

As usu­al, the code is open, and it's here in aran­duka's mer­cu­ri­al.

It's not re­al­ly in­ter­est­ing code, and re­quires tem­plite feed­pars­er and who knows what else.

The pro­duced ePub does­n't val­i­date, and it prob­a­bly nev­er will, be­cause it has chunks of the orig­i­nal feed in it, so stan­dard com­pli­ance does­n't de­pend on rss2epub.

Al­so, you get no im­ages. That would im­ply pars­ing and fix­ing all img el­e­ments, I sup­pose, and I am not go­ing to do it right now.

[#] I first saw this fea­ture in pluck­er a long time ago, and I know Cal­i­bre has it too.

eBooks and PyQt: a good match

I have been putting lots of love in­to Aran­du­ka an eBook man­ager, (which is look­ing very good late­ly, thanks!), and I did­n't want it to al­so be an eBook read­er.

But then I thought... how hard can it be to read ePub? Well, it's freak­ing easy!

Here's a good start at stack­over­flow.­com but the short of it is... it's a zip with some XML in it.

One of those XML files tells you where things are, one of them is the TOC, the rest is just a small stat­ic col­lec­tion of HTM­L/C­SS/im­ages.

So, here are the in­gre­di­ents to rol­l-y­our-own ePub read­er wid­get in 150 LOC:

  • Use python's zip­­file li­brary to avoid ex­­plod­ing the zip (that's lame)

  • Use El­e­­ment Tree to parse said XML files.

  • Use PyQt's QtWe­bKit to dis­­­play said col­lec­­tion of XM­L/C­SS/Im­ages

  • Use this recipe to make QtWe­bKit tell you when it wants some­thing from the zip­­file.

Plug some things to oth­er­s, shake vig­or­ous­ly, and you end up with this:

Share photos on twitter with Twitpic

Here's the code (as of to­day) and the UI file you need.

Miss­ing stuff:

  • It does­n't dis­­­play the cov­­er.

  • It on­­ly shows the top lev­­el of the ta­ble of con­­tents.

  • I on­­ly test­ed it on two books ;-)

  • It sure can use a lot of refac­­tor­ing!

Nei­ther should be ter­ri­bly hard to do.

Introducing Aranduka

Yes, it's yet an­oth­er pro­gram I am work­ing on. But hey, the last few I start­ed are ac­tu­al­ly pret­ty func­tion­al al­ready!

And... I am not do­ing this one alone, which should make it more fun.

It's an eBook (or just any book?) man­ager, that helps you keep your PDF/­Mo­bi/F­B2/what­ev­er or­ga­nized, and should even­tu­al­ly sync them to the de­vice you want to use to read them.

What works now? See the video!

In case that makes no sense to you:

  • You can get books from Feed­­Book­s. Those books will get down­load­­ed, added to your database, tagged, the cov­­er fetched, etc. etc.

  • You can im­­port your cur­rent fold­er of books in bulk.

    Aran­­du­­ka will use google and oth­­er sources to try to guess (from the file­­name) what book that is and fill in the ex­­tra da­­ta about it.

  • You can "guess" the ex­­tra da­­ta.

    By mark­ing cer­­tain da­­ta (say, the ti­tle) as re­li­able, Aran­­du­­ka will try to find some pos­si­ble books that match then you can choose if it's right.

    Of course you can al­­so ed­it that da­­ta man­u­al­­ly.

And that's about it. Planned fea­tures:

  • Way too many to list.

The goals are clear:

  • It should be beau­ti­­ful (I know it is­n't!)

  • It should be pow­er­­ful (not yet!)

  • It should be bet­ter than the "com­pe­ti­­tion"

If those three goals are not achieved, it's fail­ure. It may be a fun fail­ure, but it would still be a fail­ure.


Contents © 2000-2021 Roberto Alsina