26
Nov 06

Review: The Art of SQL

The Art of SQLI finished reading The Art of SQL by Peter Robson. It’s a pretty informative book, and has two pretty good uses:
1) It provides author-derived benchmarks for a bunch of special cases that you might encounter in the future, such as having indexes on a single column, having it on two columns, having it on three columns, and so on. It also has pretty good explanations of how expensive things like an index can be.
2) It provides a pretty good list of common beginner mistakes, such as running a SELECT COUNT(*) on your DB just to see if the number of results is larger than zero. That is a classic example of a wasteful query, since your programming language most likely allows you to run a SELECT query without COUNT, and then perform a foreach() on the set of results, therefore eliminating this step if the number of returned rows is zero.
The book is written with Sun Tzu’s Art of War in mind, and the chapters carry the same titles as Sun Tzu’s work.


16
Mar 06

No Nonsense XML Web Development with PHP review

My review of No Nonsense XML Web Development with PHP by Thomas Myer was published on Slashdot yesterday. It’s always interesting to read the comments the day after, and see the discussions evolved, and some interesting links like this one pop up.


29
Sep 05

David Berlind on AllofMP3.com legality

David Berlind from ZDNet got an official answer from IFPI regarding AllofMP3.com status:

We submitted a complaint to the most senior Moscow prosecutor in July (this is the third submission) and are awaiting that decision. Allofmp3.com was declared illegal by the court in Germany in May. The portal to the site in Italy, allofmp3.it was shut down by the Italian police in July. By the way, the Russian Organization for Multimedia & Digital Systems (ROMS) does not have the authority to licence the site and was thrown out of CISAC in October last year for purporting to grant licences it was not entitled to grant. We have consistently said that the site breaks international copyright laws by its sale and digital distribution of copyrighted music without the consent or authorisation of the rights holders.


17
Jul 05

The Largest Known Prime by Year

The largest known prime today is the 7,816,230 digit Mersenne prime 2^25964951-1 found in early 2005, but how big have the “largest known primes” been historically? When might we see the first billion digit bevaprime? And historically, how have these primes been found?

read more | digg story


06
Jul 05

Swik – open source product database

Swik is an open, wiki-driven, database of open source products, with a search engine to help the user find the right product. This ZDNet story says Alex Bosworth, son of Adam Bosworth, created the site, which is sponsored by SourceLabs. “With Swik, people can post information on different open-source products and subscribe to RSS alerts on areas of interest,” ZDNet story says.


03
Jul 05

Selected essays by Ray Kurzweil in a single download

The Ray Kurzweil Reader is a collection of essays by Ray Kurzweil on virtual reality, artificial intelligence, radical life extension, conscious machines, the promise and peril of technology, and other aspects of our future world.

read more | digg story


19
Jun 05

Freakonomics : A Rogue Economist Explores the Hidden Side of Everything

Freakonomics is one of those books that haphazard and has so little unified theme in it, that you wonder why the author hasn’t published each chapter as a separate title. But it’s probably one of the most interesting books you’ve ever read about economics. I can’t say I’ve read the book since I bought a CD and listened to it in my car during the daily commute, but the breadth of chapter always provided an interesting story to listen to, a story usually totally different than the previous one.

is written by an economist. This can’t be good, you say. GDP growth percentages and laws of supply and demand are interesting up to a point. Stephen D. Levitt, however, is not your typical economist. In his research he looks at some questions that intrigue him, and even conventional wisdom is there to provide the answer, he would always try to find out how the things really work.

The book, then, is a collection of questions asked followed by an answer, sometimes surprising, sometimes interesting, but never the conventional one, all backed up with statistics and economical data. The questions are all in chapter titles, the answers and some subsequent questions are discussed further in the chapters.

The chapters usually discuss the system of incentives, the usual conventional response to the question, and then the way the things really work. Why don’t we have so many criminals in the streets now and are not hit by a crime wave, predicted by pundits in the beginning of 90s? Does the existing education system provide incentives for teachers to cheat on the state exams and “beautify” the students’ answer sheets, since funding is tied to performance? Are sumo wrestling matches rigged? Can you make good money if you become a drug dealer? After all, the realities portrayed by 50 Cent videos have many more material things than you could ever hope to earn with white-collar employment? Is your real estate agent genuinely interested in selling your house for the maximum amount possible, as his/her commission depends on the final sale price? Do parents, who have many books in the house, have children, who score better than average in school? How about spanking – does that have any effect on child’s future? Is the name of the kid important for his future career?

