Titanium Developer – Some Consolidated Tips for Setup on Windows

Categories: Android, Development
Comments: No Comments
Published on: March 25, 2011

When setting up Titanium Developer on my windows machine, I ran into a few headaches, so I thought I would consolidate a few of the solutions I found from others into one place.

First thing I encountered was that Titanium Developer could not find the adb executable even after i configured the path to the Android SDK in Titanium. This was because originally adb was included in the tools directory, but was later moved to a new directory within the sdk called platform-tools. Because this relative path is specified within Titanium, you have to create a logical link so that Titanium can find it in the path it thinks that it exists in. Here is a quick guide explaining how to accomplish this in Windows XP, Windows Vista, Windows 7, and Linux.

After I got past that, I encountered another error “Error locating JDK: set $JAVA_HOME or put javac and jarsigner on your $PATH”. Once again, over at the appcelerator development forums someone posted a solution for setting the path to resolve this issue.

Next I went to Test & Package the KitchenSink application and selected “2.2″ for the SDK. Note: I did not have the “APIs” versions of the SDK in my options initially. I read that the KitchenSink app was built for 2.2, so naturally I figured 2.2 would be the correct choice. Wrong, you actually need to select “APIs 2.2″. 2.2 is only the SDK, the APIs were not downloaded and installed for me within the Android SDK Manager. I had to go back in there and find the “Google APIs” options within the Available Packages and download/install them. I grabbed them all to be on the safe side, but that may not have been necessary.

Also, here are a couple of notes from the readme included with the KitchenSink download in case you “forgot” to read it:

Multiple Select Alternatives

Categories: Development
Tags: ,
Comments: 3 Comments
Published on: March 15, 2011

I think we have all heard the argument that multiple selects are not ideal inputs because to the average user, they require explanation as to how to actually select multiple items. It seems the most common approach to partially eliminate that confusion is the use of slush boxes. This eliminates the necessity to understand how to shift-click, but even with this approach, the shift-click would speed up the process if the user always understood the option was there. Here are some great jQuery plugins I found that really take it a step further and make some really powerful and clear alternatives to both the standard multi-select and the slushbox.

In the article Select Multiple Form Fields the author touches on the points I made above, but also presents a couple of additional options. One being a scrollable list of checkboxes, which is a definite improvement, but as he describes still has some limitations. The other alternative he mentions is the jQuery plugin asmSelect. This one, in my opinion, eliminates all of the guess work from interacting with the input field. He outlines that there are still some disadvantages, one of them being that you lose ability to quickly add several or all items at once. After reading the documentation on the plugin, I noticed that there is a fork of the project called bsmSelect, which takes the same concept and enhances it with things like effects, option groups, and the ability to select all (I am not 100% sure that this feature doesn’t exist in asmSelect, if that is the case I stand corrected). The select all feature helps to address the effeciency issue that was noted before where you cannot add multiple items at once. In my opinion, this doesn’t lack much at this point. Really nice tool.

The other alternative i consider as viable as those I just mentioned is this the jQuery UI MultiSelect Widget. This offers many of the benefits of the last example, but there is a significant benefit that comes with a sacrifice. The last plugin does not give you a guarantee on how much real estate the input will use on your page because it shows all of the selections on the screen. This one hides the selections, though it has one option “Using selectedText/selectedList” that will show a limited number of the selections, but can only use the width afforded to it before it just shows the count. This is a benefit in the way you can guarantee that this input will never use up a large percentage of space on your page. However, it can also be viewed as a drawback because it takes away the benefit of seeing your selections on the screen at all times. It all depends on your situation and preference. Both are amazing tools.

Nice WebCharts3D user guide

Categories: Development
Tags:
Comments: No Comments
Published on: March 4, 2011

There is a lot you can do beyond what ColdFusion’s chart tag enables by leveraging the WebCharts3D app for generating styles. This guide was really helpful, check it out: http://www.scribd.com/doc/36780822/Cold-Fusion-8-Userguide

CFScript equivalent for CFTimer

Categories: Development
Tags:
Comments: No Comments
Published on: December 7, 2010

You may or may not have noticed, but as you start writing more and more script based components in CF9, you will no longer have CFTimer as it has no script equivalent included. I have made a couple of helper functions that provide you with similar functionality using the CFTrace tag and getTickCount method.

Here are the functions:

ColdFusion:
  1. <cffunction name="timerStart" access="public" output="false" returntype="void" hint="Makes use of getTickCount to begin a timer similar to cftimer.">
  2.         <cfargument name="label" type="string" required="true" />
  3.        
  4.         <cfif not structKeyExists(request,"timerStartInstances")>
  5.             <cfset request.timerStartInstances = [] />
  6.         </cfif>
  7.        
  8.         <cfset arrayAppend(request.timerStartInstances,{
  9.             label = arguments.label,
  10.             startTime = getTickCount()
  11.         }) />
  12.        
  13.     </cffunction>
  14.    
  15.     <cffunction name="timerEnd" access="public" output="false" returntype="void" hint="Makes use of getTickCount and cfTrace to end a timer and display the results in the trace debug section.">
  16.    
  17.         <cfset var label = request.timerStartInstances[arrayLen(request.timerStartInstances)].label />
  18.         <cfset var totalTicks = getTickCount() - request.timerStartInstances[arrayLen(request.timerStartInstances)].startTime />
  19.         <cfset var traceContent = "Timer:  [#totalTicks#ms] #label#" />
  20.  
  21.         <cftrace text="#traceContent#" />
  22.    
  23.         <cfset arrayDeleteAt(request.timerStartInstances,arrayLen(request.timerStartInstances)) />
  24.        
  25.     </cffunction>

