fusiongrokker

Entries Tagged as CFMenuCal

CFMenuCal: “True” Random vs. Evenly Distributed

Today I read Ben Nadel's post about the difference between random numbers and even distribution; which wasn't something I was unaware of, but was something that I hadn't given much consideration. Being the total geek that I am, I have a bias to support "random" numbers rather than even distribution - even though (as Ben points out) "if we were randomly selecting values between 1 and 10, it is possible (but unlikely) to randomly select 5 ten thousand times in a row;" - because I enjoy telling people they are wrong. (Sad but true. There's just something satisfying about telling people that the string 5555555 can be considered random.)

A while ago my wife asked me why it worked this way (because some meals would show up 3 times in a month, while others not at all), and that's when I explained that random numbers are not necessarily evenly distributed. She understood and then asked, in that innocent way that makes me wonder why I didn't think of it, why I used random numbers instead of even distribution.

So I have decided to put the feelers out and see what the opinions of my potential users are. There have been a handful of people who have expressed interest in the project, and if you wouldn't mind leaving a comment or sending me an email with your preference (random or evenly distributed?), it would be greatly appreciated.

Posted in CFMenuCal | ColdFusion | My projects July 20 2007

AJAX in ColdFusion 8: Don’t overthink it!

For CFMenuCal, I'm planning on using AJAX to display a "settings" type window, which will allow you to edit your meal data, allowable proximities, and other settings. To teach myself the basics of CFAjaxProxy and get a better idea of how to write my components to that end, I made a simple page that dumps the session scope, and has a form with a textbox and submit button that should - in theory - make the AJAX call to my test component, which will then update the session scope.

I know this sounds pretty simple, and in actuality, it is. But I spent at least a couple of hours on Saturday reading up on JSON, and thinking about how I'll need to implement it. I was thinking I would need to serialize my data on the client side, and then use DeserializeJSON() in my component to turn the JSON string into CF variables. As it turns out - that was wasted time. It's all done implicitly for you.

So first, let's build our component:

<cfcomponent name="AjaxTest" hint="Performs some proof of concept AJAX functionality for CFMenuCal.">       <cffunction name="updateSession" access="remote" output="false" returntype="Boolean">         <cfargument name="data" type="any" required="true">         <cftry>             <cfset session.data = arguments.data>             <cfreturn true>             <cfcatch type="any">                 <!--- log the error via cfmail or cffile --->                 <cfreturn false>             </cfcatch>         </cftry>     </cffunction>   </cfcomponent>

Notice that the I set the ACCESS of the function to REMOTE. This pretty frequently gets me (I commonly use PUBLIC), and I spend too much time trying to figure out why I'm getting "method X doesn't have any properties" JavaScript errors.

So now that we have our component, we need a page that uses it. Enter test.cfm:

<cfajaxproxy cfc="com.AjaxTest">   <cfdump var="#session#" label="Session Scope">   <form method="post" name="fooForm">     <input type="text" name="bar" size="30" />     <input type="button" onClick="sessionize(this.form.bar.value);" value="Save" /> </form>   <script type="text/javascript" language="javascript">     sessionize = function(data){         var updater = new com.AjaxTest();         var myObj = {};           myObj.numberValue = 42;         myObj.stringValue = "hello, world!";         myObj.userValue = data;           var success = updater.updateSession(myObj);           if (success == "true" || success == true){             alert('Success! Refreshing the page to update dump...');             document.location.href = document.location.href;         }else{             alert('An error occurred. Check the log for details...');         }     } </script>

The above assumes the component is named AjaxTest and resides either in a subdirectory named "com" of the current directory, or of the root folder. Running it should produce a cfdump that looks something like this:

CFDump

The moral of the story is: Don't overthink it! The ColdFusion 8 team over at Adobe has made this too easy.

Posted in AJAX | CFMenuCal | ColdFusion | Scorpio July 17 2007

Can it be? It’s finally here?

CFMenuCal α1 is, dare I say, ready for you to play with!

Considering that this is an alpha release, there is no way to modify user data (aka meals, settings) on-page. You'll need to edit config.cfm to change those things. Of course, this isn't a problem for you, because you're taking advantage of the ColdFusion 8 public beta, right?

I would love to get some feedback from anyone who plays with it. What do you like or dislike about it? What do you think should work differently? Feature requests, bug reports... bring it on!

Posted in CFMenuCal | My projects | Scorpio June 23 2007

inAction -or- Murphey’s Law In Action

The day that you make grandiose plans to spend hours working on a project when you get home, is the day that you leave the power supplies for both of your laptops at the office.

I am not giving up on or abandoning CFMenuCal, I promise.

I really want to work on it, and as soon as I have the means (when power supply availability and free time intersect) I intend to do just that. If absolutely nothing else, I'm planning on working on it during evenings or down time during CFUnited; because I'm shy and I'm sure that I'll end up alone in a corner somewhere. Bet your bottom dollar.

Posted in CFMenuCal | Meta June 20 2007