Thursday, January 25, 2007

3442.aspx

Apple's FairPlay DRM declared illegal in Norway

The Consumer Ombudsman in Norway has ruled the Apple's Digital Rights Management system, FairPlay, illegal as only iPods can play songs bought on iTunes:



"It doesn't get any clearer than this. Fairplay is an illegal lock-in technology whose main purpose is to lock the consumers to the total package provided by Apple by blocking interoperability," Waterhouse told OUT-LAW.COM. "For all practical purposes this means that iTunes Music Store is trying to kill off one the most important building blocks in a well functioning digital society, interoperability, in order to boost its own profits."

"iTunes Music Store must remove its illegal lock-in technology or appear in court," he said. "As of right now we're heading for a big breakthrough that will hopefully pave the way for consumers everywhere to regain control of music they legally purchase."


The Consumer Council believes Apple has only three options: it can license Fairplay to any manufacturer that wants iTunes songs to play on its machines; it can co-develop an open standard with other companies; or it can abandon DRM altogether.


Sometimes I am proud of being Norwegian...

Tuesday, January 16, 2007

3355.aspx

Using regular expressions in SQL Server

Regular Expressions are very powerful when working with text, and in my case when detecting blog spam. I didn't feel like modifying .TEXT so I modified the DB to match comments against a list of "bad words". I replaced MT Blacklist with regular expressions after it went offline


The user function below matches a string against a regular expression. It works in all flavors of SQL Server that I have tried it on (SQL Server 2000 MSDE, SQL Server 2005 standard, Express and Express with Advanced Services). It has caught more than 12.800 spam comments since it went online :-) But more on the anti spam later, this is the function:


CREATE FUNCTION evalRegEx


 (


   @source varchar(5000),


   @regexp varchar(1000),


   @ignorecase bit = 0


 )


RETURNS bit


AS


 BEGIN


  DECLARE @hr integer


  DECLARE @objRegExp integer


  DECLARE @objMatches integer


  DECLARE @objMatch integer


  DECLARE @count integer


  DECLARE @results bit


 


  SET @results = 0


 


  EXEC @hr = sp_OACreate 'VBScript.RegExp', @objRegExp OUTPUT


  IF @hr = 0 BEGIN


    EXEC @hr = sp_OASetProperty @objRegExp, 'Pattern', @regexp


      IF @hr = 0 BEGIN


      EXEC @hr = sp_OASetProperty @objRegExp, 'Global', false


      IF @hr = 0 BEGIN


        EXEC @hr = sp_OASetProperty @objRegExp, 'IgnoreCase', @ignorecase


        IF @hr = 0 BEGIN


          EXEC @hr = sp_OAMethod @objRegExp, 'Test', @results OUTPUT, @source         


        END


      END   


    END


    EXEC @hr = sp_OADestroy @objRegExp


 END


 RETURN @results


 END



Example calls:



  • SELECT dbo.evalRegEx( 'this is a test',  'IS',  0)
    Returns 0

  • SELECT dbo.evalRegEx( 'this is a test',  'IS',  1)

  • Returns 1

 

Tuesday, January 9, 2007

3328.aspx

My Lego NXT progress and the iRobot Create

Once in a while I find projects like the Lego NXT Segway that makes me feel sorry for hardly using my Lego NXT.


The serious bots don't use the official Lego Mindstorms NXT graphical development environment but lower level tools like NBC (Next Byte Codes & Not eXactly C) for improved performance and added features like multithreading. But while coding in "C" makes it possible to make advanced bots it completely locks out my young kids. They are better at using the computer than my parents but they still have a long way before they start messing with threads… So, I have decided to put the "advanced" bots on the shelf for a while and have fun with the kids building basic bots instead. They love Lego and it is a great satisfaction to see something you have built move around autonomously.


If you think 250 euro is too much to spend on a toy, why not consider the iRobot Create. It is considerably cheaper and it can do something useful [via Bordoni]


BTW: remember to update the Lego Mindstorms software and Firmware if you have one. There are  new features like the "mini" building blocks that save memory.

3326.aspx

The Architect and its destiny

My ex boss, Maurizio Cunico, has written an article on MSDN on the role of the architect (in Italian).


I agree with most of the points in the article but I think there is one aspect missing; teamwork. The article describes a "one man show" scenario where the Software Architect does everything. Being humble, as Maurizio mentions, also means realizing that you have limitations and have to actively seek input from the people you work with to produce the best possible solution for the client.


You sometimes have to be a Jack of all trades if you work on small projects but I don't think it is a good idea on complex projects. I have seen many examples in the past where the "Jack of all trades" architect produced brilliant architectures on paper that had major problems when deployed in the real world (scalability, security, load balancing, ...). Working side by side with the systems architect that has to deploy and mange the software is a must if you develop large/complex on line systems.


I agree that the architect does not necessarily have to code, but the architect should help the members of the team grow, not only take care of the architecture.


What do you think?

Monday, January 8, 2007

3322.aspx

Ant Colony Algorithm

This article on DrDobbs is well worth the read:  Ant Colony Algorithms.


Ant systems are usually used to solve traveling salesman problems. The ant algorithm mimic the behavior of ants in the real world to find a close to optimal solution fast without spending forever evaluation of all possible solutions. Wikipedia describes the algorithm better than I ever could:



In the real world, ants (initially) wander randomly, and upon finding food return to their colony while laying down pheromone trails. If other ants find such a path, they are likely not to keep travelling at random, but to instead follow the trail, returning and reinforcing it if they eventually find food (see Ant communication and behavior).


Over time, however, the pheromone trail starts to evaporate, thus reducing its attractive strength. The more time it takes for an ant to travel down the path and back again, the more time the pheromones have to evaporate. A short path, by comparison, gets marched over faster, and thus the pheromone density remains high as it is laid on the path as fast as it can evaporate. Pheromone evaporation has also the advantage of avoiding the convergence to a locally optimal solution. If there were no evaporation at all, the paths chosen by the first ants would tend to be excessively attractive to the following ones. In that case, the exploration of the solution space would be constrained.


The ant algorithm gives good results fast and have one big advantage over “similar“ methods like genetic algorithms; they can be run continuously so it will adapt to changes in real time. An obstacle like a traffic jam would quickly lead the ants to take a different road.


Don't you just love algorithms? There is always something new to learn that opens your mind to different ways of doing things.