Advanced Tips
Spark List Vscrollbar on Left side Print E-mail
I spend an unusual amount of time trying to figure out how to set up scrollbars in spark flex (flash builder) beta 2. I wanted a list with the scrollbar on the left side instead of the right side. With a little help from flexpotential.com I managed to figure it out. Its a bit of a hack and I'm just adding this for a comp, but here is the skinclass you need to implement on your list control with a vertical or tile layout. It doesn't include the hscrollbars and a lot more needs to be done, but I hope this helps people started!

<?xml version="1.0" encoding="utf-8"?>

<!--

ADOBE SYSTEMS INCORPORATED
Copyright 2008 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.

-->

<!--- The default skin class for a Spark List component.  

@see spark.components.List

@langversion 3.0
@playerversion Flash 10
@playerversion AIR 1.5
@productversion Flex 4
-->
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
  minWidth="112" minHeight="112"
  alpha.disabled="0.5" blendMode="normal"> 
 
 <fx:Metadata>
 <![CDATA[ 
 /** 
 * @copy spark.skins.spark.ApplicationSkin#hostComponent
 */
 [HostComponent("spark.components.List")]
 ]]>
 </fx:Metadata> 
 
 <fx:Script>
 /* Define the skin elements that should not be colorized. 
 For list, the skin itself is colorized but the individual parts are not. */
 static private const exclusions:Array = ["scroller", "background"];
 
 /** 
  * @copy spark.skins.SparkSkin#colorizeExclusions
  */     
 override public function get colorizeExclusions():Array {return exclusions;}
 
 /* Define the content fill items that should be colored by the "contentBackgroundColor" style. */
 static private const contentFill:Array = ["bgFill"];
 <!--- @inheritDoc -->
 override public function get contentItems():Array {return contentFill};
 
 override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
 {
 if (getStyle("borderVisible") == true)
 {
 border.visible = true;
 background.left = background.top = background.right = background.bottom = 1;
 //scroller.minViewportInset = 1;
 }
 else
 {
 border.visible = false;
 background.left = background.top = background.right = background.bottom = 0;
 //scroller.minViewportInset = 0;
 }
 
 super.updateDisplayList(unscaledWidth, unscaledHeight);
 }
 </fx:Script>
 
 <s:states>
 <s:State name="normal" />
 <s:State name="disabled" />
 </s:states>
 
 <!-- border -->
 <s:Rect visible="false" left="0" right="0" top="0" bottom="0" id="border">
 <s:stroke>
 <s:SolidColorStroke color="{getStyle('borderColor')}" 
 alpha="{getStyle('borderAlpha')}" 
 weight="1"/>
 </s:stroke>
 </s:Rect>
 
 <!-- fill -->
 <!--- Defines the background appearance of the list-based component. -->
 <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
 <s:fill>
 <!--- Defines the color of the background. The default color is 0xFFFFFF. -->
 <s:SolidColor id="bgFill" color="0xFFFFFF" />
 </s:fill>
 </s:Rect>
 
 <!--- The Scroller component to add scroll bars to the list. -->
 <!--- The container for the data items. -->
 <s:Scroller visible="false" id="scroller" includeInLayout="false"/>
 <s:HGroup gap="2">
 
 <s:VScrollBar height="100%" viewport="{dataGroup}" top="0" left="0" right="0" bottom="0" />
 
 <s:DataGroup id="dataGroup" clipAndEnableScrolling="true" height="{this.height}" itemRenderer="spark.skins.spark.DefaultItemRenderer">
 <s:layout>
 <s:VerticalLayout gap="0" horizontalAlign="contentJustify" />
 </s:layout>
 </s:DataGroup>
 </s:HGroup>
 
</s:SparkSkin>

 
Flex/Flash Builder Params Base Print E-mail
I looked around for a while today at support forums to find out how to include params.base by default in my flash builder flex 4, and flex 3 applications. It appears you just have to edit your html-template index.template.html file.

