Blogger Jeff = new Blogger

Programming and stuff in Western PA

Applescript to repeatedly try to connect to internet stream in ITunes

I listen to the same radio station each and every morning. Problem is, so do a lot of other people. The server I need to connect to allows for a maximum of 100 connections, so what I end up doing is repeatedly trying to connect until I can get one of those connections. Until now….

I created this little applescript to hammer away at that server. I saved it as a playlist, and just run the following :

local e
set e to 0

tell application "iTunes"
	repeat
		try
			play playlist ("My Radio Station Playlist name")
			delay (2)
		on error errStr number errorNumber
			set e to errorNumber
			
		end try
		
		if e is not equal to -5421 then
			exit repeat
		else
			log "Try again"
		end if
		
		
	end repeat
end tell

January 7, 2009 Posted by | Technology | , | 1 Comment

Finally, just DATES in SQL Server 2008

I’m just getting around to snooping around Sql Server 2008, and noticed that they have FINALLY added just a DATE datatype. What this means is that we can now just store a date, rather than a date and the time. No more will we have to write SELECT CONVERT(VARCHAR,GETDATE(),101)!!!!!

This now does the trick :

SELECT CAST(GETDATE() AS DATE)

December 18, 2008 Posted by | Technology | | Leave a comment

New GMail themes, including the coolest one ever!

I checked my GMail today, and noticed a new “Themes” link.  I clicked on it and behold, a plethora of new color themes for my GMail.  I then found the mother of all themes : Terminal!

 

11-20-2008 2-56-34 PM

November 20, 2008 Posted by | Technology | Leave a comment

How developers get answers to questions

The other day I was reading Joel Spolsky’s blog post on his new site he just released called Stackoverflow.com. To summarize, Joel and his team created Stackoverflow as a resource for developers to get answers to questions they have.  This got me to thinking about the resources I utilize on a daily basis.

Just Google it!
Joel points out that the way Developers usually go about getting those answers is to Google their question and grab the first response they find. I agree that this is usually the first thing I do, and for the most part, this usually works.  For instance if I’m trying to get a client’s C++ project up and running, and I’m coming across strange and cryptic compile time errors, I’ll do a Google search in hopes of having some light shed on the problem. Probably for most of us, Google does the trick, as nothing beats a finely indexed resource.  Like many Devs, I used to have a ton of those 600 page Wrox and O’Reilly books spread out all over the place.  But since just about any piece of information I need is on the web, tech reference books are pretty useless anymore.  In fact, I gave all of mine a way about a year ago on freecycle.org.

Use your networking skills
Of course if you work in an office with other Devs, you can always hit them up when you come across a problem.  But if you’re like me, and you telecommute, you have to build a network of resources you can bug.  I have a few pals whose ears I bend from time to time via instant messenger (and they do the same with me).  More times than not, just talking out a problem solves itself.

Message boards
Sometimes Google just doesn’t cut it and you just can’t get your question answered. So the next best thing is to post your question on a message board.  For instance, on the project I’m working on now, I’ve had to interface with the Quickbooks SDK. Intuit has a very nice message board with lots of activity. A lot of boards allow you to specify to have an email sent when a response is given to your question.  I would recommend looking at the current responses on a board to see how often people post (ie:is there a new response every minute versus a day).  If it appears as though only a few new posts per day get entered, then I would look elsewhere.

Paid technical support
A lot of products offer technical support you can pay for. One client I worked with actually purchased a year’s worth of tech support from Business Objects (Crystal Reports) and had me call them about an apparent bug with Crystal Enterprise.  I can report to you that this was a big waste of time, with me spending about a month going back and forth with the support people, who in the end, couldn’t address my issues.

Still no answers huh?
Sometimes no matter how hard you Google, or how many people you bug, you just can’t get an answer.  What I end up doing in times like this is to approach the problem differently.  For instance, I recently had to get a legacy COM application running in Windows SXS mode (this is COM free registration with the help of a manifest file). I had the majority of the app running ok, but there was one component that would continue to read from the registry rather than the manifest file I created.  I was able to narrow it down to line of code where this was happening.  I tried a few alternate approaches until finally I got it to work.

September 25, 2008 Posted by | Programming | | Leave a comment

Accessing bookmarks quickly in FireFox 3

I don’t have a problem admitting that I can be "slow" at times to discover things that have existed for a while. One of those finds, for me, is the ability to type in a FireFox’s bookmark title in the address bar.  For me, this is very similar to using Quicksilver for the Mac, where you just start typing something, and Quicksilver starts to filter through it’s huge list of applications it has indexed on your machine. The nice thing about FireFox’s address search is that you usually only have to type a letter or two of a bookmark before it appears.  This is way quicker than messing around with a mouse.  All I did below was hit Command+L (drops the cursor in the address bar), and then start typing the bookmark I want to access.

September 14, 2008 Posted by | Technology | Leave a comment

Google Chrome and Application Shortcuts

I downloaded Google’s new browser Chrome last week, and wasn’t all that impressed.  It didn’t seem, to me, to run that much faster than my Firefox 3 (keep in mind I was running Chrome through my Parallels for Mac VM).

