Category: ColdFusion

Almost a year ago I first released my ColdFusion to Confluence Gateway (read about Confluence here). Since then my use of the API spread into several applications. Not only have my requirements grown, but I found several ways to do things better. Notably from my last public version, connection state management/knowledge is significanly better.

Some new hooks include: exportSpace, getPagesOrdered (by space), getDescendents, searchSpace

Download The Latest Version Of The Coldfusion to Confluence Gateway

The other night I released a few tweaks to the already existing plugin for MangoBlog that does some code formatting and coloring. Being that I was still unhappy with the results I started tweaking. It wasn't long before I ended up with a completly redone color formating plugin. So what started out as tweaks resulted in almost a total rewrite. The changes includes modifications to the plugin parsing logic and the addition of targeted color coding. I'm starting out by targeting HTML, CF, ActionScript and MXML. There is a LOT of room for improvement, but as you can see in my examples below, I think it's very powerful.

In this first release I am supporting ColdFusion and ActionScript and MXML. Average use html and quotes will get styles applied accross the board. In design mode, simply wrap your code output with the followign styles. The nice upgrade with this feature is the ability to add this code directly into the WIZYWIG editor; so in the end I'm also parsing &lt;code&gt;, not just <code>. This results in a MUCH nicer display while editing code. No having to turn off JavaScript to edit your posts. The plugin can be downloaded at the bottom of the page.

  • <code></code>
  • <code class="as3"></code>
  • <code class="coldfusion"></code>
  • <code class="mxml"></code>

ActionSript 3 Example:
[Autowire(bean="EnvironmentVO")]
public var Environment : EnvironmentVO;

public function DownloaderDelagate() {
      Swiz.addEventListener(Swiz.INIT_COMPLETE, onSwizComplete);
}

public function onSwizComplete(event : Event) {
      /*
            Do Stuff With this.Environment Here to Init Class
      */

}

ColdFUsion Example:
<cfset var query = ""/>
<cfset var retVar = structNew() />
<cfquery name="query" datasource="myDsn">
      SELECT *
      FROM dbo.myTable
            LEFT JOIN dbo.table2
                  ON table2.id = myTable.id
      WHERE name = 'joe'
</cfquery>

<cfset retVar.query = query />
<cfreturn retVar />

The Coldfusion parser will actualy parse the <CFQUERY> sql code as well to a small extend giving color definition to [case sensative]: SELECT,FROM,WHERE,ORDER BY,GROUP BY,LEFT JOIN,RIGHT JOIN,INNER JOIN,JOIN,ON,LIKE,BETWEEN,AND,OR.

MXML Code Example:
<mx:Canvas id="wraper" width="100%" height="100%">
      <mx:Image src="«image path>" height="60" width="55"
      <display:CustomComponent id="testing" input="randomStuff" />
</mx:Canvas>


Default Code Example:
<html>
<body style="background-color: white;">
      <div>Hello World</div>
      <p clear="all"><a href="http://www.google.com">This is my example</a></p>
      <form name="form1">
            <input type="text" name="firstName" size="25" />
      </form>
</body>
</htmL>

http://www.mangoblog.org
Download the latest Version of Code Coloring by EmpireGP Services

I'm on a small Mango Blog kick tonight and decided to make a couple small adjustments to my Site Map Generator.

  1. I've tweaked the settings to only run on page and post creations, removing the onUpdate listeners.
  2. I've also updated the settings page to correctly show the last time the site map was generated from a stored attribute. In an earlier version I was storing this in the site map XML, which was causing a validation issue with the google bot; while I removed the offending code I never addressed the user interface issue.
  3. If you visit the settings page and the site map does not exist, it will be created and then shown to you. It's original behavior was to just tell you that it will be created the next time you make a post.
  4. Lastly I added a generate now link for the controlling personality in all of us.

Download the Latest Version of SiteMap Generator

I'm working on a screen saver for cooporate use that I've choosen to use Adobe Air for. Once I started building and installing my first tests I ran into a few things I didn't like when clicking the preview and settings buttons in the display properties of Windows. I decided to open up a small number of choices to the users by actualy giving them a "User Options" window. Windows is kind enough to pass some arguments along, so this was actualy pretty easy.

/c = Settings Mode
/p = A preview mode
/s = Run as Screen Saver (when you click preview or computer times out)

Step one was to create a listener set. In my case I put this in my top level application instead of my EnvironmentControl.as [in my Model-Glue-Flex framework] because I wanted to keep the entire app from initializing for a settings mode.

private function onPreInitialize():void {
      NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onArgumentsPassed);
}

private function onArgumentsPassed(e:InvokeEvent):void {
      if (e.arguments.indexOf("/p") != -1) {
            this.exit();
      } else if (e.arguments.indexOf("/c") != -1) {
            this.settingsMode = true;
      }
}

You'll notice that I have exited the screen saver on the preview mode. I did this because I found it annoying that windows would auto-launch the screen saver both on entering the tab in display properties as well as after saving and closing the settings window; These are the only two instances that the "/p" comes up in the arguments. The preview mode is suppose to launch the screen saver into mini-mode inside the faux computer screen in the pop-up, but I'm not sure how to do this or care to at this point.

I'm currently working on an Adobe Air based screen saver (technology choosen for ease of communicating to a central server). Things were going along well until I started to do performance testing today and I realized that garbage collection was not freeing up what I expected it to be.

To sum up my app very briefly I have a Canvas component that wraps an Image componant in order to give the apearance of a poloroid photo. When I get past a certain threshold I remove these wrappers via a removeChildAt(0) to sluff off the oldest image, freeing up space and memory. Turns out nothing was actualy being cleaned up. I found some good resources on garbage collecting that informed me of a few things I didn't know (specific to flash) but nothing got me closer...

Then the light upstairs randomly turned on and I thought, well if I there isn't anything on the outside of the wrapper holding on to it (such as an event listener), maybe there is something on the inside. This might seem like an obvious place to look, but my wrapper was only a handful of lines long and did absolutly nothing but look pretty... However due to the fact that I'm pulling images from a server down to the local disk (which is all done way prior to trying to draw to screen), my image source looks like this: new File(imagesDir.nativePath).resolvePath(aPhoto.name).nativePath.

SOLUTION:
In order to get garbage collection to work, I wrote a quick function inside my wrapper:

public function compact():void {
      (this.getChildAt(0) as Image).source = "";
      this.removeAllChildren();
}

I call this function first, then poof.... all my garbage collection works as "expected". Not only am I suprised that this worked, I'm suprised that I had to do this. Why on earth wouldn't an image get removed if it's container was destoyed?

Also, I ran tests without the this.removeAllChildren(); while garbage collection still worked, the overall average memory usage went up almost 650k for some reason.

 

Relate Reading:
About garbage collection
Why is the memory usage of my Flex app not coming down?
Garbage Collection and Memory Leaks