OT: Random Image from Flickr
I came across this image on flickr. It made me laugh for some reason ...
;)
.. in the middle of the night
I came across this image on flickr. It made me laugh for some reason ...
;)
I see the day is already off to a rousing start.
http://googleblog.blogspot.com/2010/04/different-kind-of-company-name.html
Wake me when it is over ...
A recent link in twitter pointed out a Science Valentine comic. It got me to thinking about the strange rituals and spectacle of Valentine's Day. It has always seemed like a hokey, greeting-card holiday, more overtly commercial than all the others. Of course most holidays have become increasingly commercialized. But despite all that, I still love the magic of Christmas, the mystery of Halloween, and the inevitable laughter and tears that accompany most dysfunctional family "get-togethers" at Thanksgiving. But to me, Valentine's Day only evokes a sense of curiosity and humor at the artificially induced drama of it all.
As a young children we usually find the whole concept "icky" and want nothing to do with it. As we get a little older we must endure the angst of deciding whether or not to give a Valentine's Day card to someone we "like". (But.. if I do that then they'll _know_ I like them!) The pins and needles of waiting to see if that person you like gives you a card. The elation when they do. The crushing disappointment when they do not. Not to mention the awkwardness of receiving a card from someone you do not like. (Mom, is there a nice way to say "Ewwww. Gross. No way."?) Oh the high drama of primary school.
Even as adults, the day still evokes strong emotions in many of us. Those that are in relationships tend to "coo" and "gush" to a revolting degree. Those that are not, either piteously wallow in sorrow while tossing back copious amounts of beer or scarfing down chocolates, or they turn morose and bitter making scathing quips about the doomed nature of all relationships.
Despite the ups and downs of many Valentine's Days past, I choose to view the day with a bit of my usual weird humor. It is best summed up by the following song requests I heard one year:
I just wanted wish everyone in the CF community a Merry Christmas. I hope you all have a wonderful holiday. See you next year!
(My favorite holiday tune)
Why NORAD Tracks Santa
In a recent post on stackoverflow.com, member Sergii mentioned a ColdFusion easter egg. (Thanks Sergii!) Go ahead and feel smug if you already knew about it. If not, check it out. It is ... interesting.
While searching for others, I came across a few other fun ones. Not all CF-related of course. But there are definitely some strange and amusing ones out there.
Various Programs (source: www.stackoverflow.com)
http://stackoverflow.com/questions/397576/whats-your-favorite-easter-egg
JQuery *This one rocks!* (source: www.aliaspooryorik.com)
http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/136
Google (source: www.danvega.org)
http://www.danvega.org/blog/index.cfm?mode=cat&catid=CCF3C429-AE69-270C-3D2E62AA9CC59D70
RIA Unleashed : Boston Site (source: www.remotesynthesis.com)
http://www.remotesynthesis.com/post.cfm/announcing-ria-unleashed-boston
* See the P.S. at the bottom
While visiting the unicode.org site, I came across this unexpected title from 1992. (Yes, it really is about unicode. Who says unicode is a dry topic ;).
I have long been a fan of Firefox. But somewhere in between versions 2 and 3.5 it started behaving like a black-hole of resources, sucking up more and more memory, growing increasing sluggish. Not to mention taking forever to start up. So fickle user that I am, I have been trying out other browsers while I give Firefox one last chance before giving it the boot.
Of course one of the browsers I am (re-)trying is Chrome. I did use it briefly when it first came out. But quickly gravitated back to my beloved Firefox, with all of its wonderful extensions and flexible configuration. But I will admit Chrome is extremely fast. No news there. What was a nice surprise was its mini-Task-Manager (Shft-Esc) and the "Stats for Geeks" breakdown.
Meanwhile, I did some file shuffling and installed a completely fresh copy of FireFox 3.5.5. Just to see if I could get a sense of whether the true culprit was FireFox itself, a specific setting or one of my plugins. I tried to start with as little functionality and minimal settings as possible. Not all of them are relevant. But in the interest of full disclosure, here is a run down of the changes I made to the default settings:
Plugins:
- *Disabled* all of the plugins detected by default (EXCEPT Shockwave Flash 10.0.32.18)
I always wondered why my plugin list displayed certain entries I never added explicitly. It turns out it is due to Firefox's automatic scan for common plugins: http://kb.mozillazine.org/Plugin_scanning#Related_preferences
Extensions:
- *Added* Echofon (aka TwitterFox)
Privacy:
- *Changed* Remember browsing history to (at least 30 days)
- *Disabled* Remember search and form history
- *Enabled* Clear history when Firefox closes: everything
Cache:
- *Changed* Cache settings to use up to 30MB
Reason: Sometime after upgrading to FF3+, I noticed the autosuggest feature in the location bar had changed. It got progressively slower over time. So I am experimenting with a lower history threshold to see how it performs (before taking the extreme step of disabling it entirely).
Content:
- *Disabled* Java (No point enabling it since I disabled the plugin)
Startup:
- *Changed* Show a blank page
Update:
- *Changed* When updates to Firefox are found: (Ask me what I want to do)
So far Firefox is doing a lot better. Definitely faster, though maybe not quite as fast as Chrome. At one point I had 15 tabs open in Firefox (only one with Flash Content). Firefox peaked at around 160-180M memory usage in the windows Task Manager and still remained very responsive.
Now to start adding back a plugin at a time, and wait for ugly things to happen. Though I have to say I am enjoying reading some of the more creative ways people express their displeasure with the latest versions of Firefox.
Update November 19, 2009: I am now experimenting with the Firefox 3.6b3 beta and also a plugin called AFOM 2.0 for memory management. (Note: I do not know if this plugin officially supports 3.6b3 yet). But the results from my limited testing seem very promising. (Windows only)
Update November 27, 2009: While the plugin helps, there are still issues. I think it is time to declare defeat. The memory problem is definitely Firefox!
Hardly a week goes by without seeing some forum post that either uses or recommends my pet peeve: the erroneous SELECT MAX(id) query. Mind you this is across the board, not just in CF. For some bizarre reason, this faulty technique never seems to die. And it REALLY should. There are so many correct alternatives, I cannot understand why anyone would still use it for new code. If you are even considering it, might I inject a note of sanity and recommend some excellent reading material on Adrian J. Moreno's blog:
Scope Creep - 1 result
Scope Creep [skohp] [kreep]
Usage:
You are being a real creep about this. Building a space shuttle is not in the scope of a web application project. End of discussion. No wait... will you be traveling on it?
A recent response by Peter Boughton on stackoverflow.com pointed out a commonly overlooked technique for handling multiple selections from a set of database values. Well it reminded me that I wanted to write a small entry on the bizarrely underused INSERT/SELECT method. (Now chances are if you are already familiar with it, you are probably not reading this entry ;) So in summary, a SELECT statement can be used to INSERT multiple records into another table. Frankly, it is so simple I do not know why it is not used more often.
Take this frivolous form as an example. It uses your typical query to generate a series of checkboxes. The checkboxes are given the same name, so the selected id's will be submitted as a comma delimited list. Nothing earth shattering here.
Code<cfquery name="getFlavours" datasource="#MyDSN#">
SELECT FlavourID, FlavourName
FROM IceCreamFlavour
ORDER BY FlavourName
</cfquery>
<form method="post" action="saveFavorites.cfm">
<b>Select your favorite ice cream flavours:</b><br/><br/>
<cfoutput query="getFlavours">
<input type="checkbox" name="flavourID" value="#FlavourID#">#FlavourName#<br/>
</cfoutput>
<br/>
<input type="submit" name="saveMe" value="Save My Flavours!" />
</form>
Form
Now when it comes time to inserting the selected values into a database, you will often see code using a <cfloop> to INSERT the values one-by-one. While that does work, it is not the most efficient technique because it requires multiple queries. That creates another disadvantage. With multiple queries, there is always the possibility of leaving the database in an inconsistent state if an error occurs. Of course that can be solved with <cftransaction>, but there is a simpler option.
Since the source of the values is a database table, you can use a SELECT statement combined with an IN (...) clause to retrieve the id's selected and INSERT them into another table. All within the same query.
Validation omitted for brevity
<cfquery name="saveData" datasource="#MyDSN#" result="results">
INSERT INTO FavoriteFlavour ( UserID, FlavourID )
SELECT <cfqueryparam value="#session.userID#" cfsqltype="cf_sql_integer">,
FlavourID
FROM IceCreamFlavour
WHERE FlavourID IN
(
<cfqueryparam value="#form.flavourID#" list cfsqltype="cf_sql_integer">
)
</cfquery>
As a side benefit, you also get some extra validation. Since a SELECT is used to retrieve the values, only valid record id's will be inserted into the second table. While not the solution for every INSERT, you might be surprised at how flexible and useful this type of INSERT can be.
Once every blue moon, I am reminded of the fact that you cannot create a null character in ColdFusion. At least not in any of the ways you would expect.
When the moon rises, I quickly run through the logical possibilities chr(0), javacast("char", chr(0)), etcetera. Only to find they do not work. Each new attempt producing everything from a space character to an empty string. But no null character in sight.
As my frustration grows, my nails begin to lengthen. My flesh erupts in fur and my teeth transform into fangs. My nails gouge the keyboard as I begin to howl. Then I remember. There is a way. Somewhere in the tombs of google there is an ancient article on Null Characters in ColdFusion.
Searching google as quickly as my claws will allow, I find it. My fangs begin to recede. I try it. My fur transforms back into flesh. It works. I am safe for another few years.
Good thing too, because trying type with claws is pretty rough on the average keyboard. Well, I am off to the computer store to buy a new one. Maybe I will pick up two .. just in case.
(Yes, it has been that kind of a day. Grrrr)
In my rush today, I accidentally rejected some recent blog comments. So if you do not see your comment, that is why. So feel free to resubmit them.
Note to self: do not review comments before consuming a full measure of caffeine ;)
Like most people, I get a moderate amount of spam. Usually annoying, but occasionally I find the subjects amusing and start dreaming up imaginary responses. (Do not ask me why, my sense of humor is just weird that way).
Subject: You Have Won the British Lottery of £x,xxxx,xxx GBP
Response: Wow. So given the economic climate, the current exchange rate, the fact that this is a total scam, how much money are you trying to steal from me?
Subject: Trusting in your urgent reply
Response: My advice, try not to be so gullible. You are bound to be disappointed - a lot.
Subject: I have a problem. Needing your help
Response: Let me guess. You are addicted to spam. You know it is wrong, but you just cannot seem to help yourself.
Subject: 70% off Brand name pharmaceuticals
Response: Sorry. I promised my mother I would never accept pharmaceutical candy from strangers
Subject: Your urgent response needed
Response: Stop spamming me. This instant! Hurry! Hurry!
Subject: ** SPAM** WINNING NOTIFICATION FOR YEAR xxxx
Response: Congratulations. Being selected the top spammer of the year must be quite an honor for you. Your parents must be so proud! (Okay, so maybe that was not the original subject ...but close enough ;-)
Though I do wonder why a large percentage of spam is in capital letters. It is not bad enough they are "spamming" me, they have to shout too? Perhaps they are just excitable people that are a little too in touch with their inner caps lock key.
I do not always pay attention to Twitter but a link posted by Todd Rafferty had me shaking my head. Now that is just sad ...
Weak Password Brings 'Happiness' to Twitter Hacker
I just wanted to say Merry Christmas and Happy Holidays to everyone!
Yes Virginia, there is a Santa Claus
As far as google doodles go .. pretty sharp. "Now that's what I'm talking about".
http://www.google.com/logos/halloween08.gif
Rey Bango posted a recent entry called "Meme(me)" that gave me a chuckle. Now I know what you are thinking .. but the funny part was not the pictures. It was some of the comments:
".. careful w/ those bag monsters. They're dangerous!"
- Rey Bango
"There are enough horrible images available on the web- I don't think it needs pictures of me making things worse. :)"
- Mark Osbun
"Oh my-- cheesy E-mail fowards just met the blogosphere. :)"
- Brad Wood
(I am with Mark on this one ;)
I subscribe to a variety of mailing lists and forums. Not only to find answers to my own questions, but because it is a great place to exchange information and ideas. On a good list, you get exposure to a wide array of technical people, with varying backgrounds and experiences. Some discussions can be quite interesting, and I often learn new tricks or approaches just by reading them.
But one thing I have noticed in some forum questions, by both beginner and intermediate programmers, is a lack of solid troubleshooting skills. I find this very puzzling. Like it or not, if you program, you are going to have to troubleshoot code problems eventually. Even a single line of code has the potential for bugs. So while a firm grasp of the language, well written code and testing will minimize the potential for errors, they do not eliminate it. How quickly you are able to diagnose problems usually depends on your ability to troubleshoot. So I think it is a very important and necessary skill to develop.
Now I am not an expert by any means, but I do consider troubleshooting one of my strengths. Occasionally, I get "tripped up" by stupid coding errors just like everyone else. However, I can usually spot the issue myself just by taking the time to think the problem through and doing a little debugging. Sometimes the solution comes quickly, other times not. But it is a necessary process, and one that I learn from. Though in a few cases the most important thing I learned is what not to do ... ever again ;) While it did nothing to improve my headache at the time, I think it ultimately improved both my coding and problem solving skills.
At times we all overlook the obvious or approach something from the wrong angle. But when I see questions in which the asker gives no evidence of trying to work the problem through, I have to shake my head. It is almost as if the asker saw an error message, or strange code behavior, got "freaked out" by it, and temporarily lost their common sense ;)
Granted, error messages are often generic or cryptic. Yet sometimes they actually do tell you the exact cause of the problem. That is if we bother to read them. But in situations where error messages are ambiguous, or there is no error at all, applying a bit of logic and basic common sense can go a long way towards solving the problem.
There is no magical solution or one-size-fits-all approach, but there are a few basics steps I have found helpful when debugging code. Some of them may seem insultingly obvious, but I think they are worth re-stating ;) and hopefully it might help someone.
Assume it is a programming error, not a bug
While there is always a small chance a problem is caused by an obscure software bug, it usually is not. So I always start with the assumption the problem is a programming error, until I have run enough tests to suggest or prove otherwise.
Read error messages
Sometimes error messages tell you everything you need to know to fix a problem. So read them. Thoroughly.
Google it
If you receive an obscure error, or one you do not understand, copy and paste it into google, minus any application specific information. Chances are you are not the first one to receive that error. The explanation and fix for many errors is often just a google away.
Identify the location
My first step is usually to identify the location of the problematic code. It may be as simple as reviewing an error message, or it may not. If there is no error, I pick a last known good state in the process and work from there. In other words, I pick a point in the code that works correctly. Then work forward, a few lines at a time, until I can identify where the code fails. Each time I move forward in the code, I re-check the state of my variables/objects. If the results are good, I repeat the process until I hit an area where the test fails. If it makes more sense to start from a first known bad state, then I simply reverse the process. Sometimes identifying the location also identifies the problem itself. If it does not, I continue debugging.
Isolate the conditions
Determine if a problem occurs all the time, or only under certain conditions. The answer often gives valuable clues about the cause of the problem and/or how to fix it.
Test the obvious first
Most of us like to believe we are above making simple mistakes, but we are not. So forget about ego and do not overlook the obvious ;) The simplest or most likely cause often turns out to be the cause. Since those conditions are often the quickest and easiest to test, check them first.
Do not make assumptions about the code
When debugging code, if you expect an if/else conditional to evaluate to true, verify that it actually does. Logic errors are easy to miss because they do not always cause an exception. So as you step through the code, always verify the expected results match the actual results.
My conclusion: While developing effective troubleshooting skills takes time, mostly it is just common sense.
While perusing a site on CSS I noticed it contained a CSS version of the old <blink> tag. Let me just say that in the few moments it took to me read the pertinent section I remembered exactly what is so annoying about <blink>. Every second or so my eyes would jump, almost involuntarily, to the irritating movement in the corner of my eye. Maybe it was an instinctive fear response: the blink tag is coming to get me! ;) Whatever the reason, it was very distracting.
For a moment there I started to daydream. Imagining the creator of the blink tag locked in a large room, filled with hundreds and hundreds of neon signs. Each sign a different size and color. All of the signs blinking at alternate rates, twenty-four hours a day. All spelling out:
© Blogger templates The Professional Template by Ourblogtemplates.com 2008
Header image adapted from atomicjeep