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 Mon, 06 Sep 2010 07:30:14 -0700 Christopher Hitchens - Authors@Google http://www.tomas-m.com/blog/16286-Christopher-Hitchens-Authors-Google.html Tomas M Tue, 31 Aug 2010 05:30:49 -0700 http://www.tomas-m.com/blog/16286-Christopher-Hitchens-Authors-Google.html The Godlessness Song http://www.tomas-m.com/blog/15417-The-Godlessness-Song.html Tomas M Mon, 31 May 2010 22:13:17 -0700 http://www.tomas-m.com/blog/15417-The-Godlessness-Song.html Beyond atheism http://www.tomas-m.com/blog/13342-Beyond-atheism.html Believing there is no God means all the suffering in the world isn't caused by an omniscient, omnipotent force that isn't bothered to help or is just testing us, but rather something we all may be responsible for, something we all may be able to help others with in the future. No God means the possibility of less suffering in the future. I feel it the same like Penn. Read more here. Tomas M Tue, 30 Mar 2010 12:00:34 -0700 http://www.tomas-m.com/blog/13342-Beyond-atheism.html 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