Access Email Domain Query

Working for an email database company, I spend quite a bit of time using Microsoft Access and over the past three years I’ve learned quite a few useful tricks. One such query I run from time to time is stripping out the domain for an email address. Lets say you have a field in Microsoft Access called EMAIL and you want to strip the domain out from that, you could run the following query:

SELECT EMAIL, Right([EMAIL],Len([EMAIL])-InStr([EMAIL],"@")) as Domain
FROM TableName

That’s it, pretty simple. Read up on the Right() function here. In our case, the first parameter in the function will be the [EMAIL] field. The second parameter is doing two things, first we take the length of the [EMAIL] string by calling the Len() function and then subtract the position of the “@” sign in the email address.
So, for user@hotmail.com the query would literally translate as follows:

  • Right(“user@hotmail.com”, Len(“user@hotmail.com”)-InStr(“user@hotmail.com”,”@”))
  • Right(“user@hotmail.com”,16-5)
  • Right(“user@hotmail.com,11)
  • hotmail.com (hotmail.com is returned because they are the 11 rightmost characters in “user@hotmail.com”)
Advertisements

Dell 2007WFP (sweeeeeet…)

Well, it’s been a long time coming but I finally have a computer monitor that fits me perfectly. I’ve had a 17″ normal CRT monitor since my college days (it’s somewhere around 4-5 years old) and while there is nothing wrong with it… I had no clue what I was missing. The 2007WFP boasts a 20″ wide-screen and has a native resolution of 1680X1050. I’m telling you, my desktop never looked so damn sexy. My 17″ monitor I normally run at 1280X1024, the new 2007WFP is about a 35% increase in desktop space. That may not seem like much, but looking at my two monitors side-by-side, there is no comparison. In fact, now when I look at my 17″ CRT the thing looks slightly blurred and I wonder how I ever used the thing. Typical users (and by typical I mean old people who can’t read small text) of a 17″ monitor probably have a 1024X768, now in their case the increase in desktop space is more than double.

First thing’s first, don’t buy a monitor from Dell unless they are offering discounts or you have a coupon. Dell regularly has sales on their website and if you are in the market for a monitor, wait until Dell has theirs on sale. My monitor was ordered on a Tuesday night (at about 11pm), so I figured my order would take a day or two to ship, and I didn’t pay extra, so the Dell website said 3-5 business days for shipping. To my astonishment the delivery man was knocking on my door Thursday at about 5:30pm. I didn’t expect it until the weekend or beginning of the following week, so that was a great surprise. Anyways, I’ll tell the rest of the story with some pictures (unfortunately they were taken on my old 2 megapixel digital camera).

Inside the box:

The stand on top:

After taking the stand out:

Oh yes Dell, you know how to excite a geek:

After following the very complicated instructions:

*Drool:

The ol’ CRT gets a new home:

Yes, I’m a computer geek:

Unfortunately my camera does not do the monitor justice, it is bright, sharp and damn sexy. In fact right now (I started this post a week ago and never got around to finishing it) I’m no longer using my CRT, I connect to my laptop via RealVNC. Oh, I should mention that the monitor does support more than one input method (VGA, S-Video, Composite, and DVI-D), but I’d rather not have to hit the switch input button everytime I want to look at my laptop. I was a little bit hesitant about choosing this monitor, but I don’t have a single complaint, I can never go back to old clunky CRTs.

And now I have all this space:

Simple AJAX

For those of you that don’t know what AJAX is, you probably want to skip right over this. Anyone else who has heard of AJAX, or maybe is a little overwhelmed by how to use it, let me see if I can make your life easier. I recently wanted to implement some AJAX coding on a website, but I was a little bit annoyed at how the XMLHttpRequest implementation worked. It didn’t really provide me with the flexibility I wanted and frankly, was overkill for what I was doing.

Let us say that you have code somewhere on a webpage that does a query to a datasource based on a URL variable (my examples are in Cold Fusion, but you should get the idea). The below could be a section of code on any page.

home.cfm
<cfif isDefined("URL.variable")>
<cfquery name="exampleQuery">
SELECT *
FROM table
WHERE field = #URL.variable#
</cfquery>
<cfoutput query="
exampleQuery">
#exampleQuery.field1#
#exampleQuery.field2#
...
</cfoutput>
</cfif>