The one awesome thing Chrome brings to the table is the concept of an Application shortcut.  This is nothing more than a desktop shortcut to a particular Web Application.  For instance, I use Google Docs an awful lot, so I created an Application shortcut to a Google spreadsheet.  Now instead of opening up a browser and navigating to Google Docs, etc… I can now just click on the shortcut, and it opens up the spreadsheet in it’s own window, with it appearing to be an independent app, much like an MS Office document.

September 12, 2008 Posted by | Firefox, Technology | 1 Comment

Moving from iPhoto to Picasa

I moved my 5 gigabytes worth of digital photos from my Mac to my PC tonight. This is usually a pretty easy thing to do, as you just copy your “Originals” folder in the iPhoto directory to it’s new destination. I didn’t care about copying the photo albums from iPhoto, but the problem I ran into was getting to the keywords my wife and I added for every stinking photo. iPhoto uses it’s own proprietary method for storing keywords, so I needed to export them somehow.

Thankfully I found the iphotokeywordutilities app that did the trick for me. It’s a little tricky to get going, as you have to :
1.download iphotokeywordutilities
2.Open iPhoto and select the photos whose keywords you want to export.
3. You then click on the applescript from the downloaded zip

What iphotokeywordutilities does is take the iPhoto keyword and embed it right into the image’s IPTC keyword attribute.

July 26, 2008 Posted by | iPhoto, Technology | 2 Comments

Need to create a Wiki?

I was tasked with this a month or so ago, and came upon a great site called http://www.wikimatrix.org/. It even has a wizard that asks you a number of questions, and then recomends different wiki apps for you.

I ended up downloading and trying 4 different Wikis. These ranged from one written in javascript, to a php based one, and even “asp.old” one. I went with ScrewTurn Wiki, which is a .Net based, Open Source app, written in C#. ScrewTurn comes with an installer, that creates an IIS site for you. One big requirement I had was that the Wiki content pages themselves had to be created outside of the Wiki, because I was using a script to pull out the API class data. Screwturn is also very easy to configure out of the box, has a support forum, and is skinnable.

April 14, 2008 Posted by | ASP.Net, Technology | Leave a comment

Sql Server 2008 CTP

You can download it from here.

I’ll have to download this and take a spin.

Two things I’ve read about that sound neat off the bat :

(1) Automatic auditing : one of my recent posts detailed how to do this. As I said, I end up doing this on practically every project, so it’s nice Microsoft is baking this right in.

(2) Date only and Time only datatypes : HALLELUJAH! I can’t tell you how many times this has screwed me when doing date comparison, and all I’m concerned with is a date, but the time element throws it off.

March 13, 2008 Posted by | SQL Server, Technology | Leave a comment

SQL Server Audit tables the easy way

One of the more common tasks I perform from project to project is the creation of audit tables. The easiest way I know how to do this is to create a copy of the table I want to audit, and then add a trigger to the parent table. For my example I’ll use my ever-so-popular MLB database and my TEAMS table. The schema for TEAMS looks like:

CREATE TABLE [dbo].[TEAMS](
    [TEAM_ID] [int] IDENTITY(1,1) NOT NULL,
    [TEAM_NAME] [varchar](50) NOT NULL,
    [CITY] [varchar](50) NOT NULL,
    [LEAGUE] [nchar](2) NULL
) ON [PRIMARY]

GO

The audit table for TEAMS will be an exact copy, with a couple of modifications. First, TEAM_ID needs to be a copy, so it’s no longer an identity column, The second change I made was to add an AUDIT_DT column to capture when the change occurred :

CREATE TABLE [dbo].[TEAMS_AUDIT](
    [TEAM_ID] [int] NOT NULL,
    [TEAM_NAME] [varchar](50) NOT NULL,
    [CITY] [varchar](50) NOT NULL,
    [LEAGUE] [nchar](2) NULL,
    [AUDIT_DT] [smalldatetime] NOT NULL DEFAULT (getdate())
) ON [PRIMARY]

I then add a trigger to the TEAMS table to capture updates and deletes (I only want to capture when the original column changes, not when it’s added) :

CREATE TRIGGER TRG_TEAMS 
   ON  TEAMS 
   AFTER UPDATE,DELETE
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    INSERT INTO [MLB].[dbo].[TEAMS_AUDIT]
           ([TEAM_ID]
           ,[TEAM_NAME]
           ,[CITY]
           ,[LEAGUE])
     SELECT [TEAM_ID]
           ,[TEAM_NAME]
           ,[CITY]
           ,[LEAGUE]
    FROM DELETED
END
GO

That’s it! A couple of things you may want to consider when creating an audit table is :

  • Remember that the audit table gets an insert for each update/delete to the parent table. This can have some performance ramifications. One of the things I do is not put any indexes on the audit table.
  • You’ll want to purge the data from this table from time to time (or back it up).



Digg!

Tags:

March 2, 2008 Posted by | SQL Server, Technology | Leave a comment

Follow

Get every new post delivered to your Inbox.