Here is how you use them:

ColdFusion:
  1. variables.helpers.timer.timerStart("A label for your timer");
  2.    
  3.         //Your code here
  4.        
  5.         timerStart("It even supports nested timers");
  6.    
  7.             //your code goes here
  8.    
  9.         variables.helpers.timer.timerEnd();
  10.    
  11.     variables.helpers.timer.timerEnd();

Performance concern with ColdFusion 9 object creation using New

Categories: Development
Tags:
Comments: No Comments
Published on: December 7, 2010

I recently deployed an application I had been working on using my local machine to my employer's testing server. After doing this, we started to notice a significant performance hit in several parts of the application. After finding out cftimer has been rendered virtually useless by writing script based components, I made a couple of functions to provide nearly identical capabilites of cftimer which you will see used in the sample code. I will spare you the details of the all of the things I was wrong on and just get to the point. In CF9, we are beginning to use Import in our components in order to initialize instances of another component using New. Here is an example of what I am referring to:

ColdFusion:
  1. import Helpers.Timer;
  2.  
  3. component{
  4.    
  5.     variables.helpers.timer = new Timer();
  6.    
  7. }

What I have found is that if the component above named Timer is located in a directory outside of your application, you will see time taken for "variables.helpers.timer = new Timer();" to execute go from 0-1ms to 40-50ms. But if you create an instance of Timer like the example below instead using the component path, the time to execute will remain 0-1ms:

ColdFusion:
  1. component{
  2.    
  3.     variables.helpers.timer = new Helpers.Timer();
  4.    
  5. }

Now don't get me wrong, the first example is my preferred approach from a syntax standpoint, and 40-50ms is not necessarily a huge amount of time. But in our testing environment we happen to be accessing our code through a file share, rather than the local machine as I use for development. In our testing environment that performance hit which was already ranging from 40-50x increased to 400-500x. The single line of code was taking 400-500ms to execute.

If you want to get my sample up and running locally to test it out for yourself download this and unzip it into your webroot. You will also need to do the following to get the test case running:

  • Define a mapping in your CF Administrator to the SandboxHelpers directory called SandboxHelpers
  • Define a mapping in your CF Administrator to the Sandbox\Model directory called SandboxModel
  • Make sure trace is turned on in your Debugging Settings in CF Administrator

Once that is all setup, just hit the index.cfm in your browser and look at the results in trace section of your debug and I suspect you will see something along these lines.
Trace Results

Download file to browser using CFScript

Categories: Development
Tags:
Comments: 3 Comments
Published on: October 20, 2010

I was working on a page that listed out previously generated exports and I wanted to provide a link that someone could click and download the actual CSV that was generated. I have done this in the past with tag based CF using something along the lines of this:

ColdFusion:
  1. <cfoutput>
  2.     <cfheader name="Content-Disposition" value="attachment; filename=#expandPath(relativePath)#">
  3.         <cfcontent type="application/unknown" file="#expandPath(relativePath)#" deletefile="No" reset="true" />
  4.     </cfheader>
  5. </cfoutput>

Well as I am now writing most of my components in CFScript, I wanted to accomplish the same thing, but without having a dummy view or a tag based component to pull it off. After pulling my hair out for a while, I was able to piece this code together based on parts of several tips I found on other blog posts and it worked like a charm:

ColdFusion:
  1. <cfscript>
  2.     private void function serveFile(string filePath){
  3.         var fileContent = fileRead(expandPath(filePath));   
  4.        
  5.         var context = getPageContext();
  6.         context.setFlushOutput(false)
  7.        
  8.         var response = context.getResponse().getResponse();
  9.         response.reset();
  10.         response.setContentType("text/csv");   
  11.         response.setContentLength(len(fileContent));       
  12.         response.setHeader("Content-Disposition","attachment; filename=#listLast(filePath,'\')#");
  13.        
  14.         var out = response.getOutputStream();     
  15.         out.write(ToBinary(ToBase64(fileContent)));       
  16.         out.flush();       
  17.         out.close();
  18.     }
  19. </cfscript>

Granted my scenario is specifically catered to downloading a CSV, but I believe just changing the contentType to something applicable to your situation would work just fine. Hope this helps someone!

UPDATE

I have since wanted to move this to a central location and use it for any file downloads. At first I changed the mime type to "application/unknown" and that was fine. Later I found I could find most mime types automatically using the library coldfusion.util.MimeTypeUtils and also was told to scrub spaces and invalid characters out of the attachment name by a coworker, so here is the modified code.

