Monday, August 17, 2009

The Save

Once upon a midnight dreary, fingers cramped and vision bleary,
System manuals piled high and wasted paper on the floor,
Longing for the warmth of bed sheets, still I sat there doing spreadsheets.
Having reached the bottom line I took a floppy from the drawer
I then invoked the SAVE command and waited for the disk to store,
Only this and nothing more.

Deep into the monitor peering, long I sat there wond'ring, fearing.
Doubting, while the disk kept churning, turning yet to churn some more.
But the silence was unbroken, and the stillness gave no token.
"Save!" I said, "You cursed mother! Save my data from before!"
One thing did the phosphors answer, only this and nothing more,
Just, "Abort, Retry, Ignore?"

Was this some occult illusion, some maniacal intrusion?
These were choices undesired, ones I'd never faced before.
Carefully I weighed the choices as the disk made impish noises.
The cursor flashed, insistent, waiting, baiting me to type some more.
Clearly I must press a key, choosing one and nothing more,
From "Abort, Retry, Ignore?"

With fingers pale and trembling, slowly toward the keyboard bending,
Longing for a happy ending, hoping all would be restored,
Praying for some guarantee, timidly, I pressed a key.
But on the screen there still persisted words appearing as before.
Ghastly grim they blinked and taunted, haunted, as my patience wore,
Saying "Abort, Retry, Ignore?"

I tried to catch the chips off guard, and pressed again, but twice as hard.
I pleaded with the cursed machine: I begged and cried and then I swore.
Now in mighty desperation, trying random combinations,
Still there came the incantation, just as senseless as before.
Cursor blinking, angrily winking, blinking nonsense as before.
Reading, "Abort, Retry, Ignore?"

There I sat, distraught, exhausted, by my own machine accosted.
Getting up I turned away and paced across the office floor.
And then I saw a dreadful sight: a lightning bolt cut through the night.
A gasp of horror overtook me, shook me to my very core.
The lightning zapped my previous data, lost and gone forevermore.
Not even, "Abort, Retry, Ignore?"

To this day I do not know the place to which lost data go.
What demonic nether world is wrought where lost data will be stored,
Beyond the reach of mortal souls, beyond the ether, into black holes?
But sure as there's C, Pascal, Lotus, Ashton-Tate and more,
You will be one day be left to wander, lost on some Plutonian shore,
Pleading, "Abort, Retry, Ignore?"

Saturday, August 15, 2009

Programmer's Night Before Christmas

'Twas the night before implementation and all through the house,
not a program was working not even a browse.
The programmers hung by their tubes in despair,
with hopes that a miracle would soon be there.

The users were nestled all snug in their beds,
while visions of inquiries danced in their heads.
When out in the machine room there arose such a clatter,
I sprang from my desk to see what was the matter.

And what to my wondering eyes should appear,
but a super programmer (with a six-pack of beer).
His resume glowed with experience so rare,
he turned out great code with a bit-pusher's flair.

More rapid than eagles, his programs they came,
On update! on add! on inquiry! on delete!
on batch jobs! on closing! on functions complete!
His eyes were glazed-over, fingers nimble and lean,
from weekends and nights in front of a screen.

A wink of his eye, and a twitch of his head,
soon gave me to know I had nothing to dread.
He spoke not a word, but went straight to his work,
turning specs into code; then turned with a jerk;

And laying his finger upon the "ENTER" key,
the systems came up and worked perfectly.
The updates updated; the deletes, they deleted;
the inquiries inquired, and closings completed.

He tested each whistle, and tested each bell,
with nary an abend, and all had gone well.
The system was finished, the tests were concluded.
The users' last changes were even included.

And the user exclaimed with a snarl and a taunt,
"It's just what I asked for, but not what I want!"

Wednesday, March 11, 2009

iPhone 3.0 Wishlist

