Archive for October, 2008
Wednesday, October 29th, 2008 by Greg Jastrab
I was waiting to post this until the results were announced which they were today. O’Reilly just posted the winners of the Adobe AIR Cook-off and I’m pleased to say I won the grand prize!
My recipe was Migrating Serialization Changes in AIR. Thanks to anyone who voted for it.
I have a follow-up recipe I haven’t gotten to write up yet, but I’ll try to get it up in the next week. It will provide a solution to add the marker which is required for this serialization to work to the front of your structures if you already have files being serialized in an existing AIR application and you want to start taking advantage of this migration technique.
Tags: AIR, cookbook
Posted in AIR, Greg Jastrab, Serialization | 3 Comments »
Tuesday, October 28th, 2008 by Scott Davis
To follow up on my other blog post about Paginating an ActiveResource model and to_xml I figured I should include the client-side code so you can see how to actually use will paginate helpers out of the box to paginate an ActiveResource request.
This is example code from my model:
def self.paginate(*args, &block)
options = args.pop
page, per_page, total_entries = wp_parse_options(options)
WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
count_options = options.except :page, :per_page, :total_entries, :finder
find_options = count_options.except(:count).update(:offset => pager.offset, :limit => pager.per_page)
args << find_options
# @options_from_last_find = nil
find_results = self.find(*args, &block)
pager.replace find_results
# magic counting for user convenience:
pager.total_entries = find_results.total_entries unless find_results.blank?
end
end
Example View code:
<%= render :partial => 'list' %>
<%= will_paginate(@model)%>
Tags: Rails Will_Paginate to_xml ActiveResource
Posted in Uncategorized | No Comments »
Tuesday, October 21st, 2008 by Greg Jastrab
A few days ago one of the commit messages in the Gumbo trunk mentioned some work for advanced CSS was beginning. I tried to create an example of using a descendant selector as well as an ID selector, but neither worked.
Tonight, another commit message said that this was now in place by default (I guess it would have worked earlier, but I needed to be specify a compiler argument). But now, after rebuilding the latest checkout of Gumbo you should now be able to compile the following example to see the advanced CSS selectors working. Below is the SWF (you’ll need Flash Player 10 to view it) and the code follows:
(more…)
Tags: CSS, Flex 4, Gumbo
Posted in Flex 4, Greg Jastrab, Gumbo, Uncategorized | 4 Comments »
Wednesday, October 15th, 2008 by Greg Jastrab
If you haven’t heard that Flash Player 10 was officially released, then get out of the hole you’ve been living in and go get Flash Player 10!
When you’re ready to deploy your first Flash Player 10 SWF, you’ll want to ensure your users have the latest Flash Player so they can actually view your content! Why not make it as easy as possible for them to upgrade and use SWFObject to embed your SWF and seamlessly upgrade older version of the Flash Player up to 10?
Let’s say you’re embedding a SWF called MyFlashPlayer10.swf. Using the dynamic publishing method there are just 3 simple steps to follow to get your SWF embedded with SWFObject…
(more…)
Tags: flash player 10, swfobject
Posted in Flash, Greg Jastrab, JavaScript | No Comments »
Tuesday, October 14th, 2008 by Scott Davis
After many failed attempts of trying to find a modal window that worked like facebox and used prototype, I gave up and started to write one from scratch. In the process I found the first port made by Phil Burrows. It wasn’t perfect but it was enough for me to build off of so with a few tweaks I was able to allow window resizing and let the box center itself. You can view the changes on my github.
Screenshot:

My Version of Facebox in our timetracker application
Tags: facebox, JavaScript, modal, prototype, window
Posted in JavaScript, JavaScript, Scott Davis | 1 Comment »
Friday, October 10th, 2008 by Scott Davis
We are currently working on a project that involves Flex and active resource + will_paginate and we needed to be able to paginate the xml transactions easily. Unfortunately, will_paginate and to_xml don’t play nicely when it comes to adding the current_page, total_pages, and page attributes to the xml. After many failed attempts I went looking around github and found in a few forks of will paginate that some people had solved this problem but, I didn’t want to install another version of the gem to risk breaking other apps on the server so I did it the rails way!
I started by creating a module that opens up the will_paginate collection class and includes ActiveResource and alias method chain the to_xml method to include these values. Example code below.
#enviroment.rb
...
require 'to_xml_extensions'
#lib/to_xml_extensions.rb
module WillPaginateHelpers
include ActiveSupport::CoreExtensions::Array::Conversions
def to_xml_with_collection_type(options = {})
serializeable_collection.to_xml_without_collection_type(options) do |xml|
xml.tag!(:current_page, {:type => ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[current_page.class.name]}, current_page)
xml.tag!(:per_page, {:type => ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[per_page.class.name]}, per_page)
xml.tag!(:total_entries, {:type => ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[total_entries.class.name]}, total_entries)
end.sub(%{type="array"}, %{type="collection"})
end
alias_method_chain :to_xml, :collection_type
def serializeable_collection #:nodoc:
# Ugly hack because to_xml will not yield the XML Builder object when empty?
empty? ? returning(self.clone) { |c| c.instance_eval {|i| def empty?; false; end } } : self
end
end
WillPaginate::Collection.send(:include, WillPaginateHelpers)
This now gives me the proper xml when I call to_xml
<?xml version="1.0" encoding="UTF-8"?>
<time-cards type="collection">
<current_page type="integer">1</current_page>
<per_page type="integer">25</per_page>
<total_entries type="integer">108</total_entries>
<time_card>
<approved type="boolean">false</approved>
<billable type="boolean">false</billable>
<created_at type="datetime">2008-10-10T14:04:13-04:00</created_at>
<date type="datetime">2008-10-10T14:04:13-04:00</date>
<has_been_billed type="boolean">false</has_been_billed>
<has_been_paid type="boolean">true</has_been_paid>
<hours type="float">2.0</hours>
<id type="integer">98</id>
<is_overtime type="boolean">false</is_overtime>
<task_id type="integer">6</task_id>
<updated_at type="datetime">2008-10-10T14:04:13-04:00</updated_at>
<user_id type="integer">1</user_id>
</time_card>
...
</timecards>
Tags: Rails Will_Paginate to_xml ActiveResource
Posted in AIR, ActiveRecord, Flex, Programming, Ruby, Ruby on Rails, Scott Davis, Serialization, XML | 4 Comments »
Wednesday, October 8th, 2008 by Greg Jastrab
A few times a day I update my subversion checkout of the Gumbo trunk. Last night I noticed a major overhaul which renamed all the Flex 4 classes, repackaged them into the mx package instead of flex. The new classes are now all (at least temporarily) prefixed with Fx, so if you are trying to compile your previously working Flex 4 code against the up-to-date SDK and suddenly see the following error:
Error: Could not resolve <Application> to a component implementation.
your issue will be resolved by changing Application to FxApplication. You’ll need to do the same for most of the other Flex 4 controls (Group, VGroup, and HGroup are exceptions that don’t need to be prefixed with Fx).
Spark Theme
You may also notice the new spark folder added in the skins directory. Below is an example application showing what these new skins look like for some of the Gumbo components:
(more…)
Tags: Flex 4, Gumbo, Spark
Posted in Flex 4, Greg Jastrab, Gumbo | 7 Comments »
Wednesday, October 8th, 2008 by John Trupiano
I’ve found myself on a benchmarking kick these last couple of weeks. Sometime last week, I dug up the better-benchmark library written by Pistos. Pistos’ library is basically just a wrapper for the rsruby gem, which is more or less an interface to R (similar to what rmagick is to ImageMagick).
Combining these tools together, we can do some pretty nifty code performance analysis in very few lines of code, e.g.
require 'rubygems'
require 'better-benchmark'
result = Benchmark.compare_realtime(:iterations => 10) { |iteration|
save_the_world()
}.with { |iteration|
save_the_world_and_save_the_girl()
}
Benchmark.report_on result
I have forked better-benchmark and wrapped the library up into a RubyGem.
(more…)
Tags: benchmark, mac osx, R, rsruby, Ruby, ubuntu
Posted in Benchmarking, John Trupiano, Programming, Ruby, Testing | 4 Comments »