November 21, 2008

Pages


Search Site


Topics



Archives

Tweets

Entries for month: July 2007

Free license for Aqua Data Studio (OS X) for O.S. Developers

July 30 2007 by Adam
Since switching to my MacBook last December I have had but one regret: The lack of MS SQL Server Enterprise Manager. I quickly found Aqua Data Studio, but as a hobbyist I can't justify the cost of a personal license, and as one of few Apple nerds at my company, I couldn't convince them to buy the license for me. I have been able to get by using phpMyAdmin (gasp! php!) for MySQL databases, and a Windows laptop when I absolutely must, for MS SQL Server. Today I saw Ray Camden's post on how Aqua Fold gave him a free license because he develops Open Source software, and I fired off an email of my own. Within the hour (I bet this is also reflected in their tech support), not only did they reply asking for my personal information to fill out the license registration, but they offered me the beta of version 6.5 of ADS (which should be a public-beta in a few weeks, and launched around September). There has been some recent discussion in the CFBloggers discussion group about advertising in your blog, and in particular, giving the impression that you are presenting an objective view, even when the possibility exists that your opinion has been biased (as it might if you were given a free license). So to keep this as objective as possible, here are some cold, hard, facts:
  • Aqua Data Studio is the only DBMS GUI for OS X that I have found, that isn't in its infancy and / or doesn't just plain suck. (The part about sucking is my opinion)
  • ADS supports a ton of different DBMS'.
  • I used the free trial, and based on that, really, really wanted a license; but eventually uninstalled the trial after it expired, shedding a single tear.
  • Aqua Fold will give you a free license for Open Source use.
Draw from that whatever you want. For me, it means more productivity, and one new icon in my dock.

Posted in Apple | Databases |

Scope Nazi

July 24 2007 by Adam
Some people are anal retentive about not using pound signs where they aren't necessary (my boss), some people are anal retentive about var-scoping local variables in components (Raymond Camden); and then there's Me. I'm anal retentive about scoping all of your variables. Consider this. When you execute this line of code:

<cfset foo="bar">

There is only one thing that could happen: A variable in the "variables" scope is set with the value "bar". (Unless you're in a CFC, in which case you should be using var scope, like Ray advocates. ;) On the other hand, when you execute this line of code:

<cfif foo is "bar">

The value could potentially be read from one of NINE scopes, in MX7. To clarify, I'm fine with implying your variable scope, however, it irks me to no end when you infer your variable scope. (What's the difference between implying and inferring?) To wit, a colleague pointed out that she was having issues with this code:

<CFQUERY name="orders" datasource="#application.DS#">   SELECT distinct ORDERS.ord_id, ORD_placedOn, ORD_billFirstName, ORD_billLastName,    ORD_Total, Ord_Total + isnull(Adjust_total,0) as net_sales, ORDERS.OSTATUS_id,    ord_assignedTo, OSTATUS_name, orders.ORD_shipAmount, p.prod_assembly_reqd   FROM ORDERS, OrderStatus, payflowpro,    (Select ord_id, sum(adjust_total) as adjust_total from Order_Adjust where result=0 group by ord_id) as Order_Adjust,    Order_Item OI, Item_View I, Product P, ordershipaddr osa   WHERE ord_completed = 1   AND … </CFQUERY>   <CFOUTPUT query="orders">   <CFQUERY name="getManu" dataSource="#application.DS#">     select distinct man_name, manufacturer.man_id, item_name, album_id     from Order_Item, item_view as item, product, manufacturer     where order_item.ord_id=#orders.ord_id#     and item.item_id=order_item.item_id     and item.prod_id=product.prod_id     and product.man_id = manufacturer.man_id   </cfquery>   <cfloop query="getmanu">     <cfif (listfind(application.vendor_inhouse_list,man_id) gt 0 or       listfind(application.inhouse_album_list,album_id) gt 0) and       prod_assembly_reqd eq 'Y' and       oitem_sample neq 1>A<cfelse> </cfif>   </cfloop> </cfoutput>

The issue was that sometimes the variable prod_assembly_reqd was undefined. The resolution was simply to use proper scoping. This is the code I sent back:

<cfif (listfind(application.vendor_inhouse_list, variables.getManu.man_id) gt 0 or   listfind(application.inhouse_album_list, variables.getManu.album_id) gt 0) and   variables.orders.prod_assembly_reqd eq 'Y' and   ?????.oitem_sample neq 1>A<cfelse>&nbsp;</cfif>

The last one, where I used the scope "?????", I noted that this is probably inferring the Variables scope, but that she should check on it and make sure she indicates which it is.

Posted in Best Practices | ColdFusion |

CFMenuCal: "True" Random vs. Evenly Distributed

July 20 2007 by Adam
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 |

AJAX in ColdFusion 8: Don't overthink it!

July 17 2007 by Adam
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 |

CFBloggers

July 13 2007 by Adam
Today I joined the CFBloggers group, started by Charlie Arehart. Anyone interested in discussing blogging in/on/about ColdFusion should check out Charlie's blog entry on the group and consider joining.

Posted in Meta |