Along with src, bin-debug, and other folder, in your application there is a html-template folder. You can open this externally or you can simply navigate to it in flex, then right click and edit it. All I had to do was add a line after

params.allowfullscreen = "true";

params.base = "http://radiologygallery.com"

Now my images and data services load direct from the website from my local machine. (Of course the website holds a crossdomain.xml file as well!)
 
Ruby performance tests 1.8 1.9 insertion sort Print E-mail
I am brushing up on some of my old algorithm books and have been benchmarking them in ruby 1.8.6 and 1.9.1

Basically I have both installed and ruby19 is the alias for ruby 1.9.1. The server I am running is currently dedicated and I put the cat /proc/cpu in case anyone is interested below as well.

In my sort algorithms I am placing an array of random integers length n (passed as an argument) randomized from 0 to n and using insertion sort to sort. I run it m times, so i run

ruby insort.rb n m
This mean a sorting of n elements from 0-n and the test is run m times

Each run I generate a new array so the data sets are different and the sort difficulty is random

Here are some runs I did

[jared@143086-web1 testc]$ ruby insort.rb 100 100
insertion_sort: 0.00369423ms average
[jared@143086-web1 testc]$ ruby19 insort.rb 100 100
insertion_sort: 0.00095015904ms average

[jared@143086-web1 testc]$ ruby insort.rb 500 100
insertion_sort: 0.05235899ms average
[jared@143086-web1 testc]$ ruby19 insort.rb 500 100
insertion_sort: 0.01686314909ms average

[jared@143086-web1 testc]$ ruby insort.rb 1000 20
insertion_sort: 0.20634605ms average
[jared@143086-web1 testc]$ ruby19 insort.rb 1000 20
insertion_sort: 0.08078076745ms average

Here is a run with a pretty big data set for insertion sort.

[jared@143086-web1 testc]$ ruby insort.rb 5000 5
insertion_sort: 4.2183736ms average
[jared@143086-web1 testc]$ ruby19 insort.rb 5000 5
insertion_sort: 1.2406564422ms average

[jared@143086-web1 testc]$ ruby insort.rb 10000 1
insertion_sort: 17.899982ms average
[jared@143086-web1 testc]$ ruby19 insort.rb 10000 1
insertion_sort: 4.949758742ms average



I don't have the time to do a true analysis, but as far as I can tell with this algorithm the ruby 1.9 compiler seems to be 10 to 100 times fater with smaller data sets, and when the data set gets larger it seems to converge on about 2 to 4 times faster.

I pasted my code below, I'm not optomizing it, just writing each algorithm as quick as I can!


Read more...
 
more bluegost fcgi issues with rails 2.3.3 and 2.3.2 Print E-mail
Here are the steps you need to take to resolve their mistake. Here is more details with a like to the ticket to hopefully help some people out! The problem is rack, not rails 2.3.3

You need to understand the command line, and a bit of rails for this...!

gem install rack
vim ~/ruby/gems/gems/rack-1.0.0/lib/rack/handler/fastcgi.rb
** Note - Depending on your configuration on bluehost you may find your gems in ~/.gem/ruby/1.8/gems, so replace ~/ruby/gems/gems/ with that

Comment out line 7
# alias _rack_read_without_buffer read

Last you need to update enviornment.rb
get your full path with
pwd
ENV['GEM_PATH'] = '/home3/radiolo1/ruby/gems:/usr/lib/ruby/gems/1.8/gems'
of course you need to replace /home3/radiolo1 with whatever your home path is, and if you are in the .gem directory it will look more like
ENV['GEM_PATH'] = '/home1/jibwacom/.gem/ruby/1.8:/usr/lib/ruby/gems/1.8/gems'
Which I had to do on another account



 
How to instal rails on bluehost 2.3.2 Print E-mail
Bluehost recently upgraded rails and I had some problems with my old and new apps. I wrote a more comprehensive tutorial here, which also has info from bluehost they haven't posted yet. I am just writing this to give a short rails install overview for bluehost for anyone with some command line and rails experience.

