Interesting TeX tricks
Simply a page with some interesting TeX tricks: volkerschatz.com.
Simply a page with some interesting TeX tricks: volkerschatz.com.
I am a recent fan of Python, a very neat scripting language.
One thing I miss from Perl is the availability of labeled breaks. What are those? Suppose you have two nested loops. When a condition is met in the inner loop, you want to exit both loops. With Python there is not straightforward way of doing it. Imagine we are reading an array of data, line by line and column by column, and we want to exit when meeting the first zero value. With Perl:
LINELOOP: foreach my $i (0..$lines)
{
COLLOOP: foreach my $j (0..$columns)
{
break LINELOOP unless $val[$i][$j];
};
};
A simple “break” will exit the innermost loop, but we can use a label to exit a specific loop. However, in Python there is no such a thing as a labeled loop, as explained in this PEP.
My rant is with the explanations given by van Rossum himself in Python mailing list to reject the change:
1. The complexity added to the language, permanently.
2. My expectation that the feature will be abused more than it will be used right.
Wow! Incredible reasons!
The first one is silly: other languages have it, and it has worked fine. Adding complexity to a tool for the sake of it is really stupid, I agree. But the fact is labeled breaks would be tremendously useful, so the increase in complexity would be justified. Surely a language that can only print “Hello world” would be less complex, yet of little use.
The second reason is absolutely over-the-shoulder-of-the-users. So now good old Guido must guide his sheep along the “correct” path, lest we get lost! He is punishing the good programmers by not giving them a useful tool, so that bad programmers are protected from their stupidity. It’s like not selling cars at all because some people drive while drunk.
Just my 2 cents…
When I see videos like the following, I always think two things:
[youtube=http://www.youtube.com/watch?v=0awjPUkBXOU]
You can page where I found it (actually somebody who found it told me) at Johnny Chung Lee’s page.
This YouTube video shows Compiz Fusion running on my work computer. It has a fairly decent CPU (P4 3.00GHz), but no “useless” things like sound cards or (more relevant for this issue) graphics card. The only thing it has is an Intel 82865G graphics chip integrated in the motherboard. We are talking about an integrated chip (not dedicated graphics card) released in May 2003.
Judge the performance for yourself (take into account that the actual performance is higher, since the recording program to make the video also uses up some resources):
Yesterday morning, a new failure from Iberdrola turned the power supply of the whole campus off. So, here goes the updated list of blackouts I have been able to compile, with comments if any:
Summary: 14 blackouts in 728 days, or 52 dpb (days per blackout). 56 days since last blackout. Average dpb went up by 0.3.
First post in the series: here
Intro
Any GNU/Linux user ends up hearing, sooner or later, the Ultimate Argument(tm) from a Windows fanboy:
If Linux is so good, and is given away for free, how can Windows still be so prominent?
Ironically, many Windows users answer the question themselves, when explaining why they can’t make the switch to Linux:
The concept than embraces all the preceding points, and answers the rhetorical question above, is vendor lock-in. I will try to explain the concept with a humble tale I have used twice so far in comments to entries in Enrique Dans’s blog.
Tales of bicycles and cars
Imagine a country with no bicycles.
One day a guy comes up with the idea of making them, and starts to produce, and sell, bicycles that we shall call of type A. Being an empty market, the A-type bicycles quickly triumph, and the maker makes a lot of money.
But some time later, a second guy devises a better bike design (type B), and decides to produce and sell it. The price and the quality are better, so when people buy a new bike or replace an old one, they tend to buy bikes of type B. Soon enough, the market is dominated by the new, better, bicycle.
Now imagine a country with no cars.
One day a guy comes up with the idea of making cars, and starts to produce and sell cars of type A. As cars need petrol to run, A-type gas stations develop in parallel to car sales. Building gas stations is expensive, but sales are guaranteed, as everyone has or will have A-type cars, and they need A-type petrol: their growth is synergistic.
But some time later, a second guy devises a better car design (type B) and decides to produce and sell it. The price and the quality are better, BUT drivers can not buy B-type cars, because there is no B-type gas station. The problem is that, since noone has a B-type car, making B-type gas stations is doomed to bankrupt. So, no B-type cars are sold, because there are no B-type gas stations, and B-type gas stations will not be made until B-type cars are popular!
The result is a vendor lock-in.
Consequences
When a market (such as the one in the tale above) is dominated by vendor lock-ins, the producers benefited by the lock-in have little, if any, incentive to make better products. Their sales are guaranteed by the lock-in situation, not by their superior product in a fair market.
On the other hand, other producers will have an extremely hard time for competing, as their products will be almost unusable for the buyers.
The moral is that the lock-in situation is bad for either the potential users of the product locked-out (the B-type car above) and the locked-in one (the A-type car). Even if a consumer would never choose the locked-out product, the lack of competition will adversely affect the evolution of the product they do choose. The lock-in is bad for everyone: all consumers and all producers but the locker ones.
And this relates to Windows vs. Linux in what way?
In a really straightforward way. Microsoft, cunning as they are, have tried their best to get as many lock-ins on the software market as they can. Ironically, instead of abhorring this practice, most Windows users happily continue not only using, but even defending the product. I shudder at the simpleton comment that “freedom is not using Linux, but using Windows and Linux whenever you feel like it”. Literally taken, it is a very wise argument. But unfortunately the reality is not so simple: using Windows helps enforce a lock-in that keeps Linux out (while in this case the contrary is not true). You can not use Windows/Linux 50/50, because Windows asks you for monogamy.
The many lock-ins that MS has forced down the throats of the users, while the latter still claim them to be benefits of Windows include (as mentioned at the beginning):
One argument I tend to hear from Windows users is that in Windows you can do as much as you can with Linux, and that the technical advantages of Linux only show up if you are really an utter geek. This is one of (I hope) a series of entries in my blog, illustrating some cases where this doesn’t hold: I took advantage of tools provided by Linux in a way that anyone could have, not just geeks.
The moral of it all is that Windows encourages a lack of choice and flexibility that makes users tend not to be creative, and think the cage Windows keeps them in is actually a shelter from the storm, when it’s not. They think that what can’t be done with Windows, needs not be done. I think otherwise…
Today I will try to provide an example in which hard links can be useful. Under Windows XP hard links can be created, using the fsutil utility, but only for NTFS file systems, and only by the Administrator account (and only from the command line). If you want to learn more about links and specially Windows links, read this interesting sell-shocked.org article.
The problem
I download a lot of music from Jamendo, using the BitTorrent p2p protocol. After having downloaded a given album, I tend to leave the torrent open, so that people can continue uploading from my computer.
However, I also want to have my music collection tidy and ordered, so I immediately organize the newly-dowloaded songs moving them to a neat directory tree I have, will all my music.
So, there is a conflict between keeping the files in the bittorrent download/upload dir, and properly organizing them. I don’t want to have to wait until I decide to stop sharing a file to organize it, and I don’t want to risk deleting the files if I remove them from the bittorrent client before saving them elsewhere. I could get over all this by simply making a copy of the files… but then I would be filling twice as much disk space, and with GBs of shared files, this is not neat at all.
The solution
What I do is hardlink all the downloaded files to their final location. If I download all torrents to /scratch/ktorrent/, a downloaded album will look like that:
% ls /scratch/ktorrent/album1/
song1.ogg song2.ogg song3.ogg [...]
If I want to save the album under my artist1 directory, I do the following:
% mkdir /scratch/music/artist1/album1
% ln /scratch/ktorrent/album1/* /scratch/music/artist1/album1/
This way all the “song*.ogg” files will appear to be in both /scratch/music/artist1/album1/ and /scratch/ktorrent/album1/ at the same time.
Benefits:
1 – I can keep sharing the files in /scratch/ktorrent/album1/, while listening to and/or manipulating the /scratch/music/artist1/album1/ files as if I had 2 copies of each.
2 – The total size is not affected. The hard links do not “occupy” space (only a few bytes each).
3 – I can delete the files in the shared directory without any fear. Only the “copy” in /scratch/ktorrent/ disappears, while the other “copy” in /scratch/music/artist1/album1/ becomes the only copy (just as if it had always been a “normal” file, and the only one).
Recall that all files are hard links. Normally a given file is the only hard link to a given piece of data in the hard disk, but there can be more “links” pointing to that data. When we remove files, we only remove the “link” pointing to the data.
From my own site at ehu.es/isilanes.
Comply with the standards
Much like in spoken languages, Internet information exchange requires a common language, understood by everyone. In this case, our browsers will be the ones making the translation from that language (HTML) into images, colors and human-readable text. Much like spoken languages, there is an “Academy” taking care of what is and what is not correct. In this case, the academy is the World Wide Web Consortium (W3C).
Much like in spoken languages, HTML evolves and changes, but when changes are not incorporated in the standards, misunderstandings happen. To assure a Web page is correctly displayed by any browser, first standards are encouraged (I wish they could be enforced), then standard-compliant browsers are made. The Web should not be designed for a specific browser, rather browsers should be made to comply with openly known standards. For a discussion on that, jump to the Viewable with any browser site.
If you want to make your site as widely viewable as possible, and keep your visitors happy, you should really follow the W3C standards, because this way you really know that any standard-complying browser will display the page correctly. Is making a standard-compliant page difficult? Not really. First, you could follow the Accessible design guide at the Viewable with any browser site. Then, learning some HTML programming could help. Finally, you are encouraged to put a “W3C correct HTML” button on the product page, as you can see I have done on my ehu.es/isilanes page (orange buttons on the left hand side above). This page, for example, has been correctly coded in HTML, and its CSS is also correct, as you can test clicking the aforementioned buttons.
The code for the HTML-correctness verification:
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401"
alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
The CSS button:
<a href="http://jigsaw.w3.org/css-validator/">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!"></a>
Recall that you can put the above buttons in your pages at early stages of page creation (when they are still incorrect), and use them yourself to see if what you have done so far is W3C-compliant. The resulting validation page (saying “OK” or “Not OK”), usually explains the errors you might have done rather understandably, and help in fixing them.
Minimize the size
Every time a web page is visited, the client (the browser of the visiting person) has to download the contents of the page to be able to display them. The more fancy pictures there are in your page, the longer it’ll take to load. The more crap that the client has to download, the slower the visiting experience for that person. If a page takes too long to load in your browser, what do you do? Exactly, you quit and go somewhere else. Human attention time span is short, and more so in the Internet, so don’t ask your visitors for the patience you didn’t have when making the page in first place.
Avoid Java, JavaScript and Flash
The problem here is dual: size and accessibility. The problem of the size is summarized in the previous section.
The issue with the accessibility is related to the fact that you should ask your visitors for as few resources as possible to view your content. If they need to get and install some fancy software to access your functionality, then this fact might discourage them and make them go away.
Remember always that it is your task to make it easy to access your content, not the visitors’ to find the suitable tools for that. Use JS or Flash if you absolutely need to, but only if you absolutely need to. Usually a clever use of plain HTML resources will give satisfactory results, and will be much more visitor-friendly.
Avoid proprietary formats
Innocuous as they might look, formats like MP3 and GIF are patent-encumbered, which means that their use should/could be restricted by the patent holders. Also, using them forces the browser (in the case of GIFs) and MP3 player makers to comply with restrictive patent requirements (like e.g. paying royalties).
The best way to eliminate software patents is to dump patented material altogether. Use Ogg Vorbis format to encode your music, and substitute your GIFs for PNGs. Recall that patented software is illegal to modify, improve or have security holes/bugs patched by third parties, without permission of patent holders, which makes the openly developed formats evolve much faster, and eventually become better.
For specific reasons to dump MP3s and GIFs, see the Wikipedia pages for PNG and Ogg Vorbis. In short: CompuServe developed the GIF format without knowing that the LZW compression algorithm it used was patented (by Unisys). Later, after GIF became popular, Unisys announced that they’d start enforcing the patent (charge royalties) to commercial programs capable of displaying GIFs. Something similar happened to MP3 and the Fraunhofer Society.
With Open formats you’ll never have any such problem, and the visitors to your page will never have to pay royalties for programs capable of displaying the contents of your site.
This is a short HowTo for making unicode work in Linux, specifically in the command line. Yet more specifically, in the konsole terminal. This is useful if you want to be able to use characters like ‘ñ’ or accents like in ‘á’ and ‘ö’.
1 – Modify your shell locale variables
You need locale settings that support UTF (for example en_US.UTF-8). For that, you can add the following lines to .tcshrc or whatever script run at login:
setenv mylang en_US.UTF-8
setenv LANG $mylang
setenv LC_CTYPE $mylang
setenv LANGUAGE $mylang
setenv LC_ALL $mylang
The ‘$mylang’ thing is just because I’m lazy, and I might want to change them all in the future, and I don’t want to type too much.
2 – Modify your global locales
I don’t know if this is needed, but it doesn’t hurt. In Debian:
% dpkg-reconfigure locales
and follow the instructions, using en_US.UTF-8 or something similar as default.
3 – Modify the encoding of Konsole
In the menus:
Settings->Encoding->Unicode (utf8)
Make this permanent with:
Settings->Save as Default
Then choose xterm and not linux as keyboard setting:
Settings->Keyboard->Xterm (XFree 4.x.x)
You can make this permanent in the Session tab of:
Settings->Configure Konsole
namely inserting “xterm” in the box labeled “$TERM”.
If you follow these instructions, you will be able to introduce non-ASCII text in the terminal, and use non-ASCII filenames without problem.
Following the “report” series started with my first summary of info about the music collection I listen to, I will update that info in this post.
The data (in parentheses the difference with respect to last report, 7 months ago).
Files
Total files 7036 (+1021)
- Commercial 4465 (+301)
- Jamendo 2533 (+713)
- Other CC 31 (+0)
- Other 7 (+7)
Total playtime 18d (+2d)
Disk usage 32GB (+5GB)
Artist count 817 (+99)
Album count 618 (+103)
MP3 count 0 (+0)
OGG count 7036 (+1021)
Last.fm
Playcount 26246 (+9502)
Most played artists JoaquÃn Sabina - 2252 plays (+810)
The Beatles - 983 plays
Silvio RodrÃguez - 626 plays
David TMX - 599 plays
Siniestro Total - 536 plays
Most played songs La del pirata cojo (J. Sabina) - 47 plays (+18)
Conductores suicidas (J. Sabina) - 46 plays
Pacto entre caballeros (J. Sabina) - 42 plays
Cuando aparezca el petróleo (E. Sánchez) - 42 plays
Y sin embargo (J. Sabina) - 40 plays
Amarok
Playcount 18186 (+5740)
Favorite artists Ska-P - 93.73%
Juan Luis Guerra - 92.84%
Peiremans - 91.96%
Su ta Gar - 91.86%
La Caja Negra - 91.64%
Favorite songs Tirado en la calle (E. Sánchez) - 97%
Fiesta pagana (Mägo de Oz) - 97%
Cuando aparezca el petróleo (E. Sánchez) - 97%
Las cuatro y diez (L.E. Aute and S. RodrÃguez) - 97%
Wheels of fire (Manowar) - 97%
« Previous Page — « Previous entries « Previous Page · Next Page » Next entries » — Next Page »