The flaw in this design is that in order to pull new information from your datasource, you need to wait for the entire webpage to reload. One of the advantages in using an AJAX-like framework is that you reload only what you need to. Let’s look at the above code and see how we can improve page performance by only reloading the section of code above. The first thing to do is remove the code that pulls the information and displays it and place it in a new page and between a <div> tag. So the code above could be removed from home.cfm and placed in a new page:

getData.cfm
<div id="QueryResult">

</div>

After moving this data we need a placeholder where the data will be dynamically inserted back in.

home.cfm
<div id="QueryContent"></div>

The trick to getting the browser to request the data and reload it involves a bit of javascript and the use of an <iframe> which the user cannot see. The javascript sends a request to the hidden <iframe> and then a little more javascript updates the content on home.cfm. First, let's add the <iframe> and javascript.

home.cfm
<script type="text/javascript">
function getData(urlVar){
document.getElementById('hiddenFrame').src = 'getData.cfm?variable=' +
urlVar;
}
</script>
<iframe name="hiddenFrame" id="hiddenFrame" src="" width="0" height="0" frameborder="0"></iframe>
<div id="QueryContent"></div>

The function above points the hidden <iframe> to the page we created which gets the data we need and displays it to the user. The final and most important step is to add some script to the page which retreives our data.

getData.cfm
<script type="text/javascript">
function UpdateParent(parentContent, content){
var pd = parent.document;
pd.getElementById(parentContent).innerHTML = document.getElementById(content).innerHTML;
}
</script>
<div id="QueryResult">

</div>
<script type="text/javascript">
UpdateParent('QueryContent','QueryResult');
</script>

The javascript above in UpdateParent is rather simple and just swaps out the content between the <div> tag hidden in the <iframe> and the <div> tag on home.cfm. What is really happening is the hidden <iframe> is doing all the work, then the javascript at the bottom of getData.cfm simply updates the home.cfm page which the user is viewing. The final step would be to replace your links with the javascript call on home.cfm. For example, instead of <a href="home.cfm?variable=1">Load Data 1</a> you would have <a href="javascript:getData('1');">Load Data 1</a>

It should be mentioned that this is not true AJAX as it does not present you with any status as to the current state of your request (ie if the query has finished, or is still running). Also, when debugging you will have to change the <iframe> to a visible height and width so you can see any error messages. Unless you are loading a incredibly large amount of data, this method should work just fine. When the user clicks the link, their browser will still display an animated icon indicating that data is being loaded. I have found that I am able to drastically increase performance by using this method and it provides me with a great deal of flexibility. Your getData.cfm page could be a template that you simply populate based on a query, which ultimately saves time waiting for pages to reload. The faster our users get what they want, they happier they are.

Why the Wii?

Remember the Power Glove for Nintendo? No?! Well for those of you that don’t, it looked something like this:

It was for Nintendo… and it totally sucked. My brother and I got this elaborate piece of crap most likely after begging our parents to buy it. Although it was a long time ago, I remember waving my hand around trying to get Mario to jump and becoming incredibly frustrated by his non-responsive diet-needing ass. Was it Mario’s fault? Of course not, perhaps it was due to the fact that you had to be wired like Robocop to get the damn thing to work. That flashy ad above is great and all, but look at this thing:

“The glove was somewhat difficult to use; in order for the glove to register with the ultrasonic sensors, one had to keep their knuckles pointing at them at all times. In addition, since each finger had 4 positions, it is difficult to have disparate fingers in different positions simultaneously. Thus, while it was possible to control 16 different states simultaneously, most people have difficulty keeping the ring and index fingers straight, while bending the middle finger. [-wikipedia]” Somewhat difficult to use? Somewhat… try impossible. Unless you are a master finger pupeteer you ain’t getting shit done with this thing.

Now Nintendo has been hard at work developing the Wii. Anyone who has heard about the Wii knows about it’s unique motion-sensitive remote. Umm… is it just me or is this thing the Power Glove all over again? Sure technology has come a long way and it’s wireless, but that doesn’t eliminate the fact that motion-sensing remotes aren’t for traditional console gaming. I really cannot see how this remote is going to make a game that much more fun. I’m sorry Nintendo, but do you really expect me to stand up in front of my TV and play virtual paintbrush or a thrilling round of golf with that thing? Just think, you too can look almost as cool as these kids:

The remote will appeal to kids between the ages of 5-11… anyone older than that… I have a hard time believing they will be standing in front of their TV for hours on end battling through Red Steel trying to make themselves think they really have a sword in their hands. However, I have yet to actually try the Wii’s remote, so I’m mostly speculating here… it is Nintendo after all, hopefully the Wii’s remote won’t suck as bad as the Power Glove.

Prey Demo

I’ve been reading for weeks about people becoming frustrated waiting for the Prey demo to be released for XBox 360. Well alas, as one of my favorite sites, XBox 360 Fanboy pointed out… the demo has been released. It’s 1.17 GB’s and the title (PREY Singleplayer and Multipla…) leads me to believe the demo will include multiplayer, which should result in quite a bit of playtime. Enjoy the holiday weekend in multiplayer mode.

Vista Beta 2

In case you live in a cave somewhere and hadn't heard yet, Microsoft recently released a beta of Windows Vista to the public. Of course I immediately went to the Vista website and downloaded the 3.2 GB ISO. Being the first few hours that it was out, I figured the Microsoft servers were probably being overwhelmed as it took me a while to get the download running smoothly. The next morning my download was complete and I burned a DVD+RW of the ISO and proceeded to install the OS. My first attempt to install Vista was on an extra external USB drive I had sitting around that I don't really use. I wasn't sure if it would work as my computer did support booting an external drive, but it was a beta version after all.

Sure enough installing to the external USB drive didn't work out, so I installed it on my second internal hard drive. The install went smoothly after that and I am currently writing this blog from Windows Vista. To be safe I left Windows XP on my machine and now am successfully dual-booting (Lifehacker has a good tutorial on how to install Vista as a dual-boot). Although I've been running Vista for about a week I haven't expierenced any major issues. The only hiccup occured after Vista installed, I had to get my CD for the drivers to my wireless network card. The flashy appearance of Vista is appealing, but it's certainly nothing to get overly-excited about in my opinion.

So far my favorite thing about Vista is Media Player 11, but you can download that (also in beta) for XP on Microsoft's website. I've never really been too big a fan of Windows Media Player due to the fact that I don't like how it arranges my music in Media Player itself as well as on my hard drive, but I think they got it right this time. The Artist or Album view is great:

For those of you who aren't nerdy enough to know about Vista or have seen the screenshots that are nearly everywhere, check out this website for some screencasts.

And to prove I'm not the only geek out there, the Vista download that was made available to the public was 'the biggest software download in history'. In fact, if you check out Alexa.com, windowsvista.com has a 200,000% increase. That is absurd, see for yourself:

The Beauty of RSS

I may never need to go to another website again (OK, so that's exaggerating). RSS is quickly changing the way in which the web can be navigated and how quickly people can be informed. For those people like myself who have an above average knowledge of internet-related technology, we already know and use RSS on a daily basis. But for those of you who are still in the dark, let me see if I can help clarify what it is and why it is so freggin' wonderful.

RSS stands for really simple syndication. If a site has an RSS 'feed' you can use certain programs or web applications to subscribe to those feeds. If you look closely on many of your favorite websites, you will see a link that says RSS or XML, or perhaps notice one of these images: This indicates that the site (or section of the site you are reading) has an RSS feed. You may say, so what? Well, let me explain…

Like the nerd I am I always must have the latest and greatest software, so I recently downloaded Microsoft Office 2007 Beta 2. Outlook 2007 supports subscribing to RSS Feeds which has really changed the way I get news from websites. To the right is the RSS section of my Navigation Pane in Outlook 2007. As you can see I have added numerous sites which I frequently visit. What this means is when a site posts a new article or gets updated, it appears as a new message in one of my RSS folders (or wherever you specifiy). What this means is I spend less and less time navigating to my favorite sites to see if they have recently been updated.

Outlook 2007 is still in Beta after all and isn't running 100% smoothly so I suggest you try using your own program. There are many other alternatives to reading RSS feeds, some are standalone applications that run as a program on your computer while others are web-based. Here is some guy that lists a bunch of 'em. In each program or website there will be a simple way to add the RSS or XML links from your favorite sites.

Want to know more? Click here to get another really good overview of RSS.

*You can even create your own feeds now without being too big a nerd. Feedburner lets users create their own RSS feeds and spares them the technical detail of writing XML.