Skip to main content

Ralsina.Me — Roberto Alsina's website

Flickr Banners

If you are one of the three per­sons who ac­tu­al­ly see this blog on its site in­stead of read­ing it through some sort of ag­gre­ga­tor, you may have no­ticed I have a ban­ner.

This is what it looks like:

//ralsina.me/lateral/lateral.jpg//ralsina.me/lateral/opinion.jpg

Nice, ah?

It's not very orig­i­nal (look for "spell with flick­r" to see where I stole the idea), but I wrote a script to do it. So here it is, feel free to steal it too, it's your turn.

You will need this, Im­ageMag­ick, and a Flickr API key.

To use it sim­ply call it like this:

python banner.py something

And you will have a some­thing.jpg with some­thing in it.

#!/usr/bin/env python

import flickr,sys,random
from urllib import urlopen
import os

g=flickr.Group(id="27034531@N00")

urls = []
for l in sys.argv[1]:
  if l=="a":
    l="aa"
  if l=="i":
    l="ii"
  photos = g.getPhotos(tags=[l], per_page=50)
  urls.append(photos[random.randrange(50)].getURL(
              size='Square', urlType='source'))


for i in range(0,len(urls)):
  f=open(str(i)+'.jpg','w')
  data=urlopen(urls[i]).read()
  f.write(data)
  f.close()

os.system ("montage -tile %dx1 -geometry +0+0 %s %s"%(
            len(urls),' '.join([ '%d.jpg'%x for x in range(0,
            len(urls)) ]), sys.argv[1]+'.jpg'))

Heads or Tails?

There is a com­mand, head, to take the first piece of a file.

There is a com­mand, tail, to take the last piece of a file.

Tail does a few ex­tra things, be­cause it's use­ful to watch the end of a file that is be­ing up­dat­ed and sim­i­lar things, but they should be pret­ty sim­i­lar pieces of code, sup­port­ing sim­i­lar op­tion­s, right?

Well, no.

  • head sup­­ports a neg­a­­tive num­ber of lines as ar­gu­­men­t, mean­ing "all but the last N lines", and tail does­n't.

  • Same about bytes in­­stead of lines

That means that you can't quite sim­ply get "all but the first two lines of this file".

But don't wor­ry, this is how you do it:

tac file |head --lines=-2 | tac

Correction: tail has what I wanted. I am just a silly guy that doesn't read the man pages completely, you can do tail -n +2 to do it.

On the oth­er hand, it's not ex­plained in the op­tion, and the syn­tax is dif­fer­ent from head­'s, so it's still slight­ly rant-­wor­thy ;-)

So, this is how it feels...

...­to scratch an itch that is­n't there!

For some rea­son I can't stop play­ing with my blog's site.

Lat­est ricer-­like "im­prove­ments": a google search box and a google sitemap so the search box will work well.

At least the sitemap was some­thing I need­ed to learn about for a client :-)

Roadmap for Qt/IUP

I have been con­tact­ed by a few peo­ple about Qt/I­UP. Here's my cur­rent state of mind...

  • It works most­­ly.

  • It lacks a few wid­gets

  • It needs some­one to walk over the docs check­­ing ev­ery­thing is im­­ple­­men­t­ed and se­­man­ti­­cal­­ly right.

  • It has a (IMVHO) de­­cent struc­­ture for the Qt back­­end. It should be pos­si­ble to im­­ple­­ment ev­ery­thing us­ing it.

  • The IUP peo­­ple know about it.

  • It's still just my toy, AFAIK

So, its fu­ture seems to re­ly on me hav­ing time and en­er­gy to fin­ish it... and there's the catch.

I am Gim­li. I am not a marathon run­ner. We dwarves are nat­u­ral sprint­er­s! So, I can usu­al­ly cook up a de­cent project in a week or a mon­th, and then it lan­guish­es.

Spe­cial­ly be­cause I re­al­ly don't need Qt/I­UP.

I on­ly got here be­cause I was try­ing to learn D and I did­n't like any of their por­ta­ble toolk­it­s, and I found no bet­ter small C tool­kit I could wrap, and then I dis­liked it be­ing Mo­tif.

As you can see, an en­tire­ly too weak link from me to Qt/I­UP to be sus­tain­able.

I will try to push it to­day, im­ple­ment­ing the miss­ing wid­get­s, and see what hap­pen­s.

Using runit is even simpler

I have post­ed in the past about runit.

One of the prob­lems peo­ple mi­grat­ing to runit have is that all your ser­vices are SysV script­s.

The runit au­thor has a col­lec­tion of scripts you can use, but usu­al­ly they re­quire some ad­just­ment to work on a spe­cif­ic ver­sion of Lin­ux.

So, I wrote a lame python script that takes the SysV scripts you are cur­rent­ly us­ing and turns them in­to runit ser­vices, in­clud­ing de­pen­den­cies.

Sup­pose you usu­al­ly start on run­lev­el 3. Then you save this script and run it like this:

mkdir services
python importinit.py 3

And you should end with a bunch of runit ser­vices in­side ser­vices/

Those ser­vices will start in rough­ly the same or­der as if you were us­ing SysV init. That's prob­a­bly way too much de­pen­den­cies.

The main dif­fer­ence is that kdm will start ear­li­er and the ttys will start way ear­li­er than you are used to.

I have found that my note­book boots faster us­ing this, but I can't pro­vide a bootchart be­cause it sim­ply does­n't seem to work in my com­put­er.

If any­one is will­ing and able to run the tests and quan­ti­fy the dif­fer­ence, I am all ears.

For some rea­son kudzu, ipt­a­bles and arpt­a­bles_jf don't work with this ap­proach, so just stick them at the bot­tom of /etc/runit/1

Al­so, please un­der­stand that these are not cor­rect runit ser­vices. They are not man­aged, so if your ser­vice crash­es it stays crashed.

So, you should still even­tu­al­ly mi­grate to cor­rect script­s. This is just a way to make that sim­pler.


Contents © 2000-2023 Roberto Alsina