Posted by & filed under Developer Blog.

First, a trick. If you want to display a comma separated list from an array all you need to do is multiply that array by a comma. “What’s that”, you say? You heard right. If you have an array in the variable @my_array you can simply place the following in your view:

<%= @my_array * ", " %>

The comma and space in your string will be added to the end of every string in your array except for the last one. Beautiful! I love rails.

Now for the reason for my post. While I’ve known this little trick for a while, I came across the need to titleize the outcome because my array contained all lowercase strings and I wanted to diplay them as titles.

It took a little trial and error, but the solution is rather simple:

<%= (@my_array * ", ").titleize %>

To apply the titleize method, you simply wrap your multiplication is parenthesis and add the .titleize as you normally would.

(Note: I still have not upgraded to Rails 2.0, so I cannot guarantee any of this will work in newer versions)

Posted by & filed under Developer Blog.

If you use the latest version of Omniture’s SiteCatalyst, you are probably aware of how poorly their nice pretty reports translate to PDF, Word, and Excel when you use the “save” tools available right there in the suite. Images get removed, text gets misaligned, and colors get skewed.

Today I devised a nice, quick method for getting a printable report that looks identical to the report you see on your screen. The one downside, no selectable text for copy/paste later. But if that’s your concern, rather than printing, you probably aren’t worried about format as much anyway.

The solution I created involves downloading a FireFox extension called Pdf It! and Omniture’s own print feature.

Once you have Pdf It! installed and your report you wish to print is on the screen, simply click the print icon in SiteCatalyst’s toolbar at the top of your report. This will open a new window with limited browser chrome (toolbars, status bars, etc.) and will load your report without any of the extra navigation at top or left of your report. Basically a nice printable report. Only to print from this screen doesn’t always give the result you desire as browser to printer support isn’t always the greatest. You will still run into issues with missing images, cut off edges, etc.

So, the next thing to do is cancel the print job that automatically appears. Now you are left with just the print window. Right click somewhere in that print window and select Pdf It! > Save as PDF > Whole Page. Pdf It! will open a save dialogue and you can save that page to your desired directory. From here you can simply open that newly created PDF and print. Or if you prefer, attach it in an email to the people who care.

Posted by & filed under Developer Blog.

Thanks to Robert who gave me this bit of information.

Apparently in Flash Player 10 the clipboard can only be invoked by user interaction. My copy/paste deterrent—that I previously blogged about and subsequently became my most popular and most frequently visited post—was based on the idea that the clipboard would be written to several times per second because it was fired in the EnterFrame event. So, needless to say, it will not work in the latest version of the Flash Player Plugin.

Here’s what Adobe has to say about it on their website:

“In Flash Player 9, ActionScript could set data on the system Clipboard at any time. With Flash Player 10, the System.setClipboard() method may be successfully called only through ActionScript that originates from user interaction. This includes actions such as clicking the mouse or using the keyboard. This user interaction requirement also applies to the new ActionScript 3.0 Clipboard.generalClipboard.setData() and Clipboard.generalClipboard.setDataHandler() methods.”

Maybe someone will be able to take my idea and figure out a way to detect “user interaction” outside the 1px by 1px flash file I was using to accomplish the task. Then maybe we can get it working again.

Oh well, it was fun while it lasted!

Posted by & filed under Developer Blog.

I’ve spent the past 3 days trying to install Adobe CS4 Web Premium on my home Windows XP computer (as the second install of my license at work). I kept getting an error before anything would install telling me something like “the following programs failed to install” (I forget the exact wording).

Upon checking the Windows System Logs (Event Viewer -> Application), all it would tell me was “Product: Adobe Anchor Service CS4 — Installation operation failed.” With no other explanation.

After spending a bunch of time trying to find the answer with Google and on Adobe’s website, I finally came across the solution. Part of the problem, as I see it, is that CS4 is so new there isn’t much help out there for it yet. In the end, the solution is for CS3 but works beautifully for CS4 as well.

Basically you need to complete 2 simple steps.

1) Download and install the Windows Installer CleanUp Utility here:
http://support.microsoft.com/kb/290301

2) Download, unzip, and run the Adobe Windows CS3 Cleanup Script (which relies on the Windows program mentioned above to run) here:
http://www.adobe.com/support/contact/cs3clean.html

I only had to run level 1 of the cleanup script to make it work.

As I said before, even though the Cleanup Script says it’s for CS3, it did work for me in installing CS4 as well.

Posted by & filed under Developer Blog.

When you use overflow:auto in your css in conjunction with Scriptaculous’ Autocomplete, there is a bug that makes the entire page jump around when you use the arrow keys on your keyboard to navigate up and down through the suggestion list. This bug normally appears only when the page itself is long enough to require a scroll bar.

I managed to come up with a very clean working solution by hacking the controls.js file that comes with scriptaculous. The solutions requires replacing the markPrevious and markNext functions and adding a small line of code to the updateChoices function.

Currently, markPrevious and markNext are telling the page to jump around like that, and I’m not sure why! As far as I can tell (please let me know otherwise) this solution could be included in the scriptaculous without breaking a thing (hint, hint to the scriptaculous team).

To implement the solution, replace:

markPrevious: function() {
 if(this.index > 0) this.index--;
  else this.index = this.entryCount-1;
   this.getEntry(this.index).scrollIntoView(true);
},
 
markNext: function() {
 if(this.index < this.entryCount-1) this.index++;
  else this.index = 0;
  this.getEntry(this.index).scrollIntoView(false);
},

With:

markPrevious: function() {
 if(this.index > 0) {this.index--;}
 else {
  this.index = this.entryCount-1;
  this.update.scrollTop = this.update.scrollHeight;
 }
 selection = this.getEntry(this.index);
 selection_top = selection.offsetTop;
 if(selection_top < this.update.scrollTop){
  this.update.scrollTop = this.update.scrollTop-selection.offsetHeight;
 }
},
 
markNext: function() {
 if(this.index < this.entryCount-1) {this.index++;}
 else {
  this.index = 0;
  this.update.scrollTop = 0;
 }
 selection = this.getEntry(this.index);
 selection_bottom = selection.offsetTop+selection.offsetHeight;
 if(selection_bottom > this.update.scrollTop+this.update.offsetHeight){
  this.update.scrollTop = this.update.scrollTop+selection.offsetHeight;
 }
},

Now find the updateChoices function and just after the code this.stopIndicator(); add this.update.scrollTop = 0; so that it looks like this:

this.stopIndicator();
this.update.scrollTop = 0;
this.index = 0;

I’ve tested in FF 2.0.0.4, FF 3.0.5, Chrome 1.0.154.43, Safari 3.2.1, Opera 9.5.1, IE 7.0.5730.13 and IE 6.0.2600 without problems.