So apparently, there are a lot of folks out there that are trying to make a profit on the new XBOX 360. While the fact that 10% of all XBOXes sold in the first few weeks were somehow resold on eBay for a profit, I was surprised to see the linked article (click the title) that accused a local portland oregon store of a major retailer of playing bait and switch tactics.
The new XBOX seems so popular that even one of my favorite 'deals' sites - Ben's Bargains has opened his own site just to track XBOX inventory. Check it out at XBOX 360 Tracker.
Personally, I just don't understand the allure. Maybe because I am not a gamer. If I do indeed buy one (which, unless it is given to me, I won't), I would wait a few months to the point at least which it could be had for the sticker price - surely not a 150% premium!
Monday, December 05, 2005
Yonah's SQL Tip #4 - SOUNDEX and DIFFERENCE
What if your boss turned to you this week and asked you to write a simple search that looked up a contact in a database table by first or last name. On the surface it sounds easy. If your last name field was called
Seems simple enough, but not without problems. Take my last name - Wolf - for example. Let's say you knew what my last name was, but you didn't know how it was spelled - so it could be Wolf, Wolfe, Wolff, Woolf, etc. The above query would require me to try every possible spelling to find a result. So maybe as a precaution, you would try to match the beginning of the word using like:
This would do a little better, but it has two major shortcomings - It will exclude names that should be included like Woolf, for example, and will include names that shouldn't like Wolfish or Wolfson. Of course, my last name is a limited example. If we were searching for, say, Smith, searching under
Fortunately, there are two SQL functions that can help in this endeavour:
This query will give us the desired effect of matching similarly sounding names with different spellings without excluding most spellings and without including different names.
What this query does is it will find names that are not quite 'Wolf', but closely related and then rank them in order of closeness (i.e. it will match, Wolf, Wolfe, and Wolfson and they will be ranked in that order respectively).
So the next time you're in a matching bind, give
LAST_NAME your query might look like this
SELECT *
FROM CONTACTS
WHERE LAST_NAME='theName'
Seems simple enough, but not without problems. Take my last name - Wolf - for example. Let's say you knew what my last name was, but you didn't know how it was spelled - so it could be Wolf, Wolfe, Wolff, Woolf, etc. The above query would require me to try every possible spelling to find a result. So maybe as a precaution, you would try to match the beginning of the word using like:
SELECT *
FROM CONTACTS
WHERE LAST_NAME like 'wolf%'
This would do a little better, but it has two major shortcomings - It will exclude names that should be included like Woolf, for example, and will include names that shouldn't like Wolfish or Wolfson. Of course, my last name is a limited example. If we were searching for, say, Smith, searching under
Smith will also return Smithson but not alternative spellings of Smith, such as Smythe.Fortunately, there are two SQL functions that can help in this endeavour:
SOUNDEX and DIFFERENCE.SOUNDEX takes a string as an argument and returns a value that is based on the way that the string sounds (I am not 100% how this is caluculated, but it still seems to work). So re-writing our earlier query:
SELECT *
FROM CONTACTS
WHERE SOUNDEX(LAST_NAME)=SOUNDEX('WOLF') This query will give us the desired effect of matching similarly sounding names with different spellings without excluding most spellings and without including different names.
DIFFERENCE takes this one step further. It essentially takes two strings as arguments and then returns the difference of their SOUNDEX values. The difference is between 0-4, with 4 being the closest match. Using difference we can re-write the query one more time, expanding our horizons to include not-so-exact matches, but also ranking them by closeness:
SELECT *,DIFFERENCE(LAST_NAME) as RANK
FROM CONTACTS
WHERE DIFFERENCE(LAST_NAME,'WOLF')>=3
ORDER BY DIFFERENCE(LAST_NAME) DESC
What this query does is it will find names that are not quite 'Wolf', but closely related and then rank them in order of closeness (i.e. it will match, Wolf, Wolfe, and Wolfson and they will be ranked in that order respectively).
So the next time you're in a matching bind, give
DIFFERENCE and SOUNDEXa try.
Wednesday, November 30, 2005
Sometimes my predictions do come true...
The FCC’s ruling earlier this week to allow for the purchase of individual cable channels is the beginning of something that I have been predicting for a while, the unbundling of broadband access from the applications that run over it. This is the first step in basically allowing us, the consumers, a choice of broadband providers that is different and independent of the choice of the application and service providers that provide us services over the IP network.
To better illustrate this, imagine if you will, that your local gas company not only charged you for the gas provided to your home, but also dictated how high you could turn your oven, or which specific cycles you could use with your dryer. Sound crazy, no? But this is exactly what the phone and cable companies do – they charge you for both the delivery mechanism (either dial tone or cable service) and then dictate how you can use those services (in fact, it was only about 25 years ago, that the phone company began to even let you plug in your own phone into the wall jack). So far, Voice over IP (VoIP) has shown us how we don’t need the phone company to provide us with phone service. In fact, I can even get cable and/or DSL service and cut out the local phone company altogether. As phone, cable, and software companies roll-out IPTV services, it is not easy to see how the cable and phone companies are at a crossroads.
Before long, as long as I have IP service at home, I can shop online for phone service, TV and video content, and a bunch of other things that we haven’t thought of yet.
Critics (read: cable companies and broadcasters) of the plan indicate that this will kill independent channels that will not have enough audience to stay afloat. As a consumer who has no need for, say, five discovery channels, I say: a) Why should I subsidize them? and b) Who cares? While I do think that this will kill some small independent channels, I don’t think it will do too much damage to the TV production industry – because on demand will change the way we think about TV. The reason we need channels right now is because we haven’t mass-marketed the technology to deliver on-demand TV and Video. We need five discovery channels because someone might want to watch 8 hours of The Crocodile Hunter while another wants to watch American Chopper. But with on-demand, there is no need for channels, so long as the video is on a server out there and my TV has a way of downloading it. Because programming an entire schedule isn’t necessary, there is no need for broadcasting one – all we need is a good search engine for video, and a credit card account (Oh, so that’s why Google created Google Video ().
Let’s hope that the FCC wins this one, and our living rooms finally catch up to our server rooms as far as technology is concerned.
To better illustrate this, imagine if you will, that your local gas company not only charged you for the gas provided to your home, but also dictated how high you could turn your oven, or which specific cycles you could use with your dryer. Sound crazy, no? But this is exactly what the phone and cable companies do – they charge you for both the delivery mechanism (either dial tone or cable service) and then dictate how you can use those services (in fact, it was only about 25 years ago, that the phone company began to even let you plug in your own phone into the wall jack). So far, Voice over IP (VoIP) has shown us how we don’t need the phone company to provide us with phone service. In fact, I can even get cable and/or DSL service and cut out the local phone company altogether. As phone, cable, and software companies roll-out IPTV services, it is not easy to see how the cable and phone companies are at a crossroads.
Before long, as long as I have IP service at home, I can shop online for phone service, TV and video content, and a bunch of other things that we haven’t thought of yet.
Critics (read: cable companies and broadcasters) of the plan indicate that this will kill independent channels that will not have enough audience to stay afloat. As a consumer who has no need for, say, five discovery channels, I say: a) Why should I subsidize them? and b) Who cares? While I do think that this will kill some small independent channels, I don’t think it will do too much damage to the TV production industry – because on demand will change the way we think about TV. The reason we need channels right now is because we haven’t mass-marketed the technology to deliver on-demand TV and Video. We need five discovery channels because someone might want to watch 8 hours of The Crocodile Hunter while another wants to watch American Chopper. But with on-demand, there is no need for channels, so long as the video is on a server out there and my TV has a way of downloading it. Because programming an entire schedule isn’t necessary, there is no need for broadcasting one – all we need is a good search engine for video, and a credit card account (Oh, so that’s why Google created Google Video ().
Let’s hope that the FCC wins this one, and our living rooms finally catch up to our server rooms as far as technology is concerned.
Trying to re-start this once more
Okay,
So after many false starts, I am trying to get my techology blog rolling again. Please bear with me as a port over my existing blog entries. I hope to actually get some Relevant posts up here soon.
So after many false starts, I am trying to get my techology blog rolling again. Please bear with me as a port over my existing blog entries. I hope to actually get some Relevant posts up here soon.
Wednesday, September 21, 2005
How to handle server-specific configuration settings in C#.Net
One of the biggest hassles I've ever had with deployment so far has been trying to ensure that I preserve the correct global variables for my application when I deploy my code from development to staging to production. The primary example being connection strings to the database.
In doing some research, I discovered that .Net allows you to create customized sections in your web.config, and then I came across this article on ToDotNet -http://todotnet.com/archive/2005/06/03/478.aspx.
The article explained how to create a custom XML handler and have it look at the URL to pick the correct connection strings.
Although it was written in VB.Net, it was very easy to port into C#, and I also added two small enhancements:
Below is my C# code. If you want to implement the full solution, look at the above article:
In doing some research, I discovered that .Net allows you to create customized sections in your web.config, and then I came across this article on ToDotNet -http://todotnet.com/archive/2005/06/03/478.aspx.
The article explained how to create a custom XML handler and have it look at the URL to pick the correct connection strings.
Although it was written in VB.Net, it was very easy to port into C#, and I also added two small enhancements:
- I added the ability to add a default section, just in case the server name doesn't match one of the other defined sections.
- I also had it include the name of the selected configuration, so that you can export it for debugging purposes - i.e. in case you are not sure which configuration is selected.
Below is my C# code. If you want to implement the full solution, look at the above article:
using System;
using System.Web;
using System.Xml;
using System.Configuration;
using System.Collections;
namespace ujci_v3
{
///
/// Summary description for ConfigHandler.
///
public class ConfigHandler:Hashtable,IConfigurationSectionHandler
{
///
/// For now, an empty constructor
///
public ConfigHandler()
{
}
///
/// This implements the Create interface of IConfigurationSectionHandler,
/// needed to be able to retreive the config info
/// from web.config
///
///
///
///
///
public object Create(object parent,object configContext,XmlNode section)
{
try
{
//Get the host name
string server=HttpContext.Current.Request.Url.Host;
XmlNodeList NodeSettings;
//Find the configuration for this hostname
NodeSettings=section.SelectNodes("configuration[contains(@url,'"+server+"')]/add");
//If no config is found, use the default.
//Also, add the 'Config' key to tell us which configuration is being used.
if(NodeSettings.Count==0)
{
NodeSettings=section.SelectNodes("configuration[contains(@url,'default')]/add");
this.Add("Config","default");
}
else
{
this.Add("Config",server);
}
foreach(XmlNode n in NodeSettings)
{
this.Add(n.Attributes.GetNamedItem("key").Value,n.Attributes.GetNamedItem("value").Value);
}
}
catch(Exception ex)
{
//If any error ocurrs, add the error message as part of the config, to help us debug.
this.Add("Error",ex.Message);
}
return this;
}
}
}
Subscribe to:
Posts (Atom)
