Search Results: "lamby"

5 February 2009

Chris Lamb: Scrap your boilerplate; POSIX shell edition

I don't remember where I saw this first - probably in the Debian Installer code. Anyway, given an n-tuple it can be somewhat unwieldy to unpack it:
VAR="Aho Sethi Ullman"
ONE="$(echo $ VAR    cut -d' ' -f1)"
TWO="$(echo $ VAR    cut -d' ' -f2)"
THREE="$(echo $ VAR    cut -d' ' -f3)"
The trick being presented is to generate the boilerplate code and then eval it:
VAR="Aho Sethi Ullman"
eval $(echo $ VAR    awk '  print "ONE=" $1 " TWO=" $2 " THREE=" $3  ')
Here's a more concrete example, with apologies to Python:
for PAIR in \
           "one    Aho" \
           "two    Sethi" \
           "three  Ullman"
do
    eval $(echo $ PAIR    awk '  print "k=" $1 " v=" $2  ')
    # .. do something with $k and $v
done

3 February 2009

Chris Lamb: Committing every time you save in Vim

I wonder if there are any non squash-heavy workflows that this goes well with.
" requires vim-python and python-git
function! CommitFile()
python << EOF
import vim, git
curfile = vim.current.buffer.name
if curfile:
    try:
        repo = git.Repo(curfile)
        repo.git.add(curfile)
        repo.git.commit(m='Update')
    except (git.InvalidGitRepositoryError, git.GitCommandError):
        pass
EOF
endfunction
au BufWritePost * call CommitFile()

25 January 2009

Chris Lamb: Matching IPs with regexes conCIDRd harmful

Some rather unfriendly software (Munin, lighttpd, etc.) require that IP ranges are specified using regexes instead of the usually more convenient CIDR notation. The following code converts instances of that notation to a regular expression. The generated pattern assumes that the input is a valid IPv4 address; that is to say, matching 0.0.0.0/0. Patches for common prefix optimisation greatly appreciated.
def cidr_to_regex(cidr):
    ip, prefix = cidr.split('/')
    base = 0
    for val in map(int, ip.split('.')):
        base = (base << 8)   val
    shift = 32 - int(prefix)
    start = base >> shift << shift
    end = start   (1 << shift) - 1
    def regex(lower, upper):
        if lower == upper:
            return str(lower)
        from math import log10
        exp = int(log10(upper - lower))
        delta = 10 ** exp
        if lower == 0 and upper == 255:
            return "\d+"
        if delta == 1:
            val = ""
            for a, b in zip(str(lower), str(upper)):
                if a == b:
                    val += str(a)
                elif (a, b) == ("0", "9"):
                    val += '\d'
                elif int(b) - int(a) == 1:
                    val += '[%s%s]' % (a, b)
                else:
                    val += '[%s-%s]' % (a, b)
            return val
        def gen_classes():
            floor_ = lambda x: int(round(x / delta, 0) * delta)
            xs = range(floor_(upper) - delta, floor_(lower), -delta)
            for x in map(str, xs):
                yield '%s%s' % (x[:-exp], r'\d' * exp)
            yield regex(lower, floor_(lower) + (delta - 1))
            yield regex(floor_(upper), upper)
        return ' '.join(gen_classes())
    def get_parts():
        for x in range(24, -1, -8):
            yield regex(start >> x & 255, end >> x & 255)
    return '^%s$' % r'\.'.join(get_parts())

30 December 2008

Chris Lamb: Kicking the Vim cursor key habit

" Unbind the cursor keys in insert, normal and visual modes.
for prefix in ['i', 'n', 'v']
  for key in ['<Up>', '<Down>', '<Left>', '<Right>']
    exe prefix . "noremap " . key . " <Nop>"
  endfor
endfor

26 December 2008

Chris Lamb: Unfortunately, we get parallel octaves at the end

A reel from Glenn Gould's 1955 recording of the Goldberg Variations contains the following dialogue between the 22-year-old pianist and the recording engineer after a take of the 30th variation, a quodlibet:
By the way, I have a quodlibet of my own which came to me in the bathtub the other night. One of these days I will be asked to perform on the fourth of July, I'm sure, and when I do I figured out that by leaving out the repeats in the Star Spangled Banner and starting your entry on the thirteenth bar of God Save The King and then playing God Save the King over again and altering the harmony in the second half of The King to modulate to the supertonic region, it has the most marvelous effect. Listen to this.. (202KiB Ogg Vorbis).

23 December 2008

Emilio Pozuelo Monfort: Collaborative maintenance

