http://www.tomas-m.com/blog/ Tomas-M.com blog http://www.tomas-m.com/favicon.ico 16 16 Tomas-M.com blog http://www.tomas-m.com/blog/ Blog of Tomas M en Tue, 09 Mar 2010 13:28:51 -0800 Slax downloaded more than 2 million times http://www.tomas-m.com/blog/11078-Slax-downloaded-more-than-2-million-times.html All downloads of Slax 6.x from the download page were always secretly counted, but it was only several weeks ago when I realized that it could be interesting to publish the counter under the download links for the general audience. The counter stated something around 1800000 downloads at that time. Today I've just realized that the counter is far beyond 2 millions! Thank you everybody who download Slax! Especially all the people from United States (16%), Russia (7%), Poland (5%), Germany (5%), Italy (4%), Czech Republic (4%), France (3%) and United Kingdom (3%). Tomas M Wed, 24 Feb 2010 05:20:37 -0800 http://www.tomas-m.com/blog/11078-Slax-downloaded-more-than-2-million-times.html What happens if a chimp sees magic (jp) http://www.tomas-m.com/blog/10174-What-happens-if-a-chimp-sees-magic-jp.html Tomas M Mon, 15 Feb 2010 05:00:04 -0800 http://www.tomas-m.com/blog/10174-What-happens-if-a-chimp-sees-magic-jp.html God loves us - really http://www.tomas-m.com/blog/10168-God-loves-us-really.html Tomas M Sat, 13 Feb 2010 02:50:47 -0800 http://www.tomas-m.com/blog/10168-God-loves-us-really.html lzma for official squashfs is here http://www.tomas-m.com/blog/4677-lzma-for-official-squashfs-is-here.html Just few days ago, Phillip Lougher added the long awaited LZMA decompression to his squashfs tree (here are the patches). I'm not sure what kernel version will incorporate these changes. I guess 2.6.32 is in the -rc state already so we will have to wait for the next one. Tomas M Wed, 21 Oct 2009 09:38:25 -0700 http://www.tomas-m.com/blog/4677-lzma-for-official-squashfs-is-here.html ORDER BY RAND() replacement http://www.tomas-m.com/blog/4153-ORDER-BY-RAND-replacement.html From time to time, I need to select a random row from MySQL table. The official documentation suggests SELECT * FROM table1 ORDER BY RAND() LIMIT 1, but this is very dangerous. It can take ages to select a random row from a table with millions of records. The reason can be noticed after running the same query with 'EXPLAIN' keyword at the beginning: Using temporary; Using filesort. It's the worst situation which could happen. I'm always looking for as best optimalization as possible, so I had to come up with something faster. And here is the result: SELECT @r:=RAND();SELECT @i:= (SELECT MIN(id) FROM table1 WHERE id>= (SELECT (@r*(SELECT MAX(id) FROM table1))));SELECT * FROM table1 WHERE id=@i;As you can see, there are 3 queries needed instead of one, but the time to find out the particular random row is reduced to the smallest possible value, because there is no more needed to create any temporary tables or sort them. After EXPLAINing the queries again, you'll find out that most of the statements were optimized away entirely, and the final SELECT uses a const reference, thus returns immediately too. Benchmark shows that my server can run 10 millions (10^7) of these queries in 1 second, while it can execute only 20 (!!!) queries using ORDER BY RAND(). This seems too good to be true, so perhaps I made an error somewhere in the benchmarking ... but in all cases, you can be 100% sure the new solution is way faster. It has one drawback though. If the table has 'holes' in the primary key column (for example when some of the rows are deleted from the table and the given ID value is no longer used), the random row is not so precisely random. That can be solved by creating a map table, but I personally don't need this since the distribution of 'holes' in my tables is pretty random too, so the result is sufficient. Tomas M Sun, 11 Oct 2009 05:03:41 -0700 http://www.tomas-m.com/blog/4153-ORDER-BY-RAND-replacement.html Squashfs LZMA support http://www.tomas-m.com/blog/4086-Squashfs-LZMA-support.html In the last few days, Phillip Lougher (squashfs author) published several patches, which is a very important step towards the new lzma support. In short, the patches move the decompressing functions to a separated file, and replace the zlib_uncompress() call by squashfs_decompress(). This is exactly what had to happen in order to provide a decompressor framework for Squashfs, 'allowing multiple decompressors to be easily supported'. Since it (lzma) is already in kernel for some time, I think that we should see LZMA support in squashfs very soon. Tomas M Fri, 09 Oct 2009 08:38:24 -0700 http://www.tomas-m.com/blog/4086-Squashfs-LZMA-support.html Her Morning Elegance / Oren Lavie http://www.tomas-m.com/blog/3690-Her-Morning-Elegance-Oren-Lavie.html Tomas M Sun, 20 Sep 2009 12:34:14 -0700 http://www.tomas-m.com/blog/3690-Her-Morning-Elegance-Oren-Lavie.html What is the purpose of life? http://www.tomas-m.com/blog/3275-What-is-the-purpose-of-life.html In the previous post's video, Richard Dawkins discussed the purpose of purpose: a human mind needs a purpose for everything, and most people think that everything HAS a purpose, even things without one. For most people the only way to see the absurdity is to think about the purpose of purpose. When I was young, we were told that the purpose of life is to live our lives the right way to go to heaven after we die. Religion gave us the ultimate answer of the purpose of our lives - to test our conformance to God, in order to be rewarded by a pleasant afterlife. But lets think a little more about it. What would be the purpose of the afterlife then? After we finally made it to the heaven, we would enjoy our afterlife and be happy. What would be the purpose of our existence? It doesn't make sense. Couldn't we just enjoy our lives just right now for the same purpose? The ultimate answer provided by all religions is a mental fallacy. We don't need a purpose. We make our purpose ourselves. Tomas M Thu, 27 Aug 2009 01:36:37 -0700 http://www.tomas-m.com/blog/3275-What-is-the-purpose-of-life.html The purpose of purpose http://www.tomas-m.com/blog/2882-The-purpose-of-purpose.html Have you ever wondered why are we here? You may find the answer in the following video. During Richard Dawkins' American tour in March 2009, he gave a talk titled "The Purpose of Purpose". The talks were filmed and edited together here. The content of the talk remains intact, while the editing moves between the different locations and Richard's Keynote presentation. Tomas M Mon, 17 Aug 2009 10:27:00 -0700 http://www.tomas-m.com/blog/2882-The-purpose-of-purpose.html What is atheism? http://www.tomas-m.com/blog/2855-What-is-atheism.html The following picture explains that clearly :) Tomas M Mon, 17 Aug 2009 08:12:13 -0700 http://www.tomas-m.com/blog/2855-What-is-atheism.html