Some points of the book are bound to cause controversy, since to many of the issues people have an emotional attachment, such as parents, believing that reading to the kid daily will eventually improve the school test scores, the chances of going to a better school, and subsequently, the chances of earning better money. Or authors’ conclusion relating the level of abortion with the level of crime (hint: most of the time it’s not an affluent 2-person household wanting to get an abortion) is bound to cause a heated debate, if you mention the results of Levitt’s findings to a pro-life activist.

The author is interesting to read (listen to in my case), he keeps the reader interested, and it’s hard to let the book go, since he keeps coming up with another set of questions to ask himself. After all, how many books give you an insight into operation and management of a crack dealer gang, and compare it to the corporate infrastructure of McDonalds?

Another good thing for those considering getting the audio version of the book is that the CD set of 6 disks came DRM-free, which allowed me to transfer one disk into MP3 and put it on my player while I was working out at the gym.

Originally I figured I’d put the book on my wish list after reading this article in Wired magazine. Wall Street Journal also ran a surprisingly positive review on the book, saying that it’s hard to criticize. Freakonomics is well-written, it’s filled with facts, not opinions, and has introductory stories of how many surveys (such as infiltrating a crack gang) were done. The authors also keep a blog on the book’s Web site. There’s also an article on baby names in Slate magazine.


13
Mar 05

Done reading The Motley Fool Investment Guide

I finished listening to two tapes of The Motley Fool Investment Guide : How The Fool Beats Wall Streets Wise Men And How You Can Too. The book has been around for a while, being published in 2001, and by now apparently a classic. Amazon has a used hardcover for 8 cents and a set of audio cassettes for 95 cents. The tapes are pretty good, clear voice, points well emphasized, read with irony where appropriate and proper intonation everywhere else.

The basic premise of the book – Internet changed the world of stock trading, so here’s how you could benefit of it. It’s not a book on what to invest in, or what stocks to pick, it’s a book about doing stock trading in the Internet age. What are mutual funds and how do you select the right ones? How to view the company financials? What to look for in Yahoo! Finance company pages? How is price-to-earnings calculated and what does it mean? What is price-to-earning-to-growth and what does it mean for you?

Several things the book teaches the reader:

  • How to select the mutual funds
  • How to choose an online broker
  • How to look for the right stocks
  • How to track your portfolio
  • Why you must track your portfolio and quantify your financial acumen
  • How to short stocks

Several key points that are left with me after reading the book:

  • Avoid mutual funds. 80% of them underperform the market, which means you’re better off buying an index fund of Dow Jones Industrials or S&P 500.
  • Choose low-commission, no inactivity fee broker. Here I would eagerly recommend my current one, Scottrade. I went with those guys after cancelling on FolioFN and so far they’ve been pretty good to me.
  • Invest in industries you know. It’s important to be able to detect actual innovation from marketing hype, and if you know airline business, but have only seen nanotechnology commercials on TV, youll probably be better off with airlines.
  • Track your portfolio. If you underperform S&P 500, maybe you’re better off buying S&P 500.
  • Avoid the jargon. Pay attention to cash flow and the actual wealth generated by the company. Other numbers (like sales, pro forma earnings, etc.) could trick you into thinking that company was doing well, when the opposite is true. Stick to reviewing the company’s bank account and their margins of doing business, it’s really what matters and defines sustainability of the business.

02
Mar 05

Finished reading ‘Blink’

Just finished Blink by Malcolm Gladwell, which was first recommended on Slashdot and then not-so-recommended by Gary Cornell, the founder of APress. I bought a set of 7 CDs and listened to it in the car while commuting to work. You get a bit more of the experience when listening to a book read by the author, as the main points are better accentuated than if you were to read a book somewhere in public transport or on the exercise bike.

