mai 05, 2008

Grand nettoyage d'AUR

AUR contient un grand nombre de paquets obsolètes, un petit dépoussiérage lui ferait du bien. Voici des exemples de paquets qui pourraient être supprimés :

  • ceux qui ont été renommés ou remplacés
  • les vieux paquets de développement (cvs/svn/etc) qui ne sont plus maintenus

Vous pouvez participer en suggérant des paquets sur la page du wiki anglophone dédiée, ou en réponse à ce fil dans le forum. Les TU se rassembleront dans une quinzaine de jours pour parcourir la liste et sélectionner les paquets à supprimer. Surtout, ne supprimez pas de suggestions de la page du wiki, ajoutez plutôt un commentaire disant pourquoi le paquet devrait être conservé. Les TU feront bien attention de ne pas supprimer de paquet utile.

Traduction de l'annonce d'Allan le 05/05/2008 sur le forum anglophone.

Forum Annoucements: Arch Linux Newsletter for May 5, 2008 Discussion

Once again this thread is created to discuss any topic that is covered on the Arch Linux Newsletter. And if you have suggestions, please share them with us here.

The Arch Linux Newsletter team has been reduced, consisting of Dusty Phillips, Ronald Van Haren, and me (Eduardo Romero). This simplifies our work and makes us better organize our thoughts, ideas and newsletter improvements. Later on, we might start looking for Translators again.

I hope the next newsletter have more stuff on it, I am on a tight schedule since I am on finals, hopefully, next week is the last one of University.:D

Non visible improvements in this newsletter is the usual code cleanup, fo better performance, I know it isn't a heavy page, but still is better to have a clean code to work with, removing obsolete HTML code.

-- posted by kensai

Official News: AUR Cleanup