The Debian Python Modules Team is discussing which DVCS to switch to from SVN. Ondrej Certik asked how to generate a list of commiters to the team s repository, so I looked at it and got this:
emilio@saturno:~/deb/python-modules$ svn log egrep "^r[0-9]+ cut -f2 -d sed s/-guest// sort uniq -c sort -n -r
865 piotr
609 morph
598 kov
532 bzed
388 pox
302 arnau
253 certik
216 shlomme
212 malex
175 hertzog
140 nslater
130 kobold
123 nijel
121 kitterma
106 bernat
99 kibi
87 varun
83 stratus
81 nobse
81 netzwurm
78 azatoth
76 mca
73 dottedmag
70 jluebbe
68 zack
68 cgalisteo
61 speijnik
61 odd_bloke
60 rganesan
55 kumanna
52 werner
50 haas
48 mejo
45 ucko
43 pabs
42 stew
42 luciano
41 mithrandi
40 wardi
36 gudjon
35 jandd
34 smcv
34 brettp
32 jenner
31 davidvilla
31 aurel32
30 rousseau
30 mtaylor
28 thomasbl
26 lool
25 gaspa
25 ffm
24 adn
22 jmalonzo
21 santiago
21 appaji
18 goedson
17 toadstool
17 sto
17 awen
16 mlizaur
16 akumar
15 nacho
14 smr
14 hanska
13 tviehmann
13 norsetto
13 mbaldessari
12 stone
12 sharky
11 rainct
11 fabrizio
10 lash
9 rodrigogc
9 pcc
9 miriam
9 madduck
9 ftlerror
8 pere
8 crschmidt
7 ncommander
7 myon
7 abuss
6 jwilk
6 bdrung
6 atehwa
5 kcoyner
5 catlee
5 andyp
4 vt
4 ross
4 osrevolution
4 lamby
4 baby
3 sez
3 joss
3 geole
2 rustybear
2 edmonds
2 astraw
2 ana
1 twerner
1 tincho
1 pochu
1 danderson
As it s likely that the Python Applications Packaging Team will switch too to the same DVCS at the same time, here are the numbers for its repo:

emilio@saturno:~/deb/python-apps$ svn log egrep "^r[0-9]+ cut -f2 -d sed s/-guest// sort uniq -c sort -n -r
401 nijel
288 piotr
235 gothicx
159 pochu
76 nslater
69 kumanna
68 rainct
66 gilir
63 certik
52 vdanjean
52 bzed
46 dottedmag
41 stani
39 varun
37 kitterma
36 morph
35 odd_bloke
29 pcc
29 gudjon
28 appaji
25 thomasbl
24 arnau
20 sc
20 andyp
18 jalet
15 gerardo
14 eike
14 ana
13 dfiloni
11 tklauser
10 ryanakca
10 nxvl
10 akumar
8 sez
8 baby
6 catlee
4 osrevolution
4 cody-somerville
2 mithrandi
2 cjsmo
1 nenolod
1 ffm
Here I m the 4th most committer :D And while I was on it, I thought I could do the same for the GNOME and GStreamer teams:
emilio@saturno:~/deb/pkg-gnome$ svn log egrep "^r[0-9]+ cut -f2 -d sed s/-guest// sort uniq -c sort -n -r
5357 lool
2701 joss
1633 slomo
1164 kov
825 seb128
622 jordi
621 jdassen
574 manphiz
335 sjoerd
298 mlang
296 netsnipe
291 grm
255 ross
236 ari
203 pochu
198 ondrej
190 he
180 kilian
176 alanbach
170 ftlerror
148 nobse
112 marco
87 jak
84 samm
78 rfrancoise
75 oysteigi
73 jsogo
65 svena
65 otavio
55 duck
54 jcurbo
53 zorglub
53 rtp
49 wasabi
49 giskard
42 tagoh
42 kartikm
40 gpastore
34 brad
32 robtaylor
31 xaiki
30 stratus
30 daf
26 johannes
24 sander-m
21 kk
19 bubulle
16 arnau
15 dodji
12 mbanck
11 ruoso
11 fpeters
11 dedu
11 christine
10 cpm
7 ember
7 drew
7 debotux
6 tico
6 emil
6 bradsmith
5 robster
5 carlosliu
4 rotty
4 diegoe
3 biebl
2 thibaut
2 ejad
1 naoliv
1 huats
1 gilir

emilio@saturno:~/deb/pkg-gstreamer$ svn log egrep "^r[0-9]+ cut -f2 -d sed s/-guest// sort uniq -c sort -n -r
891 lool
840 slomo
99 pnormand
69 sjoerd
27 seb128
21 manphiz
8 he
7 aquette
4 elmarco
1 fabian
Conclusions:
- Why do I have the full python-modules and pkg-gstreamer trees, if I have just one commit to DPMT, and don t even have commit access to the GStreamer team?
- If you don t want to seem like you have done less commits than you have actually done, don t change your alioth name when you become a DD ;) (hint: pox-guest and piotr in python-modules are the same person)
- If the switch to a new VCS was based on a vote where you have one vote per commit, the top 3 commiters in pkg-gnome could win the vote if they chosed the same! For python-apps it s the 4 top commiters, and the 7 ones for python-modules. pkg-gstreamer is a bit special :)