The book is interesting to listen to, but somehow did not get me excited to want to read it the second time. He points out some interesting things – like the test where people were asked to construct sentences with words ‘wrinkle’, ‘Florida’, ‘old’, etc. Most of the test takers walked out of the test slower than they walked in – their brain subconsciously started picturing old life, which brought up retirement worries and what not, influencing the body and mind to feel a bit older and think slower.

There’s that theory of thin-slicing that the author talks about throughout the book. Thin-slicing is an ability of your brain to make quick decisions without rationalizing them. The famous gut feeling. Or horse sense. The more trained your brain is, of course, the quicker those decisions are. An amateur would not distinguish a genuine Greek statue from a fake, but a history professor who has seen thousands of Greek statues will probably spend less than a second recognizing the fake. Most of the time those people can’t tell you why they feel certain way, they will just say “I just know it”.

Basically, at a certain level the software part of the brain tends to grow through heavy machine-level-language optimization and becomes more or less firmware, wired to act quickly, sometimes quicker than our brain can rationalize. The lesson? Practice makes it perfect. If you want to know C++ or impressionist art by gut, just dedicate more time to practicing it. Also surroundings play greater role than we imagine. If you want to get fit, read some motivational literature, place some athletic posters on the wall and watch videos of people getting fit. The brain’s subconscious part will pick up on those messages, just like it did on that test, after which people felt older.


15
Feb 05

Are Russian music sites legal?

Wall Street Journal today discusses the legal standing of MP3Search.ru and AllofMP3.com, popular online music destinations located in Russia and selling songs for extremely low prices such as 10-15c for a song, while comparable Wal-Mart download price would be at fixed 88c. Wall Street Journal’s verdict is that the sites are not legal to sell their goods in the US, although the offering does sound enticing:

What’s more, the sites feature online music not available for sale in the U.S. Though copyright holders have prevented the sale of tunes from the Beatles online, the Russian sites offer most of the Beatles catalog — “Abbey Road” sells for $1.60 on MP3search.ru.

Why Russian sites are legal in Russia

It’s worth pointing out, however, as I did before, that the services are perfectly legal in Russia. The legislature there enforces compulsory licenses, which means that anyone can get the license to distribute and sell the music as long as they pay for it. In the United States if you plan to sell a certain CD, you have to negotiate with the labels, and that’s why the original Napster got shut down by the courts – they violated the law by not obtaining the licenses from the RIAA mob.

In Russia if you prove that (a) you keep track of what you’re distributing (log number of downloads) and (b) you pay to the collection agency, you’re legal to distribute any music you want. The collection agency (ROMS, quoted in the Wall Street Journal article) will then re-distribute the money to the copyright holders.

Why Russian sites are not exactly legal in the US

However, the legislature is Russian and thus applies only on Russian territory. Which means that the sites are not exactly legal to distribute the music anywhere outside of Russia. For any 15c allocated to the Russian music site some money goes to ROMS, which then distributes the payback to Universal Music Russia, BMG Russia, or whoever. Apparently the original Universal Music or BMG would not be too happy about it, even though they do get paid somewhere in the process.

So buying music out of Russia over the Internet is illegal if you’re in the United States, as buying marijuana from Netherlands would also be illegal, if you were in the US. Might be legal if you were physically in the Netherlands, but as far as the law enforcement in the US is concerned, you cannot go to one of those Amsterdam e-commerce shops and order a nice package with international shipping pre-paid.

Certain things to consider

An astute reader would probably say right now: “Wait a minute. Your analogy is all messed up. Importing marijuana from the Netherlands would be illegal, because marijuana itself is illegal in the US. You won’t be prosecuted for unauthorized buy from the Netherlands, you would be prosecuted for possession, since that’s the actual crime”. Here’s where a legal conundrum (for me, at least) comes in. Suppose you have a penpal in Russia who has one of those nice furry hats that keep your ears warm during the winter. Suppose you live somewhere in Northern United States close to Canadian border, so that winters get pretty tough. Basically, you ask your friend for a hat, which he’s happy to oblige, and pretty soon a FedEx package (he naturally doesn’t trust Russian pochta to deliver the package) arrives at your doors.

