Pocas cosas me joden tanto como los seguidores del 'listillismo'.
Son aquellas personas que aceptan decir chorradas, a cambio de chorradas. Porque tu tiempo no vale un duro. Y el suyo? Bueno, estos se dedican a esto.
Que a veces yo estoy ahí, y me siento muy bien. Como oliendo nubes, como en un globo. Un rato rajando sin conocer, y sin interestarte. Pero no me jodas. Llega un punto, que ya dices basta, y te toca enfrentarte a los listillos profesionales, o callar y "morir un poco más por dentro".
Y mientrastanto buscas miradas cómplices en un vagón del metro. Eres como una letra A en la sopa. Buscando otras letras que se apunten a formar una palabra. Ya veremos cual, pero que jueguen. Con una B y una R, yo ya me conformo.
Aunque reconozco que no siempre apetece jugar. Que a veces se te acaban las ganas, y a mí se me han acabado, pero una y otra vez, cuando veo gente con ganas de CANT.R , o ganas de .PRENDER, o simplemente GAN.S, no me resisto. Porque un día, me ayudarán a escribir alguna palabra que ahora mismo no puedo ni pensar, pero que sería imposible sin ellas. O quizás evitaran mi suicidio, o quizas lo provocarán. Pero la cuestión es jug.r.
lunes 23 de noviembre de 2009
sábado 21 de noviembre de 2009
Mastermind in scheme
3 Days ago I read a post on programming praxis blog about writing a mastermind
game. The author splitted the game in two parts, the first
being the setter, so given a known solution, and a guess, returns a string
of B/W/.
The point is that when I tried to code it, I was in an internetless bar, so I
had to guess some parts of the exercise and I missunderstod some of the points
and the code didn't work as expected (but at least, I succeeded to make it work
as I thought it had to work)
When looking the solution proposed at programming praxis, I payed attention to
both the algorithm used, and the code.
The algorithm used is works calculating white pegs, and then substract black
pegs. Finally, it sorts the black and white pegs and prints the output.
I'll try to write my own version in near future, but, for the moment, I have
updated the perl Mastermind code I started some time ago, that until now, it only compared the solution to the given combination, and returned a good/bad value. Now it uses that algo to tell how accurated is your guess. It's still far from functional, (it only plays random (with or without repetitions (using a cache))), but I have little time to hack on those projects.
I will have to take a look at the programming praxis "standard prelude", where the author shows some generic functions that are used over his solutions.
Btw, Programming Praxis has been one of my last findings on the intertubez. A great find IMHO.
game. The author splitted the game in two parts, the first
being the setter, so given a known solution, and a guess, returns a string
of B/W/.
The point is that when I tried to code it, I was in an internetless bar, so I
had to guess some parts of the exercise and I missunderstod some of the points
and the code didn't work as expected (but at least, I succeeded to make it work
as I thought it had to work)
When looking the solution proposed at programming praxis, I payed attention to
both the algorithm used, and the code.
The algorithm used is works calculating white pegs, and then substract black
pegs. Finally, it sorts the black and white pegs and prints the output.
I'll try to write my own version in near future, but, for the moment, I have
updated the perl Mastermind code I started some time ago, that until now, it only compared the solution to the given combination, and returned a good/bad value. Now it uses that algo to tell how accurated is your guess. It's still far from functional, (it only plays random (with or without repetitions (using a cache))), but I have little time to hack on those projects.
I will have to take a look at the programming praxis "standard prelude", where the author shows some generic functions that are used over his solutions.
Btw, Programming Praxis has been one of my last findings on the intertubez. A great find IMHO.
viernes 20 de noviembre de 2009
Implement a scheme intepreter in X
It might be just a strange coincidence, but lately, every week I discover a new book/tutorial that guides you through writing a scheme interpreter in whatever language I look.
Theres's SICP , implementing scheme in scheme
Theres PLAI , implementing a variant of scheme in a variant of scheme
Also, there's "Exploring programming language architecture in Perl". A book that covers the implementation of a scheme interpreter in perl.
And now here's a new kid in the block I just discovered. Implementing a simple scheme interpreter in haskell. I'll leave it here, and see if I have some time in the near future to read it (I doubt I implement it as I know nearly no haskell)
So many good books to read and so little time and attention span....well, there's still hope on SICP and EPLAiP.
Theres's SICP , implementing scheme in scheme
Theres PLAI , implementing a variant of scheme in a variant of scheme
Also, there's "Exploring programming language architecture in Perl". A book that covers the implementation of a scheme interpreter in perl.
And now here's a new kid in the block I just discovered. Implementing a simple scheme interpreter in haskell. I'll leave it here, and see if I have some time in the near future to read it (I doubt I implement it as I know nearly no haskell)
So many good books to read and so little time and attention span....well, there's still hope on SICP and EPLAiP.
lunes 16 de noviembre de 2009
Implementing list functions in scheme
I've been messing a bit with scheme lately, and one thing I want to get well is list mangling. As you know, lists are the most basic and pure datastructure in scheme (and I think they are the only true datastructure in scheme).
This is why I want to get them right, and I'm rewriting some basic functions related to lists.
First of all, a little explanation of lisp lists in general.
Lists are based on a more simple structure called "cons". A cons is just a pair. The only thing that can contain a cons in the first (car) or the second (cdr) cell are:
First we'll see two axioms that must always be true related to conses.
(= x (car (cons x y)))
(= y (cdr (cons x y)))
Everything that guarantees this is a cons. Well, at least at this level...
a cons is represented by (x . y) , and a cons with another cons in the cdr would be (x . ( y . z))
A list is a special kind of cons with a determined structure.
( x . (y . (z . nil))) . A way to visually simplify this is ( x y z ) . That means that in a list of n elements, there are n conses linked through cdr's, with the last cdr pointing to nil. If you had to build (1 2 3) with conses, you could do it with (cons 1 (cons 2 (cons 3 nil))) .
Here I show the few scheme functions I wrote along with some explanations that davazp kindly gave me at #emacs-es and #lisp-es.
Theese are my first versions of some functions.
Here we see build-list can be abstracted to a more general (and easier to write) procedure called build-range, and I just call it with a start point = 1.
On the reverse function, we can use a different "happy idea".
Enough for today. Thanks to davazp and other #emacs-es -ers for their help and motivation.
This is why I want to get them right, and I'm rewriting some basic functions related to lists.
First of all, a little explanation of lisp lists in general.
Lists are based on a more simple structure called "cons". A cons is just a pair. The only thing that can contain a cons in the first (car) or the second (cdr) cell are:
- string
- number
- symbol
- cons
First we'll see two axioms that must always be true related to conses.
(= x (car (cons x y)))
(= y (cdr (cons x y)))
Everything that guarantees this is a cons. Well, at least at this level...
a cons is represented by (x . y) , and a cons with another cons in the cdr would be (x . ( y . z))
A list is a special kind of cons with a determined structure.
( x . (y . (z . nil))) . A way to visually simplify this is ( x y z ) . That means that in a list of n elements, there are n conses linked through cdr's, with the last cdr pointing to nil. If you had to build (1 2 3) with conses, you could do it with (cons 1 (cons 2 (cons 3 nil))) .
Here I show the few scheme functions I wrote along with some explanations that davazp kindly gave me at #emacs-es and #lisp-es.
Theese are my first versions of some functions.
Here we see build-list can be abstracted to a more general (and easier to write) procedure called build-range, and I just call it with a start point = 1.
On the reverse function, we can use a different "happy idea".
Enough for today. Thanks to davazp and other #emacs-es -ers for their help and motivation.
sábado 14 de noviembre de 2009
VL 6.0 KDE Classic Review
Vectorlinux team has released another version of this beautiful distro.
This release is a kind of tribute to kde 3.* , as it's the last vl with kde 3 bundled in it. Next versions (6.0 SOHO is already in beta) will come with kde 4, so this one is for those who want rock stable and well known kde 3.5.10.
Installing Vectorlinux
As this version still uses the "old" text installer (a new one is in the oven atm), I could boot and install the iso without having to burn a CD using vinstall-iso
sh ./vinstall-iso VL6.0-KDE-Classic.iso
And let the fun start!
The process went flawlessly. I was surprised how few options I had to install extra packages. Well, sensible defaults are ok for me.
To manage usb and CD units user can choose between the resource hog (but well tested and known worldwide) HAL and quick (and VL idiosyncratic) VL-HOT. The default is HAL, but I changed it to VL-HOT.
Since running the iso till I restarted to my new VL-kde only passed 9 minutes. Yes, only nine minutes. In the first boot, I was asked some other questions and a new reboot was required. Then I already booted to a full KDM screen.
After the first tests, everything worked fine: Sound, graphics (I installed propietary ati drivers from their page, and I already have my dualscreen setup), and all the basic things I could test.
Software selection
Vectorlinux has always come with a sensible selection of software, and most of it is already configured to "just work". For example, firefox(3.5.3) comes with flash plugin, pdf plugin, java plugin, etc... Konqueror is also installed (it's a kde distro, remember?)
For IM we have pidgin and Kopete, and KSirc to irc.
Koffice with a whole lotta apps is there, from creating spreadsheets to flowcharts. Lots of apps.
It comes with lots of dev tools by default (g++, gcc, make) and interpreters like perl (5.10.0), python (2.5) and even ruby (1.8.6).
Performance
That's the main reason I like/use Vectorlinux. It's among the fastest linux distros. And it costs nothing to install. Here's a screenshot of vl running kde, with a couple of terms and ksirc. Click the image for a larger sample.

More Software
Although the VL team selected very good apps to go into VL-kde, I *want* my desired apps NOW!. No problem at all.
I just had to edit (as root) /etc/slapt-get/slapt-getrc and uncomment the testing line from
#DISABLED=....
to
SOURCE=.....
After that, "slapt-get --update" and then, installing all my favourite software was trivial:
"slapt-get -i zsh screen vim-gvim emacs ...."
In no more than 30 minutes, I CAN HAS a workin environment with KDE 3.5.10.
Conclusion
In so little time, I can hardly make a conclusion about it, but knowing the average quality of Vectorlinux releases, and having tested it a bit, I think I can recommend it to people with a little linux knowledge (installer is in text mode, but it's really easy to follow) who want a fast distro to be used in browsing / office or, on the other side, as a developement platform I'd recommend to people who do not want to mess too much with the inners of linux
(it's not arch) but want to learn in a standard platform, that does not hides anything about pure slackware (so pure GNU/linux), and want to learn little by little (it's not ubuntu).
Personally, being a more minimalistic person, I'll stay with vl-std and vl-light, but this release is one I'd recomend to my non-so-techy friends.
There's only a way to see if it fits you. Try it and see. Make (good) use of vl community in case of trouble. It'll positively surprise you.
This release is a kind of tribute to kde 3.* , as it's the last vl with kde 3 bundled in it. Next versions (6.0 SOHO is already in beta) will come with kde 4, so this one is for those who want rock stable and well known kde 3.5.10.
Installing Vectorlinux
As this version still uses the "old" text installer (a new one is in the oven atm), I could boot and install the iso without having to burn a CD using vinstall-iso
sh ./vinstall-iso VL6.0-KDE-Classic.iso
And let the fun start!
The process went flawlessly. I was surprised how few options I had to install extra packages. Well, sensible defaults are ok for me.
To manage usb and CD units user can choose between the resource hog (but well tested and known worldwide) HAL and quick (and VL idiosyncratic) VL-HOT. The default is HAL, but I changed it to VL-HOT.
Since running the iso till I restarted to my new VL-kde only passed 9 minutes. Yes, only nine minutes. In the first boot, I was asked some other questions and a new reboot was required. Then I already booted to a full KDM screen.
After the first tests, everything worked fine: Sound, graphics (I installed propietary ati drivers from their page, and I already have my dualscreen setup), and all the basic things I could test.
Software selection
Vectorlinux has always come with a sensible selection of software, and most of it is already configured to "just work". For example, firefox(3.5.3) comes with flash plugin, pdf plugin, java plugin, etc... Konqueror is also installed (it's a kde distro, remember?)
For IM we have pidgin and Kopete, and KSirc to irc.
Koffice with a whole lotta apps is there, from creating spreadsheets to flowcharts. Lots of apps.
It comes with lots of dev tools by default (g++, gcc, make) and interpreters like perl (5.10.0), python (2.5) and even ruby (1.8.6).
Performance
That's the main reason I like/use Vectorlinux. It's among the fastest linux distros. And it costs nothing to install. Here's a screenshot of vl running kde, with a couple of terms and ksirc. Click the image for a larger sample.

More Software
Although the VL team selected very good apps to go into VL-kde, I *want* my desired apps NOW!. No problem at all.
I just had to edit (as root) /etc/slapt-get/slapt-getrc and uncomment the testing line from
#DISABLED=....
to
SOURCE=.....
After that, "slapt-get --update" and then, installing all my favourite software was trivial:
"slapt-get -i zsh screen vim-gvim emacs ...."
In no more than 30 minutes, I CAN HAS a workin environment with KDE 3.5.10.
Conclusion
In so little time, I can hardly make a conclusion about it, but knowing the average quality of Vectorlinux releases, and having tested it a bit, I think I can recommend it to people with a little linux knowledge (installer is in text mode, but it's really easy to follow) who want a fast distro to be used in browsing / office or, on the other side, as a developement platform I'd recommend to people who do not want to mess too much with the inners of linux
(it's not arch) but want to learn in a standard platform, that does not hides anything about pure slackware (so pure GNU/linux), and want to learn little by little (it's not ubuntu).
Personally, being a more minimalistic person, I'll stay with vl-std and vl-light, but this release is one I'd recomend to my non-so-techy friends.
There's only a way to see if it fits you. Try it and see. Make (good) use of vl community in case of trouble. It'll positively surprise you.
viernes 13 de noviembre de 2009
Self modifying bash script
Last month, my ten years old lappy said enough. Well, it can boot, but it doesn't get the plug correctly, so it has to stay pretty static. It came with windows 98 installed, and I've done most of my uni tasks there, as well as installing tenths of linux distros (until vectolinux).
While moving files from its HD to a safer place, I found a bash script (works on zsh too) I did about 5 years ago, which emulated a 'mute' function, and could be called through a shell (or through xbindkeys / keylaunch / ratpoison binds).
The funny thing about it is that it modifies itself to remember the last volume that was set, to restore it afterwards.
I know it could be done using a file to store the previous volume value (and in fact, I use a trick of the same kind), but well, I liked to see that trick again. It uses sed to substitute a variable that is later tested if it's 0. Pretty easy stuff.
It makes me remember my first questions about self modifying code. Now, with lisp and smalltalk, living in a life environment, everything is clearer (sure?).
Comments and improvements are obviously welcome. Enlighten me!
While moving files from its HD to a safer place, I found a bash script (works on zsh too) I did about 5 years ago, which emulated a 'mute' function, and could be called through a shell (or through xbindkeys / keylaunch / ratpoison binds).
The funny thing about it is that it modifies itself to remember the last volume that was set, to restore it afterwards.
I know it could be done using a file to store the previous volume value (and in fact, I use a trick of the same kind), but well, I liked to see that trick again. It uses sed to substitute a variable that is later tested if it's 0. Pretty easy stuff.
It makes me remember my first questions about self modifying code. Now, with lisp and smalltalk, living in a life environment, everything is clearer (sure?).
Comments and improvements are obviously welcome. Enlighten me!
miércoles 11 de noviembre de 2009
using Vim regexes everywhere
I'm at class atm, and 5 minutes ago I had to download some exams from past years.
There are quite a lot of them, and I just thought downloading them all by hand would be too much work for a Lazy man like me.
Then I used vim to help me :)
I just got the code where there were the links I wanted. It looked more or less like this:
Just open vim, paste the code and let the magic begin.
Now you just have to execute the script, and enjoy :)
Btw, yeah, I know about downThemAll, but I like using my own tools (and I dislike bloat).
There are quite a lot of them, and I just thought downloading them all by hand would be too much work for a Lazy man like me.
Then I used vim to help me :)
I just got the code where there were the links I wanted. It looked more or less like this:
<a href="2006t-c-40-lc.pdf">g40</a>,
<a href="2006t-c-40-lc-s-test.pdf"> solució del test</a>;
<a href="2006t-c-50-dc-test+problema.pdf">g50</a>,
<a href="2006t-c-50-dc-test_resuelto.pdf"> solució del test</a>,
Just open vim, paste the code and let the magic begin.
:%s:href=":http\://studies.ac.upc.edu/FIB/XC/:
:%s:.*http:http:
:%s:".*::
:%s:^:wget :
:w /tmp/downThemAll.sh
Now you just have to execute the script, and enjoy :)
Btw, yeah, I know about downThemAll, but I like using my own tools (and I dislike bloat).
Suscribirse a:
Entradas (Atom)