Friday, January 19, 2007

Running into The Man in Blue

I recently went hunting for information on detecting browser information using JavaScript and through no random chance, found myself reading the blog of The Man in Blue.

While the information was valuable, what impressed me, and inspires me, is the design of his portfolio site. It's clean, usable, and incredibly simple. The interface is poetically enjoyable and intuitive. I would hope no one would copy this site, that would be wrong, but instead find inspiration in his design.

Please have a look: The Man In Blue

Wednesday, December 13, 2006

Feeling Regular and the use of Fibre.

No, I'm feeling fine, though a tad tired.

I'm finally getting around to exploring Regular Expressions (RegEx) and coming to realize the value of the beast and the simplicity of the design. I picked the brain of my friend and mentor, Brent Ashley today and he showed me the RegEx Coach and introduced me to some of the logic. I found more in my O'Reilly book, "JavaScript: The Definative Guide" (I have the 3rd edition) tonight and I can say one thing about RegEx.

LEARN IT! Come to understand it and you'll be SO far ahead of the game. It is far from being the ONLY thing you need to know, but it will make you that much better at doing things the right way.

Now, I also asked Brent to do a code an informal code-review on a little VBScript thing I was working on. Frankly, it wasn't going well because I was just a little more rusty that I enjoy being, but I asked for the review to get an idea of where I need to improve. I found out.

It's tough to hear that you're not an ace, but you NEED to hear it. Efficiency is everything in development and my design was weak. There's much more I need to learn, but his manner of showing me where I can improve was skillful and conscientious.

Monday, November 13, 2006

Slow running Linux VM on VMWare ESX?

If your VMWare ESX implementation of a Linux guest OS is running slow... a stop-gap solution may be the following...

Create a script that connects to a reliable time server and retrieves the time:
#!/bin/bash
# Sync HWClock to timeserver.mynetwork.local
/bin/date
/sbin/service ntpd stop
/usr/sbin/ntpdate 192.168.0.50
/sbin/hwclock --systohc
/sbin/service ntpd start
/bin/date
Now, add two entries to crontab:
1 */1 * * * /var/scripts/scheduled/synctime >> /var/log/synctime.log
*/2 * * * * /sbin/hwclock --hctosys


You can certainly adjust the times, this is set to get the real time once an "hour" at the 1. Then sync the OS from the VM hardware clock every 2 minutes.

Sample output of synctime:
Mon Nov 13 16:01:01 EST 2006
Shutting down ntpd: [ OK ]
13 Nov 16:04:46 ntpdate[19413]: step time server 192.168.0.50 offset 223.590418 sec
ntpd: Synchronizing with time server: [FAILED]
Starting ntpd: [ OK ]
Mon Nov 13 16:04:49 EST 2006

Monday, October 09, 2006

UPDATE Query from Excel to (My)SQL Database

Recently I found out about a problem going between versions of MySQL last week and I though you might enjoy the solution. You see FLOAT()'s functionality changed whereby FLOAT(4,2) once meant 0000.00 to now meaning 00.00. The problem with this is that database imported with a value of 2341.33 becomes 99.99! This could be very bad. Fortunately you can export from the old DB via Query Browser to Excel (XML) and employ VBA and ODBC to get things right, fast.

Notably this does not update all values, only values where there is data, if you were to use this routine to post to a database repeatedly I would suggest adjusting the 'If ActiveCell.Value <> "" Then' functionality to set Null values as needed.

Sub UpdateDB()
'
' 09/10/2006 by Cameron Stevens
'

Set myconn = CreateObject("adodb.connection")
Connection = "Driver={MySQL ODBC 3.51 Driver}; Server=MyServer; ~SPLIT LINE~
uid=webuser; pwd=b33rg00gl3s; database=brewery; option=3; port=3306;"
myconn.Open (Connection)
Set result = CreateObject("adodb.recordset")
Sql = "USE brewery;"
Set result = myconn.Execute(Sql)

Range("A1").Select
Selection.Offset(1, 0).Select
strUpdate = "UPDATE tblBottlePrices SET "
While ActiveCell.Value <> ""
strWHERE = " WHERE order_id='" & ActiveCell.Value & "' "
Selection.Offset(0, 4).Select
strSET = " "
If ActiveCell.Value <> "" Then strSET = strSET & "retail_price='" & ActiveCell.Value & "' "
Selection.Offset(0, 1).Select
If ActiveCell.Value <> "" Then strSET = strSET & ", discount_price='" & ActiveCell.Value & "' "
'Selection.Offset(0, 1).Select

strUQuery = strUpdate & strSET & strWHERE

Set result = myconn.Execute(strUQuery)

'MsgBox strUQuery
Selection.End(xlToLeft).Select
Selection.Offset(1, 0).Select
Wend
myconn.Close
Set result = Nothing
Set myconn = Nothing

End Sub

Accessing or Deleting an Inaccessible File/Folder

While the rights may be adjusted using CACLS or the like, there are occationally files hat prove inpenitrable. It seems that the pleasantries of Long File Names can occationally curse us if that LFN gets corrupted. You can do what you want to delete the folder but it won't budge. But... there's a trick... go to a command prompt and perform a DIR /X on the folder containing this file or folder. The /X switch shows you the 8.3 or short names for these files, rename the problematic file using the short name and all is well (i.e. REN ALLDEA~2 XXX).

While this isn't the only way into a file that's inaccessible, it may be the last resort with a file that's got a corrupt filename.

3D Text Screen Saver

At one time the 3D text Screen Saver had some cool tricks that depended upon your choice of words. If you typed in 'Beer', 'Volcano', or 'rock' you had a selection of things come up in the screen saver that meant something to the developers. Windows 2000 threw this Easter Egg out, but left a treasure behind. If you're using Windows2000 you have the opportunity to inflict your personality on this screen saver. To get your own selection of words appearing you need to do the following:
  1. Open Regedit and search for the string HKEY_CURRENT_USER\Control Panel\Screen Saver.3DText
  2. Create a new String Value called Magic
  3. Enter a value for it which will be the name of the file you want to use (e.g. c:\winnt\magic.txt)
  4. Create the file (c:\winnt\magic.txt) using notepad. The format is as follows:
    -Test
    blah
    deedum
    hello
    n00b

Important - The first word must be preceded by a hyphen as this is used to designate a group of words. It is this word that you must enter into the 3D Text screensaver 'textbox'. When you run the screensaver you will get a random showing af all the words under the hyphened word in the text file. You can add more sections to the text file (again give each section a hyphened keyword to use in the screen saver dialogue box).

Safe Data: Backup and Recovery

It is critical to ensure data integrity in todays business world. Loss of data can set you back days or weeks and may put you in hot water with more than your boss or client. There are a few methods and means by which to safeguard your data and help you sleep at night. After deciding what sort of media you will use a backup schedule is the key to a good night's sleep.

Please have a look at this White Paper from Sun Microsystems and call me if you have any questions or concerns.

There is no individual ownership when you are part of a team, it's the sum of the parts that makes you the RESILIENT team you need to be...