* MMS (seriosuly, I want this, I cant stress enough how annoying it is when a friend sends me an MMS and I have to go to at&t's stupid MMS site to view it)
* Copy & Paste, there are just too many times I have needed to do this, the iPhone is not a "smart" phone if it wont allow copy & paste
* Push Notifications
* Background applications running...I want to be able to listen to music and check mail. And music means iTunes, LastFM and Pandora. I shouldn't have to choose between listening to my music and looking up stuff.
* Springboard update. Let me organize my apps more efficiently, I want scrolling on the screens and a stacks type interface (they have it on jail broken phones). Let me have more than 7 screens if I want. And let me add themes to Springboard.
* Let me use my iPhone like a harddrive....like every other iPod on the planet!!!!
* Syncing of notes....seriously, how is this not available.
* Let me delete, or hide native iPhone apps, with the weather channel app why would I use apples native weather app?
* Flash on the browser!
* Flash on the browser!!!
* Let me organize apps in iTunes, the draggin across several screens is annoying when doing major reorganizations.
* All native apps should have landscape layout...especially Mail.
* Make the functionality the same on native apps...why can't I click a telephone number in Calendar and have it call, but I can in mail and web?
* Make the native apps more interoperable. Let me turn a mail message into a task, or calendar appointment and vice versa.
* Full use of bluetooth. I want wireless headphones, and beaming of contact information. My samsung phone can sync with my Apple Laptop via bluetooth....but my Apple phone can't!!! Ridiculous

Thursday, July 31, 2008

XML Fluent Interface

Mark S. Rasmussen recently posted a wonderful way of writing out XML text in .Net simply, I found it amazingly useful for Flash development to take data and make XML files for consumption of the swf file. Several of the commentor's mentioned some improvements that could be made to the class, so I took his class and modified it.

The changes were sometime superficial, like I renamed some of the properties to names that made a little more sense (i.e., within renamed to ParentOf). Where as some of the changes were more to the core of the class, like where he used XmlDocument to write the XML, I used XmlTextWriter which made node stack management much easier. I agreed with his thought though that sometimes you don't want raw XML but you want to manipulate it still. So I added properties to output to string, XmlDocument, or XmlTextWriter (though why you'd use the last one I am not sure).

I redid his more complex structure example for you to see below:
---

xOut xo = new xOut()
.XmlDeclaration()
.Node( "root" ).ParentOf()
.Node("user").ParentOf()
.Node("username").InnerText("orca")
.Node("realname").InnerText("Mark S. Rasmussen")
.Node("description").InnerText("I'll handle any escaping (like < & > for example) needs automagically.")
.Node("articles").ParentOf()
.Node("article").Attribute("id", "25").InnerText("Handling DBNulls")
.Node("article").Attribute("id", "26").InnerText("Accessing my privates")
.CloseParent()
.Node("hobbies").ParentOf()
.Node("hobby").InnerText("Fishing")
.Node("hobby").InnerText("Photography")
.Node("hobby").InnerText("Work");


As you can see, it works very similarly to his class. It's not perfect, but ladies and gentlemen here's my class xOut:
---

using System;
using System.Xml;
using System.IO;

public class xOut
{
// The internal XmlWriter that writes the XML.
private XmlTextWriter xw;

//The internal memory stream that holds the XML.
private MemoryStream ms;

// Whether the next node should be created in the scope of the current node.
bool nextNodeChild = true;

public String GetString()
{
xw.WriteEndDocument();
xw.Flush();

ms.Position = 0;

StreamReader sr = new StreamReader(ms);

String XMLString = sr.ReadToEnd();

xw.Close();
ms.Dispose();
sr.Dispose();

return XMLString;
}

public XmlTextWriter GetXmlText()
{
return xw;
}

public XmlDocument GetXmlDoc()
{
xw.WriteEndDocument();
xw.Flush();

ms.Position = 0;

XmlDocument xd = new XmlDocument();
xd.Load(ms);

xw.Close();
ms.Dispose();

return xd;
}

public xOut ParentOf()
{
nextNodeChild = true;

return this;
}

public xOut CloseParent()
{
if (nextNodeChild)
nextNodeChild = false;
else
xw.WriteEndElement();

return this;
}

public xOut XmlDeclaration()
{
ms = new MemoryStream();

xw = new XmlTextWriter(ms, System.Text.Encoding.UTF8);
xw.WriteStartDocument();

return this;
}

public xOut Node(string name)
{
if (nextNodeChild == false)
xw.WriteEndElement();

xw.WriteStartElement(name);

nextNodeChild = false;

return this;
}

public xOut InnerText(string text)
{
return InnerText(text, false);
}

public xOut InnerText(string text, bool useCData)
{
if (useCData)
xw.WriteCData(text);
else
xw.WriteString(text);

return this;
}

public xOut Attribute(string name, string value)
{
xw.WriteAttributeString(name, value);

return this;
}
}

WebDevelopment addons for Firefox

This is my list of required addons for Firefox:
  • Clear Cache Button
  • ColorZilla
  • Firebug
  • MeasureIt
  • Screen grab!
  • View Dependencies
  • Web Developer

Configuring Firefox for Kerberos Authentication

