Archive

Archive for the ‘Misc’ Category

Getting Product and Version Information on SQL Server

June 17th, 2009 NothingMan No comments

 

SELECT SERVERPROPERTY('Edition') AS Edition,

       SERVERPROPERTY('ProductLevel') AS ProductLevel,

       SERVERPROPERTY('ProductVersion') AS ProductVersion

Edition

ProductLevel

ProductVersion

Enterprise Edition

SP2

9.00.3282.00

VN:F [1.9.1_1087]

Rating: 0.0/5 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Code, Misc, Tips Tags: , , ,

Obscure Timestamp DataType in SQL

June 15th, 2009 NothingMan No comments

In SQL Server, a Timestamp field helps to keep track of changes to a table in a Database.
To use it, you simply define a field without a name, and a data type of TIMESTAMP.
SQL Server automatically inserts an internal identifier into the column whenever a row is inserted or updated. To get the current value use ‘SELECT @@DBTS.

 

CREATE TABLE .t2

      (

      a int NULL,

      b int NULL,

      timestamp NULL

      )  ON [PRIMARY]

GO

COMMIT

 

 

 

insert into t

(a, b)

values (1, 2)

 

SELECT @@DBTS DBTS

DBTS

0x00000000000007E6

 

 

select * from t

a

b

timestamp

1

2

0x00000000000007E2

1

2

0x00000000000007E3

1

2

0x00000000000007E4

1

2

0x00000000000007E5

1

2

0x00000000000007E6

 

VN:F [1.9.1_1087]

Rating: 0.0/5 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: BI, Code, Misc, Tips Tags:

Google Geocoding in SSIS

May 20th, 2009 NothingMan 2 comments

I have an old YouTube tutorial on how to use Google Geocoding within SSIS, but I lost all the downloadable scripts.  I recently had a few people asking me if I could send them the scripts, so I deiceded to rewrite them.

Again, you can check out the YouTub video (it’s rough) for more details, just go to http://www.youtube.com/watch?v=HTSHzR-wSgc with this DISCLAIMER:  This code was just thrown together and is quite ugly and my microphone was terrible, I usually sound much better than that :-)  :-)

In a nutshell, I sniped about 18,000 golfcourses off the web with a PHP script and got basic course information for all of them, including the address information.  I wanted to use Google Maps to display these courses, so I thought I’d use Google Geocoding.  Caution, they don’t like it when you hit them 1000 times per second, so I would recommend using a Sleep command in your code like I did so you can throttle it without getting kicked off. 

So, I have an OLE Source task that reads from my database.  I created a Derived Column task to create placeholders for latitude, longitude, and level of accuracy.  I created a Script Component and selected street, city, state, and zip as input columns and added lat, long, and accuracy as read/write columns. 

Open the script editor, add a reference to System.Web, then create a new class called Google GeoCode, or whatever the heck you want to call it and paste in this code:

Option Strict Off

