Author
The Archives
-
11.12.11Unicode sorting in perlJust Normalize. Assume file.txt is a list of unicode words, then cat file.txt | perl -e 'use Unicode::Normalize; my @w ;\ while () {chomp; push @w, $_;} ; @w = sort {NFD($a) cmp NFD($b) } @w ;\ print(join("\n", @w))' will output the sorted list (well, sorted according to the NFD normalization, which for Spanish is enough).
-
07.08.11Script for making an ordered list of filesYou've got a bunch of files you want to reorder (that is rename so that they appear in a specific order) but do not want to really rename them (their original names are relevant). You may want to create a set of links to each of them with the appropriate '001', '002' term before. Here is a script for doing exactly this. Use as follows (if named 'mapnames.sh'): $ mapnames.sh digits file1 [file2 file3 ...] will use digits digits for the leading numeral (adding '0' before) and will link the files in the given order. Here is the code: #!/bin/sh length=$1 shift count=1 for name in $@ do ...
-
06.28.11The Sibyl going to the No cON NameBoth rafacas and pfortuny are going next September to Barcelona to the No cON Name conference, to talk about The Sibyl, of which we have already written here. If any of you is interested in IT Security and can make it to Barcelona in September (14-17), it would be nice to meet you there.
-
02.22.11Learning to write (GNU) makefilesI am a Mathematician and usually write more LaTeX than C but programming has been an active hobby since I owned my first Spectrum back in the eighties. What I am commenting in this post has been plaguing me for years and I have just learnt it (from laziness, no more): using pattern rules in makefiles. Caveat: I do not know whether this works for non-GNU Makes or not. I had already read a lot of pro makefiles, which contained endless funny codes like $@, $%, $< etc. Today I have learnt the meaning of some of these. I am supervising a ...
-
02.18.11Moving between encodings with emacsI live in Spain. I work at Academia. This is a problem. My School's computers are plagued with Windows (XP!), my pupils most certainly use Windows (I bet it is 7) and I use (obviously) an MBPro with Snow Leopard. Even more, my School's servers are Linux. This gives rise to latin-1, UTF-8 collisions. While writing some text-only documents for use with MATLAB (another problem, by the way) I realized I was going to need to convert them from my Mac's UTF-8 to Windows latin-1 every time I edited them. Time for a makefile. I am not commenting this though, only the ...
-
12.08.10The savannah.gnu incident and the SibylThe savannah.gnu.org compromise in December 2010 is another example of the weakness of system passwords: there will always be someone using a brute-force attackable key. And that is the weakest link. I just want to point out to all our readers out there that the Sibyl is precisely an idea to implement a secure way to store hashes of passwords and prevent brute-force attacks. It is not computationally cheap or even the simplest of setups, but security has a price. At least, it is, but for the hardware part, which depends on your implementation, 'gratis' and BSD-licenced. Hope you like it.
-
11.01.10gleeBox: mouseless browsing for Chrome, Safari & FirefoxI bet you are already tired of using the mouse for browsing. Download gleeBox and forget about it. Simply GREAT. (To be honest, I should use lynx to browse the web, but...) Apologies for taking so long to write a post, I have been working hard irl. As all of you, certainly :)
-
06.11.10hex2bin preserving endianness in CI cannot help copying this snippet. Assume f is a (char *) of length L, containing an hex string like '0aabdda' (without the leading "0x", like something coming from a sha function ---or like the sha1 stored by Leopard in the password files, which is the origin of this problem). You want to transform it into the corresponding sequence of bytes (that is, assuming the string is of even length, otherwise, we add a trailing, yes, trailing, at the end, '0'). We shall store the result in t, which points to a (char *) of length L/2. The following C code ...
-
05.20.10echo -n woesIt took me quite a while to realize that the following line does not do what you think it does: $ echo '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' | openssl base64 | tr -d '\n' You should always use the -n option if you want to make sure there is no spurious trailing newline: $ echo -n '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' | openssl base64 | tr -d '\n' (By the way, the encrypted message says just 'patata0' and it is not my password). Or... is it? Tested on two Linux systems (Fedora & Ubuntu) and one Snow Leopard.
-
04.27.10Setting variables in emacs at file headerWhen editing LaTeX files, I usually call the master file of a project 00father.ltx for historical reasons. Moreover, the following line is part of my .emacs: (setq-default TeX-master "00father.ltx") because most of the time I am editing multifile projects. However, from time to time I need to write a single-file document and in this case, naming it 00father.ltx is not that useful, and I do not want to have to set the master-file variable each time I load the file. There is an easy way to get this done. Just include a line at the top of the file -as a comment in the ...