Thursday, September 29, 2011

Create Header Row in Excel 2007

Every time I need to do this, I always have to look it up. I have the memory retention of a scratched CD. I paste something into Excel, I need to srot it, and I don't wnat the column headers to be included in teh sort. I figured since I'm stupid and have to look it up every time, there are probably a lot of other people who have to look it up to, so I'm posting it here:

View tab --> Freeze Panes --> Freeze Top Row

Baaaaaa-BAM!

As an aside, hey Microsoft, how about you put it in the right click menu? You know, I select the row, right click, and right there for all to see is an option Make Header Row.

After over a decade of Excel you'd think they could make this easier.

Tuesday, April 06, 2010

ASP: Determining Variable Types with TypeName Function

If you've been working in ASP for any length of time, you know you don't have to type variables. You just declare them using the DIM statement. Heck, you don't even have to declare them if you don't want to (but I don't recommend it).

But what if you're perofmring some sort of calculation on a variable, or you're doing some sort of boolean check after manupulating it or getting a value from a database? Or you want to put it into a database field that's been typed and you don't know if it matches and you need to convert it first?

Well here's a handy function you can use to determine what type of varient the actual value of the variable is: TypeName()

It works like this:
var = 1
Reponse.write TypeName(var)
In this case, the output would be
Integer
I've found this to be especially handy when dealing with values being returned from a database or when validating variable type to prevent an SQL injection attack.

Let's say I'm using a QueryString variable to pass a record id to a page, and then I use that id to pull a record from the database. So my URL might look like:
http://www.MySite.com/results.asp?rid=223
In this case I can validate it by
intRecordID = Request.QueryString("rid")
If TypeName(intRecordID) = Integer Then....
It's also handy when telling the differnece between NULL and an Empty String. Anyone who's done development knows that just because there's nothing in the variable doen't mean it's actually empty, since NULL and Empty are treated differently.
If TypeName(TheVar) = Empty then...
or
If TypeName(TheVar) = NULL Then...
Handy, especially whn doing some sort of conditional aggregate of data from a database pull where you're combining things.

Here's a list of all the different types than can come back:

Empty
Null
Integer
Long Integer
Single
Double
Currency
Date String
Object
Eror
Boolean
Variant
Byte
Array

Wednesday, March 31, 2010

Don't be a Programmer

My advice as a software engineer since 1999: Get out of programming as fast as you can. Go into Server Admin or Network Security.

Programmers are the ditch diggers of IT. In my experience, at least working in the large corporation world, they are treated like crap, constantly saddled with unrealistic expectations and time lines, and inevitably take direction from someone who has absolutely no experience or knowledge of programming. Even if your immediate manager is a Good Guy, his boss won't be, or his boss.... point being sooner or later as you go up the chain you run into that guy who thinks all programmers are liars and are way overpaid, and everything is easy and should only take 1 day. And testing? We don't have time to test! We need to DELIVER!

Sales people will promise the clients anything to get the sale, then dump it in your lap, take their fat commission, and go on vacation, leaving you to eat the shit sandwich they just made.

Customers will want more more more faster faster faster and, since they write the checks, that's what you'll have to produce. Scope creep? More like scope sprint. And forget about getting extra time. You don't need extra time! It's just a few additional features. How hard can it be?

You'll bust your ass for 8 months to build an in-house accounting system that saves the company 3 million a year and your bonus will be a shitty free breakfast with the CEO. And then the programmers start disappearing because guess what? The system is built and we don't need all those programmers any more!

That's right, programmers are the first to go. They're over paid and no one understands what they do anyway. Beside, you only need carpenters when you're building the house. Once the house is built....

But guess what. The Network still has to Network and be secure, and the Servers need to Server.....

So bail on programming NOW, before it's too late.

If you absolutely, positively are convinced things will be different for you (and they won't) and you want to stick it out, got for a hybrid like database development/admin. You can do database development and design to satisfy your desire to create, but when there's no development to do and all the programmers are getting fired, they'll still need a DBA to keep the Database up and running....