ColdFusion:
  1. <cfscript>
  2.     variables.mimeTypeUtils = createObject("java","coldfusion.util.MimeTypeUtils");
  3.    
  4.     public void function download(required string filePath){
  5.         var fileContent = fileRead(expandPath(filePath));
  6.         var context = getPageContext();
  7.         context.setFlushOutput(false);
  8.         var response = context.getResponse().getResponse();
  9.         response.reset();
  10.         response.setContentType(getMimeType(arguments.filePath));
  11.         response.setContentLength(len(fileContent));
  12.         response.setHeader("Content-Disposition","attachment; filename=#scrubFileName(listLast(filePath,'\'))#");
  13.         var out = response.getOutputStream();
  14.         out.write(ToBinary(ToBase64(fileContent)));
  15.         out.flush();
  16.         out.close();
  17.     }
  18.    
  19.     private string function getMimeType(required string file){
  20.         var mimeType = variables.mimeTypeUtils.guessMimeType(arguments.file);
  21.         if(isDefined("mimeType")){
  22.             return mimeType;
  23.         }
  24.         else{
  25.             return "application/unknown";
  26.         }
  27.     }
  28.    
  29.     private string function scrubFileName(required string fileName){
  30.         var extension = reverse(listfirst(reverse(arguments.fileName),"."));
  31.         arguments.fileName = reverse(listrest(reverse(arguments.fileName),"."));
  32.         arguments.fileName = Replace(arguments.fileName, ' ', '_', 'all');
  33.         arguments.fileName = REReplace(arguments.fileName, '\W', '', 'all');
  34.         return arguments.fileName & "." & extension;
  35.     }
  36. </cfscript>

Subselect with inline comma delimited query result

Categories: Development, Transact SQL
Tags:
Comments: 1 Comment
Published on: August 31, 2010

I needed to write a query that would output a list of entities, with a subselect containing all of it's related entities (could be multiple) in a comma separated list. This was for a one time report, so performance was not a concern, just simplicity. This post has a solution that dominated my task, check it out!

New ROM/Kernel combo (Ava-FroyoV6 & KiNgxKernel #4) for my Evo

Categories: Android
Tags: ,
Comments: No Comments
Published on: August 23, 2010

So far the combination of Ava-FroyoV6 and KiNgxKernel #4 seems extremely promising. I flashed last night, charged to 100%, turned on GPS, BT, Wifi, and 3G (no 4G), unplugged and went to bed. Five hours later I woke up to 98% battery left. That is pretty incredible even for standby time. We'll see how it goes as time passes. The scary part is that battery life usually improves after flashing a new ROM with more use.

GC overhead limit exceeded?

Categories: Development
Tags:
Comments: No Comments
Published on: August 16, 2010

If you are experiencing this error while (especially while using ORM in CF9), I recommend taking at look at Ray Camden's post to resolve the issue. I was absolutely destroying outlook by doing full error dumps and sending emails to myself!

Gmail’s new CheckAll Filter

Categories: Development, Other Stuff
Tags:
Comments: No Comments
Published on: August 12, 2010

With their recent update, it appears they have replaced the links that used to be at the top of your inbox (all, none, read, unread, etc) that you could click to check that subset of emails. The new convention is pretty neat. Now, the "check all" box for your inbox has been replaced with a sort of hybrid checkbox/select. You can check it and as you would expect it, would check all emails below it. Otherwise you can click the select arrow to see a list of those same commonly used subsets that used to appear at the top of your inbox. Clicking one of these options will select the corresponding subset of emails, just like the links used to.

I personally think this is a really neat idea for any criteria based list UI that has a subset of criteria that is more commonly used than most. I always liked what they were trying to accomplish by providing a shortcut to commonly used criteria, but I like this implementation better than the last. Looks cleaner.

Another new addition (at least I believe it is new) that I find noteworthy is also somewhat related to the check all functionality. In the past, check all was limited to only the records visible on your page. Any emails beyond that you, would have to click to that page and hit check all for those as well. I think this is a frustrating scenario that many developers have encountered at some point. When someone truly needs to check all, not just what is visible on the page, often times the solution I have went with is to offer a "View All" option in the pagination. Problem here is you are sacrificing the performance benefit of loading up only a single page of records. With some larger result sets, this might literally not even be an option for you.

Google has implemented a UI here that allows the user both options at the same time. Checking the check all box will check the visible results on the page for starters, but you are then also greeted with a linked message asking if you would like to check ALL results, even beyond that of what is on the page. This offers each solution, but with neither do they sacrifice the performance of paginating results.

I'd like to see them do one thing to take it a bit further. Right now, the link appears to only be presented when you check all options. I don't see any reason why you shouldn't have a link with the same option for the options available in the select for unread, read, etc. I want to be able to select all unread messages, and have it present me with a link that tells me the count of unread messages throughout the inbox and asks me whether I'd like to select those too.

Overall though, I give a thumbs up to the new enhancements.

page 1 of 5»