Monday, June 04, 2012

Solution-ish: CF10 SQL Connection Timeout After VPN Disconnect

When doing CF 9&10 development locally I would constantly run into a SQL connection timeout issue where any page that required a database connection would throw the following error.

Error Executing Database Query.

[Macromedia][SQLServer JDBC Driver]The requested instance is either invalid or not running.
My initial searches for solutions to get right back to work weren't fruitful and the only thing that worked for me was a full machine reboot. Sometime last week I got fed up with doing full reboots and spent a little more time digging. Before I had attempted to restart the usual suspect services: CF, CF ODBC, SQL, etc. but it wasn't until I read an article that mentioned DHCP that I thought to restart the DHCP Client service. Bingo! Maybe there's a more elegant solution or I'm missing some simple configuration option somewhere as other people who work similarly don't have this timeout issue. However, if you run into this issue there's a good chance that you just need to cycle the DHCP Client service anytime you disconnect from the VPN.

SQL: Adding and populating an order column in an existing table

Found this post in my drafts folder. I don't remember doing this, but I might as well put it out there.

I'm sure I'm going the long way around the tree here, but recently I had to add an OrderId column to a table where I was going to implement ordering that hadn't been there before. In my brain I was sure I could just temporarily change the column to an identity column so that SQL could do the initial ordering for me. I'd then remove the identity from the column and allow my users to change the OrderId. SSIS didn't agree. Maybe it was the lack of sleep or caffeine. So, here's how I ended automating this process. If this was SQL 2005+, I'd be able to use some nifty functions, but in SQL 2000 they don't exist.

UPDATE [mytable] set orderid = rank
FROM (
SELECT t1.RecId, t1.CategoryId, t1.RecName, COUNT(*) AS rank
FROM [mytable] t1, [mytable] t2
where t1.CategoryId = t2.CategoryId and t1.RecName <= t2.RecName
GROUP BY t1.CategoryId, t1.RecId, t1.RecName
)
o where [mytable].RecId = o.RecId

Thursday, May 26, 2011

When Shockwave/Flash Breaks in Chrome

Just a tip, if Shockwave/Flash breaks in Chrome, you can restart just that plugin and refresh your pages (no need to restart all instances of Chrome).

When Chrome is in focus, press shift-esc, find the plugin "Shockwave Flash", click on it and press "End Process". Reload your page and you should be good to go.

Thursday, February 10, 2011

Windows 7 New Folder Lag - Solution

Recently at work I've been doing tasks that require me to download files into specifically named folders. Creating new folders from the download dialogue was really frustrating as it would take up to a minute from the point of clicking "New Folder" to the time I got the prompt to name it. This issue only cropped up after the first time my computer hibernated (which is every evening).

A little Googling later and here's the solution:
  1. In an Explorer window, make the Menus visible by clicking Organize - Layout - then checking Menu bar.
  2. Now click the Tools menu and select Folder Options...
  3. Click the View tab.
  4. Scroll down and check [ ] Launch folder windows in a separate process.
Go ahead and uncheck your Menu bar to get back to normal looking folders.

Thursday, October 07, 2010

SMTP Development Solutions

I needed to send mail for a user control I was writing and since the move to Windows 7, I hadn't yet figured out what to do about W7's lack of a SMTP server.

Here are two solutions that I found and I'm kind of on the fence about:

The first is a full blown local SMTP server called, Free SMTP Server and I've used it in the past. Not much to say here. It just works.

The second, smtp4dev,  is interesting in that it doesn't actually send email messages. This is great, for when you are just testing the format of a message and would typically go through multiple revisions that you'd then have to delete. Sure, it's a minor irritation to find those emails peppered among your other daily messages, but another benefit is that smtp4dev sits in your system tray and can be configured to display the "email" as soon as it is received instead of you having to browse to your email client and open the message. My only wish is that there could be a "we'll do it live" switch that would actually send the email for those cases when your email needs to be processed by another system. I don't like the idea of installing two SMTP servers.

MD Hands-Free Details

In case you were wondering about the new hands-free law as I was:
Prohibiting a driver of a motor vehicle that is in motion from using the driver's hands to use a handheld telephone except to initiate or terminate a wireless call or to turn on or off the handheld phone; providing that a violation of the Act may be enforced only as a secondary violation; establishing penalties of $40 for a first offense and $100 for a second offense; prohibiting a driver of a school vehicle or a holder of an instructional permit or provisional driver's license from using a handheld phone while driving; etc.
Source: http://mlis.state.md.us/2010rs/billfile/SB0321.htm

Wednesday, November 25, 2009

Wednesday, July 29, 2009

Vim Non-Greedy Search

Just a self-post here to help serve as a reminder that the non-greedy search operator for vim is .\{-} instead of the .*? in most languages. This was useful when attempting to replace bad image paths for a template file that contained lots of images that were hosted on various servers and I wanted to consolidate them to get around security warnings. The search command string in vim then ends up as:
:/src=\".\{-}\.\(gif\|png\|jpg\)\"/
This can be combined with a search and replace command as:
:%s/src=\".*\(\/.\{-}\.\(gif\|png\|jpg\)\)\"/src=\"myimagelocation\1\"/gc
Oh, and a super nice thing to know is that you can copy and paste from the cmd line in vim by hitting ctrl-f to open a new cmd window. This is great for saving thost extremely wordy vim regexes that you need to type over and over.

Monday, April 13, 2009

Wednesday, February 04, 2009

I need to learn Vim

Today I stripped out lines not containing a certain string, removed all text but the codes I cared about from every line, sorted the remaining lines while removing duplicate lines and it only took 3 commands.

In short, I need to learn Vim.