Anything illegal? Of course not. It’s a gift, and what we saw was the transfer of ownership of that hat. Then suppose MP3Search or AllOfMp3 are taking your money for MP3 downloads. But since it’s not legal for you to buy MP3s at those sites, AllOfMP3 and MP3Search won’t let you download. Instead they will send the files to your Russian friend (totally legal under Russian laws), which he will e-mail to you, and promptly delete the files off his hard drive (he doesn’t care much for your gangsta rap affection). An obvious transfer of ownership (legal). An obvious sale within Russian laws (totally legal).

Take the analogy closer to reality and let’s say that your virtual friend is really a Perl script that resides on the same server as MP3Search or AllofMP3, and that they make you register for a 1 GB Gmail account before you sign up for their service. After the purchase is completed (the MP3s are sold to your friend, the Perl script), they arrive at your Gmail box (transfer of ownership). This is another case of copyright law failing to oversee the nuances that can happen in international transactions. I don’t know whether e-mailing the MP3s would be legal or not. I guess, depends on who you ask.


20
Dec 04

Self-heating coffee

In 2005 Wolfgang Puck will start selling containers of self-heating coffee, USA Today says. The combination of calcium oxide and water will heat the coffee to 145 degrees and keep it warm for the next 30 minutes. The coffee will be sold in regular grocery stores, and folks at Fool.com tell Starbucks to watch out as this product, coming from a well-known chef, might target those of us grabbing a cup of hot latte on the way to work.


10
Sep 04

C# RS232 communication via MSComm.dll

Keep forgetting to link to this good tutorial by Noah Coad on using the MSComm control (that’s not managed) with C# to write a serial port app. If you happen to dig MSComm, that, perhaps is the easiest way to go.


02
Jul 04

When marketing drives the software product – a story of Microsoft Money

Show me the money is an interesting tale of Microsoft Money from a guy who now manages software development in Tablet PC group at Microsoft.

Money’s success or failure was judged using the same metrics as MSN’s websites. Metrics like minutes viewed per month. Like ad revenue. Like click-through. Stickiness. I am not making this up.


28
Jun 04

Meshcube tiny 802.11a/b/g access point

Tiny wireless access pointTired of those huge ugly access points taking up the precious space? MeshCube is a 7x5x7 cm transparent access point supporting 3 wireless technologies as well as 100 Mbps Ethernet. 200 pounds is a bit on expensive side, though.


13
Jun 04

.NET RS232 Serial Port communication with RS232.dll

A lot of people are coming to this site searching for .NET Serial communications on Google. And while Paul Wilson made it known that System.IO.Ports.SerialPort will arrive in .NET Framework 2.0, that fact is not really useful to you if your project is due next week.

.NET Serial CommunicationJonathan Travers from Berkshire, England, is an experienced engineer, who just recently started playing with .NET and, according to his site, is impressed with Linux OS. He publishes and sells the RS232.dll .NET library for serial port communication (via C# or any other .NET-supported language), and the current price is 10 British pounds, which is pretty much a giveaway. My employer got a copy of the DLL, and so far it’s been probably the easiest tool for RS232 communication.

Download Jonathan’s help file, which he distributes for free. The instructions include adding the RS232Comms component to the Toolbox in Visual Studio, but apparently the example works only under Visual Studio .NET 2003 and higher as I have been unable to make an addition to my toolbox in the original Visual Studio .NET. Nevertheless, adding a DLL to the application is easy, and in older version of VS you just need to create a reference.

The objects reside in RS232 namespace, and you can specify the COM port number, baudrate, parity, stopbit, data bits, flow control settings and timeout value for the port. After initializing the port and setting all the parameters for the object, calling OpenComms() opens the serial port. WriteChar, WriteByte, WriteBlock(byte[]) and WriteBlock(string) account for majority of the data you’d want to send to the COM port, while everything that’s received can be handled in public event DataReceivedHandler DataRxEvent. The receiving part is completely event-driven, so no need to set up the timers and implement polling for the RS232 data, which can sometimes result in buffering errors and subsequent data loss.

public event CTS_EventHandler CTS_Event and public event CTS_EventHandler DSR_Event are there as well, but for my project I did not need them. Logging is enabled, so after discovering some errors that need debugging you can pull the data out of the ArrayList (which is really nothing more but a bunch of log strings):

ArrayList opencom = com1.GetPortOpenLog();