7 December 2008

Chris Lamb: Taking Liberties

On Saturday I went to the British Library's Taking Liberties exhibition on "the 900-year struggle for Britain's freedoms and rights". The majority of the items on display were truly iconic, including a copy of the Magna Carta, Ms Davidson's return ticket from Epsom as well as Charles I's death warrant - with Cromwell's signature easily identifiable in third position. In contrast, the video interviews that were scattered around were rather distracting at best (isn't it a library?) and embarrasingly biased at worst. I wonder how many visitors need convicing that detaining suspects without charge for forty-two days isn't a good idea. Near the exit was a wonderfully lo-fi anonymous commenting system based on a wall of bulldog clips and postcard-sized bits of paper. Fascinating in itself.

29 November 2008

Chris Lamb: Re: A timeline view in Django

Alex Gaynor writes about "timeline views" in Django. The abstract problem is to merge already-sorted lazily evaluated lists by some specified attribute. My solution is similar to Malcolm's suggestion in the comments and improves upon Alex's in that has superior space considerations, as well as supporting reverse ordering with the usual Django syntax:
import heapq
def merge_querysets(*querysets, **kwargs):
    order_by = kwargs.get('order_by', None)
    if order_by is None:
        raise ValueError, "Must specify order_by in keyword arguments"
    # Are we sorting in reverse?
    reverse = False
    if order_by.startswith('-'):
        order_by = order_by[1:]
        reverse = True
    class Wrapper(object):
        """
        Hacky wrapper class for custom sorting.
        """
        def __init__(self, sortval, val):
            self.sortval = sortval
            self.val = val
        def __cmp__(self, other):
            if reverse:
                return cmp(other.sortval, self.sortval)
            else:
                return cmp(self.sortval, other.sortval)
    iterables = map(iter, querysets)
    heap = []
    while True:
        for it in iterables:
            try:
                val = it.next()
                sortval = val.getattr(order_by)
                heapq.heappush(heap, Wrapper(sortval, val))
            except StopIteration:
                # This QuerySet has been exhausted
                iterables.remove(it)
                continue
        if not iterables:
            # All QuerySets have been exhausted; just yield from the heap
            # to save cost of insertion.
            for item in heap:
                yield item.val
            return
        yield heapq.heappop(heap).val
def my_view(request):
    tickets = Ticket.objects.order_by('-create_date')
    wikis = WikiEdit.objects.order_by('-create_date')
    changesets = Changeset.objects.order_by('-create_date')
    objs = merge_querysets(tickets, wikis, changesets, order_by='-create_date')
    return render_to_response('my_app/template.html',  
        'objects': objs,
     )

26 September 2008

Romain Francoise: Five and counting

Five years ago today, I became a Debian Developer! My account was created just a few weeks after Debian's 10th birthday and we recently celebrated the 15th, so I've been around for about a third of the project's life. In that period, we released sarge and etch, had two compromises, approximately 300,000 bugs were filed in the BTS, Ubuntu was created, three DPLs came and went, dunc-tank was launched and subsequently abandoned, and the Debian Maintainer status was created (among other notable events).

For me personally there have been ups and downs, but mostly it's been fun. I'm still proud of taking part in what is perhaps the largest volunteer project to date, and one that can produce a distribution of outstanding quality and versatility. The Debian community is huge, diverse and sometimes frighteningly technical, but always focused on making Debian (both the product and the project) better for everyone; it's worth being part of it if only for the amazing melting-pot of cultures and (sometimes antagonistic) technological philosophies.

I think that after fifteen years Debian is still relevant both as a basis for derivative distributions, and as a product for end users. I like to think that I've played a part, however insignificant, in Debian's success in the past five years and I hope that I'll be given the chance to continue contributing in the future. Rock on, Debian!

17 September 2008

Chris Lamb: Debian Developer

A few days ago I was awarded official Debian Developer status. Many thanks to: For posterity, my first experience with the Debian development process was with #400550. Never underestimate the importance of giving credit in changelog entries.

16 July 2008

Chris Lamb: BTS bot improvements