''' Might need this, might not

Imports System

Imports System.Data

Imports System.Math

Imports System.Net

Imports System.Web

Imports System.IO

Namespace GoogleGeoCoder

    Public Interface ISpatialCoordinate

        Property latitude() As Double

        Property longitude() As Double

    End Interface

    ''' <summary>   

    ''' Coordiate structure. Holds Latitude and Longitude.   

    ''' </summary>   

    Public Structure Coordinate

        Implements ISpatialCoordinate

 

        Private _latitude As Double

        Private _longitude As Double

 

        Public Sub New(ByVal lattitude As Double, ByVal longitude As Double)

            _latitude = lattitude

            _longitude = longitude

        End Sub

 

        Public Property latitude() As Double Implements ISpatialCoordinate.latitude

            Get

                Return _latitude

            End Get

            Set(ByVal value As Double)

                _latitude = value

            End Set

        End Property

 

        Public Property longitude() As Double Implements ISpatialCoordinate.longitude

            Get

                Return _longitude

            End Get

            Set(ByVal value As Double)

                _longitude = value

            End Set

        End Property

 

    End Structure

    Public Class GeoCode

        Const _googleUri As String = "http://maps.google.com/maps/geo?q="

        Const _googleKey As String = "yourgooglekeyhere"  ' get your own       

        Const _outputType As String = "csv"

        Private Shared Function GetGeoCodeUri(ByVal address As String) As Uri

            address = HttpUtility.UrlEncode(address)

            Return New Uri(String.Format("{0}{1}&output={2}&key={3}", _googleUri, address, _outputType, _googleKey))

        End Function

        ''' <summary>       

        ''' Gets a Coordinate from a address.       

        ''' </summary>       

        ''' <param name="address">An address.       

        ''' <remarks>       

        ''' <example>1600 Amphitheatre Parkway Mountain View, CA 94043</example>       

        ''' </remarks>       

        ''' </param>       

        ''' <returns>A spatial coordinate that contains the latitude and longitude of the address.</returns>       

        Public Shared Function GetCoordinates(ByVal address As String) As Coordinate

            Dim client As WebClient = New WebClient()

            Dim uri As Uri = GetGeoCodeUri(address)

            Dim geoCodeInfo As String()

            'The first number is the status code,            

            'the second is the accuracy,            

            'the third is the latitude,            

            'the fourth one is the longitude.           

            Try

                geoCodeInfo = client.DownloadString(uri).Split(",")

                Return New Coordinate(Convert.ToDouble(geoCodeInfo(2)), Convert.ToDouble(geoCodeInfo(3)))

            Catch ex As Exception

                Return New Coordinate(0.0, 0.0)

            End Try

        End Function

    End Class

End Namespace

 

Save it and then go back to the main script and add Import that class (see code).  Notice, the way I’m getting the level of accuracy with my ugly nested IF statements isn’t the prettiest way to do this, use your imagination.  Copy in this code into the Main Script:

 

' Microsoft SQL Server Integration Services user script component

' This is your new script component in Microsoft Visual Basic .NET

' ScriptMain is the entrypoint class for script components

 

Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Imports ScriptComponent_4a8732cababc49a999159a91c737082a.GoogleGeoCoder

 

Public Class ScriptMain

    Inherits UserComponent

 

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

 

        Dim coordinate As Coordinate = GeoCode.GetCoordinates(Row.street & ", " & Row.city & ", " & Row.state & ", " & Row.zip)

 

        If ((coordinate.latitude <> 0) And (coordinate.longitude <> 0)) Then

            Row.lat = Convert.ToDecimal(coordinate.latitude)

            Row.long = Convert.ToDecimal(coordinate.longitude)

            Row.acc = 1

        Else

            coordinate = GeoCode.GetCoordinates(Row.city & ", " & Row.state & ", " & Row.zip)

            If ((coordinate.latitude <> 0) And (coordinate.longitude <> 0)) Then

                Row.lat = Convert.ToDecimal(coordinate.latitude)

                Row.long = Convert.ToDecimal(coordinate.longitude)

                Row.acc = 2

            Else

                coordinate = GeoCode.GetCoordinates(Row.zip)

                If ((coordinate.latitude <> 0) And (coordinate.longitude <> 0)) Then

                    Row.lat = Convert.ToDecimal(coordinate.latitude)

                    Row.long = Convert.ToDecimal(coordinate.longitude)

                    Row.acc = 3

                Else

                    coordinate = GeoCode.GetCoordinates(Row.city & ", " & Row.state)

                    If ((coordinate.latitude <> 0) And (coordinate.longitude <> 0)) Then

                        Row.lat = Convert.ToDecimal(coordinate.latitude)

                        Row.long = Convert.ToDecimal(coordinate.longitude)

                        Row.acc = 4

                    Else

                        coordinate = GeoCode.GetCoordinates(Row.state)

                        If ((coordinate.latitude <> 0) And (coordinate.longitude <> 0)) Then

                            Row.lat = Convert.ToDecimal(coordinate.latitude)

                            Row.long = Convert.ToDecimal(coordinate.longitude)

                            Row.acc = 5

                        End If

                    End If

                End If

            End If

        End If

    End Sub

 

End Class

 

VN:F [1.9.1_1087]

Rating: 5.0/5 (2 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: BI, Code, Misc, g33k Tags: , ,

WordPress SEO – Great Tips

May 17th, 2009 Rick No comments
Categories: Misc, Site, Social, Tips Tags: , ,

I Can’t Stop Looking at This

January 17th, 2008 Rick 1 comment

Hypercube in motion

I was researching some Business Intelligence information like cubes and hypercubes and stumbled upon this transic picture and I can’t stop staring at it.

This link is directly to the wikipedia picture where I got it from and it is liked to the page I found it on in case you’re interested.  This is a hypercube.

VN:F [1.9.1_1087]

Rating: 3.0/5 (1 vote cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Misc Tags:

I Got Fired, and it was Kinda Cool :-)

January 17th, 2008 Rick 1 comment

A wise man once said, you never know who you are until you get fired.  Not sure who said that first, but I’ve heard that saying before.  People always say, you really find out who you are when you get fired and have to scramble to survive.  Well, truth be told, I wasn’t fired because I’m still employed by my consulting company, but I was “let go for budget reasons” at the place I was consulting.  So, not really fired, but let’s say I worked for a different consulting company, I’d be out on the street looking for something new and would have to face a bunch of crappy consequences.

Ok, not the same thing, I know, but my point is, I always kinda thought, everyone eventually gets cut, fired, or something like that over a career, and I always feared that day.  So when I got the news, I was pleasantly surprised that I didn’t give a crap.  I mean, it sucks to leave, it sucks to not be working and all that, but I guarantee, within a week, I’ll be working somewhere better, doing better work, learning new things… without a doubt because the company I work for is looking out for me.

Still more, what’s even better is that if they DON’T find something for me, my wife and I are finacially stable and she “sells” people with my skills, so she could find me something fast and I’d make even more money and she’d make money on my money…

Strange how this “firing” has opened my eyes.  I always feared this day, but now that it’s here, I wish it had happened a long time ago :-)   It’s just good to know that I’m in a good place right now and that I have a good career path, a good company behind me and a good wife behind me.  Working is actually kinda fun when you don’t care about getting canned :-o

VN:F [1.9.1_1087]

Rating: 2.0/5 (1 vote cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Misc Tags:

Ever Wonder How The World Will End?

January 16th, 2008 Rick No comments

I don’t even remember how I stumbled upon this site, let alone this post, but I had to share.  My naive self trusts that the content is real and that there was a good amount of research going on, but regardless, it was captivating to me. 

I found this at a Site called Best of the World (botw).  It’s Simply about 10 disasters that could cause the end of the world.  Again, being naive and uneducated in physical science, it’s amazing to me to see how plausable some of these are.  I have listened to audiobooks of the likes of Steve Hawkings and other physisists, so I kinda know what’s going on in some of these, but it just adds to the complexity that is my understanding of space/time.

You HAVE to check the descriptions and videos on the Site… I just find this stuff to be amazing.  Hope you do to.

Here are the 10 possible ends of the world: 

  1. Particle Accelerators – Very possible
  2. Rogue Black Holes – I’ve been afraid of this one since they were explained to me 20 years ago
  3. Gamma Ray Bursts - Interesting and apparently common
  4. Omega Point – Ummmm, totally don’t get this one, but I’ve read a lot about consiousness and can start to understand it… maybe
  5. Bubble Nucleation – If any of this is true, then why not.  Confusing, but interesting nonetheless
  6. Divine Intervention – Possible, I suppose.  Trying not to think on this one :-o
  7. Solar Flares (Super Flares, to be exact) - Holy crap… cool stuff.  This seems freakishly possible.
  8. Aliens Attack the Earth – As much as I don’t believe, it’s hard not to.  217 planets have been found… WTF?
  9. Global War – This isn’t number 1?
  10. Ecosystem Collapse – This isn’t number 2?  Scary

So anyway, fun stuff.  Always good to know that it could all end any time.  More reason to enjoy life now, right :-)   Dunno much about this site, but thanks to Best of the Web for this intereting article.

VN:F [1.9.1_1087]

Rating: 3.0/5 (1 vote cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Misc Tags:

HTC Touch (Eat Your Heart Out iPhone)

January 10th, 2008 Rick No comments

Motorola StarTACWell, it’s been several years since I would have considered myself a phone-whore, but now I can clearly remember why I used to be.  Of course, by phone-whore, I am referring to the fact that I used to buy a $300+ phone every single year because of the advances in technology and all of the cool new tools and goodies that came with it.  It all started with the Star-TAC.  I paid $350 for that thing.  Hard to believe when you look back.

Anyway, when I met my wife, I kinda stopped being such a kid and I eventually stuck with my Treo 650 for about 4 years.  It was a great phone and I really had no reason to get rid of it.  After a while though, I started losing reception and missed calls and dropped calls like crazy.  I had also just gotten into this freakin’ car accident and had completely covered the Treo in my blood so I thought it was a good idea and a good time to upgrade.

Well, this was the first phone I had every actually bought HTC Touchwithout researching.  I randomly decided to stop by the Sprint Store and saw the HTC touch.  I knew nothing about it, but it caught my eye and eventually took my full attention.  I played with it for no more than 5 minutes before they called my name, and I was already sold.  I didn’t actually “play” with it, I simply checked the specs and some of the control panel options and networking options and I all of a sudden couldn’t live without it.

The sad thing is that the next day I was floored by all of my concussion issues and I literally could not physically walk to go get my phone, let alone find the desire or any more interest in it.  It sat on the counter uncharged and unused for 5 or 6 days.  I didn’t even check for missed calls, let alone play with it or set anything up. 

Well, needless to say, I eventually picked the damn thing up and fell back in love.  It was a little difficult to start using because it was my first Windows Mobile phone and it was the first phone packed with all these goodies.  When I finally started figuring things out and using it like I should be using it, I couldn’t figure out how I had gone so long without a new phone and why I hadn’t known more about this one.

There’s still a LOT I’m not using on it and a lot that I don’t know about it.  I don’t even know how/where to get free apps for it yet and I don’t know of any hacks or anything, but here’s what I know and what I use:

It’s 4 oz.  It’s so much lighter than the Treo.  Seems weird, it’s only 2.5 oz lighter, but you can really tell.  It’s also  1 oz less than the iPhone.  It’s a half inch shorter than the Treo and iPhone and it’s about the same thickness of the iPhone (almost .5″ less than Treo).  It’s the same width as both.  This isn’t necessarily a GOOD thing because you lose screen real-estate compared to the iPhone, but it’s better on the pocket-space/purse-space if you’re a chick.

The Battery life really suffers compared to the others, especially the iPhone.  I have a AC/DC power charger though so I almost always have it externally powered.  It’s USB powered too, so when I hook it to my PC, I’m getting charged as well.  Not sure if the iPhone is. 

There’s a measly 152MB of built-in memory which is a big step up on the Treo, but it’s about 7.9 GB short of the iPhone.  However the iPhone is stuck at 8 GB, where the other two use SD slots.  The Touch uses microSD.  I have a 2GB in there now and that’s plenty for now.

It has Bluetooth like the others, but I had never really used the Bluetooth stuff on the Treo before.  I already have everything running with Bluetooth now and I absolutely love it.  Bluetooth deserves it’s own post though.  This version of the phone (CDMA) can’t use WiFi, which kinda sucks.  The iPhone can.  The Sprint people told me it could, so that bugs me even more, but then again, that’s something I don’t think I’d use that much.  EVDO is fast enough for what I do methinks.

HTC Touch side and backIt uses Windows.  Not PALM… not APPLE.  I’m not THAT much of a Widows fanatic, but I despise the other two greatly, so I’m thrilled to have Windows Mobile 6.  It’s also got built in GPS.  Sprint hasn’t come up with the software for this yet, so you can’t really use it unless you pay for the proprietary Sprint services.  Oh well, I’ll have this for a while and I’ve heard that this will be release 1st quarter (Sprint peeps said that).  Can’t wait, but the Map features in Windows Live are awesome enough without it.

So anyway, enough with the comparisons.  There are goods and bads as compared to the others, but this is what makes me love the phone regardless of why I did or didn’t do this on my Treo and regardless of whether other phones do this or not:

It’s my first Windows Mobile phone for starters.  I love that fact how this seamlessly integrates with all of my Office tools at work and home, mainly Outlook.  This is the first time I’ve ever been completely synched.  I have integrated all of my contacts from all of my email services (gmail, hotmail, yahoo, work and home) into my phone and then back to each of the sources.  My contact lists are now all the same.  They’re not truley synched, but I can synch them manually when I want, but the bottom line is that my phone as ALL of my contact info and so does my laptop’s Outlook.

Aside from that, I also have all of my email integrated into the phone now.  So now, when I get hotmail, gmail, work, comments from here, text messages, or Instant Messages, I know right away.  I also have all of my personal calendars and work calendars synched.  I know that sounds trivial, but the further along in my career and the further along in my family life (The older I get), the more I will live and die by these features.  I haven’t been late to a meeting and or doctor appt and I haven’t forgotten that I need to do this or that after work, etc.  I’m excited now when the alarm rings and says “Wake up, you have an 8:00 this morning”.

I love the touchFlo.  For those that don’t know, this is something that iPhone has and seems to do well.  It’s really nothing more than a flash way to browse.  For instance, you slide your finger up and it pulls up a menu, or you slide right and left to scroll through pictures or you slide it in a circle to zoom in and out.  There aren’t many buttons on this phone, so this helps make things easy to navigate without scrambling through menus.

I love the way Windows Live Search works.  I’ve always been a Google Maps mark but this map software for the phone is awesome with the driving directions and the way you can navigate and zoom on the turns and destinations.  I love the Sirius player I installed to DEATH.  Since my car has been in the shop for 25 days and still has 10 to go, I’ve been using my phone to listen to Howard and Bubba on Sirius on the ride to work.  I love Sprint TV, but not nearly as much as the Slingbox mobile software where I can actually control and stream my physical components at home (I can power on and watch my cable or Replay TV on my phone…  freain’ awesome). 

I love the mini USB.  It’s nice and easy to hook up to the PC.  It comes with a splitter so you can power it and use the headphones at the same time (the headphones are USB too).  There is an adapter for a 1/8″ headphone jack too.

I don’t like that Sprint has “disabled” the GPS, or that they haven’t done whatever they need to do for us to use the GPS chip on non-Sprint software.  I don’t like there isn’t a keyboard option like what I’ve seen on the iPhone where the numbers get larger when you press them so you can make sure you’re hitting the right key before release your finger.  I also don’t like that there’s no WiFi and I don’t like that I don’t know anything about the new features and hardware on the phone so I can’t use it for more stuff :-)   For instance, I don’t know how to use it as a modem for my phone (without paying for the Sprint add-ons) and I’m struggling to figure out  how to synch via Bluetooth dongle.  I think that’s an ActiveSync issue though, not my phone.

All in all, I love the phone, as you can clearly infer from my comments and I’m not biased in any way other than the fact that I didn’t like Palm’s OS and I don’t like Apple :-)   Really though, the phone is great.  I strongly recommend it for anyone.  I got it for $250 after rebates and would have paid more for it.  Do your research though unlike I did.  I would have still gotten this, I’m sure, but there’s plenty of info out there.  Enjoy.

VN:F [1.9.1_1087]

Rating: 4.0/5 (1 vote cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Misc Tags:

Candid Pictures of My Disaster

January 8th, 2008 NothingMan No comments

 If I can pull another excuse out of the bag as to why I haven’t been here lately, I’ll take my best shot.  Here are some quick pics of what I’ve been up to lately :-o

 I was driving home a few weeks ago, and I was no more than 1/2 mile away armed with a few  movie rentals to enjoy with my wife in front of the fire on a night without children.  It had started snowing about an hour before, but only about 10 minute prior, it started coming down really hard.  There was maybe 1/2 inch to a full inch of fresh snow on the roads, but from what I felt in my Pathfinder, it was still smoothe sailing.

I vaguely remember thinking how glad I was that my car was so “safe”, with the slip protection control, the automatic 4×4, the really-good-anti-lock breaks, the fact that it’s big, etc.  It completely slipped my mind that other people may not have that same luxury. 

The road I was on was straight, flat, and otherwise, completely safe.  There were a few side roads with stop signs, and I know the road like the back of my hand.  I noticed the car to my right, ahead of me, pulling up to the stop sign, but by the time I noticed that they weren’t stopping, the car was only about 15 feet in front of me, and I was going 30-40 mph on snow —BOOM.  I had just enough time to cut the wheel hard to the left, which at least kept me from smashing her driver-side door; I hit more of the front-end, which I would imagine saved her a LOT of pain.

After impact, I apparently spun across 4 lanes, 2 oncoming, and luckily no one hit me.  I don’t remember that, and I don’t remember the airbag or anything up to getting out of the car and calling for help.  I remember calling my wife and saying “I got into an accident, don’t worry, I’ll call you with details”.  I knew I was bleeding like crazy from my head and would be going to the ER, but I figured if I got into a wreck, I certainly don’t want her driving out here to come see me.

Since I was only 1 minute from home, she decided to come check on me and help me. Based on how she perceived the situation and the clarity of my voice when I called her, she was a little shocked to see me on a stretcher, tied down, in neck and leg restraints with blood completely covering my face.

Here I am in the ER.  I took this picture of myself after I got stictches in my hairline and after the blood was cleaned up.  You can still see some smeared across my forehead and on the bed, but most of the carnage was gone at this point…  about 6 hours after we were admitted :-/.

In ER

Here’s my  Pathfinder.  ~$16,000 in estimated repairs at this point.  Looking to get it back at the end of Jan (40 days total).  I sure hope they do a good job, I don’t want to have keep taking it in for more repairs :-/
My Car

Here’s my leg.  I remember in the ER saying that my legs “kinda” hurt.  I had no idea how bad they were until the next day.  This bruise ended up taking over my entire left leg at one point.   The knot was about the size of a baseball.  It’s still there.
Leg Bruise

Just at the time that I was able to start winding down the painkillers and muscle relaxers and start moving around a bit, I got the flu.  Just in time for the holidays.  On top of all that, apparenly I had some sort of post-concussion syndrome or whatever that was causing me to be lathargic, depressed, nausious, weak, dizzy, and all that good stuff.  I’m surprised at this point that I don’t have bedsores from all the time I spend just laying down or sitting. 

You always think “I can take care of myself”, at least I always do, and you probably can take care of yourself, but it’s times like this that really make you feel thankful for your friends and family, and especially your spouse if you have one.  I’ve never really been in a bad accident before; there’s just a lot of stuff you don’t think about that needs to be taken care of.  Getting things out of your car, talking to the police, driving you around, getting medicine, getting a rental car, talking to the insurance companies, etc. 

Thank God for my wife or I might still be on the side of the road.

VN:F [1.9.1_1087]

Rating: 0.0/5 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Misc Tags:

Back, Again, For Now

January 2nd, 2008 NothingMan No comments

Without thinking too much, I’m trying to remember when the last time I wrote a post or even came to this site to check stats, comments, or anything.  It escapes me.  At some point, I fell into a huge slump and a nasty rutt where I hardly even checked email, let alone had anything to do with a blog.

I’m not sure what happened to me, but I completely lost every desire to do any kind of personal work.  Some sort of depression I suppose, but I’m no shrink.  I even pulled the plug on my Adwords campains that were making me [some] money.  The weird thing is that I didn’t check any stats or any income numbers at ALL since my last post.  I completely abandoned it.

Well, I looked today and almost had a heart-attack.  Of course, what do I expect.  I was somewhere around 3million on Alexa for this site and something like 7million on one of my others.  The other is unranked, lol.  It’s just silly, because I was getting to a point where things were starting to run smoothly, and I just jumped ship.  Who knows.

So here I am, back for another go.  It may take me a bit to get back into a steady groove, but I’m going to try.

VN:F [1.9.1_1087]

Rating: 0.0/5 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
Categories: Misc Tags: