Monday, November 24, 2008

Gmail has themes


Gmail finally offers themes for its' web-based Gmail users. That's pretty stinking cool if you ask me.

It's just too bad I use Outlook to pull my Gmail. But....just for fun, I changed my Gmail theme to terminal
<--------------
but, realizing that my eyes couldn't take too much of it, I switched back to something else.

Pretty awesome, google.

Thursday, November 20, 2008

ForEach loop in SQL

Have you ever needed to do a ForEach loop in MSSQL? Ever wanted to be able to loop through all results of a query and perform an action? No? I needed to the other day, and it was a PAIN to figure out. So, once I did, I figured I need to document it for others who may be just as stumped.

Before I explain what I found, a quick background of the problem and the structure of the DB would be helpful.

Customer A wants to update each Contract's Remarks field with the combined remarks from all the Contract's Equipment location.

Here's the problem. Each Contract table is linked to a ContractDetails table (one to many). Each ContractDetails table is linked to the Equipments table (one to one). Since a basic update statement with an inner join only updates the contracts based on the first result of the equipment, that won't work. We could potentially have hundreds of equipments tied to each contract.


DECLARE @ContractID INT
DECLARE @Equip Varchar (500)
DECLARE @Location VARCHAR (1024)

DECLARE cur CURSOR FOR
select cd.ContractID, e.equipmentnumber, isnull(e.Location, '')[equipment location]
from contractdetails cd
inner join equipments e on cd.equipmentid = e.equipmentid
order by cd.ContractID

OPEN cur

FETCH NEXT FROM cur INTO @ContractID, @equip, @Location
WHILE @@FETCH_STATUS = 0
BEGIN
IF @Location <> ''
UPDATE Contracts SET Remarks = LEFT(Remarks + char(13) + char(10) + 'Equipment number ' + @Equip + ' is located at ' + @Location + '.', 1024)
WHERE ContractID = @ContractID

FETCH NEXT FROM cur INTO @ContractID, @equip, @Location
END

close cur
deallocate cur


We needed to declare a cursor. The cursor is a collection of results from the select statement (in this case: select cd.ContractID, e.equipmentnumber, isnull(e.Location, '')[equipment location]
from contractdetails cd
inner join equipments e on cd.equipmentid = e.equipmentid
order by cd.ContractID). Once that was done, we open the cur, and Fetch each of the results, one by one, peforming the action (in our case, the update statement) for each result.

Sunday, November 16, 2008

The HTPC Project

For that last little while, I'd been tossing around the idea of building an HTPC (Home Theater PC). The reasons for building one were fairly simple:
  • Eventually, if built correctly, it can take the place of my $13/month DVR from Comcast
  • Expandability (I'll expound)
  • It's a geek project
So, being the cheapskate I am, I watched auctions, and waited. And waited. Finally, I found a great auction on eBay for a barebone ASUS PC. The guy had listed it by it's specific model number, which makes it hard to search for. I ended up winning this computer (brand new case, motherboard, and PSU) for $35 after shipping.

Once I got that, I added these components:
  • Hauppauge HVR-1600 TV Tuner
  • Hitachi 500GB SATA HD for media (I have a 120GB SATA drive for the OS and programs)
  • AMD BE-2400 2.3Ghz X2 45W Processor
  • ASUS HD3450 HDMI Video Card
  • 2GB PQi PC2-4200 RAM
  • and an old 16x DVD-RW I had lying around
So, it's a pretty good setup, for not a lot of $$$.

The next decision was what OS to use. From various Microsoft trials and things I'd done, I had 64-bit and 32-bit Vista Ultimate, as well as XP Media Center Edition 2005. Add to that the tons of flavors of free OS's out there specifically for this purchase (MythTV, SageTV, etc).

Due to my relative inexperience with Linux (I'm learning it as we speak), as well as my desire to do more than simple TV Capture with this box (you can see that my specs dwarf the MythTV requirements) ruled out Linux and all his relatives.

Then, because I didn't want (or need) the overhead of Vista on this machine, I decided to stick with XP MCE.

Once that was setup, it was pretty simple to set the Media Center portion up. A lot of pointing and clicking and letting Windows do it's thing finding the channels based on my zip code and so forth.

In addition, I decided to not hook the PC straight into my TV via HDMI. This was partly decided by the fact that the video card was bad and needed to be RMA'd (thank heavens Newegg has the world's best customer service...I highly recommend them for all computer needs), partly decided because I didn't feel the need to shell out the cash for an HDMI switcher and more cables, and mostly decided by the fact that I already have an XBox 360 that can serve as a MCE extender, eliminating the need to fiddle with an IR and blaster, as well as allowing me to keep the HTPC in my office.

I also am using the HTPC as a media streaming device. Orb, a free piece of software, allows me to stream my media to anywhere, as long as I have the internet, with ease. Install it, tell it where to find my media and what I want to share. Then, set up usernames and passwords for anyone I want to have access to it.
Then, simply browse to http://mycast.orb.com/, enter the username and password, and decide if I want to look at pictures, listen to my music, or watch shows (if the tuner is supported). This is especially cool for me, as I'm about to start traveling more for work, and really don't want to have to dump all 60GB+ of my music onto my laptop. The downside? If your upload speeds suck...so does your streaming experience.

So, as I've been playing, I've found things I like, and things I don't. I still haven't found a good way to stream non-Windows standard video types (such as xVids or non-standard AVI's) to the 360.

I like the media remote for the 360. It's got most everything you need and works really well.

So, for those out there are already using it, what toys or programs are you using, and what do you like about it?

Friday, November 14, 2008

The Beginning

So I've come to grips with the fact that I'm a tech-geek. I like to get my hands on the latest gadgets. I like to learn new stuff about those gadgets. And you know what? I'm okay with that.

So, rather than boring those that read my family blog with details of the latest trick I learned with SQL scripting, or the cool thing I did with my HTPC, I'll post them here. That way, those that care can check it out, and those that don't....well...they don't have to be bored. Besides, lets be honest, there's a lot of people that don't even know what an HTPC is, let alone understand the specs that I'm running on it.

So that said, yes I am a geek, and I'm okay with it!