From the TUs: The AUR has a large number of obsolete packages which could use cleaning up. Examples of packages that may be cleaned up are: - packages that have been renamed or replaced - old and unmaintained developmental (cvs/svn/etc) packages This is where you can help. Post suggestions of packages in the AUR Cleanup wiki page (http://wiki.archlinux.org/index.php/AUR_CleanUp_Day). TUs will get together and go though the list in a couple of weeks and confirm which packages should be removed. Please do not remove suggestions from the wiki page but add a comment on why it should be kept instead. TUs will take great care not to delete any useful package.

Forum Annoucements: AUR Cleanup

The AUR has a large number of obsolete packages which could use cleaning up.  Examples of packages that may be cleaned up are:
  - packages that have been renamed or replaced
  - old and unmaintained developmental (cvs/svn/etc) packages

This is where you can help.  Post suggestions of packages in the AUR Cleanup wiki page (http://wiki.archlinux.org/index.php/AUR_CleanUp_Day) or as a reply to this thread.  TUs will get together and go though the list in a couple of weeks and confirm which packages should be removed.  Please do not remove suggestions from the wiki page but add a comment on why it should be kept instead.  TUs will take great care not to delete any useful package.

-- posted by Allan

mai 04, 2008

Une semaine d'OpenStreetMap

Ca avance toujours. La zone 5 est terminé. La zone 6 l'est quasiment.

Leslie Polzer: Function encapsulation in SBCL

The advice functionality allows the programmer to replace or encapsulate an existing function binding (akin to :AROUND methods in the CLOS). See Gary King’s “What is advice” for some useful links and explanations on this.

CLISP and SBCL, my favourite Common Lisp implementations, do not seem to supply this functionality. I haven’t checked whether CLISP has advice under its hood, but SBCL does, and it’s termed “Function encapsulation” there. Once you know how to do it, it’s surprisingly simple to use.

This is the definition of SB-INT:ENCAPSULATE in SBCL’s src/code/fdefinition.lisp:

;;; Replace the definition of NAME with a function that binds NAME's
;;; arguments to a variable named ARG-LIST, binds name's definition
;;; to a variable named BASIC-DEFINITION, and evaluates BODY in that
;;; context. TYPE is whatever you would like to associate with this
;;; encapsulation for identification in case you need multiple
;;; encapsulations of the same name.
(defun encapsulate (name type body)
  (let ((fdefn (fdefinition-object name nil)))
    (unless (and fdefn (fdefn-fun fdefn))
      (error 'undefined-function :name name))
    ;; We must bind and close over INFO. Consider the case where we
    ;; encapsulate (the second) an encapsulated (the first)
    ;; definition, and later someone unencapsulates the encapsulated
    ;; (first) definition. We don't want our encapsulation (second) to
    ;; bind basic-definition to the encapsulated (first) definition
    ;; when it no longer exists. When unencapsulating, we make sure to
    ;; clobber the appropriate INFO structure to allow
    ;; basic-definition to be bound to the next definition instead of
    ;; an encapsulation that no longer exists.
    (let ((info (make-encapsulation-info type (fdefn-fun fdefn))))
      (setf (fdefn-fun fdefn)
            (named-lambda encapsulation (&rest arg-list)
              (declare (special arg-list))
              (let ((basic-definition (encapsulation-info-definition info)))
                (declare (special basic-definition))
                (eval body)))))))

From this we can figure out that basic advice can be gotten from SBCL like this:

CL-USER(19): (defun gorm (x) (1+ x))
GORM
 
CL-USER(20): (SB-INT:ENCAPSULATE 'gorm 'identity '(apply sb-int:basic-definition sb-int:arg-list))
 
#<closure (SB-C::&OPTIONAL-DISPATCH SB-IMPL::ENCAPSULATION) {ACE428D}>
CL-USER(21): (gorm 10)
11
 
CL-USER(22): (SB-INT:ENCAPSULATE 'gorm 'add-five '(+ 5 (apply sb-int:basic-definition sb-int:arg-list)))
#</closure><closure (SB-C::&OPTIONAL-DISPATCH SB-IMPL::ENCAPSULATION) {ACEE31D}>
 
CL-USER(23): (gorm 10)
16
 
CL-USER(24): (SB-INT:ENCAPSULATE 'gorm 'add-seven '(+ 7 (apply sb-int:basic-definition sb-int:arg-list)))
 
#</closure><closure (SB-C::&OPTIONAL-DISPATCH SB-IMPL::ENCAPSULATION) {ACF84ED}>
CL-USER(25): (gorm)
23
</closure>

We have built a pretty onion, each layer of which calls the next inner layer via BASIC-DEFINITION (the analog to CALL-NEXT-METHOD). Let’s peel specific layers from it:

CL-USER(26): (SB-INT:UNENCAPSULATE 'gorm 'add-five)
T
 
CL-USER(27): (gorm 10)
18
 
CL-USER(28): (SB-INT:UNENCAPSULATE 'gorm 'add-seven)
T
 
CL-USER(29): (gorm 10)
11

mai 03, 2008

Eduardo Romero: Programming, Do I have what it... [Revisited]

Well, lets revisit this subject and see how I have progressed. Since I first wrote that I was going to begin learning programming, I did really started to learn programming using Ruby. Alongside with a great tutorial/book by Chris Pine (he names his kids after programming languages), programming seemed just fine for me. I got pretty good with Ruby, well not good enough to write a complicated program but I did understood most of the tutorial and even accomplished the exercises.

read more

mai 02, 2008

Leslie Polzer: A kind of magic

One often has to checking file uploads for correctness, for example with respect to size, file type or file name.

Here’s a sketch for checking the type of image files:

(defun matches-magic (file magic &optional (offset 0))
    (with-open-file (s file :element-type '(unsigned-byte 8))
      (file-position s offset)
      (loop for c across magic
            unless (eql c (code-char (read-byte s)))
            do (return-from matches-magic))
      t))
 
(defun jpeg-p (file) ; won't catch Exif files with JPEG inside
  (matches-magic file "JFIF" 6))
 
(defun png-p (file)
  (matches-magic file "PNG" 1))
 
(defun gif-p (file)
  (matches-magic file "GIF89a"))
 
(defun canonical-image-extension (file)
  (cond
    ((png-p file) "png")
    ((gif-p file) "gif")
    ((jpeg-p file) "jpeg")))
 
(defmacro any-predicate (preds &rest args)
    `(or ,@(loop for p in preds
                 collect `(,p ,@args))))
 
(defun valid-image-p (file)
  (any-predicate (jpeg-p png-p gif-p) file))

ANY-PREDICATE could also be written as a function (with a slightly different form of arguments), here’s another quick draft:

(defun any-predicate (preds &rest args) ; largely untested
  (some #'identity (mapcar (lambda (x) (apply x args))  preds)))
 
(defun valid-image-p (file)
  (any-predicate (list #'jpeg-p #'png-p #'gif-p #'exif-p) file))

Of course, you could also chain SYMBOL-FUNCTION to get rid of the sharp-signs in the call. Whatever suits you.
I like the macro better, though, since it’s clearer and probably more efficient. Update: see below for a comment by Zach Beane on this.

Homework would be writing a simple DSL to jot down file type data:

(define-file-type "jpeg" JFIF 6)

Alternatives from the outer world would be calling file(1) or parsing magic(4).

mai 01, 2008

gpm 1.20.3-1 dans [core]

La mise à jour du paquet gpm à la version 1.20.3-1 provoquera probablement le message d'erreur suivant :

error: could not prepare transaction
error: failed to commit transaction (conflicting files)
gpm: /usr/lib/libgpm.so.1 exists in filesystem
Errors occurred, no packages were upgraded.

C'est dû au fait que le lien symbolique /usr/lib/libgpm.so.1 n'était plus possédé par le paquet (FS#9949). C'est réglé dans gpm 1.20.3-1 mais sa mise à jour doit être forcée :

# pacman -Syf gpm
# pacman -Syu

Traduction de la news originale du 01/05/2008 de Eric Belanger.

Forum Annoucements: gpm 1.20.3-1 in Core

In case you haven't seen the front page news: https://dev.archlinux.org/news/391/

When attempting to update to gpm 1.20.3-1, you will most likely get the following error message:

Code:

error: could not prepare transaction
error: failed to commit transaction (conflicting files)
gpm: /usr/lib/libgpm.so.1 exists in filesystem
Errors occurred, no packages were upgraded.

This error arises because the /usr/lib/libgpm.so.1 symlink became disassociated from the package (FS#9949). This is fixed in gpm 1.20.3-1 but its upgrade needs to be forced:

Code:

# pacman -Syf gpm
# pacman -Syu
-- posted by Snowman

Official News: gpm 1.20.3-1 in Core

When attempting to update to gpm 1.20.3-1, you will most likely get the following error message: error: could not prepare transaction error: failed to commit transaction (conflicting files) gpm: /usr/lib/libgpm.so.1 exists in filesystem Errors occurred, no packages were upgraded. This error arises because the /usr/lib/libgpm.so.1 symlink became disassociated from the package (FS#9949). This is fixed in gpm 1.20.3-1 but its upgrade needs to be forced: # pacman -Syf gpm # pacman -Syu

avril 30, 2008

Gianvito Morena: Gtk Engines Benchmarks - Whats the fastest?


There is a program that benchs every kind of gtk engine…

The name is GTKPERF.

Have you ever asked: “What’s the fastest gtk engine?” (in everyday actions…)

I used gtkperf to bench some of the most famous gtk engines:

  • Clearlooks (from gnome-themes-svn)
  • Nodoka ——-> 0.7 (updated)
  • Human (from Ubuntu)
  • Murrine (thanks to CIMI (like new Clearlooks) :))
  • Aurora
  • Mac4Lin
  • Clearlooks Classic
  • Crux
  • Glossy
  • Glider
  • Mist
  • Nova
  • Simple
  • ThinIce
  • Rezlooks (gilouche)
  • Industrial
  • Experience
  • QtCurve (Added)

Updated with xfce-gtk-engines

  • Xfce
  • Xfce-4.0
  • Xfce-4.2
  • Xfce-b5
  • Xfce-basic
  • Xfce-cadmium
  • Xfce-curve
  • Xfce-dawn
  • Xfce-dusk
  • Xfce-kde2
  • Xfce-kolors
  • Xfce-light
  • Xfce-orange
  • Xfce-redmondxp
  • Xfce-saltlake
  • Xfce-smooth
  • Xfce-stellar
  • Xfce-winter

My Pc:

  • Athlon64 3000+ @ 2300 Mhz
  • 1 Gb RAM
  • Nvidia 7600GT (169.09)
  • ArchLinux with kernel: 2.6.24-zen3
(See Pages numbers on the right to change pages)

Diffuser sensmotdire ou utiliser google gadget

Je viens de découvrir que google permettait de mettre des gadgets sur sa page d'accueil. Pour cela, il faut évidement un compte google (que je n'ai pas).

J'ai donc créé un gadget google pour proposer ce service. Si vous utilisez igoogle, cliquer sur le lien suivant pour l'ajouter :

http://www.google.com/ig/adde?moduleurl=sensmotdire.gnunux.info/widget-google.xml

Voici une capture du gadget :

Il est également possible d'ajouter le gadget sur un page web :

http://gmodules.com/ig/creator?synd=open&hl=fr&url=http://sensmotdire.gnunux.info/widget-google.xml

Evidement, il est possible de mettre sensmotdire sur son site sans passer par google, en ajoutant le code suivant :

<iframe src="http://sensmotdire.gnunux.info/widget.php" scrolling="false" frameborder="0"><a href="http://sensmotdire.gnunux.info/">sensmotdire</a></iframe>

(ajouter height=... et width=... pour éventuellement controler la taille du gadget)

Par défaut sensmotdire vous donnera 3 suggestions maximum. Il est possible d'augmenter cette valeur (la valeur maximal autorisé étant 10) en replacant l'url par, par exemple : "http://sensmotdire.gnunux.info/widget.php?limit=5".

Mise à jour 2 : J'ai rajouté l'option "title=no" pour désactivé le titre et "size=..." pour définir la taille de la zone de saisie.

Cela donne :

sensmotdire

J'aurais bien voulu apparaitre dans le catalogue de gadget de google, mais je n'ai pas réussit malgré plusieurs tentatives. Si quelqu'un sait comment faire ...

Si jamais vous connaissez d'autre système de gadget, n'hésiter a faire un plugin ou me soumettre le lien !

Mise à jour : Pour netvibes : http://www.netvibes.com/subscribe.php?preconfig=a66a07b44b01f9c243cfb1c65ccade97. Comme pour igoogle, je n'ai pas réussi à le mettre dans le catalogue netvibes ... Si quelqu'un veut s'en charger ...

avril 28, 2008

Gianvito Morena: Tupac - A great utility that completes Pacman (not only a famous rapper)


“A cached pacman implementatioin”

Pacman Description

Tupac (rapper) R.I.P.

(click on the numbers on the right to change pages)

Judd Vinet: New Pronto Snapshot: 20080428

I've been busy lately, but still steadily working on the ol' web framework.  I'm starting to reorganize the core components to maintain a loose coupling between layers.  Behold an incremental improvement!  Huzzah!

Changes:

  • Change in nomenclature: "template plugins" are now also known as "helpers", and "page plugins" are now also known as simply "plugins"
  • Added a datetime widget to the Form helper
  • Moved template logic into a separate class so it can be accessed outside of page controllers (eg, a commandline client can now use it to render email content)
  • CSS fixes for IE6 and IE7 (oh how I hate thee)
  • Changed Mailer plugin to use SwiftMailer instead of PHPMailer. PHPMailer is still available via ppPHPMailer for the time being.
  • Upgraded TinyMCE to 3.0.7
  • Changes to display callback functions in tpGrid::build_grid()
  • More bugfixes

Now that input validation and templates are where they should be, I'd like to focus on URL mobility a bit more.  Mapping URLs to controller/action pairs is dead easy, but templates and controllers still hardcode URLs in many cases.  For example, if an action redirects to another controller/action after it has finished its business, then it hardcodes that URL.  Works most of the time, but if I want to move a controller to a new URL location (eg, move /blog/post/edit to /admin/blog/post/edit) then I have to actually go through the code and change all instances of that URL.

My answer is going to be basically the reverse of the current URL->Controller mapping that's currently found in app/config/urls.php.  So instead of rendering a hardcoded URL like /blog/post/edit, you would ask to render the controller Blog_Post and the action Edit.

Sounds good in theory.  I'll let you know how it works out.

avril 27, 2008

Une semaine OpenStreetMap

Beaucoup d'avancé encore !

Les zones 19, 30, 31 et 32 sont maintenant terminées !

J'ai redéfini les zones 5, 6 et 7 et j'ai ajouté une zone 35 (déjà cartographié).

La zone 5 est quasi fini. Tikismoke a cartographié dans la zone 3 qui est (pratiquement ?) fini.

avril 24, 2008

Daniel Isenmann: Holux M-241 and playing with Google Maps

Another thing I can delete from my wishlist. I have ordered a Holux M-241 which should be delivered in few days. :) In the meantime I have played with Google Maps and their API. After playing with the API of OpenLayers last week, I decided to take the Google API for my geologging mapping. You can find my first result of geologging here. There will be more tracks, more photos and more description of the single hiking tracks. But first, I must receive the M-241 and get it run under ArchLinux. I will post my experience in a later post and try to explain step by step the download procedure of the track information from the logger and generating maps like the one I linked above.

avril 22, 2008

Leslie Polzer: Escaping from higher-order functions

Among the different ways to tackle iterative processes I consider to be the higher-order function route the one I use most often. Especially in conjunction with function composition and list predicates it makes great filtering-style code.

A problem that came up several times is interrupting the list processing at an arbitrary point. For example, how do I stop MAPCAR at the third item if I see it fit? Something like that:

(let ((i 0))
  (mapcar (lambda (x)
            (when (eql (incf i) 3)
              (STOP-HERE)))
    '(a b c d)))

Sometimes, one can take alternative routes using FIND or other functions. And there’s always LOOP, DOLIST, recursion and other solutions; after all we’re working in a language that really implements the “there’s more than one way to do it” paradigm.

Using TAGBODY and GO:

(tagbody (mapcar (lambda (x) (go X)) '(a b c)) X)

Using BLOCK/RETURN-FROM:

(block X (mapcar (lambda (x) (return-from X))(a b c)))

I originally posted another version using CATCH/THROW, but as pointed out in the comments this wasn’t all well for several reasons.

Delimited continuations with CL-CONT unfortunately won’t work.

A good alternative solution would be writing your own version of MAPCAR; this has the advantage of being able to return the partially processed list. But there’s the disadvantage of having to rewrite the whole family of mapping functions, though, so for quick prototyping or occasional usage I prefer the above solution.

If you have other neat solutions or see problems with this approach, please leave a comment.

avril 20, 2008

Eduardo Romero: Update to Drupal 6.2

Well, once again, the web log was off line for most of the day because it was being upgraded to the latest version of Drupal 6.x series. I hope you didn't had any inconvenience because of this, sorry and thanks for your patience. Again the update was just a security update, but introduces some performance enhancements. Lets hope this all works out well.

avril 19, 2008

avril 18, 2008

Deux semaines d'OpenStreetMap sur Dijon

Encore des nouveautés sur Dijon :

Les zones 12 et 18 sont finis. La zone 17 est à moitié faite. Enfin, pas mal de nouveautés dans la zone 5 et la zone 1 (il faut remercier tikismoke aussi !).

avril 16, 2008

ABS 2.0 dans [core]

Avec sa version 2, ABS est passé à une méthode utilisant rsync pour récupérer l'arbre ABS, changement qui était nécessaire suite à notre passage de CVS à SVN en interne. Ça veut dire plusieurs choses :

1) cvsup/csup ne sont plus nécessaires, rsync les remplace 2) La configuration ne se fait plus dans /etc/abs/abs.conf mais /etc/abs.conf ; les fichiers dans /etc/abs/ ne sont plus nécessaires

De plus, puisque les informations sur les catégories (c'est-à-dire base, devel, editors) ne sont plus stockées dans le repo, makeworld a été mis à jour (faites makeworld -h pour plus de précisions).

Traduction de la news originale du 15/04/2008 de Travis Willard.

avril 15, 2008

Aaron Griffin: Comments Enabled

So I sat down and slapped together some comment-ability for this blog. Not that it's really needed, or anything.

I am using disqus because it allows me to push all the comment management stuff offsite. Hooray!

Gianvito Morena: New Compiz-Fusion Plugins


New Compiz-Fusion Plugins

I’ve just updated compiz fusion (git) in the repo… You can install it from there adding this and then:

sudo pacman -S compiz-fusion-git

Archlinux 2008.04-RC

Une nouvelle fournée d'images est en train d'arriver sur les miroirs. Les images FTP ont été mises à disposition ce soir, mais il faudra attendre demain pour CORE afin de distribuer la charge.

C'est la première release (bon OK, release candidate [1]) qui s'appuie sur un vrai système Arch live. Eh oui, ces images ne sont rien de plus qu'une installation de base qui démarre depuis un CD ou une clé USB.

Oooh... tu viens de dire clé USB là ? Bah oui ! En effet, des images pour clé USB qui peuvent servir de système live ou d'installeur seront dorénavant disponibles.

Le script d'installation lui-même est à peu près inchangé. La modification la plus visible pour l'utilisateur est l'utilisation d'UUID au lieu de sdX/hdX par défaut. Un changelog [2] plus détaillé devrait être disponible sur projects.archlinux.org sous peu.

Si vous en avez l'occasion, essayez ces images. Vous pourrez les trouver sur nos miroirs, dans le dossier iso. Merci de rapporter les bugs éventuels.

Au passage, le statut "RC" de ces images ne doit pas vous empêcher de les utiliser pour installer Arch, elles marcheront très probablement parfaitement pour vous.

Traduction de la news originale du 15/04/2008 de Simo Leone.

NdT :

[1] release candidate : version possédant les mêmes fonctionnalités que la version finale, mise à disposition à des fins de test.

[2] changelog : résumé des modifications.

Forum Annoucements: 2008.04-RC Images are out

http://www.archlinux.org/news/389/

A new batch of install images is currently syncing to mirrors.
FTP images have been made available tonight, while CORE images
will be pushed tomorrow night in order to distribute the load.

This marks the first release (well ok... release candidate)
based on a true live Arch system. That is, what's on the
images is just a plain old base installation which just
happens to boot off of a CD or USB stick.

Whoah... did you just say USB stick? Why yes I did! That's
right, from here on out we'll be offering bootable USB disk
images that can act as a live system or installer.

The installer script itself is roughly the same as it's always
been. The most noticable change is the use of UUIDs instead of
sdX/hdX entries by default. A more detailed changelog
should be visible on projects.archlinux.org soon-ish.

If you get the chance, please give the images a spin. You can
find them on our mirrors, in the
iso directory. Please file bugs if you encounter any problems.

By the way, the "RC" status of these images should not be a
turn-off if you're looking to install Arch, there's a very
good chance they'll work just fine for you.

Ready. Set. Go!

-- posted by neotuli

Official News: ABS 2.0 In Core

With version 2, ABS has moved to an rsync method for pulling the ABS tree, as part of the changes that needed to be made for our internal move from CVS to SVN as our source control mechanism. This means a few things: 1) cvsup/csup are no longer required, rsync is used instead 2) Configuration moved from /etc/abs/abs.conf to /etc/abs.conf - /etc/abs/* are no longer required Also, since category information (ie. base, devel, editors) is no longer stored in the repo, makeworld has been updated - check makeworld -h for more info.

Official News: Archlinux 2008.04-RC

A new batch of install images is currently syncing to mirrors. FTP images have been made available tonight, while CORE images will be pushed tomorrow night in order to distribute the load. This marks the first release (well ok... release candidate) based on a true live Arch system. That is, what's on the images is just a plain old base installation which just happens to boot off of a CD or USB stick. Whoah... did you just say USB stick? Why yes I did! That's right, from here on out we'll be offering bootable USB disk images that can act as a live system or installer. The installer script itself is roughly the same as it's always been. The most noticable change is the use of UUIDs instead of sdX/hdX entries by default. A more detailed changelog should be visible on projects.archlinux.org soon-ish. If you get the chance, please give the images a spin. You can find them on our mirrors, in the iso directory. Please file bugs if you encounter any problems. By the way, the "RC" status of these images should not be a turn-off if you're looking to install Arch, there's a very good chance they'll work just fine for you.

avril 12, 2008

Leslie Polzer: Analyzing return values with a recursive macro

Printing the argument and return values of a set of nested or sequential expressions is a common debugging tactic.

In Common Lisp we can make use of a recursive macro instead of manually inserting printing statements. Specifically, we want our macro (let’s call it WALK for want of a better name since it’s a simple code walker) to print all the return values it encounters along its way:

(walk (list (+ 5 (* 3 3))
            "Welcome to earth, third rock from the sun!"))
 
(* 3 3) => 9
(+ 5 (* 3 3)) => 14
(LIST (+ 5 (* 3 3)) "Welcome to earth, third rock from the sun!")
  => (14 "Welcome to earth, third rock from the sun!")

The following macro does that job.

(defmacro walk (form)
    (etypecase form
       (atom ; terminating base case
         form)
       (cons
         `(let ((result (,(first form) ,@(mapcar (lambda (arg) `(walk ,arg))
                                               (rest form)))))
            (format t "~S => ~S~%" ',form result)
            result))))

Modifying the output so it prints

(* 3 3) => 9
(+ 5 9) => 14
(LIST 14 "Welcome to earth, third rock from the sun!")
  => (14 "Welcome to earth, third rock from the sun!")

instead is left as an exercise to the reader (bad puns come easily in English…), as is the addition of an optional DEPTH argument.

It would also be nice to make use of the pretty printer for appropriate indentation, but I have severe problems grokking it, so maybe someone familiar with this facility can help.

In other programming languages the same problem requires a bit more effort.

avril 11, 2008

My history

C'est parti du planet fedora, mais après tout, je peux aussi donner le mien

$ history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head
150 screen
64 ssh.ashley
41 cd
40 su
40 man
28 ls
17 env
16 vi
15 mpc
15 irssi

Leslie Polzer: Escape key alternatives in Vim

The Daily Vim blog shows a bunch of ways to replace the time-consuming escape key with a faster binding. You can try all of them at once, if you’re not sure what suits you best.

Unfortunately the most attractive method — remapping CapsLock — is already assigned to the window manager on my box, so this one wasn’t really an option for me.

avril 10, 2008

Gianvito Morena: Gnome 2.22 Released


gnome222.png

Let’s see how to install it on ArchLinux…

Update 10/04/2008

  • Gnome 2.22 in [extra]
  • Gnome 2.22.1 released

(click on the numbers on the right to change pages)

avril 08, 2008

Gianvito Morena: GreaseMonkey And Userscripts.org - A way to give useful tools to your Firefox


“Allows you to customize the way a webpage displays using small bits of JavaScript. Hundreds of scripts, for a wide variety of popular sites, are already available at http://userscripts.org. You can write your own scripts, too. Check out http://wiki.greasespot.net/ to get started.”

by “https://addons.mozilla.org/it/firefox/addon/748″

(click on the numbers on the right to change pages)

Leslie Polzer: Trivial sequence shuffling

IMPORTANT NOTE: the algorithm described in this post doesn’t produce a uniform distribution of shuffled sequences (i.e. it is not fair). Be sure to read the comments and the follow-up posts.

Here’s a quickie for the newbies among you:

(defun seqrnd (seq)
  "Randomize the elements of a sequence. Destructive on SEQ."
  (sort seq #'> :key (lambda (x) (random 1.0))))
 
(seqrnd (copy-seq "abcd")) ; need to copy the literal for the destructive operation
-> "dacb"

This also shifts the efficiency of the shuffle to the efficiency of your implementation’s sorting algorithm. Look for the Fisher-Yates shuffling algorithm if you’re really, really tight on resources; it does something akin to Bubble Sort to solve the problem.

avril 07, 2008

Leslie Polzer: Sequence shuffling wrap-up

This post has two parts, a social and a technical one. Scroll down to see the technical one if you don’t care about the former.

For me, Common Lisp offers two fundamental modes of programming, often mixing together.

The first mode is serious software development (by which I’m attempting to pay my rent right now). Everything needs to work here. Thread safety, correctness, safety over speed, enough speed nonetheless, pragmatism, … well, I guess you know the score.

The second mode is exploration and experiments. My last two posts on the randomization of sequences were just that, and collaboratively that. After all, my blog is neither a newspaper nor a research journal. Unfortunately some readers seem to have misunderstood this. I suppose this is partly owing to my usual portion of kidding hyperbole, like my stating that I were “allergic to consing” and had found an exceptionally “good solution”.

So, to make it clear: both of these posts were not about presenting a well-tested algorithm ready for public copy-and-paste, but something to think about — for you and for me.
Tagging the list’s elements with a random id beforehand, as in the solutions Paul and Phil came up with, is a very nice, solid and working solution. Unfortunately this one is also so straight-forward that it hasn’t much potential for intellectual stimulation (at least not for me), and that’s why I decided to pursue the idea with hash tables and memoization further.

Now for the technical part of this wrap-up: SEQRND works for all objects where EQ reliably points out differences. This definitely excludes literals (the will be constant-folded more often than not) but includes CLOS objects. SEQRND also was three times faster than Paul’s RANDOM-SHUFFLE on SBCL.

My personal bottom line is: use one of the solid algorithms all the time and rely on Fisher-Yates if you need the speed.

avril 06, 2008

Deux semaines d'OpenStreetMap sur Dijon

Je ne suis plus le seul contributeur actif sur Dijon ! C'est le syndrome 'plus il y a de travail de faire, plus il y a de contributeur'.

Pas mal de correction ont étés faites, mais surtout, tikismoke a bien avancé sur la carte.

Pour ma part, j'ai fini (principalement) le centre historique de Dijon.

Toutes les zones supérieures à 8 sont aujourd'hui quasi fini. Il reste encore du travail, mais cela progresse.

Eduardo Romero: I'm not Open Sourced Anymore.

Don't get your hopes too high proprietary software makers, I am not moving from Linux. I just am not open sourced myself. Yesterday, I took one of the most important decisions of my life, engaging to a beautiful woman. She now owns my license rights and everything of me. So, now I guess I'm patent encumbered!?

read more

Forum Annoucements: Arch Linux Newsletter Apr 03, 2008 Discussion

The title says it all.

From now on we are going to open a forum thread for every newsletter published, so its content can be discussed, and ideas can be given to improve it. All constructive criticism is welcome, and is greatly appreciated. Please, try to keep as on topic as possible. On topic means, discuss everything that has to do with something written in the discussed newsletter.

- Thanks

Eduardo "kensai" Romero

-- posted by kensai

Leslie Polzer: Sequence shuffling revisited

In my post “Trivial Sequence Shuffling” from yesterday I showed a simple hack to shuffle a sequence.

For your convenience:

(defun seqrnd (seq)
  "Randomize the elements of a sequence. Destructive on SEQ."
  (sort seq #'> :key (lambda (x) (random 1.0))))

The only downside to this algorithm, I claimed, is its complexity, which is worse than that of a specialized sorting algorithm.

However that is not the only problem with it. The ensuing discussion (thanks for your comments, guys!) showed that I didn’t notice an allowance made by the standard: the :KEY function might be called more than once, and implementations seem to make use of this. And while it is allowed to return different keys for the same element (i.e. let the :KEY function be not a proper function, but a plain relation), the result will not be a discrete uniform random distribution, but a biased distribution depending on the intricacies of the sorting procedure.

In this post I’d like to show the alternatives proposed and my own amendment, which extends my original flawed solution.

Peter de Wachter proposed:

(defun better-shuffle (seq)
  (let ((tagged (mapcar (lambda (x) (cons (random 1.0) x)) seq)))
    (mapcar 'cdr (sort tagged #'> :key 'car))))

It’s not that I don’t like it at all (after all it’s a nice case study in functional programming!), but I’m allergic to the consing it produces. I also feel that it overcomplicates things.

Paul Khuong wrote something similar which looks a bit more elegant to me:

(defun random-shuffle (sequence)
  (map-into sequence #'car
            (sort (map 'vector (lambda (x)
                                 (cons x (random 1d0)))
                       sequence)
                  #'< :key #'cdr)))

The other approach (in Scheme) came from Phil Bewig (hope I got the indent right):

(define (shuffle x)
  (do ((v (list->vector x)) (n (length x) (- n 1)))
    ((zero? n) (vector->list v))
    (let* ((r (random n)) (t (vector-ref v r)))
      (vector-set! v r (vector-ref v (- n 1)))
      (vector-set! v (- n 1) t))))

Ah, sorry Phil, but that’s not my kind of style :) Too much imperative stuff here, a data conversion and a DO loop. Somehow the name of Rube Goldberg comes to my mind…

The <Good Solution> (alluding to Mark Tarver’s Qi blurb) involves a thing as natural as anything to a Lisp (and I include Scheme here) programmer: memoization.

While memoization, i.e. caching function results, is most often used in a performance context, we might also apply it here to make our function always return the same result for an object, thus imposing a total ordering on the list:

(defvar *random-id-ht* nil)
 
(defun initialize-memo ()
  (setf *random-id-ht* (make-hash-table :test #'eq)))
 
(defun consistent-random-id (obj)
  (multiple-value-bind (val found-p) (gethash obj *random-id-ht*)
    (if found-p val
      (setf (gethash obj *random-id-ht*)
            (random 1.0)))))
 
(defun seqrnd (seq)
  "Randomize the elements of a sequence. Destructive on SEQ."
  (initialize-memo) ; need to clear between runs
  (sort seq #'> :key (lambda (x) (consistent-random-id x))))

This is a scaled down version of a memoizer; you probably don’t want to do this at home. A generalized memoizer takes about two screenfuls (talking 24 lines here). You can find generalized memoizers everywhere on the net, for example in the Cells utility library for Common Lisp.

One might argue that this solution is too complicated. I hold against that that memoization should be present in every serious functional programmer’s toolbox, so it boils down to the function itself — which is only marginally longer than the first attempt.

Planète Arch Linux francophone

Planète Arch Linux francophone est une fenêtre sur le monde, le travail et la vie des utilisateurs francophones d'ArchLinux.

Si vous êtes un membre d'Arch Linux et vous souhaitez que votre blog soit aggrégé, contactez Benoît Chesneau..

Dernière mise à jour :
mai 05, 2008 11:30 .
Tous les entrées sont en temps UTC.

S'abonner