Saturday, July 19, 2008

Compile Flex 3 SDK from the Command Line

Here is a guide to setting up a Flex 3 project so that you can compile it from the command line:

  • download and set up the Flex 3 SDK, make sure the bin/ directory is on your path
  • make a directory for your project
  • in your projects directory make src/ and bin/ directories
  • copy the flex-config.xml from the flex SDK's frameworks directory into the root of your project
  • edit the flex-config.xml in your project, prepending ${flexlib}/ to all the libs/ paths and before the path references to manifest.xml and locale/
  • edit the flex-config.xml in your project, uncommenting the source-path element and setting its path-element element to src
  • create a compile file in the root of your project with the following content:

    Make this file executable.
  • Run the compile script to compile the project. The compiled swf will go to the bin/ directory and can be opened with your browser.

Here is a link to a zipped up version of a project where all the previously described steps have already been done for you (other than setting up the Flex 3 SDK of course).

This information primarily came from Simple Blog.

UPDATE: To use the trial data visualization components you need to copy several files over from a user that has installed flex builder. The instructions on which files and where they need to be placed in your sdk directory can be found here.

UPDATE UPDATE: The good people at Adobe have now made the data visualization components available as a separate download. You can find it here. You can download this archive and unzip it into your sdk and you will be good to go with the data visualization components - you won't need to download flex builder.

Firefox Greasemonkey Outlook Web Access Extension Part III

Other posts on OWAX: [ Part I | Part II ]

I have reverse engineered the way Microsoft Outlook Web Access uses Ajax to mark records read / unread under Internet Exploder and have added similar functionality to my Firefox Greasemonkey Outlook Web Access Extensions.

The code, also shown below, can be downloaded here.

Thursday, July 03, 2008

Firefox Greasemonkey Outlook Web Access Extension Part II

Other posts on OWAX: [ Part I | Part III ]

Small addition to my Greasemonkey Outlook Web Access Extension -- now the enter key submits the search on the find names form.


Code shown below and as a download here.

Saturday, June 28, 2008

Analyzing Rails Log Files for Slow Actions

There are plenty of packages for analyzing rails log files. These are helpful when you want to find bottlenecks in your application. A very easy to use one is rawk.rb discussed in Railscast #97. These tools are great as they help you to spend your efforts on the most costly areas of your code.

However, if you want to do a really quick, but less precise analysis of your code you can resort to some simple Unix tools as shown here:



This simple command line greps out the "Completed in" lines, cuts out the 3rd and 17th columns as separated by spaces, and then sorts the result. The two fields that have been cut out represent the number of seconds and URL for the action in question looking something like this:



9 seconds! Ouch!

Of course you can get much more advanced in the command line department with tools like awk but at that point you might as well download rawk.rb and get back to work.

Saturday, June 14, 2008

ActiveRecord Change SQL Server Query Timeout

Recently I had a rake task that was timing out while moving some data from a fact table into another data table. This task has to be run only when we get a new batch of data, do some ETL work, and then dump the data into the production database tables. I found out how to change the SQL Server query timeout on the Backyard Bamboo blog. Since I just wanted to turn off the timeout for the current session I ran some code like this:



The 0 turns the timeout off, otherwise the value is the number of seconds to set the timeout to. The default appears to be 30 seconds.

The timeout probably wouldn't occur if we add an index to a certain field on our fact table but this will get our data into production until we can make that change in the ETL process.

Wednesday, June 11, 2008

Javascript Closure

I think most people writing a lot of javascript eventually run into a misunderstanding about closures. Take a look at the code below. The code dynamically creates three buttons that show an alert box when clicked upon. What do you think will happen when you click each button?






The problem is that the animal variable used in the button's onclick event is changed in the loop and thus the event will use the value that was last assigned to the variable. In order to get the onclick event to use the value of the variable at the time the onclick is defined you will need to define an execution context which will capture this value. This can be done using a function. While this can be done with a regular function here is a nifty little example of doing this with an anonymous function:






Here is a slightly different (possibly simpler) way to create the function closure:




Friday, May 30, 2008

SQL Server information_schema.views Length Limitation and rails_sql_views

Recently I was running into a problem with a plugin called rails_sql_views (part of the Active Warehouse project). This is a great plugin created by some friends of mine that helps you manage views in a rails project. The plugin manages the proper creation of the view in the schema.rb file. For the SQL Server adapter the code to produce view comes from a query that looks like this:



The problem was that the view queries were being cut off. The cut off point seemed to be around 4000 characters. I mentioned this to my colleague Semergence and he recommended I look into the column definition for the view_definition column in the information_schema.views table. Sure enough, the column was defined as a nvarchar(4000). Who would be crazy enough to create a view that required more than 4000 characters right? Well, errrr, me I guess.

So armed with this 4000 number my google searches became very effective and turned up this from Joseph Scott. In the blog article Joseph reveals the sp_helptext stored procedure. Using this stored procedure you can easily get the full text of a views create statement, however, you do have to reconstruct it as it returns the result in separate rows under the key "Text". Here is the simple code: