Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about programming (old posts, page 25)

PyWeek progress: the 4 hour mark

Sud­den­ly I was hav­ing a calm day at work, and Rosario is tak­ing care of the baby, so I spent a few hours on the Py­Week projec­t.

I have in­te­grat­ed Chip­munk with QGraph­ic­sS­cene.

What does it mean? That I can now...

  • Cre­ate a scene

  • Cre­ate a view on­­to that scene

  • Cre­ate bal­l­s, walls and poly­­gons as scene items

  • Watch said bal­l­s/wal­l­s/poly­­gons bounce around hap­pi­­ly un­der Chip­­munk di­rec­­tion.

For ex­am­ple, here's enough code to cre­ate a few balls a box and a stair­case:

self.scene=ChipScene()
self.ui.view.setScene(self.scene)

for x in range (0, 10):
    self.scene.addBall(x*50.0+10, 50.0, 10.)
    self.scene.addBall(x*50.0+20, 20.0, 10.)
self.scene.addWall(0., 0., 0., 500.)
self.scene.addWall(0., 500., 500., 500.)
self.scene.addWall(500., 500., 500., 0.)
self.scene.addWall(500., 0., 0., 0.)
for i in range (0, 20):
    self.scene.addWall(i*20, 200+i*20, i*20+20, 200+i*20)
    self.scene.addWall(i*20+20, 200+i*20, i*20+20, 200+i*20+20)

self.scene.addPoly([[0, 50], [0, 100], [100, 100], [100, 50], [0, 50]])

I de­clare that nifty.

PyWeek5

Well, it seems I am in trou­ble for Py­Week.

Why? Be­cause it's wednes­day and I have done noth­ing. Noth­ing! It's be­cause I have been work­ing a lot, re­al­ly, and I have a 4 month baby, too.

So, I am up­ping the ante.

I will do a Py­Day.

I am tak­ing to­mor­row off (yeah, right!) and I'm do­ing the game in one day. Maybe I will scrounge a few hours on sun­day, too.

It will prob­a­bly not be fit for the con­test be­cause:

  • I will use PyQt

  • I won't test it in any plat­­form oth­­er than my Lin­ux box

But here's the game con­cept (BTW: Twist­ed sucks as a theme. It sucks re­al­ly, re­al­ly, re­al­ly hard!):

Ac­cord­ing to the dic­tio­nary, Twist­ed al­so means per­vert­ed. So, this game, Twist­ed Lit­tle Boy is about a bad boy. A re­al­ly bad boy. But a clever one. He cre­ates ma­chines us­ing ran­dom equip­ment he finds to do evil, re­al­ly mean things.

I will prob­a­bly do a live-blog thing like those tu­to­ri­als I wrote years ago about PyQt.

There's a Google code project (ob­vi­ous­ly emp­ty): http://­code.­google.­com/p/twist­edlit­tle­boy/

See you all to­mor­row.

Django, the view from a parachute

In the last few days I have been learn­ing Djan­go in per­haps the hard­est way pos­si­ble: by be­ing hired to work on a site some­one else wrote.

I al­ready had the view from 10000 feet. And since I had to get to this thing rather quick­ly, I jumped on my para­chute from those 10000 feet, and learned it on the way down.

Here's what I knew:

  • Python Web frame­­work

  • Reg­ex­p-based URL dis­­­patch­ing

  • Its own tem­­plate lan­guage

  • Its own ORM and form stuff

I have hacked stuff based on Tur­bo­Gears, Col­u­brid, pure Cher­ryPy, Mako/Kid/Chee­tah/Cher­ry­Tem­plate tem­plates, Routes, Paste and about half a dozen oth­er frame­works or pieces that are used for frame­work­s, so how new could it be? Well, not very new. I am start­ing to no­tice a sort of same­ness in these things. They are all alike.

First, the con­clu­sion: I liked it, I could work with it.

Now for some lit­tle de­tail:

  • The URL dis­­­patch­ing is nice ,if not re­al­­ly in­­ter­est­ing. there seem to be two ways to do this, all frame­­works use one or the oth­­er, and al­­most ev­ery­one likes reg­ex­ps bet­ter.

  • The OR­M+new­­forms is quite nice! Of course ev­ery­thing was done with old­­for­m­s, which is... not quite so nice. But you can switch pieces as you go, and the code ac­­tu­al­­ly sim­­pli­­fies as you hack, so it's good.

  • The tem­­plate lan­guage I could live with­­out. It does­n't seem to be spe­­cial­­ly fea­­ture­­ful, and it did­n't seem as ex­pres­­sive to me as my cur­rent favourite, Mako. Luck­­i­­ly you can re­­place it eas­i­­ly. It's not that it's bad, it's just av­er­age.

So, I see no rea­son to learn it in­stead of Tur­bo­gears, or vicev­er­sa. On the oth­er hand, if you know one, you can learn the oth­er in per­haps a week­end, so there's no point on not hav­ing at least a ba­sic knowl­edge of both.

Be afraid, young pumpkins!

Al­low me to en­ter trash-talk­ing mod­e...

Be very afraid be­cause this year, my mighty skills are en­ter­ing Py­Week for the first time.

Just to make it in­ter­est­ing and some­what chal­leng­ing:

  • I will be en­ter­ing as an in­­di­vid­u­al, not in a team.

  • I have not writ­ten a line of PyGame code in my life.

  • I have writ­ten bare­­ly any game code at al­l.

  • I will sub­­mit my fi­­nal code one day ear­lier, just be­­cause I can.

Nonethe­less, I in­tend to kick ass­es and ask no ques­tion­s. I in­tend to over­whelm you all with a game of such awe­some­ness you will all whith­er like let­tuce in La­p­land. I will write code of such in­ge­nu­ity you will try to steal it and fail.

...ex­it­ing mod­e.

Should be fun and my en­try will prob­a­bly suck. But we'll see...

Me and FLOSS in the late '90s

I have no idea how, but I ran in­to this in Lin­ux­to­day:

KDE Pro­gram­ming Tu­to­ri­al 0.2 (Dec 22nd 1998, 00:09:36 )

Rober­to Alsi­na an­nounced that he up­load­ed to ft­p.kde.org the ver­sion 0.2 of his ex­cel­lent pro­gram­ming tu­to­ri­al. It is al­so avail­able here. Hope­ful­ly, this must-have ma­te­ri­al will be soon in­clud­ed in the kdes­dk pack­age and in CVS.

Now, this was pret­ty shock­ing be­cause I don't re­mem­ber writ­ing it (any­one knows where a copy may be?). I have no idea what was in it, and in fac­t, the idea of peo­ple learn­ing C++ from me in 1998 is so stupid it's shock­ing, since I knew very lit­tle.

Then it hit me, the URL! Ul­tra­7? That was my 486 at col­lege [1].

It had a web­server? What on earth had I been drink­ing back then? Why can't I re­mem­ber this???

Way­back ma­chine, come here! Fetch!

Here's my first home page. I must say it's pret­ty good. It's not gar­ish. Very We­b2.0 in the abun­dant white space.

First in­ter­est­ing thing: there is at least one ex­tant copy of PyX­Forms, my first free soft­ware pro­jec­t, used by ab­so­lute­ly noone.

And there are even two cool screen­shot of a func­tion­al pro­gram noone ev­er used [2]:

im1im2

In fac­t, I have no idea how I did that high­light­ed mes­sage dis­play.

Then all that pro­to-­good taste goes away when you reach the page for my most "pop­u­lar" project ev­er... Krn in my 1999 home page [4]. It' so 1999 free soft­ware style. All that's miss­ing is an elec­tric blue back­ground.

It seems I had dis­cov­ered The Gimp and it's ban­ner script­s!

BTW: I won­der what's Mag­nus Ref­tel do­ing nowa­days? We used to ex­change dozens of mails a day and for some rea­son we lost con­tac­t.

There was al­so a mail­ing list ar­chive for the very very very first posts of our pro­to LUG (which would lat­er be­come LUGLI)

And here's the best part, and the one that makes me kin­da sad... Themes for Qt1.

You can read a lit­tle about them in this thread.

I have writ­ten about them once or twice be­fore but here's the short ver­sion:

Raster­man was start­ing to hack themes for Gtk. I de­cid­ed they could­n't be the on­ly ones with this cool new tech­nol­o­gy but I had the big dis­ad­van­tage of not be­ing able to touch Qt's code be­cause of li­cens­ing is­sues. So I in­ter­cept­ed the draw­ing events us­ing a LD_PRELOAD hack and im­ple­ment­ed a theme full of gra­di­ents with­out mod­i­fy­ing or re­com­pil­ing Qt or KDE.

Now that's one of the most im­pres­sive hacks I have ev­er per­formed, even if it was a hack done with the most evil code ev­er, and... there seems to be no ex­tant copy of the code or the screen­shots.

Which is kin­da sad, in­deed.


Contents © 2000-2024 Roberto Alsina