A little while ago I completely rewrote the #debian-devel-changes IRC bot so it was actually maintainable. At the same time I added some commands suitable for developers, but I didn’t really advertise them anywhere. Here goes.
!bug <bug-number>
Print a one-line synopsis of the specified bug. The parser is fuzzy and will find the bug number embedded in URLs, etc.
!madison <source-package>
Print a colourful rmadison output for the specified package.
!qa <source-package>
!overview <source-package>
Prints the URL of the Debian PTS entry for the specified package.
!changelog <source-package>
Prints a URL containing the most recent debian/changelog file for the specified package.
!copyright <source-package>
Prints a URL containing the most recent debian/copyright file for the specified package.
!bug_graph <source-package>
!buggraph <source-package>
Prints the URL of the bug graph for the specified package.
!buildd <source-package>
Prints the URL of the non-experimental buildd status of the specified package.
!popcon <source-package>
Prints the URL which contains the popularity-contest data for the specified package.
!dehs <source-package>
Prints the URL which contains the Debian External Health Status of the specified package.
Some notes: As always, patches and suggestions welcome. (Source).

Chris Lamb: Nouveau nVidia drivers now available in Debian experimental

You can now try the “Nouveau” free software nVidia video drivers from Debian experimental. If you would like to try them: Editing your xorg.conf may be as simple as the replacing nvidia or nv with nouveau; nouveau won’t be chosen automatically over nv yet. If your xorg.conf has collected a lot of cruft over the years, see this wiki page for some pointers on what you can remove. For the status of the drivers with your particular card, please see upstream’s compatibility matrix. My experience has been positive; I have been using them for about two months on my dual-head 8600GT (NV50) setup with only a few small issues and a generally superior Gnometris experience. Some notes: Many thanks to:

23 June 2008

Chris Lamb: Strange loops

$ eval $(printf "echo Is this a strange loop\?"; for X in $(seq 13); do printf " cowsay -%s -n" $(echo bdgpstwy cut -b$(expr $(dd if=/dev/urandom bs=1k count=1 2>/dev/null cksum cut -d' ' -f1) % 7 + 1)); done; echo) Thanks to Silver and zx64.

22 June 2008

Sandro Tosi: Graph NEW and RC bugs from #d-d-c

I was on trains these days, so I got some time, and what's best then take xchat log of #d-d-c and print some graphs? well, there are tons best, but that's what I chose to do...

The script to generate the graph is here (I know, it's not beautiful, you can finds many points to improve it, etc etc) and the graph it generates is (run a couple of minutes ago):


Guess what's NEW and what's RC bugs :)

It lakes dates, legends or so; if someone is interested I can cron its generation (or lamby can take the script, it's Python+matplotlib, and use it somewhere).

21 June 2008

Chris Lamb: Devon

This weekend I finally picked up my German bow from Devon after it got damaged earlier this year (picture hidden behind this link to protect the squeamish). The repair was done to an amazingly high standard, with the join literally invisible modulo the brass pins on the top. I stayed with my grandparents, which was delightful as well as educational - I think I’ve located the source of my affection for cats. Curiously, I think I saw Ian Jackson on the train opposite me on the way back, but I don’t think he recognised me. I should probably wear more Debian t-shirts.

11 June 2008

Chris Lamb: Do not purchase goods or services from Aria Technology Ltd.

After six months of sending approximately one email a week to this company, I finally received my replacement item today. The vast majority of my queries went unanswered, and the responses I did receive were either blatant copy pasta, or requested details I had purposefully laid out in my exposition. Such gross incompetence clearly wasn’t the 5 I saved, so at least I learnt something. Avoid.

31 May 2008

Chris Lamb: Debconf8

Due to a number of personal reasons, I won’t be attended Debconf8 in Argentina. I have removed myself from my (rather undeserved) high place in the sponsorship queue.

13 March 2008

Chris Lamb: AptFs - FUSE filesystem for APT source repositories

(This was one of those pesky “oh, it’ll only take an hour” ideas.) AptFs is a FUSE-based filesystem that provides a view to unpacked and patched Debian source packages as regular folders on a filesystem. Binary packages are modelled as symbolic links pointing to their respective source package. This arrangement allows one to: The program maintains a sliding window of unpacked packages to perform automatic cleanup of unpacked packages — it would not be very helpful if commands such as
% find /path/to/aptfs
…unpacked the entire archive into your temporary directory. Source (GPLv3) is available in Git:
% git-clone git://git.chris-lamb.co.uk/aptfs  # or
% git-clone http://git.chris-lamb.co.uk/repo/aptfs.git
Patches always welcome, and shout if you like it; I’ll file an ITP and try and upload it.

9 March 2008

Chris Lamb: Timeline of the Debian project

I’ve put together a partial timeline of the Debian project using the SIMILE Project’s DHTML timeline component. This is definately work in progress: I would welcome additional events (by email or merge request please, not via blog comments) regarding: The timeline is available to view here. Update: Assistance fixing the (non-Webkit) Konqueror issue would also be appreciated.

21 February 2008

Chris Lamb: FOSDEM 2008

I’m off to FOSDEM in a few minutes (it’s nearly bedtime, right?), getting the 10:00 Eurostar. Give me a shout if I owe you a beverage or something..

Next.

Previous.