1.) Get shell enabled.
2.) Go to your home
> cd ~
> rails -D appname
> rm public_html
> ln -s appname/public public_html

Done... goto sitename.com and you will see rails welcome.

For mysql and to make sure dispatch.fcgi is running right you need to log into mysitename.com/cpanel and create a mysql user account.

(remember they append your bluehost username to the db name)

Here is what you should see in your appname/config/database.yml for development

development:
  adapter: mysql
  database: dbname
  username: dbusername
  password: dbuserpass
  socket: /var/lib/mysql/mysql.sock
  timeout: 5000

For a quick test type
> cd appname
> script/generate controller test
> vim app/views/test/index.erb
Put some text into the index file and save

now goto mysitename.com/test and you should see you text and rails is running!

One small note for those that aren't used to running rails in this manner, when you update config files, or routes you usually need to kill the dispatch process.
1..) Login to your cpanel
2.) Click on process manager
3.) Find the dispatch process and click on kill

Now you can reload an see new routes, etc.
 
bluehost rails update cgi problems Print E-mail
Recently Bluehost updated rails from 2.2.2 to 2.3.2 removing support for the older gem. My sites started to go down so I tried to get to the root of the issue and after a few phone calls I talked to support. My main problem is that I was using cgi for some reason.  Eventually I realized the problem wasI had an old version of .htaccess from years ago modified incorrectly.

The scripting support was nice enough to send me the New Rails Install tutorial that hasn't been updated on their website but should reflect what currently needs to be done. I pasted it below for those of you having trouble with initial installation. I also wrote a quick tutorial.

This document can help a new install as well as an upgrade to function properly under the new server configuration.

First you need to make sure that you dispatch.fcgi and .htaccess files are correct. I pasted the below,