While working at a client's location, I found that they used Kerberos authentication on their LAN. While Firefox can natively use Kerberos authentication, by default it is not turned on. Here is how you can configure Firefox:
  1. Enter about:config in the URL bar
  2. In the filter text box start typing in network.negotiate, to filter the results
  3. Change network.negotiate-auth.delegation-uris to your domain
  4. Change network.negotiate-auth.trusted-uris to your domain
  5. Restart Firefox
That's all there is to it. Now you should be authenticating nicely across the network.

Friday, June 30, 2006

Avoiding Duplicate Key Values in Excel

A co-worker was looking to store some records in Excel, but wanted to make sure that there were no duplicate values within the key field. Since this was just a flat record system, converting it to Access of FileMaker Pro seemed like overkill, but we were at a loss as to how to prevent key values in Excel since it is not a database system and does not index. The short answer is, you can't without VBA. However, with a little formula you can help avoid the problem of duplicate entries. This is actually a two step process, though for simplicities sake you only need do the first one.

Conditional Formatting

To avoid duplicates, you can emply conditional formatting. This will enable any duplicate values to show up as a different colour and give you a visual clue that this was a duplicate. The draw back to this step, is it does not prevent duplicates it only warns you that you have made a duplicate but it is still up to you to change the key value so it is no longer a duplicate. Here is how to set up the conditonal formatting:
  1. Go to the cell that will contain the key entry for your first record. (In this example we use row 1 for a header, and column A is where we are typing our key values. So, our first record will go on row 2, since 1 is for headers, making the cell we select A2)
  2. Click on the Format menu, then click on Conditional Formatting... ( a pop-up box will display)
  3. There should be a drop-down box that says "Cell Value Is". Click the down-arrow next to that and change the selection to "Formula Is"
  4. To the right of our drop-down box is where we will type our formula. This is the formula you will want to type out:
    =COUNTIF(A:A,A2)>1
  5. Now that we have told Excel what to look for, we need to tell it how to format the cells. Click on the Format... button in the dialogue box, another pop-up box will display.
  6. Choose your format to anything you want, I chose changing the font to white and then clicked on the Patterns tab and chose a red background, so that the cell and text will really stand out.
  7. Click OK, to close the second dialog box. (You should be able to see a preview of how your new formatting will look, if you don't like it go back and make some changes.) Then, click OK on the first dialog box to return to your spreadsheet.
  8. Without moving the Excel cursor, copy the cell by hitting [CTRL]+[C] on your windows keyboard.
  9. Now, select the entire column by hitting [CTRL]+[SPACEBAR] on your windows keyboard.
  10. We will now paste this formatting to every cell in this column by choosing Edit, from the menu, then clicking on Paste Special...
  11. Select the Format option under the paste header, then click OK
Now, any time you enter a duplicate value the duplicate values will show up with your special formatting.

Data Validation

This technique will prevent anyone from typing in any duplicate values at all. While this may seem the preferable way its drawback is it only works for someone typing in the cell, if they cut & paste the data validation will not work. So, this technique must be used in conjunction with conditional formatting. However, if they do a lot of manual typing to enter the values this is an extra layer of security to insure no human error. Here is the procedure to turn on data validation:
  1. Go to the cell that will contain the key entry for your first record. (In this example we use row 1 for a header, and column A is where we are typing our key values. So, our first record will go on row 2, since 1 is for headers, making the cell we select A2)
  2. Select the Data menu, then Validation...
  3. On the Settings tab, change the Allow drop-down box to Custom.
  4. In the Formula box, enter this formula:
    =(COUNTIF(A:A,A2)>1=FALSE)
  5. Make sure the Ignore Blank check box has a check in it
  6. Click on the Error Alert tab
  7. Our error will be a Stop error, add an appropriate Title (like, Duplicate Data) and explain the error in the Error Message box (I wrote: "You have already used this value, please select another")
  8. Click OK
  9. Without moving the Excel cursor, copy the cell by hitting [CTRL]+[C] on your windows keyboard.
  10. Now, select the entire column by hitting [CTRL]+[SPACEBAR] on your windows keyboard.
  11. We will now paste this formatting to every cell in this column by choosing Edit, from the menu, then clicking on Paste Special...
  12. Select the Validation option under the paste header, then click OK
You have now added a validation option to each cell in your primary field, and any hand entry that results in a duplicate value will not be allowed by Excel. Between both of these options you should be able to succesfully avoid duplicate values in an Excel database without the use of VBA.