ColdFusion

Forgive the title, I'm not sure it best describes the task. I was asked by a reader to consider a simple problem. Given a list of dates, how would you rewrite them so that two (or more) consecutive dates are displayed together? For examp...
Forgive the title, I'm not sure it best describes the task. I was asked by a reader to consider a simple problem. Given a list of dates, how would you rewrite them so that two (or more) consecutive dates are displayed together? For example, imagine this input.dates = [(May 1, 2013), (May 4, 2013), (May 5, 2013), (May 7, 2013)] I want to take this list and join the values that are one day apart. I should end up with: dates = [(May 1, 2013), (May 4, 2013 - May 5, 2013), (May 7, 2013)] I wrote two solutions for this - one in ColdFusion and one in JavaScript. Let's start with ColdFusion. First I create my sample data and a new array that will store my results. Now for the real "meat" of the logic. My idea here was to store objects in the new date array. The object contains a first and last property referring to the first and last date. What this allows for is a quick date comparison. If the next item in my source data is one day after the last value in the previous range, than we 'extend' the range by resetting the last property. Otherwise we need to add a new item in the result array. Finally, let's make this easier to use by doing some formatting on the array elements. We will loop through each item and add a 'formatted' key. And the result is this: Woot. Ok, now let's look at the JavaScript version. I'll just share the complete template first and talk about the differences. Ignore our two helper functions on top for now. Our initial seed data very similar to the ColdFusion one. Instead of using dateNew we use the Date constructor. The first loop is also pretty similar. Do remember that JavaScript arrays begin with 0. The main issue we have is doing the date comparison. There is no dateDiff in JavaScript. You can find great Date libraries out there, but as I had a very simple need here, I just wrote a quick function that compares the millisecond values of two dates and sees if the difference is less than one day. (By the way, the best JavaScript data library out there - imo - is Moment.js.) Finally, I did my formatting. Again, I could have grabbed a library for this, but instead I simply ran toDateString. My dtFormat function is a bit simple. Almost too simple to even be it's own function. But I was imaging that I'd probably want to make formatting a bit more complex in the future. This lets me handle that later. The result: Note - I switched to Firefox for the screenshot as I think it prints objects nicer in the console. I've included a zip with the complete code for both examples. Note the CFM has a tag-version as well for older CF engines.
score: 1 about 2 hours ago
Due to a problem back home, I have to leave the conference early. I'm giving my Mobile Web Debugging session in the first slot this morning (this schedule change will be announced this morning). Dave Ferguson will be covering my CF10+HTM...
Due to a problem back home, I have to leave the conference early. I'm giving my Mobile Web Debugging session in the first slot this morning (this schedule change will be announced this morning). Dave Ferguson will be covering my CF10+HTML5 session and Matt Gifford will be covering my PhoneGap session.
score: 1 3 days ago
Passing it on... My name is Derek Bowes and I used to run whousescoldfusion.com and twitter is @whousescf. I am currently working for healthendeavors.com and our Health Care application uses CF10 with SQL 2008. We need more CF de...
Passing it on... My name is Derek Bowes and I used to run whousescoldfusion.com and twitter is @whousescf. I am currently working for healthendeavors.com and our Health Care application uses CF10 with SQL 2008. We need more CF developers and are having a hard time finding good ones. They need to be on site in our Scottsdale, AZ office and we would be willing to pay to relocate the right candidate (US relocation only). Need someone mid-senior, with jQuery and JavaScript. If you could put the word out, it would be greatly appreciated. I can be reached at derek@healthendeavors.com.
score: 1 4 days ago
I've come across multiple people lately who have been bitten by this so I thought a quick blog post would be useful for me readers. If you've recently upgraded your ColdFusion server or patched it, you may find some forms return an error...
I've come across multiple people lately who have been bitten by this so I thought a quick blog post would be useful for me readers. If you've recently upgraded your ColdFusion server or patched it, you may find some forms return an error when submitted. Here is an example: To cause this error, I simply created a form with 101 fields like so: If you modify the loop to go to 100 instead of 101, it works fine. People using ColdFusion 10 or a recently patched ColdFusion 9 will encounter this. The cause is a recent security fix. You can read the details here (Adobe ships patch for ColdFusion flaw that could lead to DoS attacks), but most likely you are only concerned about how to get around this. In the ColdFusion 10 Administrator, under Settings, way at the bottom, you will find this new setting: You can tweak this to a value that makes sense for your form. For folks using ColdFusion 8 and 9, you have to edit a bit of XML to handle this. Details may be found here: ColdFusion Security Hotfix
score: 1 5 days ago
Ok, maybe "poetic" is a bit much... but you can listen to my Nerd Radio interview here: MAX Day 3: Ray Camden and Stupid Questions Ray Camden, Adobe Creative Cloud Evangelist, talks with us about his sessions at MAX covering topics...
Ok, maybe "poetic" is a bit much... but you can listen to my Nerd Radio interview here: MAX Day 3: Ray Camden and Stupid Questions Ray Camden, Adobe Creative Cloud Evangelist, talks with us about his sessions at MAX covering topics like PhoneGap Build and web development tools. Thanks to Leif and and Garth for inviting me!
score: 1 6 days ago
It has been a few weeks (ok, a few months) since my last blog post on JavaScript design patterns. I'd apologize, but frankly, it will probably be a few more weeks until I blog on this subject again, so hopefully people aren't expecting a...
It has been a few weeks (ok, a few months) since my last blog post on JavaScript design patterns. I'd apologize, but frankly, it will probably be a few more weeks until I blog on this subject again, so hopefully people aren't expecting a fast series here (grin). As a reminder, the idea behind this series is to create real, practical examples of various JavaScript design patterns based on the book, "Learning JavaScript Design Patterns" by Addy Osmani. (See my review here.) In this blog entry I'll be discussing the Revealing Module pattern.Addy Osmani describes the Revealing Module pattern as: The Revealing Module pattern came about as [Christian] Heilmann was frustrated with the fact that he had to repeat the name of the main object when he wanted to call one public method from another or access public variables. He also disliked the Module pattern's requirement of having to switch to object literal notation for the things he wished to make public. There's two main issues here. First, the concept
score: 1 6 days ago
This year was my second MAX as an employee and was both exciting - and pretty tiring. If you weren't able to make it though there is an easy way to catch what you missed.Keynotes Monday's keynote was focused on our product announcemen...
This year was my second MAX as an employee and was both exciting - and pretty tiring. If you weren't able to make it though there is an easy way to catch what you missed.Keynotes Monday's keynote was focused on our product announcements and featured our first hardware announcements ever - Mighty and Napoleon. If you haven't heard yet, Creative Suite is now Creative Cloud. You can find out more at the FAQ or feel free to just ask me. By the way - the hardware announcements were a complete surprise to me! Tuesday's keynote was cool as well. It focused on four different creatives discussing their process and showcasing their work. Sneaks There isn't a filtered list of the sneaks yet, and it looks like they aren't even all online (there were 12 total), but if you go to the AdobeCreativeCloud channel on YouTube, you can find a playlist called Adobe Max 2013. In this playlist are 6 of the 12 sneaks. Unfortunately, both of the Brackets sneaks are not there. I'm going to do a separate blog po
score: 1 9 days ago
As a User Experience (UX) designer, I spend a lot of time with pen and paper, sketching interfaces, testing ideas, and fleshing out use-case workflows. I work exclusively in grayscale. This holds true for both sketching and digital proto...
As a User Experience (UX) designer, I spend a lot of time with pen and paper, sketching interfaces, testing ideas, and fleshing out use-case workflows. I work exclusively in grayscale. This holds true for both sketching and digital prototyping. On paper, I use a black pen (Pilot Precise Grip, Bold) on white, unruled paper; on the computer, I use a single font-face (Helvetica Neue LT Std) and about 5 different shades of gray. ... Read More »
score: 1 9 days ago
Oddly, the last of my Adobe MAX sessions is available online now but none of my earlier ones. I assume they will show up in the next day or so. But for now, enjoy my eloquent presentation on the more advanced aspects of using PhoneGap Bu...
Oddly, the last of my Adobe MAX sessions is available online now but none of my earlier ones. I assume they will show up in the next day or so. But for now, enjoy my eloquent presentation on the more advanced aspects of using PhoneGap Build. You can download the source code for the sample apps and slide deck as well. As always, I hope this is helpful!
score: 1 10 days ago
Someone came up to me after my MAX session on web development debugging and asked for some advice on how to 'sell' unit testing to his clients. This was my response: Simple. Tell the client you feel unit testing is so important that...
Someone came up to me after my MAX session on web development debugging and asked for some advice on how to 'sell' unit testing to his clients. This was my response: Simple. Tell the client you feel unit testing is so important that you're willing to talk about it with him face to face. In fact, you'll even fly him to your location. In order to save money though you're going to use a budget airline that skips testing.
score: 1 11 days ago