Another way to get them right is to type on the command line, rails -D sampleapp. This will install the sample app, which you can cd sampleapp/public and just copy the dispatch files to your app
cp sampleapp/public/* myapp/public

Remember to remove index.html

Lastly check two things
myapp/config/enviornment.rb
If you have a require_rails_version make sure that version is 2.3.2

Also make sure to rename
myapp/app/controllers/application.rb ro application_controller.rb

And that should fix you up.


Read more...
 
Rails viewing nested attributes with xml Print E-mail
I've run into this problem many times with rails. I need to list out something and inside of this list may be other nested lists of properties.  I'm using two models for this example

CustomTask has_many StateChanges
StateChange belongs_to CustomTask


You would think a simple CustomTask.all.to_xml(:methods => ['state_changes']) would give you a nice list with nested state_changes, but unfortunately to_xml seems to not want to serialize this array properly. Also, forcing the :include in the find does nothing to help the to_xml either.

I've done this on multiple nested models and it always converts to xml much better.

  def list
        custom_tasks = CustomTask.find(:all).collect do |ct|
                h = ct.attributes
                h['state_changes'] = ct.state_changes
                h
        end

        render :xml => custom_tasks.to_xml(:dasherize => false)

  end

If there is a simpler way, by all means, let us know and we'll post it here!

 
Flex Datagrid persistant Caseless Sorting Print E-mail
I've been working on a project with multiple data grids with multiple columns. The users requested two things: when they get the refreshed list from the server they would like the datagrid to keep the sort that was on it prior, they also want the sort to be case insensative. Below is the actionscript class I created to do just this. I haven't done much testing, but if I make some major updates I'll update the code! I also plan to have it hold the last selected item and reselect it after the reload of data as well!

I just extended datagrid, and this is Flex 3.0, I am guessing it will work the same with gumbo, and around the same way with advanced data grid.
Read more...
 
Rails nested attributes custom modification Print E-mail
I have been working with an issue for a while where every time I have associations they seem to have a lot of issues going to and from XML/Params. I was impressed with nested_attributes written by Eloy Duran and packaged with Rails 2.3.2. I realized thought that there was no means of having attributes that weren't sent back up to the server deleted. I also realized there was no simple workaround this without just skipping the nested_attributes.rb altogether. I asked the main group and it seems the consent is that it is dangerous to do this, but none the less, my software needs this feature so I just copied and updated Eloy's code and created my own dangerous_nested_attributes.rb . Which is below... and here.

It should have all of Eloy's features, with the addition of an option to :destroy_missing, and I only added it to the has_many relationship.
1.) Put dangerous_nested_attributes.rb in /lib
2.) Add two lines at the bottom of config/enviornment.rb

include DangerousNestedAttributes
ActiveRecord::Base.send :include, DangerousNestedAttributes

3.) Declare it in your the model linke so

class Recommendation < ActiveRecord::Base
        has_many :recommendation_type_details, :dependent => :destroy
        has_many :recommendation_details, :through => :recommendation_type_details
        accepts_dangerous_nested_attributes_for :recommendation_type_details, :destroy_missing => true
...
end

4.) Restart your server
 
XML child bindings and change watchers in actionscript Print E-mail
I have spent the better part of two days trying to figure out this issue about XML and setting changewatchers on child elements. I ended up talking to Mike at DigitalPrimates to find the answer. Here is the short of the conversation.

Preface 

When you have itemrenderers bound to an xmllist, and each item is
bound to the xml object their properties update when the xml data is
updated. Even if I had a list with a single element like

<observations>
<observation>
<name>Josh</name>
<report_text>needs help</report_text>
<observation>
<observations>

And maybe I change the data outside the itemrenderer, like name to "Joshua"

The label would reflect the change as long as I put the code to
assigne label.text in the overridde set data method


Short Question:

How do I add a change watcher to a child node of XML or some way for a
child of a stack to know that the XML it holds a reference to has been
updated elsewhere in the program with as3?



Short Answer

"When you have itemrenderers bound to an xmllist"

No such concept. If you look in the datagrid or list controls, as soon
as you pass it an XMLList, it wraps it in an XMLListCollection.
XMLListCollections broadcast an event named collectionChange when their
contents change. That is how list controls know to reset the data on
your item renderer.

My Solution (Dirty, but it worked)

Pass reference to the xml into a new xmllistcollection with an event listener

xmlC = new XMLListCollection()
                         xmlC.addItem(myXML)
                         xmlC.addEventListener(CollectionEvent.COLLECTION_CHANGE, isSelected)

If anyone comes up with a better way I'd love to hear it This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

 
rails associations deep to xml troubles Print E-mail
I've been working with rails for a while now and have been trying to figure out how to render complex associated models to_xml for use in my flex frontend without a bunch of messy code. I've set association builders in the model, which ends up breaking down when I need to call a similar association. I've manually generated a hash with lots of loops and for each statements, and tried to use rails built in include and methods statements, and still haven't found a really nice way to make deep nested associations convert to xml well.

Recently I started playing with the collect method and I've settled on this as my best practice method, with the least amount of code. I'm sure it can be improved upon, and I'd gladly hear about a better method. Below is a bit about my models and the controller code to get them into xml format properly.
Read more...
 
FFMpeg on Bluehost or per user installation elsewhere Print E-mail
I noticed today that there was a new ffmpeg version ( .50 ) out and decided to get it installed on my bluehost account. It was suprisingly easy. The only thing I couldn't find out an easy way to do bluehost was get the svn checkout or the git checkout. I just sshed over to another of my servers that did and then put the file up on the web. I will leave it up, on this site if anyone wants to download the version from today, but I don't plan to keep the most recent version up. 

If you want to see if my compiled binary works on your bluehost server, which it should, just download it from my web server
> wget http://jibwa.com/ffmpeg.bin

On bluehost your bash configuration will by default add any files you put in the ~/bin directory or home/bin. So I put the file there and changed the permissions for my user to run it.

> mkdir ~/bin
> mv ffmpeg.bin ~/bin/ffmpeg
> chmod u+x ffmpeg.bin

If you want to compile it, just get onto your command line and



Read more...
 
Ruby on Rails on Ubuntu Print E-mail

This is a very basic set of steps that I would follow to set up Ruby on Rails so you can do the 15 minute rails blog tutorial on a ubuntu desktop.

Here is a 15 minute blog tutorial. It shows the simplicity of rails, but doesn't talk too much about installation and database configuration. There are other such tutorials on the web, but this one I thought was good.


Read more...
 
Rails Mongrel and Apache all together now 2 Print E-mail
From my prior doc  Rails Mongerl and Apache All togerher now 1 I created a very basic rails application, mostly for the purpose of displaying text, and maybe some images afterwards. I am going to run mongrel which I installed with

gem install mongrel

to see whether what I wrote displays through mongrel. I run

script/console

Which runs mongrel on port 3000. So I navigate to

http://jibwa.com:3000/photo

and I get XML back

Now I know my Rails is working properly and is rendering form the db. Now I need to get apache
Read more...
 
Rails Mongrel and Apache all together now 1 Print E-mail
I spent a lot of time looking at ways to run rails on Apache a few months ago. Whether or not there is an easier way to to it I think this is the best way to do it.. I am running a fully updated Redhat 5 Rackspace Server

I have done all this before but its been a while so I am just going to do a fresh application and get it runnning some basic code, and then get it live. If you already have a working app you can skip down. I do this all from a bash command line.

First I go to my rails app directory

cd /home/jbwhite/rubyprojects
mkdir photoalbum
rails photoalbum

Now Rails is installed and I have to make a mysql database and configure that.
mysql -u root -p

>create database photoalbum_development
>grant all on photoalbum_development to rbuser@localhost identified by 'password'


Read more...
 
Excel file size reduction Print E-mail
I have been working on an Excel 2003 Workbook with about 10 Sheets, and about 50 pages of visual basic scripts. The actual data content shouldn't be all that big because the worksheets are relatively small. I spent a lot of time trying to find ways to reduce the file size and nothing seemed to help until I found a posting on mrexcel.com about  the  
Read more...
 
Find exploit and remove it with python regular expressions Print E-mail
I had an explot hit a site that wasn't on one of my servers and there wasn't an backup availalbe to resore from. Still having to fix this I decided to write a script to inspect all the files and remove the bad text. Mostly the exploit appended an iframe at the end of files, but I wrote my script to remove particular text no matter where it sat in the file.

I wrote a bit about a python file structure crawler and I'll include my whole method below for reference.


Read more...
 
Python path walk list directories and files Print E-mail
I needed to crawl a directory structure and get a list of all the files with their absolute location, I think the easiest way to do this is with os.path.walk. The syntax is a little confusing at first, but it works fine and I end up with the list of all files with their folders from whatever location I start at.



Read more...
 
Ubuntu Advanced Desktop Cube Video Print E-mail
 
Radeon Ubuntu 7.10 fglrx Print E-mail
I spent the better part of a week trying different tutorials and ways to get my Radeon 9700 set up to work with Ubuntu Desktop 7.10. (Advance Desktop Effects are a must)  All the tutorials I found were steering me in so many directions I called an expert to see what he thought was the best way. He reccomended I simply revert everything back
Read more...
 

Jibwa Work Samples

Contact Jibwa LLC

Under Construction

Jibwa.com is under construction. Watch out for broken links, missing pages, potholes and bulldozers. We apologize for the temporary inconvenience - Jibwa.com Staff

News and Updates

Radiology Gallery

Jibwa and Tripwirearts have built and  launched a new website with Dr Benjamin Strong. radiologygallery.com for radiology continuing medical educ...
Read More ...

Spark List Vscrollbar on Left side

I spend an unusual amount of time trying to figure out how to set up scrollbars in spark flex (flash builder) beta 2. I wanted a list with the scrollb...
Read More ...

Flex/Flash Builder Params Base

I looked around for a while today at support forums to find out how to include params.base by default in my flash builder flex 4, and flex 3 applicati...
Read More ...

TripwireArts Website

Jibwa LLC partner TripwireArts has a newly designed website with information on some of our clients and established services....
Read More ...