<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>Avi Tzurel</title>
  <link href="http://kensodevkensodev.com/feed.xml" rel="self"/>
  <link href="http://kensodevkensodev.com/"/>
  <updated>2012-01-17T17:57:24+02:00</updated>
  <id>http://kensodevkensodev.com/</id>
  <author>
    <name>Avi Tzurel</name>
  </author>

  
  <entry>
    <title type="html">Copy files from remote server to your local box</title>
    
      <link href="http://kensodevkensodev.com/2012/01/17/copy_file_from_remote_server_to_local_machine"/>
    
    <id>http://kensodevkensodev.com/2012/01/17/copy_file_from_remote_server_to_local_machine</id>
    <updated>2012-01-17T17:42:00+02:00</updated>
    <summary>Quick post with example of how you can copy a file from remote server to your local machine using SSH</summary>
    <content type="html">
      
        &lt;p&gt;I work a lot with remote servers (as any developer working with production).&lt;/p&gt;

&lt;p&gt;Sometimes, I want to download a file from the remote server to my local box, this includes log files, maybe some mysql backup or generally any other file.&lt;/p&gt;

&lt;p&gt;I can&amp;#8217;t copy the file to an HTTP accessible location and download since all of the servers are behind a load balancer and it will probably get to a 404.&lt;/p&gt;

&lt;p&gt;To copy a file from a remote server to my local box I use this&lt;/p&gt;

&lt;p&gt;&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;scp &lt;span class='o'&gt;{&lt;/span&gt;username&lt;span class='o'&gt;}&lt;/span&gt;@&lt;span class='o'&gt;{&lt;/span&gt;server_address&lt;span class='o'&gt;}&lt;/span&gt;:&lt;span class='o'&gt;{&lt;/span&gt;file_location&lt;span class='o'&gt;}&lt;/span&gt; .
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Sometimes your server requires a key file&lt;/p&gt;

&lt;p&gt;&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;scp -i &lt;span class='o'&gt;{&lt;/span&gt;key_file_location&lt;span class='o'&gt;}&lt;/span&gt; &lt;span class='o'&gt;{&lt;/span&gt;username&lt;span class='o'&gt;}&lt;/span&gt;@&lt;span class='o'&gt;{&lt;/span&gt;server_address&lt;span class='o'&gt;}&lt;/span&gt;:&lt;span class='o'&gt;{&lt;/span&gt;file_location&lt;span class='o'&gt;}&lt;/span&gt; .
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;For the times when you need something quick, just to download a log file and continue with it, this works out great.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Rails polymorphic association without the type column, possible?</title>
    
      <link href="http://kensodevkensodev.com/2011/12/16/rails-polymorphic-association-without-the-type-column-possible-"/>
    
    <id>http://kensodevkensodev.com/2011/12/16/rails-polymorphic-association-without-the-type-column-possible-</id>
    <updated>2011-12-16T19:01:00+02:00</updated>
    <summary>Open question to all Rails experts. Can you define a polymorphic association that doesn't use the type column (for better mysql performance)?</summary>
    <content type="html">
      
        &lt;p&gt;These last two weeks has been very hard on me, this post will describe why and how you can help me&lt;/p&gt;

&lt;p&gt;Around two weeks ago, I started doing heavy database optimizations on the &lt;a href='http://gogobot.com'&gt;Gogobot&lt;/a&gt; website, after a discussion with a DBA from &lt;a href='http://www.percona.com/'&gt;Percona&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Changing the database schema of such a big app is not easy let me tell you, you need to make sure you break nothing, write more tests, unit and integration.&lt;/p&gt;

&lt;p&gt;I found out many things about Rails, ActiveRecord and mysql during those 2 weeks, I found creative ways to save many GB on the tables size and on the index size. (posts coming up, I promise).&lt;/p&gt;

&lt;p&gt;Now, one of the things (very first things) the DBA mentioned was that the use of polymorphic associations is not recommended in mysql.&lt;/p&gt;

&lt;p&gt;Since when you use it, you need two columns item_id, item_type (in most cases).&lt;/p&gt;

&lt;p&gt;item_type is a string &amp;#8220;Hotel&amp;#8221;, &amp;#8220;User&amp;#8221; etc… and since this is UTF-8 it&amp;#8217;s actually taking up lots of space on the row size and on the index size.&lt;/p&gt;

&lt;p&gt;Because of mysql limitations, when your row is too big, mysql will fall back to disk, and this is a very bad thing (VERY!)&lt;/p&gt;

&lt;p&gt;What he suggested was to move to an enum column in mysql and just have all of our type in the enum, this way you can save lots of time on the query (like 50%) and the index will be much smaller, which will also result in querying straight from the index (if you use the right queries).&lt;/p&gt;

&lt;h3 id='to_make_a_long_story_short'&gt;To make a long story short.&lt;/h3&gt;

&lt;p&gt;Rails doesn&amp;#8217;t support mysql enum column (and boy did it take energy to find out) and for some reason even using the &lt;a href='https://github.com/electronick/enum_column'&gt;enum_column_3&lt;/a&gt; gem had errors when dumping the schema to the schema.rb file.&lt;/p&gt;

&lt;h3 id='some_air_thinking_time'&gt;Some air, thinking time&amp;#8230;&lt;/h3&gt;

&lt;p&gt;At Gogobot, we have unique id&amp;#8217;s for each object, no model has the same range of id&amp;#8217;s as another model, from the id I can have the model type, I don&amp;#8217;t need the class name.&lt;/p&gt;

&lt;p&gt;We made it so we can simplify API calls and not use a composite id.&lt;/p&gt;

&lt;p&gt;Now, we have that, so I was wondering if I could leverage that into using it in the polymorphic associations.&lt;/p&gt;

&lt;p&gt;I started going through the AR code, but this is an open call for all you Rails experts out there, can you suggest a solution for this situation?&lt;/p&gt;

&lt;p&gt;Comments?&lt;/p&gt;

&lt;p&gt;I would love a discussion on that as well…&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Replace the Hash syntax to the 1.9 syntax for all files, with a regular expression</title>
    
      <link href="http://kensodevkensodev.com/2011/12/13/replace-the-hash-syntax-to-the-1-9-syntax-for-all-files-with-a-regular-expression"/>
    
    <id>http://kensodevkensodev.com/2011/12/13/replace-the-hash-syntax-to-the-1-9-syntax-for-all-files-with-a-regular-expression</id>
    <updated>2011-12-13T09:46:00+02:00</updated>
    <summary>How can you switch an entire project to the new Ruby 1.9.2 syntax with a single Regular expression.</summary>
    <content type="html">
      
        &lt;p&gt;This morning I got this email from my buddy &lt;a href='http://twitter.com/elado'&gt;@elado&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At &lt;a href='http://gogobot.com'&gt;Gogobot&lt;/a&gt; we try to keep everyone on the same coding style as much as we can, follow conventions and readability.&lt;/p&gt;

&lt;p&gt;This works best for us since you can be reading code someone else wrote and you won&amp;#8217;t feel alienated.&lt;/p&gt;

&lt;p&gt;Any way, back to the email, here&amp;#8217;s a quote…&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Hi guys,&lt;/p&gt;&lt;p&gt;Whoever isn't yet, can you please start using colon notation for hashes instead of arrows?&lt;/p&gt;&lt;p&gt;RIGHT:&lt;br /&gt;render partial: &quot;name&quot;, locals: { item: item }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;:DEPRECATED =&gt;&lt;br /&gt;render :partial =&gt; &quot;name&quot;, :locals =&gt; { :item =&gt; item }&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now, like I said in my reply, I am one of the culprits doing that still, but definitely not alone :-)&lt;/p&gt;

&lt;p&gt;So, I replied with a challenge, here&amp;#8217;s what I wrote…&lt;/p&gt;

&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;Good idea, although I admit I am one of the culprits, it's just embedded into my brain.&lt;br /&gt;I'll do my best...&lt;/p&gt;&lt;p&gt;Challenge for @elado, regular expression to replace those with bash script...&lt;/p&gt;&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;Now, Elad is known as &amp;#8220;The Regex king&amp;#8221; amongst other nicknames.&lt;/p&gt;

&lt;p&gt;After about 10 minutes, I get a Skype ping, Elado is telling me to check my email, this is what I see…&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='no'&gt;Dir&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;**/*.rb&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;].&lt;/span&gt;&lt;span class='n'&gt;each&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;f&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;
  &lt;span class='n'&gt;s&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nb'&gt;open&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;f&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;read&lt;/span&gt;
  &lt;span class='n'&gt;awesome_rx&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='sr'&gt;/(?&amp;lt;!return)(?&amp;lt;!:)(?&amp;lt;!\w)(\s+):(\w+)\s*=&amp;gt;/&lt;/span&gt;
  &lt;span class='n'&gt;count&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='n'&gt;s&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;scan&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;awesome_rx&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;length&lt;/span&gt;
  &lt;span class='k'&gt;next&lt;/span&gt; &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='n'&gt;count&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;zero?&lt;/span&gt;
  &lt;span class='n'&gt;s&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;gsub!&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;awesome_rx&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;\1\2:&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  &lt;span class='nb'&gt;puts&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;&lt;/span&gt;&lt;span class='si'&gt;#{&lt;/span&gt;&lt;span class='n'&gt;count&lt;/span&gt;&lt;span class='si'&gt;}&lt;/span&gt;&lt;span class='s2'&gt; replacements @ &lt;/span&gt;&lt;span class='si'&gt;#{&lt;/span&gt;&lt;span class='n'&gt;f&lt;/span&gt;&lt;span class='si'&gt;}&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;&lt;/span&gt;
  &lt;span class='nb'&gt;open&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;f&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;w&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;b&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;b&lt;/span&gt; &lt;span class='o'&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class='n'&gt;s&lt;/span&gt; &lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;we did not end up running it on the project, but we definitely plan on running it on files we are working on, so when we commit it will be with the new Syntax.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href='http://twitter.com/elado'&gt;@elado&lt;/a&gt; for the awesomeness.&lt;/p&gt;

&lt;p&gt;UPDATE: Elad thought it was worth a post as well, so here&amp;#8217;s a link to his blog &lt;a href='http://devign.me/convert-ruby-file-hash-syntax-to-1-9-2/'&gt;here&lt;/a&gt;.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Get information about all your mysql database tables with a single query</title>
    
      <link href="http://kensodevkensodev.com/2011/12/12/get-information-about-all-your-mysql-database-tables-with-a-single-query"/>
    
    <id>http://kensodevkensodev.com/2011/12/12/get-information-about-all-your-mysql-database-tables-with-a-single-query</id>
    <updated>2011-12-12T23:07:00+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I am working on tweaking our database these days, doing tons of work on making the queries faster, making sure the users are not being delayed by infrastructure stuff.&lt;/p&gt;

&lt;p&gt;One piece of info I wanted was to get a quick birds eye view of all the tables I have in the database, how many rows, what is the avg row length (for index purpose), size in MB and the size of the index in MB.&lt;/p&gt;

&lt;p&gt;All you need to do is exeucute this query (set the DB name to your database name and you are done).&lt;/p&gt;
&lt;notextile&gt;&lt;div class='CodeRay'&gt;
  &lt;div class='code'&gt;&lt;pre&gt;&lt;span class='class'&gt;set&lt;/span&gt; &lt;span class='variable'&gt;@database&lt;/span&gt;=&lt;span class='string'&gt;&lt;span class='delimiter'&gt;'&lt;/span&gt;&lt;span class='content'&gt;db_name&lt;/span&gt;&lt;span class='delimiter'&gt;'&lt;/span&gt;&lt;/span&gt;;
&lt;span class='class'&gt;select&lt;/span&gt; table_name, 
                &lt;span class='directive'&gt;engine&lt;/span&gt;, 
                row_format, 
                table_rows, 
                avg_row_length, 
                (data_length+index_length)/&lt;span class='integer'&gt;1024&lt;/span&gt;/&lt;span class='integer'&gt;1024&lt;/span&gt; &lt;span class='keyword'&gt;as&lt;/span&gt; total_size, 
                (index_length)/&lt;span class='integer'&gt;1024&lt;/span&gt;/&lt;span class='integer'&gt;1024&lt;/span&gt; &lt;span class='keyword'&gt;as&lt;/span&gt; index_size 
        &lt;span class='keyword'&gt;from&lt;/span&gt; 
                information_schema.tables 
        &lt;span class='keyword'&gt;where&lt;/span&gt; 
                table_schema=&lt;span class='variable'&gt;@database&lt;/span&gt; 
        &lt;span class='keyword'&gt;order&lt;/span&gt; &lt;span class='keyword'&gt;by&lt;/span&gt; 
                &lt;span class='integer'&gt;6&lt;/span&gt; &lt;span class='directive'&gt;desc&lt;/span&gt;;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/notextile&gt;
&lt;p&gt;As always, I would love your feedback&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">A Whole new page</title>
    
      <link href="http://kensodevkensodev.com/2011/12/10/a-whole-new-page"/>
    
    <id>http://kensodevkensodev.com/2011/12/10/a-whole-new-page</id>
    <updated>2011-12-10T00:00:00+02:00</updated>
    <summary>Why I moved my blog away of wordpress and why this is a good thing, even though it originated as a bad situation.</summary>
    <content type="html">
      
        &lt;p&gt;This blog is brand new, on Saturday, December 09 2011, for some reason which is still not clear to me, my wordpress website was wiped clean.&lt;/p&gt;

&lt;p&gt;I have been meaning to move to jekyll for a while now, so I took it as an opportunity to start fresh, new theme, simpler, cleaner and I am ready to go.&lt;/p&gt;

&lt;p&gt;Hope to see you here.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Setup your laptop for Ruby and Rails development</title>
    
      <link href="http://kensodevkensodev.com/2011/11/15/setup-your-laptop-for-ruby-and-rails-development"/>
    
    <id>http://kensodevkensodev.com/2011/11/15/setup-your-laptop-for-ruby-and-rails-development</id>
    <updated>2011-11-15T00:00:00+02:00</updated>
    <summary>Not the regular walkthrough tutorial that will take you ages, a simple elegant one click solution to get your new machine (and yourself) up to speed.</summary>
    <content type="html">
      
        &lt;p&gt;Setting up a new machine has never been an easy task, I remember back in the days where I was a windows user, setting up a new machine was a real pain in the ass.&lt;/p&gt;

&lt;p&gt;I used to write everything I had installed on a piece of paper and then go one by one and install everything, if I needed to download it could take even days to get a new machine up to speed.&lt;/p&gt;

&lt;p&gt;Today I am a Mac user (Thank god), so installing a new machine for myself is the easiest, I simply restore it from a time machine, and I am ready to go in a matter of minutes (well, maybe more, because the data can take quite some GB&amp;#8217;s)&lt;/p&gt;

&lt;p&gt;&lt;img alt='Macbook pro' src='/images/posts/mac_laptop/mac_laptop.png' /&gt;&lt;/p&gt;

&lt;p&gt;At &lt;a href='http://www.gogobot.com'&gt;Gogobot&lt;/a&gt;, we have new developers coming in (Yeah, we are growing), they all get a brand new Mac machine and they need to get it up and running, this is a common thing, since many developer buy new machines and they want the environment for Ruby, Rails, RVM and the rest of the stack be ready for them, no hassle.&lt;/p&gt;

&lt;p&gt;When I came in to &lt;a href='http://www.gogobot.com'&gt;Gogobot&lt;/a&gt;, we were still running on rails 2 with no bundler, so this was a bigger pain, but today, we are on rails 3 and we have bundler which certainly makes the process easier, but still, not as easy as I wanted it to be.&lt;/p&gt;

&lt;p&gt;Our development environment uses almost across the stack technologies, we use mysql of course, we use Redis, memcached, Resque, SOLR and many more, so installing everything can take a long time.&lt;/p&gt;

&lt;p&gt;We wanted to take this pain away, enabling new developers (and of course all of the community) to get their machines up and running in a matter of minutes with no interruption for the developer. So, while the developer is doing his tour around the system, his machine will be ready for him when he gets back.&lt;/p&gt;

&lt;p&gt;(B.T.W, I keep saying him, but I am referring to female developers as well, don&amp;#8217;t get me wrong here ha…)&lt;/p&gt;

&lt;p&gt;Last week, I got me a brand new machine, and I could not access my time machine (I was out of my house).&lt;/p&gt;

&lt;p&gt;So, I said this is a good opportunity to do what I wanted to do in ages now and get this script up and running.&lt;/p&gt;

&lt;p&gt;I cheated I started with a script &lt;a href='http://www.thoughtbot.com'&gt;Thoughbot&lt;/a&gt; had released, I tweaked it and twisted it to fit our needs.&lt;/p&gt;

&lt;p&gt;I got my new machine up and running with our project in about 20 minutes, that was amazing and it certainly breaks a Gogobot record.&lt;/p&gt;

&lt;p&gt;So, as I always do when I have something half decent, I released it as open source.&lt;/p&gt;

&lt;p&gt;You can find it &lt;a href='http://www.github.com/gogobot/laptop'&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please feel free to use it, if you are having any issues, open an issue in the repo and I will try to address it.&lt;/p&gt;

&lt;p&gt;Keep in mind the script is provided AS IS.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Kill all resque workers with a single command</title>
    
      <link href="http://kensodevkensodev.com/2011/09/17/kill-all-resque-workers-with-a-single-command"/>
    
    <id>http://kensodevkensodev.com/2011/09/17/kill-all-resque-workers-with-a-single-command</id>
    <updated>2011-09-17T00:00:00+03:00</updated>
    <summary>Resque can be quite tricky to manage, kill, restart, this post will show you how you can kill all resque workers with a single command.</summary>
    <content type="html">
      
        &lt;p&gt;At &lt;a href='http://www.gogobot.com'&gt;Gogobot&lt;/a&gt; we are running background processes with &lt;a href='http://www.github.com/defunkt/resque'&gt;Resque&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We are using &lt;a href='http://god.rubyforge.org/'&gt;God&lt;/a&gt; to start workers on all servers, both front end and back end (with different queues).&lt;/p&gt;

&lt;p&gt;God sometimes has an issue with leaving some stale workers laying around which cache old code, so if you change your code, this is your enemy since you start seeing failed jobs that should not fail what so ever.&lt;/p&gt;

&lt;p&gt;Even when you stop the rakes (Workers run by rake) with god, it will still leave those lying around.&lt;/p&gt;

&lt;p&gt;In one word, Frustrating&amp;#8230;&lt;/p&gt;

&lt;p&gt;So, I was IM&amp;#8217;ng with &lt;a href='http://twitter.com/#!/chiuki'&gt;Chiu-Ki&lt;/a&gt; and we were talking about killing workers, and I was telling her how to kill those.&lt;/p&gt;

&lt;p&gt;She told me she has a shell script for it.&lt;/p&gt;

&lt;p&gt;There you go&amp;#8230;&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;sudo &lt;span class='nb'&gt;kill&lt;/span&gt; -9  &lt;span class='sb'&gt;`&lt;/span&gt;ps aux | grep &lt;span class='o'&gt;[&lt;/span&gt;r&lt;span class='o'&gt;]&lt;/span&gt;esque | grep -v grep | cut -c 10-16&lt;span class='sb'&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;and if you just want to test before doing some killing, you can run this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='nb'&gt;echo&lt;/span&gt; &lt;span class='sb'&gt;`&lt;/span&gt;ps aux | grep &lt;span class='o'&gt;[&lt;/span&gt;r&lt;span class='o'&gt;]&lt;/span&gt;esque | grep -v grep | cut -c 10-16&lt;span class='sb'&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Of course after this GOD will restart the workers with the new code and that&amp;#8217;s it, you have fresh workers, with new code, ready to be up and running.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Re-Queue failed jobs with Resque</title>
    
      <link href="http://kensodevkensodev.com/2011/09/08/re-queue-failed-jobs-with-resque"/>
    
    <id>http://kensodevkensodev.com/2011/09/08/re-queue-failed-jobs-with-resque</id>
    <updated>2011-09-08T00:00:00+03:00</updated>
    <summary>How you can re-queue your failed workers so you won't loose valuable data.</summary>
    <content type="html">
      
        &lt;p&gt;I have been working with resque for about 1-2 months now, while migrating an application from rails 2 to rails 3, I have switched from Delayed Jobs almost completely.&lt;/p&gt;

&lt;p&gt;Sometimes, your workers / jobs fail and you need to re-queue them.&lt;/p&gt;

&lt;p&gt;The trick is to requeue the job and remove it from the failed stats, this way, if it will fail again, the next time you re-queue the job will not be executed twice.&lt;/p&gt;

&lt;p&gt;Here’s the code (from a rake task I have)&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='no'&gt;Resque&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Failure&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;count&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;downto&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;each&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;i&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;
  &lt;span class='k'&gt;begin&lt;/span&gt;
    &lt;span class='no'&gt;Resque&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Failure&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;requeue&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;i&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
    &lt;span class='no'&gt;Resque&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Failure&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;remove&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;i&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  &lt;span class='k'&gt;rescue&lt;/span&gt; &lt;span class='no'&gt;Exception&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='n'&gt;e&lt;/span&gt;
    &lt;span class='nb'&gt;puts&lt;/span&gt; &lt;span class='n'&gt;e&lt;/span&gt;
  &lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='nb'&gt;sleep&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='mi'&gt;5&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;minutes&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I have this rake running every X minutes and requeing failed tasks. If a task keeps failing, then I can check the code in depth and check what the problem is, but sometimes it’s just failing due to HTTP error or something else not related to the code.&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;

&lt;p&gt;Drop me a line if it does or you have questions and comments.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Rails uninitialized constant Resque::Server</title>
    
      <link href="http://kensodevkensodev.com/2011/08/31/rails-uninitialized-constant-resqueserver"/>
    
    <id>http://kensodevkensodev.com/2011/08/31/rails-uninitialized-constant-resqueserver</id>
    <updated>2011-08-31T00:00:00+03:00</updated>
    <summary>A problem with one of the Resque gem versions, what did I do to fix it.</summary>
    <content type="html">
      
        &lt;p&gt;One of the most significant changes in my migration of a rails app from Rails 2.3.10 to rails 3.0.9 was the move from &lt;a href='https://github.com/collectiveidea/delayed_job'&gt;delayed_jobs&lt;/a&gt; to &lt;a href='https://github.com/defunkt/resque'&gt;Resque&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Resque is a Queue system that&amp;#8217;s based on &lt;a href='http://redis.io/'&gt;Redis&lt;/a&gt;, which is much faster and reduces the load on your database. Also we were experiencing some nasty deadlocks with delayed jobs that really broke our transactions and our backs.&lt;/p&gt;

&lt;p&gt;I installed the gem and installed Redis on my development machine, &lt;a href='http://www.kensodev.com/2011/08/22/mount-a-sinatra-app-on-your-ruby-on-rails-3-application/'&gt;mounted the Sinatra app&lt;/a&gt; on my rails app and navigated to the web view of resque.&lt;/p&gt;

&lt;p&gt;Then, I saw this error:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;	RuntimeError at /resque/overview
	ERR unknown &lt;span class='nb'&gt;command&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;server&amp;#39;&lt;/span&gt;
	file: client.rb location: call line: 47
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Which looked like that:&lt;/p&gt;

&lt;p&gt;&lt;img alt='Resque server error' src='http://f.cl.ly/items/3A3w351J1y2g2h1E0k1H/Screen%20Shot%202011-08-29%20at%207.44.00%20PM.png' /&gt;&lt;/p&gt;

&lt;p&gt;After doing some digging into the code (as I always do when I encountered a problem with a gem), I found that the version of the gem (resque) I was using called the “server” method on the redis instance which was not there any more.&lt;/p&gt;

&lt;p&gt;Looking at the code for the new gem showed that the app is now using the property “redis_id” which looks like this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;	&lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;redis_id&lt;/span&gt;
	  &lt;span class='c1'&gt;# support 1.x versions of redis-rb&lt;/span&gt;
	  &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='n'&gt;redis&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;respond_to?&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:server&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
	    &lt;span class='n'&gt;redis&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;server&lt;/span&gt;
	    &lt;span class='k'&gt;elsif&lt;/span&gt; &lt;span class='n'&gt;redis&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;respond_to?&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:nodes&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='c1'&gt;# distributed&lt;/span&gt;
	      &lt;span class='n'&gt;redis&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;nodes&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;map&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;n&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;n&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;id&lt;/span&gt; &lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;join&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;, &amp;#39;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
	    &lt;span class='k'&gt;else&lt;/span&gt;
	      &lt;span class='n'&gt;redis&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;client&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;id&lt;/span&gt;
	  &lt;span class='k'&gt;end&lt;/span&gt;
	&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Upgrading the gem to the newest version solved my problem and everything got back to normal. So, if you encounter this issue, just upgrade the resque gem and you are all good.&lt;/p&gt;

&lt;p&gt;The gem version I was using was “resque (1.8.2)”, now I am using “resque (1.18.2)”&lt;/p&gt;

&lt;p&gt;As always, if this post was helpful, drop me a comment, I would love to hear.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Use specific version of RubyGems per project with RVM</title>
    
      <link href="http://kensodevkensodev.com/2011/08/24/use-specific-version-of-rubygems-per-project-with-rvm"/>
    
    <id>http://kensodevkensodev.com/2011/08/24/use-specific-version-of-rubygems-per-project-with-rvm</id>
    <updated>2011-08-24T00:00:00+03:00</updated>
    <summary>Sometimes, you have some legacy projects where you need an older version of RubyGems in order for them to work, this post will show you how you can do it through RVM without affecting your new projects.</summary>
    <content type="html">
      
        &lt;p&gt;If you’re following this blog (and of course you should), you know by now that I have been upgrading a bug project to rails 3. One of the things that I needed to do was to upgrade RubyGems.&lt;/p&gt;

&lt;p&gt;Since I did not make the switch completely (production still on rails 2.3.10), I’m fixing p0 bugs on the old project and merging the changes.&lt;/p&gt;

&lt;p&gt;One problem I encountered is that rails 2.3.10 does not run with the latest RubyGems.&lt;/p&gt;

&lt;p&gt;Since I am using RVM, it made since that this project will run on a specific version of RubyGems and the main project (the rails 3 one) will run on the latest.&lt;/p&gt;

&lt;p&gt;It turned out to be very simple:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;rvm rubygems 1.4.2
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Once you execute this bit of code, it will download RubyGems and this RVM folder will use it.&lt;/p&gt;

&lt;p&gt;As always, if this helped you, drop me a note, let me know.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Mount a Sinatra app on your Ruby on rails (3) application</title>
    
      <link href="http://kensodevkensodev.com/2011/08/22/mount-a-sinatra-app-on-your-ruby-on-rails-3-application"/>
    
    <id>http://kensodevkensodev.com/2011/08/22/mount-a-sinatra-app-on-your-ruby-on-rails-3-application</id>
    <updated>2011-08-22T00:00:00+03:00</updated>
    <summary>Mounting the Resque sinatra app on your Rails 3 project.</summary>
    <content type="html">
      
        &lt;p&gt;I have been migrating a Rails 2.3.10 application to Rails 3.0.9, while doing so I also migrated our queue system from delayed_jobs that ripped our system apart to Resque.&lt;/p&gt;

&lt;p&gt;Resque comes with a Sintra app to monitor the Queue, see what’s going on and what jobs failed etc.&lt;/p&gt;

&lt;p&gt;It’s very convenient and you can really grasp what’s going on with your system. I really missed that in delayed_job (amongst other things).&lt;/p&gt;

&lt;p&gt;So, I wanted to mount this Sinatra app onto our rails application.&lt;/p&gt;

&lt;p&gt;It turns out to be VERY easy and straight forward.&lt;/p&gt;

&lt;p&gt;Just add this to your routes.rb file:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='n'&gt;mount&lt;/span&gt; &lt;span class='no'&gt;Resque&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Server&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='ss'&gt;:at&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;/resque&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;In an initializer, just require the “resque/server” and you are done!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Uninitialized constant Syck::Syck (NameError)</title>
    
      <link href="http://kensodevkensodev.com/2011/08/16/uninitialized-constant-sycksyck-nameerror"/>
    
    <id>http://kensodevkensodev.com/2011/08/16/uninitialized-constant-sycksyck-nameerror</id>
    <updated>2011-08-16T00:00:00+03:00</updated>
    <summary>Short post on how you can save a huge amount of time when upgrading to Rails 3, this was a HUGE problem for me...</summary>
    <content type="html">
      
        &lt;p&gt;It’s old news for you devoted reader, but as you know I love coding with Ruby on Rails and that’s what my story for today is all about.&lt;/p&gt;

&lt;p&gt;I just spent about an hour scratching my head and throwing my keyboard (don’t tell Jobs) around my home office on this issue.&lt;/p&gt;

&lt;p&gt;I am upgrading an existing project (guess which…) from rails2 and ruby1.8.7 to rails3 and ruby 1.9.2.&lt;/p&gt;

&lt;p&gt;First thing is of course installing bundler and working with the Gemfile (thank god).&lt;/p&gt;

&lt;p&gt;So, when I did “bundle install” it crashed on me with this error message:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;Fetching &lt;span class='nb'&gt;source &lt;/span&gt;index &lt;span class='k'&gt;for &lt;/span&gt;http://rubygems.org/
/Users/avitzurel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:289:in &lt;span class='sb'&gt;`&lt;/span&gt;load&lt;span class='s1'&gt;&amp;#39;: uninitialized constant Syck::Syck (NameError)&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:289:in `_load&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:133:in &lt;span class='sb'&gt;`&lt;/span&gt;load&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:133:in `fetch_spec&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/remote_specification.rb:47:in &lt;span class='sb'&gt;`&lt;/span&gt;_remote_specification&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/remote_specification.rb:53:in `method_missing&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:101:in &lt;span class='sb'&gt;`&lt;/span&gt;block in __dependencies&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:98:in `each&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:98:in &lt;span class='sb'&gt;`&lt;/span&gt;__dependencies&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:68:in `activate_platform&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:317:in &lt;span class='sb'&gt;`&lt;/span&gt;resolve_requirement&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:287:in `block in resolve&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:286:in &lt;span class='sb'&gt;`&lt;/span&gt;reverse_each&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:286:in `resolve&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:160:in &lt;span class='sb'&gt;`&lt;/span&gt;start&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:128:in `block in resolve&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:127:in &lt;span class='sb'&gt;`&lt;/span&gt;catch&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/resolver.rb:127:in `resolve&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/definition.rb:151:in &lt;span class='sb'&gt;`&lt;/span&gt;resolve&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/definition.rb:90:in `specs&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/definition.rb:85:in &lt;span class='sb'&gt;`&lt;/span&gt;resolve_remotely!&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/installer.rb:43:in `run&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/installer.rb:8:in &lt;span class='sb'&gt;`&lt;/span&gt;install&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/cli.rb:220:in `install&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/vendor/thor/task.rb:22:in &lt;span class='sb'&gt;`&lt;/span&gt;run&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/vendor/thor.rb:263:in &lt;span class='sb'&gt;`&lt;/span&gt;dispatch&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/lib/bundler/vendor/thor/base.rb:386:in `start&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/gems/bundler-1.0.17/bin/bundle:13:in &lt;span class='sb'&gt;`&lt;/span&gt;&amp;lt;top &lt;span class='o'&gt;(&lt;/span&gt;required&lt;span class='o'&gt;)&lt;/span&gt;&amp;gt;&lt;span class='s1'&gt;&amp;#39;&lt;/span&gt;
&lt;span class='s1'&gt;	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/bin/bundle:19:in `load&amp;#39;&lt;/span&gt;
	from /Users/avitzurel/.rvm/gems/ruby-1.9.2-p290@rails_3_gogobot/bin/bundle:19:in &lt;span class='sb'&gt;`&lt;/span&gt;&amp;lt;main&amp;gt;&lt;span class='err'&gt;&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;After digging around the web, reading some useless information that it’s relevance to my issue was close to zero, I updated rubygems on my system to the latest version and this solved the problem.&lt;/p&gt;

&lt;p&gt;I executed this command:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;gem update --system
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Hope this saves you some time, if it does, drop me a comment let me know.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Capistrano - Deploy to servers from different load balancers</title>
    
      <link href="http://kensodevkensodev.com/2011/08/09/capistrano-deploy-to-servers-from-different-load-balancers"/>
    
    <id>http://kensodevkensodev.com/2011/08/09/capistrano-deploy-to-servers-from-different-load-balancers</id>
    <updated>2011-08-09T00:00:00+03:00</updated>
    <summary>How can you use Capistrano to deploy your rails app onto a cluster of servers on multiple load balancers</summary>
    <content type="html">
      
        &lt;p&gt;As I posted back on March 14th, I work at Gogobot, an app that connects you with your friends all over the world and helps you plan your next new travel.&lt;/p&gt;

&lt;p&gt;At Gogobot we are working with Capistrano to deploy our production and to our staging servers.&lt;/p&gt;

&lt;p&gt;Recently, we changed out architecture and we now have user facing production servers (where you see the pages coming from) and backend servers that run delayed_jobs, resque, photos uploading and many more things that have no business in affecting the load of the user experience.&lt;/p&gt;

&lt;p&gt;So, of course we did not want to deploy twice, once for the http servers and once for the backed servers, so I changed the deploy script.&lt;/p&gt;

&lt;p&gt;The important thing to understand is that due to loads, we don&amp;#8217;t just write the server DNS&amp;#8217;s in the deploy script, we change the number of servers constantly so we want to do it very dynamically and just grab the servers from the load balancer that it&amp;#8217;s attached to.&lt;/p&gt;

&lt;p&gt;For example, if we have 100 servers on the front end and 50 servers on the backend, we will deploy to 150 servers and tomorrow that number can change, and we will need no change in the deploy script.&lt;/p&gt;

&lt;p&gt;This is the deploy script part that handles the servers:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;fetch_from_ec2&lt;/span&gt;
    &lt;span class='nb'&gt;require&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;right_aws&amp;#39;&lt;/span&gt;
    &lt;span class='n'&gt;instances_for_deploy&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='o'&gt;[]&lt;/span&gt;

    &lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='n'&gt;backend_load_balancer&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;aws_load_balancer&lt;/span&gt;&lt;span class='o'&gt;].&lt;/span&gt;&lt;span class='n'&gt;each&lt;/span&gt; &lt;span class='k'&gt;do&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;load_balancer&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;
      &lt;span class='n'&gt;payload&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='n'&gt;elb&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;describe_load_balancers&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;load_balancer&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
      &lt;span class='n'&gt;instances&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='n'&gt;aws&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;describe_instances&lt;/span&gt; &lt;span class='n'&gt;payload&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;first&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='ss'&gt;:instances&lt;/span&gt;&lt;span class='o'&gt;]&lt;/span&gt;
      &lt;span class='n'&gt;instances_for_deploy&lt;/span&gt; &lt;span class='o'&gt;+=&lt;/span&gt; &lt;span class='n'&gt;instances&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;collect&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;instance&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;instance&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='ss'&gt;:dns_name&lt;/span&gt;&lt;span class='o'&gt;]&lt;/span&gt; &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;instance&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='ss'&gt;:aws_state&lt;/span&gt;&lt;span class='o'&gt;]&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;running&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;)}&lt;/span&gt;
    &lt;span class='k'&gt;end&lt;/span&gt;
    &lt;span class='n'&gt;instances_for_deploy&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This is the target of capistrano:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='n'&gt;role&lt;/span&gt; &lt;span class='ss'&gt;:app&lt;/span&gt; &lt;span class='k'&gt;do&lt;/span&gt;
  &lt;span class='no'&gt;ENV&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;TARGET&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;]&lt;/span&gt; &lt;span class='o'&gt;||&lt;/span&gt; &lt;span class='n'&gt;fetch_from_ec2&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;So, if there&amp;#8217;s an ENV variable defined called &amp;#8216;TARGET&amp;#8217; the script will only deploy to this server, if not, it will deploy to all of the servers from the load balancers.&lt;/p&gt;

&lt;p&gt;Now, in the production.rb in your deploy folder, all you need is to define the load balancer names:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='n'&gt;set&lt;/span&gt; &lt;span class='ss'&gt;:aws_load_balancer&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;prod-load-balancer-name&amp;quot;&lt;/span&gt;
&lt;span class='n'&gt;set&lt;/span&gt; &lt;span class='ss'&gt;:backend_load_balancer&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;backend-load-balancer-name&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Fuck you, pay me!</title>
    
      <link href="http://kensodevkensodev.com/2011/07/12/fuck-you-pay-me"/>
    
    <id>http://kensodevkensodev.com/2011/07/12/fuck-you-pay-me</id>
    <updated>2011-07-12T00:00:00+03:00</updated>
    <summary>Ranting about shitty enterpeneurs (if you can call them that), searching aroung the web for 'partners' to work for free in return for imaginaty shares.</summary>
    <content type="html">
      
        &lt;p&gt;As every developer, I am a member of numerous groups, email groups, chats, forums, facebook groups, Quora etc…&lt;/p&gt;

&lt;p&gt;Usually, I really try and help people in those groups, even if they ask the most simple question, one that a developer with just a few years behind him take for absolute granted. Once in a while, there’s a question that hits me in the stomach, that touches a nerve.&lt;/p&gt;

&lt;p&gt;I am far from taking any of this too personally, this is also becuase I will never follow up on these offers, but the reason it makes me angry is becuase other people might, some developer with less experience might fall into the bullshit some slick salesman sells to them.&lt;/p&gt;

&lt;p&gt;One of these questions was posted today to a user group I am a member of in Israel, it’s a forum for &lt;a href=&quot;http://www.kensodev.com&quot;&gt;web developer&lt;/a&gt;s.&lt;/p&gt;

&lt;p&gt;The message was posted by an SEO company representetive, most of the time just this title is enough to get what the content is about.&lt;/p&gt;

&lt;h2&gt;What was the message about and why did it make me angry?&lt;/h2&gt;

&lt;p&gt;Well, the message went on and on as in how they are one of the leading companies in Israel (but provided no link to a website, nor the company email, or even the name). He said that over time, they gained an astonishing experience in developing content management systems (but have none of their own).&lt;/p&gt;

&lt;p&gt;Now, they are looking for a guy (it’s ok if he will be a beginner), that will work for no money, just for the amazing experience they have.&lt;/p&gt;

&lt;p&gt;They will give him tips as to what the system should look like, and then he will develop it. They will then sell it to customers and “most” of the profit will go to that developer.&lt;/p&gt;

&lt;p&gt;No data was supplied as to what the demands are and what is the quantity of the work.&lt;/p&gt;

&lt;p&gt;Just in case you know how to read Hebrew, here’s a link to the message: here&lt;/p&gt;

&lt;h2&gt;Fuck you pay me!&lt;/h2&gt;

&lt;p&gt;A while ago, I watched a presentation over on Vimeo that was really well put together.  It was nothing new to me, and I have experience these sort of behaviors when I was the CTO of a web design/development firm. What’s amazing about this talk, is that when you take out the language, it’s structured really well, and the attourney speaking there is quite a sharp guy.&lt;/p&gt;

&lt;iframe src=&quot;http://player.vimeo.com/video/22053820?title=0&amp;amp;byline=0&amp;amp;portrait=0&quot; width=&quot;400&quot; height=&quot;225&quot; frameborder=&quot;0&quot; webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href=&quot;http://vimeo.com/22053820&quot;&gt;2011/03 Mike Monteiro | F*ck You. Pay Me.&lt;/a&gt; from &lt;a href=&quot;http://vimeo.com/sanfranciscocm&quot;&gt;San Francisco Creative Mornings&lt;/a&gt; on &lt;a href=&quot;http://vimeo.com&quot;&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;So, what is my point?&lt;/h2&gt;

&lt;p&gt;Well, I talked about the message that through me into this post, I talked about the presentation, so what the hell is my point?&lt;/p&gt;

&lt;p&gt;My point is that you should not work while not getting payed!
Never, Ever.&lt;/p&gt;

&lt;p&gt;The only exception is that if you are in a partnership with a party on the same professional level as you.&lt;/p&gt;

&lt;p&gt;The relatioship between you should be equal, what this guy is offering is far from it.&lt;/p&gt;

&lt;p&gt;No serious professional developer I know will ever follow up on these suggestion, nor should any beginner developer.&lt;/p&gt;

&lt;h2&gt;The business of free&lt;/h2&gt;

&lt;p&gt;There are many things you can do for free that will promote you as a professional and as a person. You can build a website for a charity organization, you can contribute to open source project etc…&lt;/p&gt;

&lt;p&gt;As a conclusion, you can watch this funny as hell youtube video.&lt;/p&gt;

&lt;iframe width=&quot;420&quot; height=&quot;315&quot; src=&quot;http://www.youtube.com/embed/HyTpzgAW5NA&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;

&lt;h2&gt;Is this post the entrepreneur killer?&lt;/h2&gt;

&lt;p&gt;No, it is not, I am not going against people in pursuit of their dream, I am not going against people who build a startup from the ground up, I am going against messages targetting youg developers, dismissing the professional capabilities our business demands and holding back the web.&lt;/p&gt;

&lt;p&gt;That is what I am against, nothing else.&lt;/p&gt;

&lt;h2&gt;Personal note&lt;/h2&gt;

&lt;p&gt;I really don’t get the people offering these things, how do they run a business and how are they able to request such a thing.&lt;/p&gt;

&lt;p&gt;Did any of them ever offer anything to a client for free, will they give me a car with a sticker advertising their business?&lt;/p&gt;

&lt;p&gt;What do you think?
Comment below and let’s discuss this issue…&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Get shit done. I mean it!</title>
    
      <link href="http://kensodevkensodev.com/2011/07/11/get-shit-done-i-mean-it"/>
    
    <id>http://kensodevkensodev.com/2011/07/11/get-shit-done-i-mean-it</id>
    <updated>2011-07-11T00:00:00+03:00</updated>
    <summary>Time is money, saving time that you usually spend on worthless shit can make you money!</summary>
    <content type="html">
      
        &lt;p&gt;Like any other &lt;a href='http://kensodev.com'&gt;web developer&lt;/a&gt; that respects what he does, I am constantly trying to better myself as to how productive I am, how much I am really getting done and what is the quality of what I do.&lt;/p&gt;

&lt;p&gt;Along the way, I tried many systems and methods for getting myself in focus, for not getting distracted by all the noise, both digital (mostly) and human around me.&lt;/p&gt;

&lt;p&gt;I think that finally after a long time, I did find what I was looking for, and there’s nothing fancy about it, no fancy system, no calm music no nothing.&lt;/p&gt;

&lt;h2 id='so_what_is_it'&gt;So, what is it?&lt;/h2&gt;

&lt;p&gt;First, let’s focus on the problem, as I am sure most of you will relate to it.&lt;/p&gt;

&lt;p&gt;The problem, and this comes as a personal confession of mine as well, is all of the so called “social” websites, and all of the news around us. Think about it really, in an average day, you are exposed to so much digital noise that can blow your head. There’s Facebook, Twitter, Google Plus, DM, Email, Messages etc… How will you be able to get shit done with all of these in your way?&lt;/p&gt;

&lt;p&gt;Well, You can’t, at least I can’t.&lt;/p&gt;

&lt;p&gt;Let’s talk about a slice of 10 minutes from a regular, not that focused day of programming.&lt;/p&gt;

&lt;p&gt;But first, a short introduction…&lt;/p&gt;

&lt;p&gt;You come to work, maybe you are a bit tired, you are not the “sharpest” that you can be, your mind drifts to the car you want to buy, to those shiny Dr. Dre headphones in the Apple store on University Ave. Palo Alto.&lt;/p&gt;

&lt;p&gt;Well, you get the drift, you are not as concentrated in the work as you should be, Add an iPhone notifications through Facebook to that mix and you get a mishmush of thoughts that can go through your mind in a single minute.&lt;/p&gt;

&lt;p&gt;My focus is very fragile, if I don’t really focus at what I do, I can’t be the coding machine that people think of me, I really can’t. So, back to the slice of 10 minutes of work.&lt;/p&gt;

&lt;p&gt;00:00 – Sit down, open up textmate on the project 01:00 – Open up the test and save it, just to see nothing breaks 02:00 – Watch the console as it goes green on 100+ tests 03:00 – Forget you are doing something, go to Facebook 10:00 – hehe, this is a funny youtube kitten &lt;a href='http://twitter.com/elado'&gt;@elado&lt;/a&gt; posted.&lt;/p&gt;

&lt;p&gt;Maybe, I got the times wrong, but the second your mind gets a chance (probably before minute 3) it will drift away to the less painfull, not thinking part of it (a.k.a twitter and facebook).&lt;/p&gt;

&lt;p&gt;Don’t get me wrong, I LOVE twitter and I LOVE facebook, it’s just there’s a time and a place for these websites and coding time aint one of them.** What have I tried and failed (and probably you did too)I tried being tough on myself, I tried closing up my facebook account and removing the Twitter icon from the dock.&lt;/p&gt;

&lt;p&gt;Nothing helped, the behaviour pattern is so embedded in me, that it just failed.&lt;/p&gt;

&lt;h2 id='what_the_hell_does_cezar_millan_got_to_do_with_that'&gt;What the hell does Cezar Millan got to do with that?&lt;/h2&gt;

&lt;p&gt;&lt;a href='http://www.cesarsway.com/'&gt;Cezar Millan&lt;/a&gt; is the dog whisperrer, I am addicted to his show on National Geographic. What he always does, to snap a dog (sorry about the comparison here, stay with me) out of his bad behavior is touch him firmly on the body.&lt;/p&gt;

&lt;p&gt;Well, I thought about it, but the conclusion was not that I hit myself every time I go to Facebook, it’s just a virtual slap in the face.&lt;/p&gt;

&lt;p&gt;OK, I am getting to the point.&lt;/p&gt;

&lt;p&gt;So, what’s a slap in the face virtaully, when you want to go to Facebook.&lt;/p&gt;

&lt;p&gt;This is:&lt;/p&gt;

&lt;p&gt;&lt;img alt='Facebook page, after get shit done' src='http://f.cl.ly/items/0x3p2u0b1Q122l1A0T3K/Screen%20shot%202011-07-11%20at%207.44.23%20PM.png' /&gt;&lt;/p&gt;

&lt;p&gt;How did I do it?&lt;/p&gt;

&lt;p&gt;At first, I did it manually, I changed the hosts file on my Mac, and made all of the websites I don’t want just go to localhost. That is brutal force right.&lt;/p&gt;

&lt;p&gt;BUT&lt;/p&gt;

&lt;p&gt;That was all I needed to get back to focus, the distraction part was so automatic, I did not intentionally go to Facebook (I swear), I just did it in a moment where my mind drifted, in the nanosecond where focus is fragile. So now, when I do it, I just see the Forbidden message and go right back to work.&lt;/p&gt;

&lt;p&gt;And then, it got even better.&lt;/p&gt;

&lt;p&gt;But I will let you see for yourself.&lt;/p&gt;

&lt;p&gt;You can go to my fork of the repository &lt;a href='https://github.com/kensodev/get-shit-done'&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, all I do when I want to really work and focus is go to the terminal and hit&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;sudo get-shit-done work
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;and when I have time, like after lunch for 10 min’s or so, or at night from home is just&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;sudo get-shit-done play
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Beautiful, elegant and simple solution for the problem, it helped me a great deal to be much more productive and my focus now lasts for hours (that sounded like a cheap Viagra spam message )&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Foursquare live updates with the Push API using rails.</title>
    
      <link href="http://kensodevkensodev.com/2011/06/02/foursquare-live-updates-with-the-push-api-using-rails"/>
    
    <id>http://kensodevkensodev.com/2011/06/02/foursquare-live-updates-with-the-push-api-using-rails</id>
    <updated>2011-06-02T00:00:00+03:00</updated>
    <summary>Have your application accept push notification when your users check-in to foursquare.</summary>
    <content type="html">
      
        &lt;p&gt;Recently, I have been working extensively with the Foursquare API, also contributing to the open source &lt;a href='http://www.github.com/kensodev/foursquare2'&gt;foursquare2&lt;/a&gt; gem.&lt;/p&gt;

&lt;p&gt;While working on these features, I got a sneak peak preview to the new push API through Foursquare. Until I got that, I needed to pull checkins for each user, which was a slow and unefficient process.&lt;/p&gt;

&lt;p&gt;Facebook had this feature for a while that for every checkin a user has, the application (he authorized) get a push notification to a callback URL – this is highly effective and more streamlined process.&lt;/p&gt;

&lt;p&gt;So, &lt;a href='http://www.kensodev.com/tag/foursquare/'&gt;Foursquare&lt;/a&gt; added it and like I said, I was happy to get a sneak peak to it.&lt;/p&gt;

&lt;p&gt;Since it has no documentation yet, adding it to the application was not as smooth as I am used to, so I thought I would post the code for it on my blog, so you will have it easier then me :-)&lt;/p&gt;

&lt;p&gt;Foursquare posts the json for the checkin to your controller with no parameter, so you need to use the post body in order to read it.&lt;/p&gt;

&lt;p&gt;Here’s the controller code:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='k'&gt;class&lt;/span&gt; &lt;span class='nc'&gt;FsRealtimeController&lt;/span&gt; &lt;span class='o'&gt;&amp;lt;&lt;/span&gt; &lt;span class='no'&gt;ApplicationController&lt;/span&gt;
  &lt;span class='n'&gt;protect_from_forgery&lt;/span&gt; &lt;span class='ss'&gt;:except&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;post&amp;#39;&lt;/span&gt;

  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;post&lt;/span&gt;
    &lt;span class='n'&gt;posted_json&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='n'&gt;request&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;body&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;read&lt;/span&gt;

    &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='n'&gt;posted_json&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;blank?&lt;/span&gt;
      &lt;span class='n'&gt;render&lt;/span&gt; &lt;span class='ss'&gt;:nothing&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='kp'&gt;true&lt;/span&gt;
      &lt;span class='k'&gt;return&lt;/span&gt;
    &lt;span class='k'&gt;end&lt;/span&gt;

    &lt;span class='n'&gt;parsed_json&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='no'&gt;JSON&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;parse&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;posted_json&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;to_s&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;

   &lt;span class='c1'&gt;# Do whatever you want with the parsed json&lt;/span&gt;

    &lt;span class='n'&gt;render&lt;/span&gt; &lt;span class='ss'&gt;:nothing&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='kp'&gt;true&lt;/span&gt;
  &lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The typical json will look something like this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;checkin&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;createdAt&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='mi'&gt;1298129668&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;4d5fe304d7206ea8e90aeef1&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;shout&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;#4sqhackathon&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;timeZone&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;America/New_York&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;type&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;checkin&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;venue&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;categories&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;[&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;icon&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;http://foursquare.com/img/categories/building/default.png&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;4bf58dd8d48988d125941735&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;Tech Startup&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;parents&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;[&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;Home / Work / Other&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;Corporate / Office&amp;quot;&lt;/span&gt;
&lt;span class='p'&gt;],&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;primary&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='kc'&gt;true&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;],&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;contact&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;twitter&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;gnrlassembly&amp;quot;&lt;/span&gt;
&lt;span class='p'&gt;},&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;4c5c076c7735c9b6af0e8b72&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;location&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;address&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;902 Broadway, 4th Floor&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;city&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;New York&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;crossStreet&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;btw 20th and 21st&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;lat&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='mf'&gt;40.739197437761383&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;lng&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mf'&gt;73.989760279655457&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;postalCode&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;10010&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;state&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;NY&amp;quot;&lt;/span&gt;
&lt;span class='p'&gt;},&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;General Assembly&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;stats&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;checkinsCount&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='mi'&gt;1357&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;usersCount&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='mi'&gt;557&lt;/span&gt;
&lt;span class='p'&gt;},&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;todos&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;count&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;
&lt;span class='p'&gt;},&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;verified&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='kc'&gt;false&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;},&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;user&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;firstName&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;Neil&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;gender&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;male&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;homeCity&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;New York, NY&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;2097&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;lastName&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;Sanchala&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;photo&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;http://playfoursquare.s3.amazonaws.com/userpix_thumbs/0QYGOJMDGLTJOOQG.jpg&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
&lt;span class='s2'&gt;&amp;quot;relationship&amp;quot;&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;self&amp;quot;&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;You can find some more details &lt;a href='https://github.com/foursquare/hackathon/wiki/Foursquare-Push-API'&gt;here&lt;/a&gt; (json from the link).&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Install Membase 1.6.5.3 on Amazon EC2 and configure it on EBS.</title>
    
      <link href="http://kensodevkensodev.com/2011/05/15/install-membase-1-6-5-3-on-amazon-ec2-and-configure-it-on-ebs"/>
    
    <id>http://kensodevkensodev.com/2011/05/15/install-membase-1-6-5-3-on-amazon-ec2-and-configure-it-on-ebs</id>
    <updated>2011-05-15T00:00:00+03:00</updated>
    <summary>Installing a membase server on Amazon EC2 machine, attaching an EBS volume and having membase read from this volume, a step by step walkthrough.</summary>
    <content type="html">
      
        &lt;p&gt;As your application grows (like ours did) you will need more space to store your cache.&lt;/p&gt;

&lt;p&gt;In our case, we needed to move from memcached to membase and make use of both memory and disk space. The decision was made and we decided to go with a 2 server solution, each server has 16G of memory and 100G of EBS volume attached to it. Also, both will have membase latest stable version installed and perform as a cluster in case one falls or anything happens, a fail safe if you will.&lt;/p&gt;

&lt;p&gt;In this post, I will walk you though what was done to perform this and how exactly it was done on the amazon cloud.&lt;/p&gt;

&lt;p&gt;First things first, select an AMI from your list and click on “Launch instance”.&lt;/p&gt;

&lt;p&gt;&lt;img alt='Launch an instance from an AMI' src='http://farm3.static.flickr.com/2659/5722254735_2ed3106a45.jpg' /&gt;&lt;/p&gt;

&lt;p&gt;You will see a dialog popup where you need to select the instance type.&lt;/p&gt;

&lt;p&gt;&lt;img alt='Select instance type on Amazon' src='http://farm3.static.flickr.com/2118/5722254923_c61a5d3950.jpg' /&gt;&lt;/p&gt;

&lt;p&gt;I selected the 16G memory server, I launched 2 instances from this type. Like I said before, I wanted those to perform in a cluster so I will have a fail safe option.&lt;/p&gt;

&lt;p&gt;Now, you have 2 servers up and running. Because those servers are serving as a membase solution to production servers, I also configured an elastic IP to them.&lt;/p&gt;

&lt;p&gt;Now, let’s create our volumes.&lt;/p&gt;

&lt;h2 id='creating_ebs_volumes_and_attaching_to_your_instance'&gt;Creating EBS volumes and attaching to your instance&lt;/h2&gt;

&lt;p&gt;Go to the EBS section and click on create volume (top right in this image).&lt;/p&gt;

&lt;p&gt;&lt;img alt='Create an EBS volume' src='http://farm3.static.flickr.com/2451/5722811584_f56d95c100.jpg' /&gt;&lt;/p&gt;

&lt;p&gt;You will see this dialog:&lt;/p&gt;

&lt;p&gt;&lt;img alt='Select the size of your new EBS volume' src='http://farm4.static.flickr.com/3286/5722811826_28b7e72e44.jpg' /&gt;&lt;/p&gt;

&lt;p&gt;Just select how many Gigs you want, availability zone (make sure it’s the same as the server availability zone or you will have performance issues).&lt;/p&gt;

&lt;p&gt;Once the EBS volumes (I needed 2) are ready, all you need is to attach those to your servers.&lt;/p&gt;

&lt;p&gt;You right click on the volume and select “attach”, you will see very detailed information about what you need to do there (very simple)&lt;/p&gt;

&lt;p&gt;OK, so now we have our servers and volumes attached to them (instances don’t “know” the EBS’s yet).&lt;/p&gt;

&lt;p&gt;SSH into your instance.&lt;/p&gt;

&lt;h2 id='mounting_your_ebs_volume_to_the_instance'&gt;Mounting your EBS volume to the instance&lt;/h2&gt;

&lt;p&gt;After you ssh into your instance run these commands to have your volume installed on the instance (You can mount in another folder and not the one I selected here).&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;yes | mkfs -t ext3 /dev/sdf
mkdir /mnt/data-store
mount /dev/sdf /mnt/data-store
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This will mount the EBS to the /mnt/data-store folder, which we will use in a few minutes to have membase work on this folder and not steal space from the server main disk (which will result in a crash).&lt;/p&gt;

&lt;h2 id='downloading_and_installing_membase_on_your_new_instance'&gt;Downloading and installing membase on your new instance&lt;/h2&gt;

&lt;p&gt;First, a cleanup…&lt;/p&gt;

&lt;p&gt;I had the instances created from an AMI that already had a previous version of membase (1.6.4) installed on it. So first, you will need to clean those up like so:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;rpm -e membase-server-1.6.5.3
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now, go to membase.com, register for the download and you will be able to download the package you need, you can select from a variety of versions.&lt;/p&gt;

&lt;p&gt;&lt;img alt='Couchbase website, select your download' src='http://farm3.static.flickr.com/2227/5722255511_ce219f2b70.jpg' /&gt;&lt;/p&gt;

&lt;p&gt;Copy the download link and go back to your server.&lt;/p&gt;

&lt;p&gt;Put this in your shell and click ‘Enter’.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;wget your_download_link
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I have a server with RPM but it’s all the same with another package manager.&lt;/p&gt;

&lt;p&gt;After you have the file downloaded to the server, run this command:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;rpm --install your_rpm_file.rpm
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now you have membase installed on the server. Congrats! All should be running now.&lt;/p&gt;

&lt;h2 id='configuring_the_membase_server_after_installation'&gt;Configuring the membase server after installation&lt;/h2&gt;

&lt;p&gt;From here, you can read the getting started in the membase wiki, it’s very good from here on:&lt;/p&gt;

&lt;p&gt;&lt;a href='http://techzone.couchbase.com/wiki/display/membase/Getting+Started'&gt;Getting started guide, Couchbase website.&lt;/a&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Ssl Verification Issue With The Foursquare2 Gem</title>
    
      <link href="http://kensodevkensodev.com/2011/04/27/ssl-verification-issue-with-the-foursquare2-gem"/>
    
    <id>http://kensodevkensodev.com/2011/04/27/ssl-verification-issue-with-the-foursquare2-gem</id>
    <updated>2011-04-27T00:00:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Solving the SSL issue with the Rapleaf API</title>
    
      <link href="http://kensodevkensodev.com/2011/04/25/solving-the-ssl-issue-with-the-rapleaf-api"/>
    
    <id>http://kensodevkensodev.com/2011/04/25/solving-the-ssl-issue-with-the-rapleaf-api</id>
    <updated>2011-04-25T00:00:00+03:00</updated>
    <summary>Solving a problem with an SSL certificate in the Rapleaf API.</summary>
    <content type="html">
      
        &lt;p&gt;While working with the &lt;a href='https://www.rapleaf.com/'&gt;Rapleaf&lt;/a&gt; API, I encountered some major issues with SSL on production and staging servers.&lt;/p&gt;

&lt;p&gt;Discarding what I did, the application just couldn’t get through to the external service using SSL and kept giving me errors regarding SSL communication.&lt;/p&gt;

&lt;p&gt;After reading the Rapleaf gem documentation I found that you should reference your certificate file, this “telling” the service where your certificate file is.&lt;/p&gt;

&lt;p&gt;I am working with Amazon EC2 for deployment of my application, both for production and for staging, I had some trouble finding the file, so I executed a unix command and found the files in no time.&lt;/p&gt;

&lt;p&gt;Here’s how you find the file:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;find / -name &lt;span class='s1'&gt;&amp;#39;*.pem&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Once you find the file, you just create the API instance and refer to it’s path like so:&lt;/p&gt;

&lt;p&gt;&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='vi'&gt;@api&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='no'&gt;RapleafApi&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Api&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;new&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;YOUR_API_KEY&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='ss'&gt;:timeout&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='ss'&gt;:ca_file&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;path_to_pem_file&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Have fun!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Set the correct content type when using paperclip</title>
    
      <link href="http://kensodevkensodev.com/2011/04/24/set-the-correct-content-type-when-using-paperclip"/>
    
    <id>http://kensodevkensodev.com/2011/04/24/set-the-correct-content-type-when-using-paperclip</id>
    <updated>2011-04-24T00:00:00+03:00</updated>
    <summary>How can you set the correct content type of the file when working with the paperclip gem.</summary>
    <content type="html">
      
        I have been using paperclip for image uploads for quite some time now.

On a project I am doing right now, I encountered a problem that all of the file uploaded were not in the correct content type. The content type was set as stream and not as the image type that was uploaded.

After some research I found that this problem was occurring because in the file upload process I was using fancy upload (Ajax upload using flash).

The fix was very simple, I just added another post process callback on the model like so:

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;before_post_process&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:set_content_type&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;set_content_type&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sketch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instance_write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:content_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;MIME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Types&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type_for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sketch_file_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


Keep in mind you should put this method after the has_attached_file method that paperclip adds or you will get an exception.
Like so:

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;  &lt;span class=&quot;n&quot;&gt;has_attached_file&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:avatar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;:styles&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;ss&quot;&gt;:thumb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;55x55&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;ss&quot;&gt;:preview&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;175x175&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;ss&quot;&gt;:huge&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;500x500&amp;gt;&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;:storage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:s3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;:s3_credentials&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/config/s3.yml&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;:path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;:class/:attachment/:token/:style.:extension&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;:bucket&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;your_bucket_name&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;:default_url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;/images/photo01.jpg&amp;quot;&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;before_post_process&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:set_content_type&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


If you are using Ajax/flash upload, this is the fix for you. The best thing about it is that it’s on the model, using the slim controller fat model best practice and thus it will also happen regardless of the controller you are using to upload the image.
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Set the correct content type when using paperclip</title>
    
      <link href="http://kensodevkensodev.com/2011/04/24/set-the-correct-content-type-when-using-paperclip"/>
    
    <id>http://kensodevkensodev.com/2011/04/24/set-the-correct-content-type-when-using-paperclip</id>
    <updated>2011-04-24T00:00:00+03:00</updated>
    <summary>How can you set the correct content type of the file when working with the paperclip gem.</summary>
    <content type="html">
      
        
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Meet the client</title>
    
      <link href="http://kensodevkensodev.com/2011/03/14/meet-the-client-1-gogobot"/>
    
    <id>http://kensodevkensodev.com/2011/03/14/meet-the-client-1-gogobot</id>
    <updated>2011-03-14T00:00:00+02:00</updated>
    <summary>As a consultant to many clients around the world, I occasunaly introduce you to my clients, this time it's Gogobot</summary>
    <content type="html">
      
        &lt;p&gt;Kenso specilizes in &lt;a href='http://www.kensodev.com' target='_blank' title='Web Development'&gt;Web Development&lt;/a&gt; and works with local and international clients. Recently Kenso started to work with &lt;a href='http://www.gogobot.com/' target='_blank' title='Gogobot'&gt;Gogobot&lt;/a&gt;, which is an app that connects you with friends all over the world and makes your travel planning easier and exciting.&lt;/p&gt;

&lt;p&gt;To better understand what&amp;#8217;s and who&amp;#8217;s Gogobot, here is a short video about the company&amp;#8217;s product. &lt;object height='390' width='640'&gt;&lt;param name='movie' value='http://www.youtube.com/v/dBU8Smc22II?fs=1&amp;amp;hl=en_US' /&gt;&lt;param name='allowFullScreen' value='true' /&gt;&lt;param name='allowscriptaccess' value='always' /&gt;&lt;embed allowfullscreen='true' allowscriptaccess='always' height='390' src='http://www.youtube.com/v/dBU8Smc22II?fs=1&amp;amp;hl=en_US' type='application/x-shockwave-flash' width='640' /&gt;&lt;/object&gt;&lt;/p&gt;

&lt;p&gt;Another great explanation by Travis Katz, the CEO and co-founder of Gogobot. &lt;object height='390' width='640'&gt;&lt;param name='movie' value='http://www.youtube.com/v/AOoPV0SjIcg?fs=1&amp;amp;hl=en_US' /&gt;&lt;param name='allowFullScreen' value='true' /&gt;&lt;param name='allowscriptaccess' value='always' /&gt;&lt;embed allowfullscreen='true' allowscriptaccess='always' height='390' src='http://www.youtube.com/v/AOoPV0SjIcg?fs=1&amp;amp;hl=en_US' type='application/x-shockwave-flash' width='640' /&gt;&lt;/object&gt; &lt;h2&gt;Kenso's Job&lt;/h2&gt; Kenso will be aiding the company with: &lt;ul&gt;
	&lt;li&gt;&lt;a href='http://www.kensodev.com/category/ruby-on-rails/' target='_blank' title='Ruby on Rails'&gt;Ruby on Rails&lt;/a&gt; development&lt;/li&gt;
	&lt;li&gt;Matching Algorithm Development&lt;/li&gt;
	&lt;li&gt;Client side development&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Use before_destroy on a model with paperclip</title>
    
      <link href="http://kensodevkensodev.com/2011/01/04/use-before_destroy-on-a-model-with-paperclip"/>
    
    <id>http://kensodevkensodev.com/2011/01/04/use-before_destroy-on-a-model-with-paperclip</id>
    <updated>2011-01-04T10:19:57+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I have an application that I&amp;#8217;m working on, this application has a demand that I will show the total files and the file total size inside a project. Here is my model:&lt;/p&gt;
&lt;a href='http://www.flickr.com/photos/51960246@N07/5323289774/' title='Screen shot 2011-01-04 at 10.15.18 AM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2011-01-04 at 10.15.18 AM' height='400' src='http://farm6.static.flickr.com/5201/5323289774_a6c335fc1b.jpg' width='375' /&gt;&lt;/a&gt;
&lt;p&gt;Of course I have the option of using joins and so on and then calculating the file size, but because every project has many folders and every folder has many attachments this seems a bit off and not straight forward.&lt;/p&gt;

&lt;p&gt;This is absolutely not the Rails way of doing things, so what I added a couple of fields inside the project model and here is what my model looked like after the change:&lt;/p&gt;
&lt;a href='http://www.flickr.com/photos/51960246@N07/5323294436/' title='Screen shot 2011-01-04 at 10.18.59 AM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2011-01-04 at 10.18.59 AM' height='432' src='http://farm6.static.flickr.com/5004/5323294436_2c7702d32d.jpg' width='428' /&gt;&lt;/a&gt;
&lt;p&gt;Now, I have straight forward fields inside my model, and the database work is very light, fast and straight forward. I added an observer for the attachment model, just to update the count and the total file size in the project model.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s my observer&amp;#8217;s code:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='k'&gt;class&lt;/span&gt; &lt;span class='nc'&gt;AttachmentObserver&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;lt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='no'&gt;ActiveRecord&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Observer&lt;/span&gt;
  &lt;span class='n'&gt;observe&lt;/span&gt; &lt;span class='ss'&gt;:attachment&lt;/span&gt;

  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;after_create&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
    &lt;span class='n'&gt;project&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;project&lt;/span&gt;
    &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='n'&gt;project&lt;/span&gt;
      &lt;span class='n'&gt;project&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;increment!&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:file_count&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
      &lt;span class='n'&gt;project&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;increment!&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:file_size&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;sketch_file_size&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='k'&gt;unless&lt;/span&gt; &lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;sketch_file_size&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;nil?&lt;/span&gt;
    &lt;span class='k'&gt;end&lt;/span&gt;
    &lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='kp'&gt;true&lt;/span&gt;
  &lt;span class='k'&gt;end&lt;/span&gt;

  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;before_destroy&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
    &lt;span class='n'&gt;project&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;project&lt;/span&gt;
    &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='n'&gt;project&lt;/span&gt;
      &lt;span class='n'&gt;project&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;decrement!&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:file_count&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
      &lt;span class='n'&gt;project&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;decrement!&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:file_size&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;sketch_file_size&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='k'&gt;unless&lt;/span&gt; &lt;span class='n'&gt;record&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;sketch_file_size&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;nil?&lt;/span&gt;
    &lt;span class='k'&gt;end&lt;/span&gt;
    &lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='kp'&gt;true&lt;/span&gt;
  &lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I added the observer to the application configuration.&lt;/p&gt;

&lt;p&gt;Now, everything seemed to be working fine on create, when I deleted a model (deleted an attachment) I got a nil exception on the skecth_file_size property. The problem is that the paperclip plugin deleted the sketch file before my callback and so prevented me from using it.&lt;/p&gt;

&lt;p&gt;This required a patch to the paperclip plugin.&lt;/p&gt;

&lt;p&gt;Inside the paperclip plugin there&amp;#8217;s a file called paperclip.rb Ffor me, it was line 242, I changed it from before_destroy to after_destory like so:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='n'&gt;after_destroy&lt;/span&gt; &lt;span class='ss'&gt;:destroy_attached_files&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now, also in attachment.rb (also in paperclip plugin)&lt;/p&gt;

&lt;p&gt;For me it was line 335:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='k'&gt;unless&lt;/span&gt; &lt;span class='n'&gt;instance&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;frozen?&lt;/span&gt;
  &lt;span class='n'&gt;instance_write&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:file_name&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='kp'&gt;nil&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  &lt;span class='n'&gt;instance_write&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:content_type&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='kp'&gt;nil&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  &lt;span class='n'&gt;instance_write&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:file_size&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='kp'&gt;nil&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  &lt;span class='n'&gt;instance_write&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:updated_at&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='kp'&gt;nil&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This worked like a charm and now my callback works, updating the model of the project as the files are adding and deleting, I don&amp;#8217;t have to do complicated joins to get simple data.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s how it looks in my application now:&lt;/p&gt;
&lt;a href='http://www.flickr.com/photos/51960246@N07/5323306412/' title='Screen shot 2011-01-04 at 10.26.28 AM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2011-01-04 at 10.26.28 AM' height='136' src='http://farm6.static.flickr.com/5083/5323306412_e3b98bc477.jpg' width='311' /&gt;&lt;/a&gt;
&lt;p&gt;This is the code I use to make it happen:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;  &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;lt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='n'&gt;h2&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
    &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;lt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='sx'&gt;%= @project.name %&amp;amp;gt;&lt;/span&gt;
&lt;span class='sx'&gt;  &amp;amp;lt;/h2&amp;amp;gt;&amp;amp;lt;em&amp;amp;gt;&amp;amp;lt;%=&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='c1'&gt;#{@project.file_count} files, #{number_to_human_size(@project.file_size)}&amp;amp;quot;%&amp;amp;gt;&amp;amp;lt;/em&amp;amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Use token instead of id in paperclip's path</title>
    
      <link href="http://kensodevkensodev.com/2010/12/17/use-token-instead-of-id-in-paperclips-path"/>
    
    <id>http://kensodevkensodev.com/2010/12/17/use-token-instead-of-id-in-paperclips-path</id>
    <updated>2010-12-17T12:52:27+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I have been using paperclip in more then a couple of applications that I&amp;#8217;m developing now, I really like it and it gives me the flexibility that I require.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;&amp;#8221; align=&amp;#8221;alignnone&amp;#8221; width=&amp;#8221;500&amp;#8221; caption=&amp;#8221;Url with Token example&amp;#8221;&lt;/span&gt;&lt;a href='http://www.flickr.com/photos/51960246@N07/5267932629/' title='Screen-shot-2010-12-17-at-12.57 by KensoDev, on Flickr'&gt;&lt;img alt='Screen-shot-2010-12-17-at-12.57' height='232' src='http://farm6.static.flickr.com/5204/5267932629_ec11d80ab8.jpg' width='500' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;A couple of days ago, I wanted the path of the file to include a token instead of the id of  a user class.&lt;/p&gt;

&lt;p&gt;This was my code before the change:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;  &lt;span class='n'&gt;has_attached_file&lt;/span&gt; &lt;span class='ss'&gt;:avatar&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
    &lt;span class='ss'&gt;:styles&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
    &lt;span class='p'&gt;{&lt;/span&gt;
      &lt;span class='ss'&gt;:tiny&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;48&lt;/span&gt;&lt;span class='n'&gt;x48&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
      &lt;span class='ss'&gt;:preview&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;175&lt;/span&gt;&lt;span class='n'&gt;x175&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
      &lt;span class='ss'&gt;:large&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;300&lt;/span&gt;&lt;span class='n'&gt;x300&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
      &lt;span class='ss'&gt;:huge&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;500&lt;/span&gt;&lt;span class='n'&gt;x500&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
    &lt;span class='p'&gt;},&lt;/span&gt;
    &lt;span class='ss'&gt;:storage&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='ss'&gt;:s3&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
    &lt;span class='ss'&gt;:s3_credentials&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='c1'&gt;#{RAILS_ROOT}/config/s3.yml&amp;amp;quot;,&lt;/span&gt;
    &lt;span class='ss'&gt;:path&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='ss'&gt;:class&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='ss'&gt;:attachment&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='ss'&gt;:id&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='ss'&gt;:style&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='ss'&gt;:extension&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
    &lt;span class='ss'&gt;:bucket&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;lopsum&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
    &lt;span class='ss'&gt;:default_url&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='n'&gt;images&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='n'&gt;photo01&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;jpg&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Notice that the path parameter includes the id of the user, this was not the requirement, because if this in an id parameter then the URL&amp;#8217;s will be very easy to resolve and I of course don&amp;#8217;t want that for user privacy.&lt;/p&gt;

&lt;p&gt;I don&amp;#8217;t want anyone to change the URL and get to the other profile images easily.&lt;/p&gt;

&lt;p&gt;So, I needed a token which will be a random string for each user and I wanted that to be included in the path. This way, no one can tell the other paths in the system (it&amp;#8217;s harder, a lot harder).&lt;/p&gt;

&lt;p&gt;So, first thing first, I added this code to the user model:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;  &lt;span class='n'&gt;validates_presence_of&lt;/span&gt; &lt;span class='ss'&gt;:token&lt;/span&gt;

  &lt;span class='kp'&gt;protected&lt;/span&gt;
    &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;before_validation_on_create&lt;/span&gt;
      &lt;span class='nb'&gt;self&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;token&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nb'&gt;rand&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='mi'&gt;36&lt;/span&gt;&lt;span class='o'&gt;**&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;to_s&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='mi'&gt;36&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;upcase&lt;/span&gt; &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='nb'&gt;self&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;new_record?&lt;/span&gt; &lt;span class='ow'&gt;and&lt;/span&gt; &lt;span class='nb'&gt;self&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;token&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;nil?&lt;/span&gt;
    &lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I used a random code, you can of course use MD5 of the date or whatever you may want, just replace this code:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='nb'&gt;rand&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='mi'&gt;36&lt;/span&gt;&lt;span class='o'&gt;**&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;to_s&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='mi'&gt;36&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;upcase&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now that I have a token saved in the database I changed the image saving code to this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;  &lt;span class='n'&gt;has_attached_file&lt;/span&gt; &lt;span class='ss'&gt;:avatar&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
    &lt;span class='ss'&gt;:styles&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
    &lt;span class='p'&gt;{&lt;/span&gt;
      &lt;span class='ss'&gt;:tiny&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;48&lt;/span&gt;&lt;span class='n'&gt;x48&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
      &lt;span class='ss'&gt;:preview&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;175&lt;/span&gt;&lt;span class='n'&gt;x175&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
      &lt;span class='ss'&gt;:large&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;300&lt;/span&gt;&lt;span class='n'&gt;x300&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
      &lt;span class='ss'&gt;:huge&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;500&lt;/span&gt;&lt;span class='n'&gt;x500&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
    &lt;span class='p'&gt;},&lt;/span&gt;
    &lt;span class='ss'&gt;:storage&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='ss'&gt;:s3&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
    &lt;span class='ss'&gt;:s3_credentials&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='c1'&gt;#{RAILS_ROOT}/config/s3.yml&amp;amp;quot;,&lt;/span&gt;
    &lt;span class='ss'&gt;:path&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='ss'&gt;:class&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='ss'&gt;:attachment&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='ss'&gt;:token&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='ss'&gt;:style&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='ss'&gt;:extension&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;,&lt;/span&gt;
    &lt;span class='ss'&gt;:bucket&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;lopsum&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;
    &lt;span class='ss'&gt;:default_url&lt;/span&gt; &lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='n'&gt;images&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='n'&gt;photo01&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;jpg&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This code did not work, the path only included the word :token but without the actual token from the database. &lt;h2&gt;So, how can you fix this?&lt;/h2&gt; You need to add an initializer for paperclip.&lt;/p&gt;

&lt;p&gt;You add a file called&lt;em&gt; paperclip.rb&lt;/em&gt; into the&lt;em&gt; config/initializers&lt;/em&gt; folder&lt;/p&gt;

&lt;p&gt;You paste in this code:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='no'&gt;Paperclip&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;interpolates&lt;/span&gt; &lt;span class='ss'&gt;:token&lt;/span&gt; &lt;span class='k'&gt;do&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;attachment&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;style&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;
  &lt;span class='n'&gt;attachment&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;instance&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;token&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This will &amp;#8220;tokenize&amp;#8221; your user avatar path.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Removing a model from your rails project</title>
    
      <link href="http://kensodevkensodev.com/2010/11/24/removing-a-model-from-your-rails-project"/>
    
    <id>http://kensodevkensodev.com/2010/11/24/removing-a-model-from-your-rails-project</id>
    <updated>2010-11-24T19:59:11+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;During the work on a project I created a model. Right after clicking the Enter key I realized that I didn&amp;#8217;t need it and wanted to roll back. Because I am using GIT, I could of course have done this using it, but I wanted to do it using a Rails command. Turns out, there&amp;#8217;s a command to do this (if you haven&amp;#8217;t migrated the db yet). The command is as follows:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;script/destroy model contact
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This will remove all of the files that were added by this command.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;script/generate model contact user_id:integer &lt;span class='nb'&gt;type&lt;/span&gt;:integer
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Nice to know you can either do this with GIT or with Rails. Obviously the best solution is to think before you click Enter :-) but it&amp;#8217;s nice to know nevertheless.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">A solution for the “I Follow” bug with cucumber and Capybara</title>
    
      <link href="http://kensodevkensodev.com/2010/11/23/a-solution-for-the-i-follow-bug-with-cucumber-and-capybara"/>
    
    <id>http://kensodevkensodev.com/2010/11/23/a-solution-for-the-i-follow-bug-with-cucumber-and-capybara</id>
    <updated>2010-11-23T17:21:29+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;While working on a new application and writing tests I encountered a problem: This is the test I have been using:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;  &lt;span class='no'&gt;Scenario&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='no'&gt;Deleting&lt;/span&gt; &lt;span class='n'&gt;a&lt;/span&gt; &lt;span class='n'&gt;project&lt;/span&gt; &lt;span class='n'&gt;from&lt;/span&gt; &lt;span class='n'&gt;the&lt;/span&gt; &lt;span class='n'&gt;main&lt;/span&gt; &lt;span class='n'&gt;page&lt;/span&gt;
    &lt;span class='no'&gt;Given&lt;/span&gt; &lt;span class='n'&gt;I&lt;/span&gt; &lt;span class='n'&gt;am&lt;/span&gt; &lt;span class='n'&gt;on&lt;/span&gt; &lt;span class='n'&gt;the&lt;/span&gt; &lt;span class='n'&gt;account&lt;/span&gt; &lt;span class='n'&gt;home&lt;/span&gt; &lt;span class='n'&gt;page&lt;/span&gt;
	&lt;span class='no'&gt;When&lt;/span&gt; &lt;span class='n'&gt;I&lt;/span&gt; &lt;span class='n'&gt;follow&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='no'&gt;Delete&lt;/span&gt; &lt;span class='no'&gt;Project&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
	&lt;span class='no'&gt;Then&lt;/span&gt; &lt;span class='n'&gt;I&lt;/span&gt; &lt;span class='n'&gt;should&lt;/span&gt; &lt;span class='n'&gt;see&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='no'&gt;Your&lt;/span&gt; &lt;span class='n'&gt;project&lt;/span&gt; &lt;span class='n'&gt;has&lt;/span&gt; &lt;span class='n'&gt;been&lt;/span&gt; &lt;span class='n'&gt;deleted&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The error that was shown is this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;undefined &lt;span class='nb'&gt;local &lt;/span&gt;variable or method &lt;span class='sb'&gt;`&lt;/span&gt;node&lt;span class='err'&gt;&amp;#39;&lt;/span&gt; &lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='c'&gt;#&amp;amp;lt;Capybara::Driver::Node tag=&amp;amp;quot;a&amp;amp;quot; ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Here&amp;#8217;s a screen shot of the test run: &lt;a href='http://www.flickr.com/photos/51960246@N07/5201208261/' title='Screen shot 2010-11-23 at 5.36.24 PM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2010-11-23 at 5.36.24 PM' height='135' src='http://farm5.static.flickr.com/4129/5201208261_b5193c9cda.jpg' width='500' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After browsing around for quite some time, I found that the error is originated with this line in env.rb file:&lt;/p&gt;

&lt;p&gt;&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='nb'&gt;require&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;cucumber/rails/capybara_javascript_emulation&amp;#39;&lt;/span&gt; &lt;span class='c1'&gt;# Lets you click links with onclick javascript handlers without using @culerity or @javascript&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Commenting out this line solved the problem for me and now I can continue with my testing. I hope it will solve your problem as well.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Pluralization in flex application(s)</title>
    
      <link href="http://kensodevkensodev.com/2010/10/28/pluralization-in-flex-applications"/>
    
    <id>http://kensodevkensodev.com/2010/10/28/pluralization-in-flex-applications</id>
    <updated>2010-10-28T18:42:32+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='SingularPluralSort.pdf.00' class='alignleft' height='240' src='http://farm5.static.flickr.com/4071/5123639196_e8dff2d0c2_m.jpg' width='185' /&gt;
&lt;p&gt;As you may know (or not) I am a Flex developer, I am also a Ruby On Rails developer.&lt;/p&gt;

&lt;p&gt;As a Ruby On Rails developer I often find myself hoping just a fraction of the stuff Ruby On Rails has would come to Flex or someone will port parts of it to Action Script 3.&lt;/p&gt;

&lt;p&gt;This week I had a bug reported by a client that the alerts he received from the systems are inconsistent to the amount of items he is selecting.&lt;/p&gt;

&lt;p&gt;For instance, he has a grid showing modules, and he can delete the selected item/s, when he clicks delete he gets the standard confirm message &amp;#8220;are you sure you want to delete the selected module&amp;#8221;, this message is the same when more then a single module is selected.&lt;/p&gt;

&lt;p&gt;This is across the entire system and not only in this single module.&lt;/p&gt;

&lt;p&gt;So, I sat down, scratched my head for a little while and then remembered that Ruby On Rails has something like that - out of the box and it&amp;#8217;s called Pluralization (Inflector).&lt;/p&gt;

&lt;p&gt;It goes something like this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;lt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='o'&gt;%=&lt;/span&gt; &lt;span class='n'&gt;pluralize&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;messages&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;length&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;&lt;span class='n'&gt;module&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;quot&lt;/span&gt;&lt;span class='p'&gt;;)&lt;/span&gt; &lt;span class='o'&gt;%&amp;amp;&lt;/span&gt;&lt;span class='n'&gt;gt&lt;/span&gt;&lt;span class='p'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I googled for a bit and found that &lt;a href='http://flexonrails.net/' target='_blank'&gt;http://flexonrails.net/&lt;/a&gt; had an as3 version of that, I rewrote it a bit, exposed only one function outside and this is the outcome (complete code):&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='kd'&gt;package&lt;/span&gt; &lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;kensodev&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
	&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;class&lt;/span&gt; &lt;span class='nx'&gt;PluralizationHelper&lt;/span&gt;
	&lt;span class='p'&gt;{&lt;/span&gt;
		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;PluralizationHelper&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;static&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='nx'&gt;PluralizationHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;initPluralization&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;pluralWords&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt;
			&lt;span class='p'&gt;[&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/$/&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;s&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/s$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;s&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(ax|test)is$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1es&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(octop|vir)us$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1i&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(alias|status)$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1es&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(bu)s$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ses&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(buffal|tomat)o$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1oes&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([ti])um$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1a&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/sis$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;ses&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(?:([^f])fe|([lr])f)$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1$2ves&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(hive)$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1s&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([^aeiouy]|qu)y$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ies&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(x|ch|ss|sh)$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1es&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(matr|vert|ind)ix|ex$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ices&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([m|l])ouse$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ice&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/^(ox)$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1en&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(quiz)$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1zes&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;
			&lt;span class='p'&gt;];&lt;/span&gt;

		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;singularWords&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt;
			&lt;span class='p'&gt;[&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/s$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(n)ews$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ews&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([ti])a$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1um&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1$2sis&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(^analy)ses$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1sis&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([^f])ves$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1fe&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(hive)s$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(tive)s$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([lr])ves$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1f&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([^aeiouy]|qu)ies$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1y&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(s)eries$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1eries&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(m)ovies$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ovie&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(x|ch|ss|sh)es$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/([m|l])ice$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ouse&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(bus)es$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(o)es$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(shoe)s$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(cris|ax|test)es$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1is&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(octop|vir)i$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1us&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(alias|status)es$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/^(ox)en/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(vert|ind)ices$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ex&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(matr)ices$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1ix&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='sr'&gt;/(quiz)zes$/i&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;$1&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;
			&lt;span class='p'&gt;];&lt;/span&gt;

		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;irregularWords&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt;
			&lt;span class='p'&gt;[&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;person&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;people&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;man&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;men&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;child&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;children&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;sex&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;sexes&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;
				&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;move&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;moves&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;
			&lt;span class='p'&gt;];&lt;/span&gt;

		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;uncountableWords&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt;
			&lt;span class='p'&gt;[&lt;/span&gt;
				&lt;span class='s1'&gt;&amp;#39;equipment&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;information&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;rice&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;money&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;species&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;series&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;fish&amp;#39;&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;sheep&amp;#39;&lt;/span&gt;
			&lt;span class='p'&gt;];&lt;/span&gt;

		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;makePlural&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;singular&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;uncountableWords&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;indexOf&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;singular&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
				&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;singular&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

			&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;plural&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='k'&gt;new&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
			&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;item&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;pluralWords&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
			&lt;span class='p'&gt;{&lt;/span&gt;
				&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;p&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;singular&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;replace&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;item&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;item&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;]);&lt;/span&gt;
				&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;p&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='nx'&gt;singular&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
					&lt;span class='nx'&gt;plural&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;p&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
			&lt;span class='p'&gt;}&lt;/span&gt;
			&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;plural&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;makeSingular&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;plural&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;

			&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;uncountableWords&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;indexOf&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;plural&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
				&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;plural&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

			&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;singular&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='k'&gt;new&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
			&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;item&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;singularWords&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
			&lt;span class='p'&gt;{&lt;/span&gt;
				&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;s&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;plural&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;replace&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;item&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;item&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;]);&lt;/span&gt;
				&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;s&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='nx'&gt;plural&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
					&lt;span class='nx'&gt;singular&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;s&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
			&lt;span class='p'&gt;}&lt;/span&gt;
			&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;singular&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
				&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;plural&lt;/span&gt;
			&lt;span class='k'&gt;else&lt;/span&gt;
				&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;singular&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;Bindable&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;event&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;pluralizationChangedEvent&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;)]&lt;/span&gt;
		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;pluiralize&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;count&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;int&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;word&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;count&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
				&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;makeSingular&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt; &lt;span class='nx'&gt;word&lt;/span&gt; &lt;span class='p'&gt;);&lt;/span&gt;

			&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;makePlural&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt; &lt;span class='nx'&gt;word&lt;/span&gt; &lt;span class='p'&gt;);&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;initPluralization&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;arr&lt;/span&gt; &lt;span class='o'&gt;:&lt;/span&gt; &lt;span class='nb'&gt;Array&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;irregularWords&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
			&lt;span class='p'&gt;{&lt;/span&gt;
				&lt;span class='nx'&gt;pluralWords&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;pluralWords&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;length&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;arr&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;arr&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;]];&lt;/span&gt;
				&lt;span class='nx'&gt;singularWords&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;singularWords&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;length&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;arr&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;arr&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='p'&gt;]];&lt;/span&gt;
			&lt;span class='p'&gt;}&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;
	&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;You activate the pluralization like this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='nx'&gt;PluralizationHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;pluralize&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;count&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;module&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This will return the correct string.&lt;/p&gt;

&lt;p&gt;You can also find the source on github &lt;a href='http://github.com/KensoDev/Flex-Generic-Helpers' target='_blank'&gt; http://github.com/KensoDev/Flex-Generic-Helpers&lt;/a&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Scroll to selected index in Tree control (Flex)</title>
    
      <link href="http://kensodevkensodev.com/2010/10/03/scroll-to-selected-index-in-tree-control-flex"/>
    
    <id>http://kensodevkensodev.com/2010/10/03/scroll-to-selected-index-in-tree-control-flex</id>
    <updated>2010-10-03T21:14:05+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Sometimes, in your application you have a tree that has many nodes, folders, sub-folders and many items.&lt;/p&gt;

&lt;p&gt;Often, this tree needs to have a scroll bar, and usually you want the scroll to be on the spot with the selected item.&lt;/p&gt;

&lt;p&gt;I recently encountered some weird solutions for this in a company I work for these days, I have actually seen a custom control with saving the scroll position in memory, height calculations for items and many more &amp;#8220;solutions&amp;#8221;.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s actually a simple way to do this, it is so simple that when the developers saw it they laughed so hard (the team leader didn&amp;#8217;t) on the time they have spent on this solution.&lt;/p&gt;

&lt;p&gt;By the way, the solution can also be for Grid and List controls so you can use it there as well.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the code:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;tree&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;selectedIndex&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
	&lt;span class='nx'&gt;tree&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;scrollToIndex&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt; &lt;span class='nx'&gt;tree&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;selectedIndex&lt;/span&gt; &lt;span class='p'&gt;);&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Simple isn&amp;#8217;t it?&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Make your life easier with this Flash Builder 4 plugin (sourcemate)</title>
    
      <link href="http://kensodevkensodev.com/2010/10/03/make-your-life-easier-with-this-flash-builder-4-plugin-sourcemate"/>
    
    <id>http://kensodevkensodev.com/2010/10/03/make-your-life-easier-with-this-flash-builder-4-plugin-sourcemate</id>
    <updated>2010-10-03T08:45:18+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.flickr.com/photos/51960246@N07/5047608197/' title='Screen shot 2010-10-03 at 8.02.59 PM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2010-10-03 at 8.02.59 PM' class='alignleft' height='142' src='http://farm5.static.flickr.com/4139/5047608197_836751ec0d.jpg' width='256' /&gt;&lt;/a&gt;
&lt;p&gt;I have been working with flex for about 4 years now and moved to Flash Builder 4 about six months ago. The one thing I have really missed in programming flex is the proper IDE that makes your life easier, making simple tasks simple for the programmer.&lt;/p&gt;

&lt;p&gt;For instance, I always wanted to write private vars (with shortcuts) and then make getters and setter with a click of a button, with no real need for typing them all.&lt;/p&gt;

&lt;p&gt;Typing is a waste of time for programmers. Don&amp;#8217;t get me wrong, we all have to type code, after all this is how we make a living, but writing the complete method template other than just a shortcut and then a click on a button is something that at the end of the day takes the toll from your project.&lt;/p&gt;

&lt;p&gt;So, let&amp;#8217;s take some scenarios that I encountered in my life as a Flex programmer and team leader. &lt;h2&gt;Code generation&lt;/h2&gt; This is one of the things that I have been looking at deeply upon when I was about to buy sourcemate plugin, the plugin promised and kept it&amp;#8217;s promise to make your life simpler by being able to define what they call snippets.&lt;/p&gt;

&lt;p&gt;Those snippets have a set that comes predefined, you can also define as many snippets as you want.&lt;/p&gt;

&lt;p&gt;One killer feature is being able to share snippets with others, this is just a terrific feature. It allows the team to write the same code, or at least code with the same signature, all methods look the same, all vars look the same and more.&lt;/p&gt;

&lt;p&gt;A sample template:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;index&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;int&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;index&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;array&lt;/span&gt;&lt;span class='p'&gt;}.&lt;/span&gt;&lt;span class='nx'&gt;length&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;index&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;++&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;indent&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;element&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;varName&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;type&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;array&lt;/span&gt;&lt;span class='p'&gt;}[&lt;/span&gt;&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;index&lt;/span&gt;&lt;span class='p'&gt;}]&lt;/span&gt; &lt;span class='nx'&gt;as&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;type&lt;/span&gt;&lt;span class='p'&gt;};&lt;/span&gt;
&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;indent&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;cursor&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;this template&amp;#8217;s shortcut is &amp;#8216;for&amp;#8217; and then a CMD+SPACE &lt;a href='http://www.flickr.com/photos/51960246@N07/5046665676/' title='Screen shot 2010-10-03 at 8.29.10 AM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2010-10-03 at 8.29.10 AM' height='98' src='http://farm5.static.flickr.com/4126/5046665676_a23dfafdbf.jpg' width='366' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can probably see, this is a peace of code you have probably written dozens of time, it usually takes you much more than just couple of seconds.&lt;/p&gt;

&lt;p&gt;You can navigate your way inside the template with the TAB key on you keyboard, clicking the TAB on the keyboard will take you on this path (in this template): &lt;ol&gt;
	&lt;li&gt;define the array param (rename)&lt;/li&gt;
	&lt;li&gt;define the element type (rename)&lt;/li&gt;
&lt;/ol&gt; So, you can customize the template, generally speaking, making this code fit your array and your element type takes about 5 seconds, this is a huge improvement in times, you can shave quite some time from your work day. &lt;h3&gt;Customized snippet&lt;/h3&gt; Now, let&amp;#8217;s see how we can customize a snippet to fit our own code.&lt;/p&gt;

&lt;p&gt;In a project I am currently working on there&amp;#8217;s a class (ViewHelper) that has a base class (BaseViewHelper).&lt;/p&gt;

&lt;p&gt;This base class has a model property, in the class you are writing, you want to make a getter that will be called myModel, and this will return a casted instance of the model property&lt;/p&gt;

&lt;p&gt;Generally, it looks like this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='kd'&gt;get&lt;/span&gt; &lt;span class='nx'&gt;myModel&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;CurrentConfiguration&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;CurrentConfiguration&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;this&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;model&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Just take a look at this code, as you can see there&amp;#8217;s a template here. Llet&amp;#8217;s check what the template is: &lt;ul&gt;
	&lt;li&gt;decide if the method is public/private/protected&lt;/li&gt;
	&lt;li&gt;set the type of the getter&lt;/li&gt;
&lt;/ul&gt; This is what the template looks like now:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;visibility&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;link&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='kd'&gt;public&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='kd'&gt;protected&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='kd'&gt;private&lt;/span&gt;&lt;span class='p'&gt;)}&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='kd'&gt;get&lt;/span&gt; &lt;span class='nx'&gt;myModel&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;modelName&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
&lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;indent&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;$&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;modelName&lt;/span&gt;&lt;span class='p'&gt;}(&lt;/span&gt;&lt;span class='k'&gt;this&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;model&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now, when I want to put this in my class all I have to type is myModel and then CTRL+SPACE, set the type, select the visibility and I&amp;#8217;ll have a myModel getter inside my class. &lt;h2&gt;Refactoring&lt;/h2&gt; The next best thing this plugin gives you is refactoring.&lt;/p&gt;

&lt;p&gt;After reading uncle Bob&amp;#8217;s book (&lt;a href='http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882' target='_blank'&gt;Clean Code&lt;/a&gt;) I am crazy about refactoring, it makes my code so much simpler, also when getting into other programmers code, I refactor it, break a method into several smaller, more single responsibility methods and then, just then I start working on what I have to do.&lt;/p&gt;

&lt;p&gt;The great thing about refactoring with sourcemate is that the function created is created with all of the params (variables) that it needs in order to work, the refactoring also detects if the function should return a value or just be void.&lt;/p&gt;

&lt;p&gt;These are the options for refactoring, I don&amp;#8217;t think it needs much more explanations then thus:&lt;/p&gt;
&lt;a href='http://www.flickr.com/photos/51960246@N07/5046071659/' title='Screen shot 2010-10-03 at 8.46.34 AM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2010-10-03 at 8.46.34 AM' height='115' src='http://farm5.static.flickr.com/4147/5046071659_9f01aef95b_z.jpg' width='640' /&gt;&lt;/a&gt;&lt;h2&gt;More&lt;/h2&gt;
&lt;p&gt;This plugin gives you so much more than what I have written about, it has many more great features like generating ASDoc comments, generating documentation for the project and many more.&lt;/p&gt;

&lt;p&gt;This plugin is by far the best thing that have happened to my Flex development experience since Flex builder 3 came out :-)&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">gitignore template for a Ruby on Rail project</title>
    
      <link href="http://kensodevkensodev.com/2010/09/26/gitignore-template-for-a-rails-project"/>
    
    <id>http://kensodevkensodev.com/2010/09/26/gitignore-template-for-a-rails-project</id>
    <updated>2010-09-26T20:42:35+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Been working with &lt;a href='http://www.kensodev.com/category/ruby-on-rails/' title='Ruby on Rails'&gt;Ruby On Rails&lt;/a&gt; for about 10 months now, about the same amount of time with GIT, I enjoy them both very much.&lt;/p&gt;

&lt;p&gt;When I start a rails project and connect it to GIT, I always create the same gitignore file. Therefore, I thought I should share it with you.&lt;/p&gt;

&lt;p&gt;Here it is:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;log/*
tmp/*
.DS_Store
db/*
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Link Bag September 05 2010</title>
    
      <link href="http://kensodevkensodev.com/2010/09/05/link-bag-september-05-2010"/>
    
    <id>http://kensodevkensodev.com/2010/09/05/link-bag-september-05-2010</id>
    <updated>2010-09-05T07:40:09+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Yet another post that will gather links and useful information of intersting stuff, that will probably be useful to my readers. &lt;h2&gt;General&lt;/h2&gt; &lt;a href='http://feedproxy.google.com/~r/CodeBetter/~3/Q4nfqG-olcc/launching-beta-or-how-to-decide-when-and-where-to-cut-corners.aspx' target='_blank'&gt; Launching beta, or “How to decide when and where to cut corners&lt;/a&gt; - A great post from &lt;a href='http://CodeBetter.com'&gt;CodeBetter.com&lt;/a&gt; with a reference to &lt;a href='http://kohari.org/'&gt;Nate Kohari's&lt;/a&gt; post on the same subject. A very good read if you are planning in launching a product anytime soon. &lt;h2&gt;Freelancing&lt;/h2&gt; &lt;a href='http://feedproxy.google.com/~r/FreelanceSwitch/~3/WxF8mgNbf3E/'&gt;10 Requirements for Working with Clients in Other Countries&lt;/a&gt; - I work with clients in other countries all of the time, mostly in the US and Japan. Therefore, I think this post will be very useful if you are in the same situation. I got something out of it, and so will you.&lt;/p&gt;
&lt;a href='http://feedproxy.google.com/~r/SixRevisions/~3/fbakDDeyN5k/'&gt;Craftsmanship in Designing Websites&lt;/a&gt;&lt;h2&gt;CSS&lt;/h2&gt;&lt;a href='http://devign.me/css-stretch-a-box-to-its-parent-bounds/'&gt;CSS: Stretch a Box to its Parent’s Bounds&lt;/a&gt;&lt;h2&gt;GIT&lt;/h2&gt;
&lt;p&gt;I am (as you already know) a huge fan of Git. I know Git is a big source of misuse and misunderstanding. I have read a couple of great posts about it recently on how to use GitK tool.&lt;/p&gt;
&lt;a href='http://feedproxy.google.com/~r/LosTechies/~3/ZShb4VMewhc/use-gitk-to-understand-git.aspx'&gt;use-gitk-to-understand-git.aspx&lt;/a&gt;&lt;a href='http://feedproxy.google.com/~r/LosTechies/~3/-zSO-aPGUk4/use-gitk-to-understand-git-merge-and-rebase.aspx'&gt;Use gitk to understand git – merge and rebase&lt;/a&gt;
&lt;p&gt;That&amp;#8217;s all for now. Hope you&amp;#8217;ll find my post useful.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Maintain sort on a DataGrid when the dataProvider is changed</title>
    
      <link href="http://kensodevkensodev.com/2010/09/05/maintain-sort-on-a-datagrid-when-the-dataprovider-is-changed"/>
    
    <id>http://kensodevkensodev.com/2010/09/05/maintain-sort-on-a-datagrid-when-the-dataprovider-is-changed</id>
    <updated>2010-09-05T07:02:42+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Usually, in our &lt;a href='http://www.kensodev.com/category/flex/' title='Flex'&gt;Flex&lt;/a&gt; application we do have a data-grid. This component is very useful for displaying data and have a sorting, ordering of columns and more, out of the box.&lt;/p&gt;

&lt;p&gt;I can speak for my applications and say that every enterprise application I have ever build had at least one or more data-Grid&amp;#8217;s inside it.&lt;/p&gt;

&lt;p&gt;So, what can we say about a grid that has not been said before in the past&amp;#8230;?&lt;/p&gt;

&lt;p&gt;I recently had a grid that I enabled sorting on it. It had a data-Provider (ArrayCollection) and I needed to preserver the sorting when the collection had changed.&lt;/p&gt;

&lt;p&gt;The default behavior when you hookup a collection to the dataProvider property of the grid, is that when the collection changes, it will change the sorting back to default.&lt;/p&gt;

&lt;p&gt;This is the code before the fix:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;			&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGrid&lt;/span&gt;  &lt;span class='nx'&gt;width&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;100&lt;/span&gt;&lt;span class='o'&gt;%&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;height&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;100&lt;/span&gt;&lt;span class='o'&gt;%&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;dataGrid&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;dataProvider&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;myHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;widgetModel&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;data&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;itemClick&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;myHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;updateCustomFieldsButtonBar&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;allowMultipleSelection&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='kc'&gt;true&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;updateComplete&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;myHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;gridUpdateComplete&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;event&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
				&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;columns&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;visible&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='kc'&gt;false&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Field&lt;/span&gt; &lt;span class='nx'&gt;Name&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;description&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Description&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;typeDisplayName&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Type&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;entityTypes&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Entity&lt;/span&gt; &lt;span class='nx'&gt;Type&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;listId&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Entity&lt;/span&gt; &lt;span class='nx'&gt;Type&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;visible&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='kc'&gt;false&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
				&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;columns&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

			&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGrid&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This peace of code it the most important peace in the puzzle, wiring up (binding) between a model (collection) and the dataProvider:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='nx'&gt;dataProvider&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;myHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;widgetModel&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;data&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;So, we know that this way does not work. What do we need to do in order to save the sorting when the provider changes? What we actually need to do is to create a view of our collection, provide it with data and wire it up to the grid&lt;/p&gt;

&lt;p&gt;This is how we do it.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;ListCollectionView&lt;/span&gt; &lt;span class='nx'&gt;list&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;helper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;widgetModel&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;data&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;listCollectionView&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

			&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGrid&lt;/span&gt;  &lt;span class='nx'&gt;width&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;100&lt;/span&gt;&lt;span class='o'&gt;%&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;height&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;100&lt;/span&gt;&lt;span class='o'&gt;%&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;dataGrid&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;dataProvider&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='nx'&gt;listCollectionView&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;itemClick&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;myHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;updateCustomFieldsButtonBar&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;allowMultipleSelection&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='kc'&gt;true&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='nx'&gt;updateComplete&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;myHelper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;gridUpdateComplete&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;event&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
				&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;columns&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;visible&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='kc'&gt;false&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Field&lt;/span&gt; &lt;span class='nx'&gt;Name&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;description&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Description&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;typeDisplayName&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Type&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;entityTypes&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Entity&lt;/span&gt; &lt;span class='nx'&gt;Type&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGridColumn&lt;/span&gt; &lt;span class='nx'&gt;dataField&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;listId&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;headerText&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Entity&lt;/span&gt; &lt;span class='nx'&gt;Type&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;visible&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='kc'&gt;false&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
				&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;columns&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

			&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;DataGrid&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Notice that the grid&amp;#8217;s data provider is not the collection view.&lt;/p&gt;

&lt;p&gt;Now, when the data will change, the sorting will not change.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Memory management in flex applications</title>
    
      <link href="http://kensodevkensodev.com/2010/08/22/memory-management-in-flex-applications"/>
    
    <id>http://kensodevkensodev.com/2010/08/22/memory-management-in-flex-applications</id>
    <updated>2010-08-22T07:24:33+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;span&gt;Lately there is &lt;span&gt;alot&lt;/span&gt; of buzz about Flex application performance, keeping your memory low and just in general, keeping everything managed under your fingers and not just counting on the flex framework to manage your memory.&lt;/span&gt;&lt;a href='http://www.kensodev.com/tag/flex/' title='Flex'&gt;Flex&lt;/a&gt;&lt;span&gt;First thing we need to understand is that any application we will build in our careers will be using some amount of memory, and because memory is not infinite, we should keep our applications memory as low as possible.&lt;/span&gt;
&lt;p&gt;I always say the best way to describe memory management is to &amp;#8220;be smart&amp;#8221; meaning - always have memory in mind, never let it go and by doing this your application will keep lean and thin all the time.&lt;/p&gt;
&lt;span&gt;By taking up too much memory you can get into alot of trouble - you can make your users hate the application because it is running slowly and making their computer run slowly. Also, the application can simply crash.&lt;/span&gt;&lt;span&gt;I hear from programmers in my consulting that computers are getting more and more memory and you can see laptops coming with 4G of memory out of the box and so on, but actually we are also seeing a movement towards mobile devices such as mobile phones etc. these mobile devices do no allow us to use too much memory because it's limited resource.&lt;/span&gt;&lt;h2&gt;&lt;span&gt;Memory leaks&lt;/span&gt;&lt;/h2&gt;&lt;span&gt;Memory leaks is a big issue in flex programming and it's generally speaking divided into 2 parts, first when our application is using memory in parts we didn't want it to use and the other part is when we didn't handle the cleaning part efficiently enough.&lt;/span&gt;&lt;a href='http://www.kensodev.com/tag/flash/' title='Flash'&gt;Flash&lt;/a&gt;&lt;h3&gt;Event Listeners&lt;/h3&gt;
&lt;p&gt;Event listeners are by-far the most mis-used, mis-understood part of flex applications. I have seen people/developers using those without even understanding what is actually happening behind the scenes and when (and if) those are cleaned up in memory.&lt;/p&gt;

&lt;p&gt;I will try to explain. Let&amp;#8217;s take this peace of code:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='c1'&gt;//objectX&lt;/span&gt;
&lt;span class='nx'&gt;objectY&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;addEventListener&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;some_event&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;some_function&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;We have two objects (ObjectX, ObjectY) - Object Y has a reference to a function in objectX just by passing the function. Now, if your application has a reference to objectY, object X will not get cleaned because it has a reference to a function.&lt;/p&gt;

&lt;p&gt;There is actually something called weak event listeners, by default the event listeners are &amp;#8220;strong&amp;#8221; meaning every event listener is a function, if you specify the event listener is &amp;#8220;weak&amp;#8221; then the event listener does not count as a reference. &lt;h3&gt;Static Variables&lt;/h3&gt; Static variables are never cleaned in the entire session of a flex application, meaning if you set the variable&amp;#8217;s value with an object, this object will never get cleaned.&lt;/p&gt;

&lt;p&gt;If you want to make sure the object is cleaned you should null out the variable.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='c1'&gt;// static variable&lt;/span&gt;
&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;_foo&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Foo&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='c1'&gt;//setting the value&lt;/span&gt;
&lt;span class='nx'&gt;_foo&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='k'&gt;new&lt;/span&gt; &lt;span class='nx'&gt;Foo&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
&lt;span class='c1'&gt;//clean&lt;/span&gt;
&lt;span class='nx'&gt;_foo&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='kc'&gt;null&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h3&gt;Dictionaries&lt;/h3&gt;
&lt;p&gt;Dictionaries are another big problem and source of misunderstanding in flex applications.&lt;/p&gt;

&lt;p&gt;Dictionaries are key-value collections, meaning you have a collection that is built in the form of a key and a value attached to it.&lt;/p&gt;

&lt;p&gt;You can use objects as your key and your value, for example let&amp;#8217;s say we have two objects (ObjectX, ObjectY), you add an entry to the dictionary where ObjectX is the key and ObjectY is the value.&lt;/p&gt;

&lt;p&gt;By default the values in dictionaries are &amp;#8220;strong&amp;#8221; and you can specify a &amp;#8220;weak&amp;#8221; key, by doing this, you can actually make sure that if nothing else has a reference to ObjectX, it will get cleaned by the garbage collection. BUT, ObjectY will not get cleaned even though the key for it got cleaned from the dictionary.&lt;/p&gt;

&lt;p&gt;There are many questions on this issue from flex experts to adobe, those questions generally start with a WHYYYYYY????&lt;/p&gt;

&lt;p&gt;I would also like to understand why, but this is the situation and we have to deal with it. In the Flex-Show podcast Aaron says that if you iterate through the values of the dictionary, then all values that don&amp;#8217;t have a key (it was cleaned remember?) gets cleaned immediately.&lt;/p&gt;

&lt;p&gt;I never encountered this behavior, but Aaron knows what he is talking about, so I trust him :) (Thanks Aaron). &lt;h2&gt;Conclusion&lt;/h2&gt; I think those are the main three issues in flex applications. There are a few more, but if you handle those three you should be fine and your application will actually be pretty lean (at least in memory management).&lt;/p&gt;

&lt;p&gt;** this post was inspired by Aaron&amp;#8217;s talk on the podcast, I enjoyed it so much I decided to make a post on the issue.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Keep your mxml files neat with View Helpers</title>
    
      <link href="http://kensodevkensodev.com/2010/08/19/keep-your-mxml-files-neat-with-view-helpers"/>
    
    <id>http://kensodevkensodev.com/2010/08/19/keep-your-mxml-files-neat-with-view-helpers</id>
    <updated>2010-08-19T18:00:53+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I have been working with&lt;a href='http://www.kensodev.com/category/flex/' title='flex'&gt; flex&lt;/a&gt; and consulting about flex development for quite some time now. I guess about 3 years of consulting and 4 years of hands-on development.&lt;/p&gt;

&lt;p&gt;I have seen flex applications written in many ways: mxml files, as files, namespaces and more. I guess there is no &amp;#8220;right&amp;#8221; way to do so, or at least not just one &amp;#8220;right&amp;#8221; way.&lt;/p&gt;

&lt;p&gt;These past few months, I have started working with mxml files in a way I think is very convenient. It keeps my mxml file very lean and clean, all of the view code is in a separate action-script file which inherits from a base class. &lt;p style='text-align: center;'&gt;I want to show you this, first. This is the sample project, this is what it looks like in flash builder:
&lt;a href='http://www.flickr.com/photos/51960246@N07/4907663294/' title='Screen shot 2010-08-19 at 5.26.08 PM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2010-08-19 at 5.26.08 PM' class='aligncenter' height='349' src='http://farm5.static.flickr.com/4142/4907663294_69ebd7233a.jpg' width='385' /&gt;&lt;/a&gt;&lt;/p&gt; As you can see, there is the main application, an mxml component, the BaseViewHelper class and that is just about it.&lt;/p&gt;

&lt;p&gt;Now, let&amp;#8217;s have a look at the BaseViewHelper class. &lt;em&gt;note: this is a stripped down version of the class, it has many additions in my project, like a way to add validations, clean and dirty modes for the model and more, this is just to see the way I work, you can add your own additions to it.&lt;/em&gt;&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='kd'&gt;package&lt;/span&gt; &lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;kensodev&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;core&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
	&lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;core&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;UIComponent&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;class&lt;/span&gt; &lt;span class='nx'&gt;BaseViewHelper&lt;/span&gt;
	&lt;span class='p'&gt;{&lt;/span&gt;
		&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;_view&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;UIComponent&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;BaseViewHelper&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;

		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;init&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;

		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='kd'&gt;set&lt;/span&gt; &lt;span class='nx'&gt;view&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;v&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;UIComponent&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='nx'&gt;_view&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;v&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='kd'&gt;get&lt;/span&gt; &lt;span class='nx'&gt;view&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;UIComponent&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;_view&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;
	&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, I kept it very simple. It has a view getter and setter to set the view it handles, and an init function (for creation complete events).&lt;/p&gt;

&lt;p&gt;Now, let&amp;#8217;s see an mxml component and how does the helper fits, but first let&amp;#8217;s see a view helper which inherits from the BaseViewHelper class.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='kd'&gt;package&lt;/span&gt; &lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;kensodev&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;views&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;helpers&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
	&lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;kensodev&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;core&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;BaseViewHelper&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
	&lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;kensodev&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;views&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;MyViewComponent&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;class&lt;/span&gt; &lt;span class='nx'&gt;MyViewComponentHelper&lt;/span&gt; &lt;span class='kd'&gt;extends&lt;/span&gt; &lt;span class='nx'&gt;BaseViewHelper&lt;/span&gt;
	&lt;span class='p'&gt;{&lt;/span&gt;
		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;MyViewComponentHelper&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='kd'&gt;super&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='kd'&gt;get&lt;/span&gt; &lt;span class='nx'&gt;myView&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;MyViewComponent&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;return&lt;/span&gt; &lt;span class='nx'&gt;MyViewComponent&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;this&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;view&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;override&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;init&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='c1'&gt;//TODO Auto-generated method stub&lt;/span&gt;
			&lt;span class='kd'&gt;super&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;init&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;myButton_clickHandler&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;event&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;MouseEvent&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='c1'&gt;// TODO Auto-generated method stub&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;
	&lt;span class='p'&gt;}&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This is a helper file for the MyViewComponent. Now, here&amp;#8217;s the source code for implementing the helper inside each View component&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;?&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt; &lt;span class='nx'&gt;version&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mf'&gt;1.0&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;encoding&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;utf&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;8&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;?&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Canvas&lt;/span&gt; &lt;span class='nx'&gt;xmlns&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;http&lt;/span&gt;&lt;span class='o'&gt;://&lt;/span&gt;&lt;span class='nx'&gt;www&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;adobe&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='sr'&gt;/2006/m&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		   &lt;span class='nx'&gt;width&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;400&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		   &lt;span class='nx'&gt;height&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;300&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		   &lt;span class='nx'&gt;creationComplete&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;helper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;init&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		   &lt;span class='nx'&gt;xmlns&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;helper&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;kensodev&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;views&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;helpers&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='o'&gt;*&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
		&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;!&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;CDATA&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;

		&lt;span class='p'&gt;]]&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
	&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;helper&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;MyViewComponentHelper&lt;/span&gt; &lt;span class='nx'&gt;view&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;&lt;span class='k'&gt;this&lt;/span&gt;&lt;span class='p'&gt;}&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;helper&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Button&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;myButton&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;click&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;helper&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;myButton_clickHandler&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;event&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Canvas&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, the file is very clean, it has only data relevant to understand the structure of the component (which is all you need in mxml), all of the logic files &amp;#8220;seats&amp;#8221; behind the scenes.&lt;/p&gt;

&lt;p&gt;There is a naming conventions for views and view helpers its view_name view_nameHelper This way, when you navigate your way through the code, you can always see what you are looking for with ease like so: &lt;p style='text-align: center;'&gt;&lt;a href='http://www.flickr.com/photos/51960246@N07/4907684584/' title='Screen shot 2010-08-19 at 5.36.53 PM by KensoDev, on Flickr'&gt;&lt;img alt='Screen shot 2010-08-19 at 5.36.53 PM' class='aligncenter' height='399' src='http://farm5.static.flickr.com/4137/4907684584_169980e5f0.jpg' width='500' /&gt;&lt;/a&gt;&lt;/p&gt; I hope you take inspiration with this way, I assure you I did, it&amp;#8217;s a very useful way to manage large projects with many views and view helpers.&lt;/p&gt;

&lt;p&gt;The source code of the example project is on &lt;a href='http://github.com/KensoDev/view-helper-example' target='_blank'&gt;git&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;update:&lt;/p&gt;

&lt;p&gt;After a discussion with &lt;a href='http://www.twitter.com/douglasknudsen'&gt;@douglasknudsen&lt;/a&gt; I want to make things clear, this is not the ViewHelper implementation of cairngorm Mvc framework, it&amp;#8217;s something you should (or can) write on your own just to make things organized and clean.&lt;/p&gt;

&lt;p&gt;I am using it regardless to the MVC framework I am using which is RobotLegs B.T.W&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Find truncated string (paths) in SQL server</title>
    
      <link href="http://kensodevkensodev.com/2010/08/19/find-truncated-string-paths-in-sql-server"/>
    
    <id>http://kensodevkensodev.com/2010/08/19/find-truncated-string-paths-in-sql-server</id>
    <updated>2010-08-19T10:24:22+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I recently encountered a strange bug on a database of a client, which I designed. The &amp;#8220;bug&amp;#8221; was that the paths he entered into the database got truncated, because it was too long of a string. I made the field length at 250 chars and he needed more.&lt;/p&gt;

&lt;p&gt;The problem was he already submitted quite some data into the database and could not remember where the paths were extra long. So, I needed to find it for him so he could re-submit those.&lt;/p&gt;

&lt;p&gt;I scratched my head for a couple of minutes on how can I find those truncated strings, it could be quite difficult, because it&amp;#8217;s a path to an MP3 file, I found a way to do it with a simple T-SQL script.&lt;/p&gt;

&lt;p&gt;What I did was to simply find all of the song-paths that did not have an &amp;#8220;.mp3&amp;#8221; at the end.&lt;/p&gt;

&lt;p&gt;This is the script:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;sql&lt;/span&gt; SELECT layerID, layerName, mp3FileUrl FROM appLayers WHERE ( mp3FileUrl NOT LIKE &amp;#8216;%.mp3&amp;#8217; ) &lt;span&gt;/sql&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;An example result /Maximum_Basof_Nipol/Od_Paam/Acc Gtr Chorus St 2.m&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Edit the hosts file on the mac</title>
    
      <link href="http://kensodevkensodev.com/2010/08/18/edit-the-hosts-file-on-the-mac"/>
    
    <id>http://kensodevkensodev.com/2010/08/18/edit-the-hosts-file-on-the-mac</id>
    <updated>2010-08-18T10:00:36+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Sometimes, you may need to edit the hosts file on the mac.&lt;/p&gt;

&lt;p&gt;The hosts file is a file that controls the routing to websites, both localhost and other websites. For example, I can say that whenever I enter http://www.kensodev.com in the browser, the address is then traced back to 127.0.0.1 instead of going to the DNS server and lookup the address there.&lt;/p&gt;

&lt;p&gt;This is a very efficient way to do testing to websites, so you don&amp;#8217;t have to use localhost or everything. For example, I always use a local prefix to a website to identify it&amp;#8217;s on my machine. http://local.kensodev.com will be the local version of this website and so on and so forth.&lt;/p&gt;

&lt;p&gt;There are many cases where you might want to edit the hosts file. In mac it&amp;#8217;s not that intuitive to find it like in windows so here&amp;#8217;s a quick tip (I am using textmate bug you can use whatever you want).&lt;/p&gt;

&lt;p&gt;To edit the file simply enter this command into the terminal:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;sudo mate /private/etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;You will then be prompted to enter a password and after you edit the file and press save, you will have to enter the password again.&lt;/p&gt;

&lt;p&gt;This is it, that is how you edit the hosts file on the mac.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Link bag 15 August 2010</title>
    
      <link href="http://kensodevkensodev.com/2010/08/15/link-bag-15-august-2010"/>
    
    <id>http://kensodevkensodev.com/2010/08/15/link-bag-15-august-2010</id>
    <updated>2010-08-15T17:48:06+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;After declaring the opening of the category - &lt;a href='http://www.kensodev.com/category/link-bag/' title='Link Bag'&gt;Link Bag&lt;/a&gt;, the first post is fresh and hot out of the oven. &lt;h2&gt;CSS&lt;/h2&gt; &lt;a href='http://css-tricks.com/css-sprites-workflow/' target='_blank'&gt;CSS sprites workflow&lt;/a&gt; - Chris Coyier posted a very useful tip about the workflow of creating a website when you plan to use sprite css, he suggests a two-step process. &lt;h2&gt;Freelancing&lt;/h2&gt; &lt;a href='http://freelanceswitch.com/inspiration/are-you-giving-back-to-your-community/' target='_blank'&gt;Are You Giving Back to Your Community?&lt;/a&gt; - FreelanceSwitch with another great post. I actually posted on a very similar subject here &amp;#8221;&lt;a href='http://www.kensodev.com/2010/08/03/should-all-developers-be-members-of-the-virtual-community/'&gt;should all developer be (active) members in the virtual community&lt;/a&gt;.&amp;#8221;&lt;/p&gt;
&lt;a href='http://freelanceswitch.com/inspiration/freelance-success/' target='_blank'&gt;The real secret to freelance success&lt;/a&gt;&lt;a href='http://sixrevisions.com/productivity/9-productivity-techniques-for-freelancers/' target='_blank'&gt;9 productivity techniques for freelancers&lt;/a&gt;&lt;h2&gt;Ruby on rails&lt;/h2&gt;&lt;a href='http://mongomatic.com/'&gt;Mongomatic&lt;/a&gt;
&lt;p&gt;That&amp;#8217;s it (short) for the first link bag, another one is coming in about a week, be sure to keep yourself up to date though the RSS feed (link on the right).&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Declaring a new category &quot;link bag&quot;</title>
    
      <link href="http://kensodevkensodev.com/2010/08/15/declaring-a-new-category-link-bag"/>
    
    <id>http://kensodevkensodev.com/2010/08/15/declaring-a-new-category-link-bag</id>
    <updated>2010-08-15T17:31:15+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Well, I have decided. After a while of reading very interesting blogs and stumbling upon quite a few useful links for fellow developers, I decided to put together a new category in the blog.&lt;/p&gt;

&lt;p&gt;The category will be called &amp;#8221;&lt;a href='http://www.kensodev.com/category/link-bag/' title='Link Bag'&gt;link bag&lt;/a&gt;&amp;#8221; and I will post new things to it on a weekly basis hopefully.&lt;/p&gt;

&lt;p&gt;The links will vary from technology links to freelancing tips, everything that is an interest to me and hopefully for the readers of this blog as well.&lt;/p&gt;

&lt;p&gt;You can keep yourself up to date though the &lt;a href='http://feeds.feedburner.com/KensoDev-en'&gt;RSS Feed&lt;/a&gt; or come back later this week.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Should all developers be (active) members of the virtual community?</title>
    
      <link href="http://kensodevkensodev.com/2010/08/03/should-all-developers-be-members-of-the-virtual-community"/>
    
    <id>http://kensodevkensodev.com/2010/08/03/should-all-developers-be-members-of-the-virtual-community</id>
    <updated>2010-08-03T18:12:25+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Usually when I blog, I make comments, raise decisions, write code or something like that, it&amp;#8217;s never a question. This post, above anything else is a question and a try to spark a debate from my fellow developers and software craftsman out there.&lt;/p&gt;

&lt;p&gt;Earlier this week I started working on a very interesting project for an international company creating test suites for devices and applications. The suite is cross platform and can run on any machine both windows and Linux and test any device, from mobile phones to DVD&amp;#8217;s to diving sensors.&lt;/p&gt;

&lt;p&gt;The client side is written in &lt;a href='http://www.kensodev.com/category/flex/' title='flex'&gt;flex&lt;/a&gt; and pure &lt;a href='http://www.kensodev.com/tag/as3/' title='As3'&gt;AS3&lt;/a&gt;, the server and services are written in &lt;a href='http://www.kensodev.com/category/java/' title='Java'&gt;Java&lt;/a&gt; and Perl scripts. &lt;h2&gt;What is my point?&lt;/h2&gt; My point is that this company has some pretty strong developers, all know a thing or 2 on software developement, both in Java and Flex.&lt;/p&gt;

&lt;p&gt;Another thing, usually when I get invited to consult and develop for a company saying &amp;#8220;we have a flex application&amp;#8221; I do see an application but it&amp;#8217;s horrible, un-scalable, mxml+code in the same file, services calls in mxml and more.&lt;/p&gt;

&lt;p&gt;In this company, that wasn&amp;#8217;t the case. The application is actually pretty solid, stable and gone over more then a couple of QA steps inside the company and clients. You can imagine that the developers over there can contribute a thing or two to the community. &lt;h2&gt;OK, so far so good, what am I saying here?&lt;/h2&gt; From conversations I had with the developers I found out something amazing, none of them has a twitter account, none of them has a blog and none, absolutely none contributed to an open source project, not even a line of code, not even opened a case in the WIKI.&lt;/p&gt;

&lt;p&gt;so, what do you think? Should all developers be active members of the community? Should every developer have a profile and answer questions on the amazing &lt;a href='http://www.stackoverflow.com'&gt;StackOverflow&lt;/a&gt;&lt;a href='http://www.stackoverflow.com'&gt;.com&lt;/a&gt;? Should every developer write a blog?&lt;/p&gt;

&lt;p&gt;Love to hear your thoughts on this&amp;#8230;&lt;/p&gt;

&lt;p&gt;Another thing, when you interview programmers, do you care about these issues?&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">java.io.UnsupportedEncodingException problem &amp; solution</title>
    
      <link href="http://kensodevkensodev.com/2010/08/02/java-io-unsupportedencodingexception-problem-solution"/>
    
    <id>http://kensodevkensodev.com/2010/08/02/java-io-unsupportedencodingexception-problem-solution</id>
    <updated>2010-08-02T16:02:57+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;As a &lt;a href='http://www.kensodev.com/2011/09/17/kill-all-resque-workers-with-a-single-command/' target='_blank' title='web developer'&gt;web developer&lt;/a&gt;, I&amp;#8217;m working on lots of things. Today, while working on a windows machine and trying to run an ANT task and then run JBoss to test my build, I encountered this error:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;java.io.UnsupportedEncodingException: cp1255
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;After quite some time of Googling and finding nothing, I remembered I changed my regional settings on the machine to use Hebrew as the locale. This appeared to be a mistake. Once I changed the locale back to English (USA) everything got back to normal and worked absolutely fine (as always).&lt;/p&gt;

&lt;p&gt;So, the conclusion is: When you get this error, verify that the machine you are using is set to English Locale and not other locales.&lt;/p&gt;

&lt;p&gt;Hope this saves you some time, I know I pulled more then a couple of hairs to find out what is causing this issue.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">RobotLegs makes me smile every time</title>
    
      <link href="http://kensodevkensodev.com/2010/07/31/robotlegs-makes-me-smile-every-time"/>
    
    <id>http://kensodevkensodev.com/2010/07/31/robotlegs-makes-me-smile-every-time</id>
    <updated>2010-07-31T12:58:49+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi All,&lt;/p&gt;

&lt;p&gt;I have been using the &lt;a href='http://www.robotlegs.org/' target='_blank'&gt;RobotLegs&lt;/a&gt; MVC framework for &lt;a href='http://www.kensodev.com/category/flex/' target='_blank' title='Flex'&gt;flex&lt;/a&gt; for about a month and a half now, I have been using &lt;a href='http://mate.asfusion.com/' target='_blank'&gt;MATE&lt;/a&gt; before that and &lt;a href='http://puremvc.org/' target='_blank'&gt;PureMVC&lt;/a&gt; before that, I have never got so much out of an MVC framework, it is so flexible, so customizable (&lt;a href='http://github.com/KensoDev/robotlegs-framework' target='_blank'&gt;the code is on git&lt;/a&gt;) and helps me with my tasks all of the time.&lt;/p&gt;

&lt;p&gt;So, why have I posted it on the blog and not just tweeted about it? Well, I have tweeted about it for quite a bit, but the real reason for posting it on the blog is that I have made a new category on the blog called &lt;a href='http://www.kensodev.com/category/robotlegs/'&gt;RobotLegs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I plan on posting some example code for it and being involved in the community.&lt;/p&gt;

&lt;p&gt;You can keep yourself updated through my &lt;a href='http://feeds.feedburner.com/KensoDev-en' target='_blank'&gt;RSS FEED&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">gitignore template for flex projects</title>
    
      <link href="http://kensodevkensodev.com/2010/07/28/gitignore-template-for-flex-projects"/>
    
    <id>http://kensodevkensodev.com/2010/07/28/gitignore-template-for-flex-projects</id>
    <updated>2010-07-28T22:03:38+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi All,&lt;/p&gt;

&lt;p&gt;Well, me being an enthusiastic &lt;a href='http://www.kensodev.com/about-avi-tzurel/' target='_blank' title='Flex developer'&gt;flex developer&lt;/a&gt; is no secret, nor me being a GIT fan-boy.&lt;/p&gt;

&lt;p&gt;I thought it will be helpful to post my template for the gitignore files in all repositories containing flex projects.&lt;/p&gt;

&lt;p&gt;This is how it looks like:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;.DS_Store
.actionScriptProperties
.flexProperties
.project
.settings/*
bin-debug/*
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span&gt;/shell&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The reason I&amp;#8217;m ignoring all the settings files and the properties files is because all of these are environment specific, often not all developers on the team use the same settings and properties and that can break the entire working process.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">jQuery colorbox plugin no opacity (overlay) - IE7</title>
    
      <link href="http://kensodevkensodev.com/2010/07/26/jquery-colorbox-plugin-no-opacity-overlay-ie7"/>
    
    <id>http://kensodevkensodev.com/2010/07/26/jquery-colorbox-plugin-no-opacity-overlay-ie7</id>
    <updated>2010-07-26T23:59:58+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Today, while checking a website I did heavy client side work - converting PSD&amp;#8217;s to html, CSS and &lt;a href='http://www.kensodev.com/tag/javascript/' title='JavaScript'&gt;JavaScript&lt;/a&gt;, I checked everything on IE7. One of the most annoying things I encountered was that the colorbox overlay color was pitch black.&lt;/p&gt;

&lt;p&gt;On other browsers, such as Firefox or Chrome everything seemed fine and the overlay was in the correct opacity. However, I like fixing everything and found a very easy way to do so.&lt;/p&gt;

&lt;p&gt;This was my code before:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;js&lt;/span&gt; $(&amp;#8216;.guestboox_more&amp;#8217;).colorbox({ inline:true, href:&amp;#8217;.guestbook_more_details&amp;#8217;, innerWidth:&amp;#8217;610px&amp;#8217;, opacity: &amp;#8216;.2&amp;#8217;, transition: &amp;#8216;elastic&amp;#8217; }); &lt;span&gt;/js&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;And this is the code after (this fixed the problem):&lt;/p&gt;

&lt;p&gt;&lt;span&gt;js&lt;/span&gt; $(&amp;#8216;.guestboox_more&amp;#8217;).colorbox({ inline:true, href:&amp;#8217;.guestbook_more_details&amp;#8217;, innerWidth:&amp;#8217;610px&amp;#8217;, opacity: &amp;#8216;0.2&amp;#8217;, transition: &amp;#8216;elastic&amp;#8217; }); &lt;span&gt;/js&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The problem was only that IE7 didn&amp;#8217;t recognizance .2 as 0.2 and needed to be more specific (as often IE needs). I hope this will save you some time.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Flash media server security hardening</title>
    
      <link href="http://kensodevkensodev.com/2010/07/25/flash-media-server-security-hardening"/>
    
    <id>http://kensodevkensodev.com/2010/07/25/flash-media-server-security-hardening</id>
    <updated>2010-07-25T14:51:43+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Today, while browsing my feed in google reader, I found something very interesting. This &lt;a href='http://www.adobe.com/devnet/flashmediaserver/articles/hardening_guide.html'&gt;link&lt;/a&gt; is a hardening guide for &lt;a href='http://www.kensodev.com/tag/flash-media-server/' title='Flash media server'&gt;flash media server&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For quite some time now I have been developing and consulting on flash media server advanced topics. I have been teaching students and consulting companies on issues regarding this great peace of software.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/tag/adobe/' title='Adobe'&gt;Adobe&lt;/a&gt;
&lt;p&gt;I highly recommend you to open the link and read it.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Set button width to text width in flex</title>
    
      <link href="http://kensodevkensodev.com/2010/07/14/set-button-width-to-text-width-in-flex"/>
    
    <id>http://kensodevkensodev.com/2010/07/14/set-button-width-to-text-width-in-flex</id>
    <updated>2010-07-14T10:07:18+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Well, I have been working on a very interesting project recently, really stretching &lt;a href='http://www.kensodev.com/tag/flex/' title='Flex'&gt;flex&lt;/a&gt; to the limits :-) I needed to set buttons, linkButtons, Labels and more components width to the width of the text inside them. Usually, &lt;a href='http://www.kensodev.com/category/flex/' title='Flex'&gt;flex&lt;/a&gt; does it for you, but the width was hardcoded in compile time and I needed to change the text and the width in runtime and resize the component according to that.&lt;/p&gt;

&lt;p&gt;I have written a nifty helper function for that.&lt;/p&gt;

&lt;p&gt;Here it is:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='cm'&gt;/**&lt;/span&gt;
&lt;span class='cm'&gt;* This function will accept the text and the UI component and set the width to the width of the text&lt;/span&gt;
&lt;span class='cm'&gt;* @param text the text or label of the component&lt;/span&gt;
&lt;span class='cm'&gt;* @param container the container casted to a UIComponent&lt;/span&gt;
&lt;span class='cm'&gt;*&lt;/span&gt;
&lt;span class='cm'&gt;*/&lt;/span&gt;
&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;measureTextWidthAndResizeComponent&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;container&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;UIComponent&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
&lt;span class='p'&gt;{&lt;/span&gt;
	&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;_measuredWidth&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Number&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
	&lt;span class='k'&gt;var&lt;/span&gt;  &lt;span class='nx'&gt;_paddingLeft&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;uint&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
	&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;_paddingRight&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;uint&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
	&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;_horizontalGap&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;uint&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
	&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;_addedToWidth&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;int&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='kc'&gt;null&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
		&lt;span class='k'&gt;return&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;length&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;=&lt;/span&gt; &lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
		&lt;span class='k'&gt;return&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

	&lt;span class='nx'&gt;_paddingLeft&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;container&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;getStyle&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;paddingLeft&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
	&lt;span class='nx'&gt;_paddingRight&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;container&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;getStyle&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;paddingRight&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
	&lt;span class='nx'&gt;_horizontalGap&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;container&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;getStyle&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;horizontalGap&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;

	&lt;span class='nx'&gt;_addedToWidth&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nb'&gt;int&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;_horizontalGap&lt;/span&gt; &lt;span class='o'&gt;+&lt;/span&gt; &lt;span class='nx'&gt;_paddingLeft&lt;/span&gt; &lt;span class='o'&gt;+&lt;/span&gt; &lt;span class='nx'&gt;_paddingRight&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;

	&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;lineMetrics&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;TextLineMetrics&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;container&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;measureText&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;

	&lt;span class='nx'&gt;_measuredWidth&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;lineMetrics&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;width&lt;/span&gt; &lt;span class='o'&gt;+&lt;/span&gt; &lt;span class='nx'&gt;_addedToWidth&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
	&lt;span class='nx'&gt;container&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;width&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;_measuredWidth&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;That&amp;#8217;s it, enjoy!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">jQuery - wait for animation to end then do something</title>
    
      <link href="http://kensodevkensodev.com/2010/07/12/jquery-wait-for-animation-to-end-then-do-something"/>
    
    <id>http://kensodevkensodev.com/2010/07/12/jquery-wait-for-animation-to-end-then-do-something</id>
    <updated>2010-07-12T19:09:51+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I have been using &lt;a href='http://www.kensodev.com/category/jquery/' title='jQuery'&gt;jQuery&lt;/a&gt; for quite some time now. Following a question on one of the many forums and discussions group I visit daily, I found that not many know that &lt;a href='http://www.kensodev.com/tag/jquery/' title='jQuery'&gt;jQuery&lt;/a&gt; has a built in way to &amp;#8220;listen&amp;#8221; for an animation to end and then continue work. For instance, if I am using the slideDown effect, I can create a function that will only execute when the slide is finished.&lt;/p&gt;

&lt;p&gt;Wish to know how?&lt;/p&gt;

&lt;p&gt;Just like that&amp;#8230;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;js&lt;/span&gt; $(&amp;#8216;div.menuOurHotel&amp;#8217;).slideDown(&amp;#34;slow&amp;#34;, function() { $(&amp;#34;div.order_form&amp;#34;).hide(); }); &lt;span&gt;/js&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This is a very useful way to create a responsive intuitive user interface.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Copy object properties to another object - Flex</title>
    
      <link href="http://kensodevkensodev.com/2010/06/22/copy-object-properties-to-another-object-flex"/>
    
    <id>http://kensodevkensodev.com/2010/06/22/copy-object-properties-to-another-object-flex</id>
    <updated>2010-06-22T11:23:42+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;In a project I am working on with &lt;a href='http://www.kensodev.com/tag/flex/' title='Flex'&gt;Flex&lt;/a&gt; and &lt;a href='http://www.kensodev.com/tag/as3/' title='AS3'&gt;AS3&lt;/a&gt; I needed to copy all of the object&amp;#8217;s properties and accessors to another object. Because I didn&amp;#8217;t want to hard code the properties for various reasons, I needed to write a function that will &amp;#8220;crawl&amp;#8221; the object properties and accessors and copy then to the new object.&lt;/p&gt;

&lt;p&gt;I created a static function that does exactly that:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;		&lt;span class='cm'&gt;/**&lt;/span&gt;
&lt;span class='cm'&gt;		 * copies a source object to a destination object&lt;/span&gt;
&lt;span class='cm'&gt;		 * @param sourceObject the source object&lt;/span&gt;
&lt;span class='cm'&gt;		 * @param destinationObject the destination object&lt;/span&gt;
&lt;span class='cm'&gt;		 *&lt;/span&gt;
&lt;span class='cm'&gt;		 */&lt;/span&gt;
		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;copyObject&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Object&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Object&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='c1'&gt;// check if the objects are not null&lt;/span&gt;
			&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;((&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;amp&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;amp&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
				&lt;span class='k'&gt;try&lt;/span&gt;
				&lt;span class='p'&gt;{&lt;/span&gt;
					&lt;span class='c1'&gt;//retrive information about the source object via XML&lt;/span&gt;
					&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;sourceInfo&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;XML&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;describeType&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
					&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;XML&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;propertyName&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

					&lt;span class='c1'&gt;// loop through the properties&lt;/span&gt;
					&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;sourceInfo&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;variable&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
					&lt;span class='p'&gt;{&lt;/span&gt;
						&lt;span class='nx'&gt;propertyName&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
						&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='kc'&gt;null&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
						&lt;span class='p'&gt;{&lt;/span&gt;
							&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;hasOwnProperty&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
								&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;];&lt;/span&gt;
							&lt;span class='p'&gt;}&lt;/span&gt;
						&lt;span class='p'&gt;}&lt;/span&gt;
					&lt;span class='p'&gt;}&lt;/span&gt;
					&lt;span class='c1'&gt;//loop through the accessors&lt;/span&gt;
					&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;sourceInfo&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;accessor&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
						&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;access&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;readwrite&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
							&lt;span class='nx'&gt;propertyName&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='kc'&gt;null&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
							&lt;span class='p'&gt;{&lt;/span&gt;
								&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;hasOwnProperty&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
									&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;];&lt;/span&gt;
								&lt;span class='p'&gt;}&lt;/span&gt;
							&lt;span class='p'&gt;}&lt;/span&gt;
						&lt;span class='p'&gt;}&lt;/span&gt;
					&lt;span class='p'&gt;}&lt;/span&gt;
				&lt;span class='p'&gt;}&lt;/span&gt;
				&lt;span class='k'&gt;catch&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;err&lt;/span&gt;&lt;span class='o'&gt;:*&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
					&lt;span class='o'&gt;;&lt;/span&gt;
				&lt;span class='p'&gt;}&lt;/span&gt;
			&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This function will copy everything. You can simply add an &amp;#8220;allowedProperties&amp;#8221; definition and make the function only copy definitions and properites which exist in your allowed definition.&lt;/p&gt;

&lt;p&gt;Like so:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;allowedProperties&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;height&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;width&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;visible&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;styleName&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;x&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;y&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;alpha&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;visible&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;source&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;dataProvider&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;styleDecleration&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;label&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;horizontalScrollPolicy&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt;&lt;span class='nx'&gt;labelField&lt;/span&gt;&lt;span class='o'&gt;,&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;;&lt;/span&gt;

		&lt;span class='kd'&gt;public&lt;/span&gt; &lt;span class='kd'&gt;static&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;copyDisplayObjectData&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Object&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Object&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
		&lt;span class='p'&gt;{&lt;/span&gt;
			&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;((&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;amp&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;amp&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
				&lt;span class='k'&gt;try&lt;/span&gt;
				&lt;span class='p'&gt;{&lt;/span&gt;
					&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;sourceInfo&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;XML&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;describeType&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
					&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;XML&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;propertyName&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
					&lt;span class='err'&gt;�&lt;/span&gt;
					&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;sourceInfo&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;variable&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
					&lt;span class='p'&gt;{&lt;/span&gt;
						&lt;span class='nx'&gt;propertyName&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
						&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;allowedProperties&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;indexOf&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;propertyName&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
						&lt;span class='p'&gt;{&lt;/span&gt;
							&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='kc'&gt;null&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
							&lt;span class='p'&gt;{&lt;/span&gt;
								&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;hasOwnProperty&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
									&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;];&lt;/span&gt;
								&lt;span class='p'&gt;}&lt;/span&gt;
							&lt;span class='p'&gt;}&lt;/span&gt;

						&lt;span class='p'&gt;}&lt;/span&gt;
					&lt;span class='p'&gt;}&lt;/span&gt;
					&lt;span class='err'&gt;�&lt;/span&gt;
					&lt;span class='k'&gt;for&lt;/span&gt; &lt;span class='k'&gt;each&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='nx'&gt;sourceInfo&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;accessor&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
						&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;access&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;readwrite&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
							&lt;span class='nx'&gt;propertyName&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
							&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;allowedProperties&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;indexOf&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;propertyName&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;1&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
							&lt;span class='p'&gt;{&lt;/span&gt;
								&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;!=&lt;/span&gt; &lt;span class='kc'&gt;null&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
								&lt;span class='p'&gt;{&lt;/span&gt;
									&lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;hasOwnProperty&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
										&lt;span class='nx'&gt;destinationObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;]&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;sourceObject&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;objectProperty&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='err'&gt;@&lt;/span&gt;&lt;span class='nx'&gt;name&lt;/span&gt;&lt;span class='p'&gt;];&lt;/span&gt;
									&lt;span class='p'&gt;}&lt;/span&gt;
								&lt;span class='p'&gt;}&lt;/span&gt;
							&lt;span class='p'&gt;}&lt;/span&gt;
						&lt;span class='p'&gt;}&lt;/span&gt;
					&lt;span class='p'&gt;}&lt;/span&gt;
				&lt;span class='p'&gt;}&lt;/span&gt;
				&lt;span class='k'&gt;catch&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;err&lt;/span&gt;&lt;span class='o'&gt;:*&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt;
					&lt;span class='o'&gt;;&lt;/span&gt;
				&lt;span class='p'&gt;}&lt;/span&gt;
			&lt;span class='p'&gt;}&lt;/span&gt;
		&lt;span class='p'&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;That&amp;#8217;s it, tricky but absolutely can be done :-)&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">YUI Calendar page to the selected date (multi calendar)</title>
    
      <link href="http://kensodevkensodev.com/2010/06/22/yui-calendar-page-to-the-selected-date-multi-calendar"/>
    
    <id>http://kensodevkensodev.com/2010/06/22/yui-calendar-page-to-the-selected-date-multi-calendar</id>
    <updated>2010-06-22T10:54:01+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I have been working with YUI calendar for a couple of weeks now on a project. I found that it is highly customizable although the documentation are not always clear and you have to dig around the internet to find your answers.&lt;/p&gt;

&lt;p&gt;So, I am here to help.&lt;/p&gt;

&lt;p&gt;In this new website I have a multi-calendar where you can page forwards and backwards through the dates. The calendar is also showing and hiding according to a user click (see photo).&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/06/22/yui-calendar-page-to-the-selected-date-multi-calendar/yui_calenda_popup/' rel='attachment wp-att-497'&gt;&lt;img alt='' class='aligncenter size-full wp-image-497' height='204' src='http://www.kensodev.com/wp-content/uploads/2010/06/yui_calenda_popup.png' title='YUI Calendar popup' width='330' /&gt;&lt;/a&gt;
&lt;p&gt;The problem was (for me anyway) that when the user clicked the calendar&amp;#8217;s button and the calendar showed the last paging position.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s say I selected a date, or even better a date interval (from Feb 2nd to Feb 10th) and then paged to see other months available dates, closed the calendar and re-opened it, it seemed as if the selection cleared and the paging position kept.&lt;/p&gt;

&lt;p&gt;My client&amp;#8217;s request was &amp;#8220;if the client selected a date and paged, always take him back to his selection when the calendar is shown&amp;#8221;&lt;/p&gt;

&lt;p&gt;Well, this is the way to do it.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;js&lt;/span&gt; var dates = cal1.getSelectedDates();&lt;/p&gt;

&lt;p&gt;if(dates.length &amp;#62; 0) { var l = dates&lt;span&gt;0&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;cal1.cfg.setProperty(&amp;#34;pagedate&amp;#34;, l); cal1.render(); } &lt;span&gt;/js&lt;/span&gt;&lt;/p&gt;
&lt;strong&gt;What did we do here?&lt;/strong&gt;
&lt;p&gt;First, we checked if there are selected dates in the calendar. If there were, we got the lowest date (the first date of the interval). Then we set a property on the calendar called &amp;#8220;pagedate&amp;#8221; with this lowest date and WHALLLA, it works! Now, every time you open the calendar it pages to the selected dates section, no matter if you paged forward before hiding the calendar.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Empty dialogs in flex builder 3 + Flash builder 4</title>
    
      <link href="http://kensodevkensodev.com/2010/06/10/empty-dialogs-in-flex-builder-3-flash-builder-4"/>
    
    <id>http://kensodevkensodev.com/2010/06/10/empty-dialogs-in-flex-builder-3-flash-builder-4</id>
    <updated>2010-06-10T15:58:17+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;This week I needed to work with My PC on a&lt;a href='http://www.kensodev.com/tag/flex/' title='Flex'&gt; flex&lt;/a&gt; project. I usually stay away of the PC with flex projects, I&amp;#8217;m used to working on the mac with these project, but I needed to work on the PC.&lt;/p&gt;

&lt;p&gt;While trying to configure the project in flex builder 3 (and with 4 as well), I stumbled upon a weird bug that made me scratch my head for a while.  The bug was that all of the dialogs appeared empty, no configuration, almost no buttons.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s a screenshot of the problem: &lt;p style='text-align: center;'&gt;&lt;a href='http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-14.png' rel='facebox'&gt;&lt;img alt='' class='size-medium wp-image-473 aligncenter' height='249' src='http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-14-300x249.png' title='Flex empty dialog' width='300' /&gt;&lt;/a&gt;&lt;/p&gt; Now, I remembered a teammate I had a while back that had the same problem and it appeared to be a WACOM with a windows 7 driver that caused the problem, so I started disabling devices one after the other.&lt;/p&gt;

&lt;p&gt;The problem was a logitech mouse software I have installed on the pc. Once I quited this application everything went back to normal.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the icon on the taskbar (not hard to trace).&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-43.png' rel='attachment wp-att-474 facebox'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-474' height='26' src='http://www.kensodev.com/wp-content/uploads/2010/06/10-06-2010-11-06-43-300x26.png' title='Logitech Mouse Icon in taskbar' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Hope this post helps you and you won&amp;#8217;t scratch your had for hours like I did.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Git export (like SVN export)</title>
    
      <link href="http://kensodevkensodev.com/2010/06/09/git-export-like-svn-export"/>
    
    <id>http://kensodevkensodev.com/2010/06/09/git-export-like-svn-export</id>
    <updated>2010-06-09T18:16:15+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;I have been working with git for a while now on my &lt;a href='http://www.kensodev.com/2011/09/16/kill-all-resque-workers-with-a-single-command/' title='Ruby on Rails'&gt;Ruby on Rails&lt;/a&gt; projects and client side (css, Html and &lt;a href='http://www.kensodev.com/tag/javascript/' title='JavaScript'&gt;JavaScript&lt;/a&gt;) projects. I haven&amp;#8217;t moved completely in &lt;a href='http://www.kensodev.com/category/flex/' title='Flex'&gt;flex&lt;/a&gt; projects and other projects, but I do plan to in the near future, mainly because of the reason that you can integrate &lt;a href='http://www.kensodev.com/tag/git/' title='GIT'&gt;GIT&lt;/a&gt; into flash builder 4. But, that is not the point.&lt;/p&gt;

&lt;p&gt;This week I was working with a company on a client side project. I had to email them the files every time and the .git folders inside the project were heavy and unnecessary.&lt;/p&gt;

&lt;p&gt;If you worked with SVN, you probably know the export command, after searching for a bit in git help I found how you can do it in git with ease.&lt;/p&gt;
&lt;strong&gt;How to do?&lt;/strong&gt;
&lt;p&gt;This is the command you should use:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;git checkout-index -a -f --prefix&lt;span class='o'&gt;=&lt;/span&gt;/path/to/your/folder/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The ending forward slash is very important! Do not forget to use it please.&lt;/p&gt;

&lt;p&gt;A screenshot of my shell:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/06/09/git-export-like-svn-export/screen-shot-2010-06-09-at-7-13-54-pm/' rel='attachment wp-att-468'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-468' height='182' src='http://www.kensodev.com/wp-content/uploads/2010/06/Screen-shot-2010-06-09-at-7.13.54-PM-300x182.png' title='Git export to folder (shell)' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Access flex application through the SWFLoader component</title>
    
      <link href="http://kensodevkensodev.com/2010/05/30/access-flex-application-through-the-swfloader-component"/>
    
    <id>http://kensodevkensodev.com/2010/05/30/access-flex-application-through-the-swfloader-component</id>
    <updated>2010-05-30T18:18:32+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;As you know, I&amp;#8217;m a &lt;a href='http://www.kensodev.com/about-avi-tzurel/' target='_blank'&gt;web developer&lt;/a&gt; and I love learning new stuff and blogging about it here. My blog post for today is about access flex application through the SWFLoader component.&lt;/p&gt;

&lt;p&gt;Often you load flex applications through another flex application using the SWFLoader component. It&amp;#8217;s not that common knowledge that you can actually access all of that application exactly the same way you are accessing your own application. &lt;h3&gt;What does that mean?&lt;/h3&gt; It means you can access that application components, get the children and get a good knowledge on how this application is build. You can also access it&amp;#8217;s component and dispatch events. &lt;h3&gt;OK, how?&lt;/h3&gt; Let&amp;#8217;s start doing it. We will create a simple application, put a SWFLoader on stage and create a listener for the complete event. Lets&amp;#8217;s also add 2 global variables - one for SystemManager, another for IUIComponent (I will explain later).&lt;/p&gt;

&lt;p&gt;This is what the application code should look like:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;actionscript3&lt;/span&gt; &amp;#60;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;utf-8&amp;#34;?&amp;#62; &amp;#60;mx:Application xmlns:mx=&amp;#34;http://www.adobe.com/2006/mxml&amp;#34; layout=&amp;#34;absolute&amp;#34; minWidth=&amp;#34;955&amp;#34; minHeight=&amp;#34;600&amp;#34;&amp;#62; &amp;#60;mx:Script&amp;#62; &amp;#60;&lt;span&gt;CDATA&lt;span&gt;import mx.core.IUIComponent; import mx.managers.SystemManager;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;		private var _systemManager:SystemManager;
		private var _innerApplication:IUIComponent;

		protected function loader_completeHandler(event:Event):void
		{
			_systemManager = SystemManager(loader.content);
		}
	]]&amp;amp;gt;
&amp;amp;lt;/mx:Script&amp;amp;gt;

&amp;amp;lt;mx:SWFLoader id=&amp;amp;quot;loader&amp;amp;quot; source=&amp;amp;quot;VistaRemix.swf&amp;amp;quot; width=&amp;amp;quot;800&amp;amp;quot; height=&amp;amp;quot;600&amp;amp;quot; autoLoad=&amp;amp;quot;true&amp;amp;quot; complete=&amp;amp;quot;loader_completeHandler(event)&amp;amp;quot;/&amp;amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#60;/mx:Application&amp;#62; &lt;span&gt;/actionscript3&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;As you can probably see, we are assigning a value to &lt;em&gt;systemManager when the loader (SWFLoader) finished loading. This enables us to work with that application system Manager and access properties.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Continuing&amp;#8230;&lt;/p&gt;

&lt;p&gt;We will add 2 Event listeners inside that function:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;actionscript3&lt;/span&gt; &lt;em&gt;systemManager.addEventListener(FlexEvent.APPLICATION&lt;/em&gt;COMPLETE, sysManage_ApplicationComplete_Handler); &lt;em&gt;systemManager.addEventListener(FlexEvent.UPDATE&lt;/em&gt;COMPLETE, sysManage_UpdateComplete_Handler); &lt;span&gt;/actionscript3&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Now that we have those in place, let&amp;#8217;s add the closure functions:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;actionscript3&lt;/span&gt; private function sysManage_UpdateComplete_Handler(event:FlexEvent):void { &lt;em&gt;innerApplication =&lt;/em&gt;systemManager.application; }&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;		private function sysManage_ApplicationComplete_Handler(event:FlexEvent):void
		{
			_innerApplication = _systemManager.application;
		}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span&gt;/actionscript3&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Great! Now &lt;em&gt;innerApplication is actually an application. You can get it&amp;#8217;s children, get properties, get components, dispatch events and more.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This comes in very handy when you want control over an application and you don&amp;#8217;t have the source. You can create a clone of that application and create your own GUI for it. It&amp;#8217;s an amazing feature!&lt;/p&gt;

&lt;p&gt;This here is a screenshot of debugging mode. Check out the debugger watch section, these are all methods you can use on that variable, you can of course use much more.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/05/30/access-flex-application-through-the-swfloader-component/screen-shot-2010-05-30-at-7-23-21-pm/' rel='attachment wp-att-464'&gt;&lt;img alt='Debug view of the application in Flash builder 4' class='aligncenter size-medium wp-image-464' height='179' src='http://www.kensodev.com/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-7.23.21-PM-e1275236766248-300x179.png' title='Debug view of the application in Flash builder 4' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Flash builder 4 - sharing a project with your team using SVN Screencast</title>
    
      <link href="http://kensodevkensodev.com/2010/05/24/flash-builder-4-sharing-a-project-with-your-team-using-svn-screencast"/>
    
    <id>http://kensodevkensodev.com/2010/05/24/flash-builder-4-sharing-a-project-with-your-team-using-svn-screencast</id>
    <updated>2010-05-24T06:38:26+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/05/24/flash-builder-4-sharing-a-project-with-your-team-using-svn-screencast/flash-builder-4/' rel='attachment wp-att-450'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-450' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/05/Flash-Builder-4-150x150.png' title='Flash Builder 4' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;But before watching my screencast, I wish to tell you something a bit personal. This is my first screencast in English, after quite a few in my native tongue language. so please excuse me if I stutter or swallow some of my words. I promise to keep getting better with time.&lt;/p&gt;
&lt;!--more--&gt;&lt;object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' height='309' width='550'&gt;&lt;param name='allowfullscreen' value='true' /&gt;&lt;param name='allowscriptaccess' value='always' /&gt;&lt;param name='src' value='http://vimeo.com/moogaloop.swf?clip_id=11974122&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1' /&gt;&lt;embed allowfullscreen='true' allowscriptaccess='always' height='309' src='http://vimeo.com/moogaloop.swf?clip_id=11974122&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1' type='application/x-shockwave-flash' width='550' /&gt;&lt;/object&gt;&lt;a href='http://vimeo.com/11974122'&gt;Flash builder 4 - share project with your team using SVN&lt;/a&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Change WebOrb default port from 2037 to what you want</title>
    
      <link href="http://kensodevkensodev.com/2010/05/09/change-weborb-default-port-from-2037-to-what-you-want"/>
    
    <id>http://kensodevkensodev.com/2010/05/09/change-weborb-default-port-from-2037-to-what-you-want</id>
    <updated>2010-05-09T17:36:06+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/05/09/change-weborb-default-port-from-2037-to-what-you-want/brown_net/' rel='attachment wp-att-434'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-434' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/05/brown_net-150x150.jpg' title='Weborb' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;I have been running production machines for a client. This client request to test the WebOrb service on another port other then 2037 (default). It&amp;#8217;s actually quite simple to create, but not intuitive.&lt;/p&gt;

&lt;p&gt;If you are using WebOrb from the command line, you have a setting called &amp;#8220;port&amp;#8221;. All you have to do is run the command with the port param and everything will work great.&lt;/p&gt;

&lt;p&gt;Like so:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;c:&lt;span class='se'&gt;\i&lt;/span&gt;netpub&lt;span class='se'&gt;\w&lt;/span&gt;wwroot&lt;span class='se'&gt;\w&lt;/span&gt;eborb30&lt;span class='se'&gt;\w&lt;/span&gt;eborbee.exe -port 1935
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Dynamic streaming (Adaptive bitrate) using Flash media Server</title>
    
      <link href="http://kensodevkensodev.com/2010/04/15/dynamic-streamin-adaptive-bitrate-using-flash-media-server"/>
    
    <id>http://kensodevkensodev.com/2010/04/15/dynamic-streamin-adaptive-bitrate-using-flash-media-server</id>
    <updated>2010-04-15T20:56:09+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/04/15/dynamic-streamin-adaptive-bitrate-using-flash-media-server/fms/' rel='attachment wp-att-418'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-418' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/04/fms-150x150.png' title='Flash Media Server' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Video can be downloaded (progressive download) to the client like YouTube or can be streamed to him.&lt;/p&gt;

&lt;p&gt;I won&amp;#8217;t discuss the pro&amp;#8217;s &amp;#38; con&amp;#8217;s of streaming and progressive. We&amp;#8217;ll only be discussing streaming in this post.&lt;/p&gt;

&lt;p&gt;So, What is the post worthy problem we have when streaming video to the client?&lt;/p&gt;

&lt;p&gt;Continue reading and find out. &lt;!--more--&gt;When streaming video, you usually encode your video in a certain bitrate. This bitrate will work well in certain computers and won&amp;#8217;t work well in others. Why is that?&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s because each of your users has a different connection thus being capable to receive a limited amount of bytes streamed to him. So, you always have to find the &amp;#8220;sweet spot&amp;#8221; where you deliver a video that looks good and also light enough to fit a wider range of network connection speeds.&lt;/p&gt;

&lt;p&gt;That is of course a problem, becuase sometimes you want to stream hiQuality video and audio (HD) and you can&amp;#8217;t, because some of your users won&amp;#8217;t be able to watch it smoothly. Well, this is a problem we will solve here in this post.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/tag/flash-media-server/' target='_blank' title='Flash media server'&gt;Flash media server&lt;/a&gt;
&lt;p&gt;That way, you can create several encodes to the same source movie and supply a movie best fit to the user cosuming it.&lt;/p&gt;

&lt;p&gt;Another obvious advantage of this approach is the way it skips on top of the movie, when you skip to a further point in the movie, you are actually being supplied a different movie from the lowest quality to the highest.&lt;/p&gt;

&lt;p&gt;So, how is it done, first, let&amp;#8217;s create a flash file (I&amp;#8217;m using flash CS4). &lt;p style='text-align: center;'&gt;&lt;a href='http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-15-at-9.37.06-PM.png' rel='facebox'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-419' height='171' src='http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-15-at-9.37.06-PM-300x171.png' title='New flash file (Adaptive bitrate) dynamic streaming' width='300' /&gt;&lt;/a&gt;&lt;/p&gt; Now, we will create (by dragging and dropping from the components panel) an FLVPlayback control.&lt;/p&gt;

&lt;p&gt;We will give it the same dimensions as the movie itself so it will fill the entire surface.&lt;/p&gt;

&lt;p&gt;Now, we will give the player an instance name of &amp;#8220;flvPlayer&amp;#8221;&lt;/p&gt;

&lt;p&gt;So, we have a movie, we have an FLVPlayback control, we called it &amp;#8220;flvPlayer&amp;#8221;.&lt;/p&gt;

&lt;p&gt;We will create another layer, called &amp;#8220;action script&amp;#8221; and we will create this code inside.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;fl&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;video&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='o'&gt;*;&lt;/span&gt;
&lt;span class='nx'&gt;VideoPlayer&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;iNCManagerClass&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;NCManagerDynamicStream&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='nx'&gt;flvPlayer&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;source&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;dynamicStream&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;smil&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;OK, so as we can see, we created a pointer to a file called &amp;#8220;dynamicStream.smil&amp;#8221;, this is a special file (XML format).&lt;/p&gt;

&lt;p&gt;This file details the following: &lt;ul&gt;
	&lt;li&gt;FMS Url&lt;/li&gt;
	&lt;li&gt;Files you have encoded and a network speed in correlation&lt;/li&gt;
&lt;/ul&gt; The file looks like this:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;xml&lt;/span&gt; &amp;#60;smil&amp;#62; &amp;#60;head&amp;#62; &amp;#60;meta base=&amp;#34;rtmp://your_fms_location/vod/&amp;#34; /&amp;#62; &amp;#60;/head&amp;#62; &amp;#60;body&amp;#62; &amp;#60;switch&amp;#62; &amp;#60;video src=&amp;#34;mp4:erets7_03_vod1_300.mp4&amp;#34; system-bitrate=&amp;#34;300000&amp;#34;/&amp;#62; &amp;#60;video src=&amp;#34;mp4:erets7_03_vod1_500.mp4&amp;#34; system-bitrate=&amp;#34;500000&amp;#34;/&amp;#62; &amp;#60;video src=&amp;#34;mp4:erets7_03_vod1_800.mp4&amp;#34; system-bitrate=&amp;#34;800000&amp;#34;/&amp;#62; &amp;#60;/switch&amp;#62; &amp;#60;/body&amp;#62; &amp;#60;/smil&amp;#62; &lt;span&gt;/xml&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Now, when we put this file on our web-server, the user will get the file it can receive and play, not slower, not faster, just the perfect file for him.&lt;/p&gt;

&lt;p&gt;NO buffering, NO waiting, NO frustration, smooth, cool and fast user experience.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;

&lt;p&gt;You can download the complete solution from here: &lt;span&gt;download id=&amp;#8221;3&amp;#8221;&lt;/span&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Enumeration on a property - Flex 3</title>
    
      <link href="http://kensodevkensodev.com/2010/04/07/enumeration-on-a-property-flex-3"/>
    
    <id>http://kensodevkensodev.com/2010/04/07/enumeration-on-a-property-flex-3</id>
    <updated>2010-04-07T10:28:47+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/wp-content/uploads/2010/04/fx-icon.png' rel='attachment wp-att-409'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-409' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/04/fx-icon-150x150.png' title='Flex 3' width='150' /&gt;&lt;/a&gt;&lt;!--more--&gt;
&lt;p&gt;lack of documentation often lead to situation when the developer consuming your component doesn&amp;#8217;t know what are the values you expect of him to set.&lt;/p&gt;

&lt;p&gt;Well, there&amp;#8217;s a solution for this, Flex introduced the &amp;#8220;Inspectable&amp;#8221; metadata tag, you can simply set this tag above your setter and the developer will get full intellisense and be able to know what you meant.&lt;/p&gt;

&lt;p&gt;In this simple application, I create a custom mxml component based on Canvas, I create a property called myString and created an &amp;#8220;Inspectable&amp;#8221; metatag.&lt;/p&gt;

&lt;p&gt;like so:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;actionscript3&lt;/span&gt; &lt;span&gt;Bindable&lt;/span&gt; private var &lt;em&gt;myString:String;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Inspectable (enumeration=&amp;#34;stringValue1,stringValue2,stringValue3&amp;#34;)&lt;/span&gt; public function set myString(val:String):void { &lt;em&gt;myString = val; } &lt;span&gt;/actionscript3&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So far, it&amp;#8217;s as simple as it can get, now, check out a screenshot of my flex builder when setting this property from outside &lt;p style='text-align: center;'&gt;&lt;a href='http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-07-at-11.20.01-AM.png' rel='attachment wp-att-384 facebox'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-384' height='137' src='http://www.kensodev.com/wp-content/uploads/2010/04/Screen-shot-2010-04-07-at-11.20.01-AM-300x137.png' title='Flex enum on peoprty' width='300' /&gt;&lt;/a&gt;&lt;/p&gt; And that&amp;#8217;s it, that&amp;#8217;s how simple it is to create enumeration and ease the life on your fellow developers.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Backup all databases (SQL Express) with a single T-Sql</title>
    
      <link href="http://kensodevkensodev.com/2010/04/05/backup-all-databases-sql-express-with-a-single-t-sql"/>
    
    <id>http://kensodevkensodev.com/2010/04/05/backup-all-databases-sql-express-with-a-single-t-sql</id>
    <updated>2010-04-05T16:00:20+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/01/16/shrink-all-databases-on-server-sql/istock_000010274670xsmall/' rel='attachment wp-att-302'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-302' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/01/iStock_000010274670XSmall-150x150.jpg' title='Database server' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;One of the things I often see when people talk about the express disadvantages is the lack of support for JOBS so you cannot create a custom backup for your database.&lt;/p&gt;

&lt;p&gt;Well, in this post I will show you how you can create a single database on your development machine that will be responsible for all of the backups, create a table that will log the backups and a stored procedure that will do the work.&lt;/p&gt;

&lt;p&gt;In a later post, I will also show how you can integrate this into a command line and then into your nightly backup strategy.&lt;/p&gt;

&lt;p&gt;The most beautiful part of this solution is that it is totally free of charge and uses custom T-Sql, and the command line is using a custom tool supplied by the EXPRESS package.&lt;/p&gt;

&lt;p&gt;So, without talking too much, let&amp;#8217;s dive into the solution. &lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;First, we will create the database.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;sql&lt;/span&gt; SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE &lt;span&gt;dbo&lt;/span&gt;.DatabaseBackupName] &lt;a href='128'&gt;varchar&lt;/a&gt; NOT NULL, &lt;span&gt;BackupFlagFull&lt;/span&gt;(1) NOT NULL, &lt;span&gt;BackupFlagLog&lt;/span&gt;(1) NOT NULL, &lt;span&gt;RetentionPeriodFull&lt;/span&gt; NOT NULL, &lt;span&gt;RetentionPeriodLog&lt;/span&gt; NOT NULL, PRIMARY KEY NONCLUSTERED ( &lt;span&gt;Name&lt;/span&gt; ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON &lt;span&gt;PRIMARY&lt;/span&gt; ) ON &lt;span&gt;PRIMARY&lt;/span&gt; GO SET ANSI_PADDING OFF GO &lt;span&gt;/sql&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Now, we have the database all set-up, let&amp;#8217;s create the stored procedure&lt;/p&gt;

&lt;p&gt;&lt;span&gt;sql&lt;/span&gt; SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Procedure &lt;span&gt;dbo&lt;/span&gt;.&lt;span&gt;s_BackupAllDatabases&lt;/span&gt; @Path varchar(128) , @Type varchar(4) &amp;#8211; Full / Log as set nocount on declare @sql varchar(1000)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;-- Get all database names
create table #DBName
	(
	ID int identity (1,1) ,
	Name varchar(128) not null ,
	RetentionPeriod datetime null
	)

insert #DBName
	(Name)
select name
from master..sysdatabases

-- Include any new databases in the backup
insert DatabaseBackup
	(
	Name ,
	BackupFlagFull ,
	BackupFlagLog ,
	RetentionPeriodFull ,
	RetentionPeriodLog
	)
select #DBName.Name ,
	&amp;#39;Y&amp;#39; ,
	&amp;#39;N&amp;#39; ,
	&amp;#39;2 jan 1900&amp;#39; , -- default 2 days
	&amp;#39;1 jan 1900&amp;#39;
from #DBName
	left outer join DatabaseBackup
		on DatabaseBackup.Name = #DBName.Name
where DatabaseBackup.Name is null
and lower(#DBName.Name) &amp;amp;lt;&amp;amp;gt; &amp;#39;tempdb&amp;#39;

-- Remove any non-existant databases
delete DatabaseBackup
where not exists
	(
	select *
	from #DBName
	where #DBName.Name = DatabaseBackup.Name
	)

delete #DBName

create table #ExistingBackups
	(
	Name varchar(128) ,
	ID int identity (1,1)
	)

-- loop through databases&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;declare @Name varchar(128) , @RetentionPeriod datetime , @LastBackupToKeep varchar(8) , @ID int , @MaxID int&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;insert #DBName
	(Name, RetentionPeriod)
select Name, case when @Type = &amp;#39;Full&amp;#39; then RetentionPeriodFull else RetentionPeriodLog end
from DatabaseBackup
where (@Type = &amp;#39;Full&amp;#39; and BackupFlagFull = &amp;#39;Y&amp;#39;)
or (@Type = &amp;#39;Log&amp;#39; and BackupFlagLog = &amp;#39;Y&amp;#39;)

select @MaxID = max(ID) ,
	@ID = 0
from #DBName

while @ID &amp;amp;lt; @MaxID
begin
	-- get next database to backup
	select @ID = min(ID) from #DBName where ID &amp;amp;gt; @ID

	select @Name = Name ,
		@RetentionPeriod = RetentionPeriod
	from #DBName
	where ID = @ID

	-- Delete old backups
	delete #ExistingBackups
	select @sql = &amp;#39;dir /B &amp;#39; + @Path
	select @sql = @sql + &amp;#39;&amp;amp;quot;&amp;#39; + @Name + &amp;#39;_&amp;#39; + @Type + &amp;#39;*.*&amp;amp;quot;&amp;#39;

	insert #ExistingBackups exec master..xp_cmdshell @sql

	if exists (select * from #ExistingBackups where Name like &amp;#39;%File Not Found%&amp;#39;)
		delete #ExistingBackups

	select @LastBackupToKeep = convert(varchar(8),getdate() - @RetentionPeriod,112)
	delete #ExistingBackups where Name &amp;amp;gt; @Name + &amp;#39;_&amp;#39; + @Type + &amp;#39;_&amp;#39; + @LastBackupToKeep&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;declare @eID int , @eMaxID int , @eName varchar(128)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;	-- loop round all the out of date backups
	select 	@eID = 0 ,
		@eMaxID = coalesce(max(ID), 0)
	from 	#ExistingBackups

	while @eID &amp;amp;lt; @eMaxID
	begin
		select @eID = min(ID) from #ExistingBackups where ID &amp;amp;gt; @eID
		select @eName = Name from #ExistingBackups where ID = @eID

		select @sql = &amp;#39;del &amp;#39; + @Path + &amp;#39;&amp;amp;quot;&amp;#39; + @eName + &amp;#39;&amp;amp;quot;&amp;#39;
		exec master..xp_cmdshell @sql, no_output
	end
	delete #ExistingBackups

	-- now do the backup
	select @sql = @Path + @Name + &amp;#39;_&amp;#39; + @Type + &amp;#39;_&amp;#39;
			+ convert(varchar(8),getdate(),112) + &amp;#39;_&amp;#39;
			+ replace(convert(varchar(8),getdate(),108),&amp;#39;:&amp;#39;,&amp;#39;&amp;#39;) + &amp;#39;.bak&amp;#39;
	if @Type = &amp;#39;Full&amp;#39;
		backup database @Name
			to disk = @sql
	else
		backup log @Name
			to disk = @sql
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;GO /****** Object: Check &lt;span&gt;CK__DatabaseB__Backu__023D5A04&lt;/span&gt; Script Date: 04/05/2010 16:49:17 ***&lt;strong&gt;&lt;em&gt;/ ALTER TABLE &lt;span&gt;dbo&lt;/span&gt;.&lt;span&gt;DatabaseBackup&lt;/span&gt; WITH CHECK ADD CHECK ((&lt;span&gt;BackupFlagFull&lt;/span&gt;=&amp;#8217;N&amp;#8217; OR &lt;span&gt;BackupFlagFull&lt;/span&gt;=&amp;#8217;Y&amp;#8217;)) GO /&lt;/em&gt;&lt;/strong&gt;*** Object: Check &lt;span&gt;CK__DatabaseB__Backu__03317E3D&lt;/span&gt; Script Date: 04/05/2010 16:49:17 ***&lt;strong&gt;&lt;em&gt;/ ALTER TABLE &lt;span&gt;dbo&lt;/span&gt;.&lt;span&gt;DatabaseBackup&lt;/span&gt; WITH CHECK ADD CHECK ((&lt;span&gt;BackupFlagLog&lt;/span&gt;=&amp;#8217;N&amp;#8217; OR &lt;span&gt;BackupFlagLog&lt;/span&gt;=&amp;#8217;Y&amp;#8217;)) GO &lt;span&gt;/sql&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, we have our database, we have our stored procedure.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s execute the stored procedure.&lt;/p&gt;

&lt;p&gt;Right click on the stored procedure and click on &amp;#8220;Execute&amp;#8230;&amp;#8221; &lt;p style='text-align: center;'&gt;&lt;a href='http://www.kensodev.com/wp-content/uploads/2010/04/05-04-2010-16-55-15.png' rel='attachment wp-att-378 facebox'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-378' height='225' src='http://www.kensodev.com/wp-content/uploads/2010/04/05-04-2010-16-55-15-300x225.png' title='Execute stored procedure' width='300' /&gt;&lt;/a&gt;&lt;/p&gt; Now, set the parameters&lt;/p&gt;

&lt;p&gt;The first parameter is the library and the second is the backup type, you can use full, log &lt;p style='text-align: center;'&gt;&lt;a href='http://www.kensodev.com/wp-content/uploads/2010/04/05-04-2010-16-55-47.png' rel='attachment wp-att-379 facebox'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-379' height='268' src='http://www.kensodev.com/wp-content/uploads/2010/04/05-04-2010-16-55-47-300x268.png' title='Store procedure execution parameters' width='300' /&gt;&lt;/a&gt;&lt;/p&gt; That&amp;#8217;s it, you have a backup up and running.&lt;/p&gt;

&lt;p&gt;in the next post I will show how you can do it from command line and integrate it into your backup program post-backup action.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Install Wamp on a Windows machine</title>
    
      <link href="http://kensodevkensodev.com/2010/03/23/install-wamp-on-a-windows-machine"/>
    
    <id>http://kensodevkensodev.com/2010/03/23/install-wamp-on-a-windows-machine</id>
    <updated>2010-03-23T10:20:53+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Quite a while ago I shot a screen cast about how to configure and install WAMP on a windows machine without it clashing with IIS 7 or anything else for that matter.&lt;/p&gt;

&lt;p&gt;The video is very popular on &lt;a href='http://www.vimeo.com'&gt;Vimeo&lt;/a&gt; so I thought I&amp;#8217;d put it here as well so my readers can enjoy it. &lt;!--more--&gt; &lt;object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' height='261' width='550'&gt;&lt;param name='allowfullscreen' value='true' /&gt;&lt;param name='allowscriptaccess' value='always' /&gt;&lt;param name='src' value='http://vimeo.com/moogaloop.swf?clip_id=5185953&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1' /&gt;&lt;embed allowfullscreen='true' allowscriptaccess='always' height='261' src='http://vimeo.com/moogaloop.swf?clip_id=5185953&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1' type='application/x-shockwave-flash' width='550' /&gt;&lt;/object&gt;&lt;/p&gt;
&lt;a href='http://vimeo.com/5185953'&gt;install WAMP on windows 7 / Vista / XP&lt;/a&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Flash media server statistics using sawMill</title>
    
      <link href="http://kensodevkensodev.com/2010/03/14/flash-media-server-statistics-using-sawmill"/>
    
    <id>http://kensodevkensodev.com/2010/03/14/flash-media-server-statistics-using-sawmill</id>
    <updated>2010-03-14T08:40:50+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/03/14/flash-media-server-statistics-using-sawmill/_graphics-statistics-graph-preview3-by-dragonart/' rel='attachment wp-att-371'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-371' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/03/graphics-statistics-graph-preview3-by-dragonart-150x150.png' title='Stats' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Flash media server has some disadvantages, one of those is definitely the lack of normal statistics. The terminal will give you the real time data but if you want to drill down into last month and 3 month ago or more, you won&amp;#8217;t be able to get any data in a comfortable and nice view. &lt;!--more--&gt; I found a product called &lt;a href='http://www.sawmill.net/' target='_blank'&gt;SawMill&lt;/a&gt;, this product is unobtrusive on your flash media server, you don&amp;#8217;t even have to install it on your server.&lt;/p&gt;

&lt;p&gt;So, how can you get Stats you ask?&lt;/p&gt;

&lt;p&gt;Well, you simply install the product, you give it a path to your log files and it will do the rest, it has a built in support for the Flash Media Server log format so you don&amp;#8217;t have to &amp;#8220;teach&amp;#8221; it how to read the logs or do any kind of configuration.&lt;/p&gt;

&lt;p&gt;You have stats like: &lt;ul&gt;
	&lt;li&gt;Client Ip's&lt;/li&gt;
	&lt;li&gt;Media files played&lt;/li&gt;
	&lt;li&gt;amount of data streamed&lt;/li&gt;
	&lt;li&gt;time of use&lt;/li&gt;
	&lt;li&gt;pressure hours&lt;/li&gt;
&lt;/ul&gt; And many more of course, the real treat is that you can drill down from year to month to day to hourly stats.&lt;/p&gt;

&lt;p&gt;Those can come in handy if you want to learn more about your website and the usage.&lt;/p&gt;

&lt;p&gt;Example of what a stat sheet looks like:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/03/14/flash-media-server-statistics-using-sawmill/screen-shot-2010-03-14-at-8-35-22-am/' rel='attachment wp-att-372'&gt;&lt;img alt='SawMill stats' class='aligncenter size-medium wp-image-372' height='121' src='http://www.kensodev.com/wp-content/uploads/2010/03/Screen-shot-2010-03-14-at-8.35.22-AM-300x121.png' title='SawMill Stats' width='300' /&gt;&lt;/a&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">RTMP being blocked by firewalls - Flash media server</title>
    
      <link href="http://kensodevkensodev.com/2010/02/19/rtmp-being-blocked-by-firewalls-flash-media-server"/>
    
    <id>http://kensodevkensodev.com/2010/02/19/rtmp-being-blocked-by-firewalls-flash-media-server</id>
    <updated>2010-02-19T19:34:27+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/02/19/rtmp-being-blocked-by-firewalls-flash-media-server/fms-logo/' rel='attachment wp-att-360'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-360' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/02/FMS.logo_-150x150.jpg' title='Flash media server logo' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Now, if you have users working behind a firewall, they probably can&amp;#8217;t get passed it&amp;#8217;s restrictions and they will (in most cases) be blocked and unable to see your application / video.&lt;/p&gt;

&lt;p&gt;If you are working on a server like WebOrb (I&amp;#8217;m working with it) then the data will also be blocked, and that is a bug issue.&lt;/p&gt;

&lt;p&gt;Today we&amp;#8217;re going to solve the problem together. Here&amp;#8217;s a way to solve it. &lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;Well, let&amp;#8217;s first talk a bit more about RTMP, before ditching it and moving on.&lt;/p&gt;

&lt;p&gt;With flash media server you can use RTMP over a few ports (1935, 80). 1935 will probably always be blocked, because it is not a known port and even simple routers often block it.&lt;/p&gt;

&lt;p&gt;Port 80 makes things a bit more complicated, you have to make FMS listen to a specific IP or your web-server (if on the same server) will not work.&lt;/p&gt;

&lt;p&gt;So, first rule is always to use port 80, this is one way to make more users be able to connect to your application, watch your videos and interact with your service.&lt;/p&gt;

&lt;p&gt;The connection is being made like so:&lt;/p&gt;

&lt;p&gt;rtmp://your_ip_address:80/app_name&lt;/p&gt;

&lt;p&gt;DO NOT use any type of arrays of ports, simply use port 80. If the client can&amp;#8217;t connect to RTMP on port 80, he will not be able to connect on RTMP no matter the port you are using. &lt;h2&gt;So, What am I actually saying over here...?&lt;/h2&gt; I&amp;#8217;m saying you should only make 1 connection attempt, this attempt is on port 80 using RTMP - this should be your first choice. If the connection is unsuccessful, you should move the connection to use RTMPT, which is RTMP encapsulated over HTTP. Firewalls will not block this connection, because it makes RTMP &amp;#8220;hide&amp;#8221; behind HTTP traffic on port 80.&lt;/p&gt;

&lt;p&gt;The connection is made practically the same way:&lt;/p&gt;

&lt;p&gt;rtmpt://your_ip_address:80/app_name &lt;h2&gt;Why not use RTMPT at all times?&lt;/h2&gt; You should not use RTMPT at all times. because there&amp;#8217;s a performance issue, there is an overhead on top of each packet sent. &lt;h2&gt;Why not go through all the possible ports with RTMP first, Why only 80?&lt;/h2&gt; In most cases, firewalls will block every port (but 80), the timeouts the user will have to go through will be very long before he will finally be redirected to RTMPT.&lt;/p&gt;

&lt;p&gt;I will post some code on how to fallback more efficiently later on this week, this post was actually inspired from a client&amp;#8217;s solution I did this week during a consulting session.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">How can you give quality service to your clients</title>
    
      <link href="http://kensodevkensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients"/>
    
    <id>http://kensodevkensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients</id>
    <updated>2010-02-19T15:11:55+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients/client-support-crossword/' rel='attachment wp-att-350'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-350' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/02/iStock_000009671781XSmall-150x150.jpg' title='Client support crossword' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;As a freelancer, all of the client&amp;#8217;s communication and service is up to you, you need to provide them with the best platform to work on, with you, along side with the existing team inside the company (in-case you are working with them).&lt;/p&gt;

&lt;p&gt;So, because I believe I have that kind of platform I thought I&amp;#8217;d share (as I always do) with you, how I work with my clients, although there are tools and services in this post, it&amp;#8217;s not about them, it&amp;#8217;s about how you can use them, seeing the customer&amp;#8217;s needs in the center of your concerns.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;I as a &lt;a href='http://www.kensodev.com/about-avi-tzurel/' title='Avi Tzurel'&gt;freelancer&lt;/a&gt; very often work as a team leader inside a company, sometimes as the architect and sometimes as the development director, sometimes both and I even love working as a lead developer.&lt;/p&gt;

&lt;p&gt;So, my service must be customizable around who I am at the moment and what does the client expect of me to be.&lt;/p&gt;

&lt;p&gt;Let us begin&amp;#8230; &lt;h2&gt;SVN - Source control system&lt;/h2&gt; First, whether the company is working with a source control or not, I always bring my source control system with me, I work with SVN (or GIT). I use &lt;a href='http://www.beanstalkapp.com' target='_blank'&gt;beanstalk&lt;/a&gt;, you can read about it in a previous post I wrote &lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/' target='_blank'&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You probably ask yourself the same question everyone is asking me, why not use a regular SVN server hosted in a farm or something, well, my answer is always the same, beanstalk are giving me an all around solution for my needs for example: &lt;h2&gt;&lt;strong&gt;TimeLine&lt;/strong&gt;&lt;/h2&gt; All of the team commits can be seen inside a time line very similar to facebook, to me as the leader or the architect it&amp;#8217;s very easy to know in the morning what has been accomplished yesterday and by who.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_351&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;300&amp;#8221; caption=&amp;#8221;Beanstalk svn timeline&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients/screen-shot-2010-02-19-at-2-31-46-pm/' rel='attachment wp-att-351'&gt;&lt;img alt='' class='size-medium wp-image-351' height='175' src='http://www.kensodev.com/wp-content/uploads/2010/02/Screen-shot-2010-02-19-at-2.31.46-PM-300x175.png' title='beanstalk svn timeline' width='300' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;As you can see, I can see very clearly who are the team members on this specific project, what are the change-sets they are responsible for and the file that have been changed during the work Yesterday or last month for that matter.&lt;/p&gt;

&lt;p&gt;Also, I can use webhooks to do whatever I want, I can use email notifications for every commit (very useful) and many other more very useful features. &lt;h2&gt;Project management system&lt;/h2&gt; I work with &lt;a href='http://www.basecamphq.com'&gt;basecamp&lt;/a&gt; to manage all of the project aspects.&lt;/p&gt;

&lt;p&gt;What do I manage: &lt;ul&gt;
	&lt;li&gt;deadlines&lt;/li&gt;
	&lt;li&gt;to-do's&lt;/li&gt;
	&lt;li&gt;messages&lt;/li&gt;
	&lt;li&gt;chat&lt;/li&gt;
	&lt;li&gt;files&lt;/li&gt;
	&lt;li&gt;source&lt;/li&gt;
&lt;/ul&gt; I&amp;#8217;ll explain the source line :-)&lt;/p&gt;

&lt;p&gt;Every commit from beanstalk posts a message on the board at basecamp dashboard, meaning I can comment (beanstalk added a feature similar to that recently) on a team member commit and give him feedback on it.&lt;/p&gt;

&lt;p&gt;Everything is kept inside the &amp;#8220;project&amp;#8221; context, I&amp;#8217;ll five you an example, because at beanstalk you can see the source changes, very easily I can review the code in the web browser, that means when a team member writes bad code or code I expect to be cleaner or even if he didn&amp;#8217;t comment his code enough ( I have clear rules on that) i simple message him the second I see it and he gets an email about it.&lt;/p&gt;

&lt;p&gt;Another use I have for this feature is commenting out new features in the system, If I (or another team member) added a new code to the system, I usually post a comment to the commit and say what I added and what are the usage for it, this clarifies the usage for the team and there are no questions.&lt;/p&gt;

&lt;p&gt;If the team is not clear how they can use a feature I added they go to the message and there they will see example source code and comments about that feature.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_353&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;300&amp;#8221; caption=&amp;#8221;Basecamp project dashboard&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients/screen-shot-2010-02-19-at-2-43-32-pm/' rel='attachment wp-att-353'&gt;&lt;img alt='' class='size-medium wp-image-353' height='180' src='http://www.kensodev.com/wp-content/uploads/2010/02/Screen-shot-2010-02-19-at-2.43.32-PM-300x180.png' title='basecamp dashboard' width='300' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;In the screen shot above you can see a project dashboard. This is for a specific project, you as the owner of the account have a dashboard for all the project you are running in the system.&lt;/p&gt;

&lt;p&gt;With the morning coffee, you can review what you have to do urgently and what can wait another day, making choices based on data is always better then choices based on your memory or anything else for that matter. &lt;h2&gt;Backup&lt;/h2&gt; If I could create a shouting voice in this title I would, your client&amp;#8217;s code, data, files and everything you have at your possession is very important you your client, so you should provide a descent backup service for him.&lt;/p&gt;

&lt;p&gt;The client must know, no data is being lost, no matter if your laptop caught fire, stolen, broken or any other natural or synthetic disaster that can be caused in our daily crazy life on this world :-)&lt;/p&gt;

&lt;p&gt;I my self have a double backup.&lt;/p&gt;

&lt;p&gt;I use a free software called syncback to backup all of the data to an external HD.&lt;/p&gt;

&lt;p&gt;Also, I use a remote backup using Mozy.com.&lt;/p&gt;

&lt;p&gt;So, every night, my computer backs up twice, once to a close location (HD) and one to a remote location (Cloud service).&lt;/p&gt;

&lt;p&gt;Of course, using SVN is having sort of a backup for the code, but I so another backup just in case, of course for all the other stuff that are not code like images, documents or anything else. &lt;h2&gt;Sync&lt;/h2&gt; Keeping in sync with your client is very important, I&amp;#8217;m talking from the files point of view right now. I use dropbox on my computer and have dropbox installed for every team member, this way if we have a design document or a mockup or anything else, the file is being updated for everyone at the same time.&lt;/p&gt;

&lt;p&gt;So, every time you talk to your team or a member of your team, you are talking about the same thing, you actually look at the same file exactly, so if a team member has a comment he can write it down and everyone will see it the next time they open the file.&lt;/p&gt;

&lt;p&gt;This is a very helpful feature dropbox has and I love using it.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_354&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;300&amp;#8221; caption=&amp;#8221;Dropbox shared folder&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients/screen-shot-2010-02-19-at-2-57-06-pm/' rel='attachment wp-att-354'&gt;&lt;img alt='' class='size-medium wp-image-354' height='198' src='http://www.kensodev.com/wp-content/uploads/2010/02/Screen-shot-2010-02-19-at-2.57.06-PM-300x198.png' title='Dropbox share folder on a mac' width='300' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt; &lt;h2&gt;Time tracking&lt;/h2&gt; I almost entirely work on an hourly basis with my clients, so I have to use a reliable system to track my time.&lt;/p&gt;

&lt;p&gt;When working on an hourly basis you must be very careful not to work on a client X project on client&amp;#8217;s Y dime.&lt;/p&gt;

&lt;p&gt;For that, I use &lt;a href='http://www.toggl.com' target='_blank'&gt;toggl.com&lt;/a&gt;, this service is another cloud service to track your time, the clear advantage of that service is that it has a desktop based widget, you begin to track time, if for some reason you left your computer during that time, the widget will inform you on that error when you get back.&lt;/p&gt;

&lt;p&gt;That way, a client only pays for time you actually worked, he is more comfortable with working this way.&lt;/p&gt;

&lt;p&gt;You can also set custom rates for each client, you can export reports in PDF format and more, the client has a public report, meaning he can see at real time what you are working on and how much time you spent on this mission.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_355&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;300&amp;#8221; caption=&amp;#8221;Toggl client report&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients/client_report/' rel='attachment wp-att-355'&gt;&lt;img alt='' class='size-medium wp-image-355' height='228' src='http://www.kensodev.com/wp-content/uploads/2010/02/client_report-300x228.png' title='Client report' width='300' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;If you use the paid account those reports are available to the client, also you can brand it with your logo so when the client&amp;#8217;s print it out it will look nice as well. &lt;h2&gt;iPhone&lt;/h2&gt; I recently bought an iPhone, so here are some thoughts on how I use it to give a quality service.&lt;/p&gt;

&lt;p&gt;Mail &amp;#8211;&amp;#62; always available, whether I&amp;#8217;m traveling or I&amp;#8217;m out of my home office.&lt;/p&gt;

&lt;p&gt;ToDo&amp;#8211;&amp;#62; always synced&lt;/p&gt;

&lt;p&gt;Calendatr -&amp;#62; synced&lt;/p&gt;

&lt;p&gt;Dropbox -&amp;#62; synced&lt;/p&gt;

&lt;p&gt;Many many more features such as to do lists (app store) and many more, I used blackberry and Nokia E71 before, I must say I really feel I am more productive when using the iPhone and more in touch with everything when I travel around.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_356&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;220&amp;#8221; caption=&amp;#8221;iPhone&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/02/19/how-can-you-give-quality-service-to-your-clients/apple-iphone/' rel='attachment wp-att-356'&gt;&lt;img alt='' class='size-medium wp-image-356' height='300' src='http://www.kensodev.com/wp-content/uploads/2010/02/apple-iphone-220x300.jpg' title='apple iphone' width='220' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it for now :-)&lt;/p&gt;

&lt;p&gt;part-2 coming soon&amp;#8230;&lt;/p&gt;

&lt;p&gt;I&amp;#8217;d love to see your comments&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Beanstalk blog mentioned my post</title>
    
      <link href="http://kensodevkensodev.com/2010/02/03/beanstalk-blog-mentioned-my-post"/>
    
    <id>http://kensodevkensodev.com/2010/02/03/beanstalk-blog-mentioned-my-post</id>
    <updated>2010-02-03T17:48:21+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/02/03/beanstalk-blog-mentioned-my-post/2297346285_fc2599bcaa/' rel='attachment wp-att-342'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-342' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/02/2297346285_fc2599bcaa-150x150.jpg' title='Beanstalkapp' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;It hit waves around Twitter and Facebook and got very popular over the weekend I wrote it.&lt;/p&gt;

&lt;p&gt;I was also mentioned in their blog so here&amp;#8217;s a &lt;a href='http://blog.beanstalkapp.com/2010/01/21/svn-on-steriods-using-beanstalk-and-basecamp/'&gt;link &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you guys for the mention and thank you for this really amazing product I use daily.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">jQuery and UpdatePanels (Asp.Net)</title>
    
      <link href="http://kensodevkensodev.com/2010/02/01/jquery-and-updatepanels-asp-net"/>
    
    <id>http://kensodevkensodev.com/2010/02/01/jquery-and-updatepanels-asp-net</id>
    <updated>2010-02-01T17:51:00+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/02/01/jquery-and-updatepanels-asp-net/jquery-logo-9/' rel='attachment wp-att-336'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-336' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/02/jquery-logo-9-150x150.jpg' title='jQuery' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;I think this open-source js library is simply the best when you want to create a richer user experience in your websites and applications.&lt;/p&gt;

&lt;p&gt;Some will argue Mootools is better but hey, this is a long and exhausting battle, almost like the one between PHP and ASP.net&lt;/p&gt;

&lt;p&gt;This post comes to explain the difficulties when using jQuery dom event like &amp;#8220;click&amp;#8221; and &amp;#8220;change&amp;#8221; with an update panel.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;Just one thing before I start, this post assumes you know jQuery, it also assumes you know your way around .net and you also know what an UpdatePanel is.&lt;/p&gt;

&lt;p&gt;So, let&amp;#8217;s begin&lt;/p&gt;

&lt;p&gt;This is what our application looks like:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/02/01/jquery-and-updatepanels-asp-net/post_2/' rel='attachment wp-att-337'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-337' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/02/post_2-300x150.png' title='Mockup' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;What do we have here?&lt;/p&gt;

&lt;p&gt;We have an UpdatePanel containing a grid with data from the server and a client-side button.&lt;/p&gt;

&lt;p&gt;This client-side button has an event attached to it with jQuery like so: &lt;script src='http://gist.github.com/291760.js?file=jquery_add_event_to_button.js' type='text/javascript' /&gt;Now, let&amp;#8217;s explain what&amp;#8217;s happening.&lt;/p&gt;

&lt;p&gt;When the UpdatePanel fires an update event, all of the content inside it will be replace, but, with replacing this content all of the DOM data attached to it will also be disposed.&lt;/p&gt;

&lt;p&gt;So, when we try to click the button after an UpdatePanel update the event will not be fired. To avoid this, jQuery offers a &amp;#8220;live&amp;#8221; event So, we will use the code like this&lt;script src='http://gist.github.com/291764.js?file=jquery_live_event.js' type='text/javascript' /&gt;&lt;/p&gt;

&lt;p&gt;This will solve the problem for you.&lt;/p&gt;

&lt;p&gt;Questions, comments?&lt;/p&gt;

&lt;p&gt;Feel free&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">SVN on steroids using beanstalk and integrating basecamp</title>
    
      <link href="http://kensodevkensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp"/>
    
    <id>http://kensodevkensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp</id>
    <updated>2010-01-20T20:35:59+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/istock_000006154797xsmall/' rel='attachment wp-att-322'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-322' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/01/iStock_000006154797XSmall-150x150.jpg' title='Code' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Whether you are using GIT or SVN, both self hosted or in the cloud.&lt;/p&gt;

&lt;p&gt;Me, I&amp;#8217;m a huge fan of cloud services and moving things and services into the cloud, managing my entire work (almost) in the cloud, from my email (GMail) to my backup service (Mozy) and now, SVN.&lt;/p&gt;

&lt;p&gt;I will tell you about my solution in this post along with screenshots of what it looks like&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;Just to give you an idea, I&amp;#8217;m talking about a solution on steroids, the sort of solutions that makes you feel like: &amp;#8220;how the hell did I do this up until now&amp;#8221;, this solution will work amazing for you if you are working in a team or working alone.&lt;/p&gt;

&lt;p&gt;I do both, and I absolutely love this solution.&lt;/p&gt;

&lt;p&gt;Like I said in the title, the solution is based on 2 cloud services&lt;/p&gt;

&lt;ol&gt;
&lt;li /&gt;

&lt;li /&gt;
&lt;/ol&gt;

&lt;p&gt;The concept of the solution is simple, see what&amp;#8217;s being done, by who, when and why, all this inside the context of a web page with a link from the project management system back to the SVN and vice versa.&lt;/p&gt;

&lt;p&gt;Also, you are able to track time being &amp;#8220;wasted&amp;#8221; on a mission, everything from within the comfort of the environment convenient to you.&lt;/p&gt;

&lt;p&gt;You won&amp;#8217;t need to change anything in your habits, if you are used to using a command line, you will use the same command line with some extra commands to track time and do other things.&lt;/p&gt;

&lt;p&gt;So, let&amp;#8217;s dig into just how you can do this:&lt;/p&gt;

&lt;p&gt;First, open an account in Beanstalk, the pricing range is convenient and I found myself rising from the trial period to my current account in no time.&lt;/p&gt;

&lt;p&gt;Second, go and open an account in Basecamp (this is not a must, just an extra).&lt;/p&gt;

&lt;p&gt;In Basecamp, find your account details and grab your API token (you can regenerate a new one at any time you want)&lt;/p&gt;

&lt;p&gt;OK, we are set to go.&lt;/p&gt;

&lt;p&gt;When you log in into Beanstalk you will see the repositories tab on the top, when you click it, you can see all of your repositories. it&amp;#8217;s important to understand, each of your clients/users will see different things in this tab, meaning there&amp;#8217;s a permission system, if you give access to a client he will see his projects only.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled/' rel='attachment wp-att-323'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-323' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-300x192.png' title='Repositories - Beanstalk' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Now, click &amp;#8220;Create Repository&amp;#8221; This screen will come up&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-1/' rel='attachment wp-att-324'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-324' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-1-300x192.png' title='Open new repository - Beanstalk' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Select a repository name (you will not be able to change this in the future so select it wisely)&lt;/p&gt;

&lt;p&gt;After you give a name, you will be redirected to the next phase in the wizard, here, you can import your working copy (if you have one). This is actually a very important feature for me, all of my SVN was self hosted and I wanted to keep the repo consistent and be able to revert back to older revisions of files and more.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-2/' rel='attachment wp-att-325'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-325' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-2-300x192.png' title='Open new repository - phase 2' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;After you import (or not) you will be redirected to giving permissions to clients/users. you can skip this phase if you don&amp;#8217;t need it or you don&amp;#8217;t know yet, you can change the permissions at any time in the future.&lt;/p&gt;

&lt;p&gt;You can also select (of course) the type of permissions the user has.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-3/' rel='attachment wp-att-326'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-326' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-3-300x192.png' title='Create repository - permissions' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;That&amp;#8217;s it, your repository (first one) is setup. Nnow, you can click the activity page and you will see just a blank (or something else if you imported data) page.&lt;/p&gt;

&lt;p&gt;This is your activity page and it will get filled with each commit user does.&lt;/p&gt;

&lt;p&gt;On the right side, you can see a textInput where you can copy and paste he repository URL for this repository. This url is the one you type into the SVN tool you are using, whether you are using the command line or Versions (mac) or even tortoise SVN (windows).&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-4/' rel='attachment wp-att-327'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-327' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-4-300x192.png' title='Repository page - Activity' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Cool, so let&amp;#8217;s create a connection to Basecamp now.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s click the setup tab in the top. We will get this screen&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-5/' rel='attachment wp-att-328'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-328' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-5-300x192.png' title='Integration setup' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;As you can see, Basecamp is my option of choice but you you can select any service they have to offer, from twitter to freckle and many more.&lt;/p&gt;

&lt;p&gt;What&amp;#8217;s next.&lt;/p&gt;

&lt;p&gt;type your Basecamp url, paste in your API token.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-7/' rel='attachment wp-att-329'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-329' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-7-300x192.png' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;After you type in the details and click next you will be able to select a project from you project management system.&lt;/p&gt;

&lt;p&gt;After you select a project you&amp;#8217;ll be able to select the category to which every commit message will be transmitted to. I always select &amp;#8220;code&amp;#8221;&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll explain a bit. When you commit a revision and type a message, this message will be posted to the &amp;#8220;messages&amp;#8221; section in Basecamp. The messages section contains every message users post, so the code revisions and every other message is in once place, for me this is amazing also because I can reply to a message. When a programmer from you team posts a commit message you can reply, giving him anything from a feedback to rejects.&lt;/p&gt;

&lt;p&gt;Also, you have a link from Basecamp to the changeset in Beanstalk. you don&amp;#8217;t have to exit, log in and look for the latest change, it&amp;#8217;s just a click of a button away.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s see how it looks. When I commit a revision it looks like this:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-9/' rel='attachment wp-att-330'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-330' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-9-300x192.png' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;and this is where I go after I click the link inside Basecamp&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2010/01/20/svn-on-steroids-using-beanstalk-and-integrating-basecamp/untitled-10/' rel='attachment wp-att-331'&gt;&lt;img alt='' class='aligncenter size-medium wp-image-331' height='192' src='http://www.kensodev.com/wp-content/uploads/2010/01/untitled-10-300x192.png' width='300' /&gt;&lt;/a&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Source Code: Credit card number validation (Israeli Visa)</title>
    
      <link href="http://kensodevkensodev.com/2010/01/18/source-code-credit-card-number-validation-israeli-visa"/>
    
    <id>http://kensodevkensodev.com/2010/01/18/source-code-credit-card-number-validation-israeli-visa</id>
    <updated>2010-01-18T07:46:06+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/01/18/source-code-credit-card-number-validation-israeli-visa/credit-card-with-dollars/' rel='attachment wp-att-309'&gt;&lt;img alt='' class='alignleft size-thumbnail wp-image-309' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/01/iStock_000004333130XSmall-150x150.jpg' title='Credit card with dollars' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Usually, it&amp;#8217;s enough, yet sometimes a client demand or a product demand is to create a more sophisticated validation, using known credit card algorithm that the CreditCard company issues from time to time.&lt;/p&gt;

&lt;p&gt;I had just that need a while back.&lt;/p&gt;

&lt;p&gt;So, I created the validation and I decided to share it with you here. &lt;!--more--&gt; First, let&amp;#8217;s create a helper for checking wether a number is an even or an odd number. this will be used later in the validation process. &lt;script src='http://gist.github.com/279810.js?file=gistfile1.cs' /&gt; A credit card validation is being done using something that&amp;#8217;s called a &amp;#8220;weight number&amp;#8221;, each credit card number is attached to a weight number and some calculations are done accordingly. So, let&amp;#8217;s create a class which takes a number and a weight number, we will also create a constructor for this class. &lt;script src='http://gist.github.com/279812.js?file=gistfile1.cs' /&gt;&lt;/p&gt;

&lt;p&gt;Now, we have the helper to check whether a number is odd or even, we have a class to hold the credit card numbers.&lt;/p&gt;

&lt;p&gt;The algorithm says something simple, starting at the &lt;strong&gt;right &lt;/strong&gt;side of the number (credit card number) start attaching weight numbers.&lt;/p&gt;

&lt;p&gt;Start with 1, then 2 and so on and so fourth till the end of the number.&lt;/p&gt;

&lt;p&gt;like so:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_315&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;364&amp;#8221; caption=&amp;#8221;Numbers and weight numbers&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/01/18/source-code-credit-card-number-validation-israeli-visa/18-01-2010-07-50-56/' rel='attachment wp-att-315'&gt;&lt;img alt='' class='size-full wp-image-315' height='52' src='http://www.kensodev.com/wp-content/uploads/2010/01/18-01-2010-07-50-56.png' title='Credit card numbers' width='364' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;After you do this, multiply the number with the weight number, if the result you get is greated then the number 10, add the first number to the second number.&lt;/p&gt;

&lt;p&gt;Example: if you get 16 in the result, simply add 1+6 and the final result is 7.&lt;/p&gt;

&lt;p&gt;like so:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;caption id=&amp;#8221;attachment_316&amp;#8221; align=&amp;#8221;aligncenter&amp;#8221; width=&amp;#8221;373&amp;#8221; caption=&amp;#8221;Calculation metod - weight numbers&amp;#8221;&lt;/span&gt;&lt;a href='http://www.kensodev.com/2010/01/18/source-code-credit-card-number-validation-israeli-visa/18-01-2010-07-55-39/' rel='attachment wp-att-316'&gt;&lt;img alt='' class='size-full wp-image-316' height='109' src='http://www.kensodev.com/wp-content/uploads/2010/01/18-01-2010-07-55-39.png' title='Credit card validation numbers' width='373' /&gt;&lt;/a&gt;&lt;span&gt;/caption&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;After you do this, simply sum up the result&lt;/p&gt;

&lt;p&gt;8+5+7+0+2+4+0+0+0+1+4+1+6+2+2+8&lt;/p&gt;

&lt;p&gt;Any result should is OK as long as the number is divided by 10, if the number is not divided by 10 exactly something is wrong with the credit card.&lt;/p&gt;

&lt;p&gt;This is the final validation function&lt;/p&gt;

&lt;p&gt;The function is commented so no further explanation is needed.&lt;/p&gt;
&lt;script src='http://gist.github.com/279817.js?file=gistfile1.cs' /&gt;
&lt;p&gt;Feel free to ask any question in the comments&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Execute a T-Sql statement on all Databases - Sql Server</title>
    
      <link href="http://kensodevkensodev.com/2010/01/16/execute-a-t-sql-statement-on-all-databases-sql-server"/>
    
    <id>http://kensodevkensodev.com/2010/01/16/execute-a-t-sql-statement-on-all-databases-sql-server</id>
    <updated>2010-01-16T21:01:02+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='' class='alignleft size-thumbnail wp-image-259' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000009154776XSmall-150x150.jpg' title='server farm' width='150' /&gt;
&lt;p&gt;I had this issue about a week ago, I needed to change my users table on all databases. Because all of my tables are named the same on all db&amp;#8217;s (convention) I wanted to avoid the hassle of going through the databases manually with Management studio and just wanted to execute the code on all of the db&amp;#8217;s.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;This is the script.&lt;/p&gt;

&lt;p&gt;I added some comments to better understand it.&lt;/p&gt;
&lt;script src='http://gist.github.com/278952.js?file=gistfile1.sql' /&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Shrink all databases on server (sql)</title>
    
      <link href="http://kensodevkensodev.com/2010/01/16/shrink-all-databases-on-server-sql"/>
    
    <id>http://kensodevkensodev.com/2010/01/16/shrink-all-databases-on-server-sql</id>
    <updated>2010-01-16T13:53:52+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2010/01/16/shrink-all-databases-on-server-sql/istock_000010274670xsmall/' rel='attachment wp-att-302'&gt;&lt;img alt='Database server' class='alignleft size-thumbnail wp-image-302' height='150' src='http://www.kensodev.com/wp-content/uploads/2010/01/iStock_000010274670XSmall-150x150.jpg' title='Database server' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;About a month ago, I got a call from a client of mine saying he has 2 database servers, each holding about 150 databases.&lt;/p&gt;

&lt;p&gt;The servers were both SQL Server 2008, he had 2 HD&amp;#8217;s with 74GB each and there was absolutely no space on any of them.&lt;/p&gt;

&lt;p&gt;After a short research I found that the backup files were absolutely huge and fill the disk up to a point that the server had no space to store any more data and the website connected to that database crashed.&lt;/p&gt;

&lt;p&gt;Without going too much into details why these things happen (bad programming) I will give you a method to fix this.&lt;/p&gt;

&lt;p&gt;It is recommended to backup your databases to an external HD before doing this, this way you will have the full backup at all times. &lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;Simply run this script, your databases (all of them) will shrink the log file, creating more room on the HD for you to use.&lt;/p&gt;

&lt;p&gt;Good luck&lt;/p&gt;
&lt;script src='http://gist.github.com/267427.js' /&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">The .net myth balloon exploding</title>
    
      <link href="http://kensodevkensodev.com/2009/11/12/the-net-myth-balloon-exploding"/>
    
    <id>http://kensodevkensodev.com/2009/11/12/the-net-myth-balloon-exploding</id>
    <updated>2009-11-12T19:50:41+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2009/11/12/the-net-myth-balloon-exploding/surprise/' rel='attachment wp-att-290'&gt;&lt;img alt='bursting the .net rumors bubble' class='alignleft size-thumbnail wp-image-290' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000008504500XSmall-150x150.jpg' title='bursting the .net rumors bubble' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Also, you probably know that I do love to code .net and create amazing application with these technologies and frameworks MS are putting out into the market for years now.&lt;/p&gt;

&lt;p&gt;Frankly, I&amp;#8217;ve seen the myths about .net being written about, talked about and the buzz is out there. .net is being trashed talked at about every open source community out there. recently I started coding with Ruby On Rails and I was absolutely shocked by the myth&amp;#8217;s that are going on in that online community of developers.&lt;/p&gt;

&lt;p&gt;So, in this post I will take each point and act as a myth buster :-) It&amp;#8217;s going to be interesting&amp;#8230;&lt;/p&gt;
&lt;!--more--&gt;&lt;h3&gt;If I code asp.net my code will only fit IE and will not be in the new standards&lt;/h3&gt;
&lt;p&gt;You probably guessed it but this myth is not true, it exists since the beginning of time with .net 1.1 and the controls you dragged and dropped into the HTML which created ugly HTML.&lt;/p&gt;

&lt;p&gt;Since then .net has grown, nowadays you can write you own HTML, every control that exists in web-Forms like the grid or data-list are now creating totally customizable code which you can write css for and have your own way of work with.&lt;/p&gt;

&lt;p&gt;.net mvc did even better, you can write you own templates, even the default code generated by the templates is OK, it&amp;#8217;s not great but it&amp;#8217;s not ugly as well, comparing it to the code the Scaffolding feature of ROR created it&amp;#8217;s pretty much the same stuff.&lt;/p&gt;

&lt;p&gt;If you know what you want to create and you don&amp;#8217;t use Controls when clean lean and mean HTML is needed your code will be clean, readable, validated and you&amp;#8217;ll love it. &lt;h3&gt;.net is SLOW&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/12/the-net-myth-balloon-exploding/istock_000006457005xsmall/' rel='attachment wp-att-292'&gt;&lt;img alt='slow' class='size-full wp-image-292 alignleft' height='101' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000006457005XSmall.jpg' title='slow' width='153' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one actually makes me laugh every time, .net code is compiled (if you want) and if you know what you are doing the code is super fast, super efficient and in tests I&amp;#8217;ve made and in test&lt;a href='http://twitter.com/misfitgeek'&gt; @misfitgeek&lt;/a&gt; published on his blog .net wins in most cases.&lt;/p&gt;

&lt;p&gt;You can argue both ways here really, you can say the tests were made on MS servers and not on Linux but that doesn&amp;#8217;t change the fact that even if there is a difference it won&amp;#8217;t be noticeable to your client&amp;#8217;s.&lt;/p&gt;

&lt;p&gt;If you keep your code clean on server side, if you intelligently divide your calls to the database so you won&amp;#8217;t access it 200 time on page load (seen that happening I swear) then your code will be fast.&lt;/p&gt;

&lt;p&gt;The ability to work side by side with &lt;a href='http://www.kensodev.com/tag/sql/' title='SQL'&gt;SQL&lt;/a&gt; (all versions) is also an advantage with speed. &lt;h3&gt;I have to work with an expensive IDE&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/12/the-net-myth-balloon-exploding/istock_000008650446xsmall/' rel='attachment wp-att-293'&gt;&lt;img alt='expensive' class='alignleft size-thumbnail wp-image-293' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000008650446XSmall-150x150.jpg' title='expensive' width='150' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, this is also a very ugly myth meant to discourage the use of .net. Today MS released an amazing IDE that is totally free of charge it is called Visual Web Developer Express and it is a free version of Visual Studio (with some features missing).&lt;/p&gt;

&lt;p&gt;You can work with this IDE on small or on huge and complex websites, it does not limit you to the level that you can&amp;#8217;t do something, some things are harder than with Visual Studio but it&amp;#8217;s definitely possible.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve used this IDE for about a year and I enjoyed working with it very much, when comparing it to other environments and languages which IDE&amp;#8217;s cost hundreds of dollars it wins every time.&lt;/p&gt;

&lt;p&gt;BTW, Visual studio and Visual Web Developer are in my opinion the total best IDE&amp;#8217;s out there, the experience of development and debugging is absolutely amazing and easy. &lt;h3&gt;I can't be agile with .net&lt;/h3&gt; Hmm&amp;#8230; If someone will explain this myth to me I&amp;#8217;ll think i&amp;#8217;ll burst it in a second :-) You can. You can. We can, yes! We can!&lt;/p&gt;

&lt;p&gt;You can be agile when developing .net just as much like when you are using &lt;a href='http://www.kensodev.com/category/ruby-on-rails/' title='Ruby on Rails'&gt;Ruby on Rails&lt;/a&gt; or PHP or any other language or framework. &lt;h3&gt;With .net development is slow&lt;/h3&gt; HA, .net development is not slow for a very long time now, with .net MVC, nHibernate, code generation templates, LINQ you can be super fast, super efficient coder.&lt;/p&gt;

&lt;p&gt;just take a look at the new MVC screencasts on the asp.net website by microsoft, sure, the screencasts never show the best practice and rush to coding just to explain the point but, you can code just as fast with Interfaces, TDD and every other best practice you may know.&lt;/p&gt;

&lt;p&gt;Imagine yourself as a commander in the army, when you go to a mission you have to choose the soldiers carefully right?&lt;/p&gt;

&lt;p&gt;Right.&lt;/p&gt;

&lt;p&gt;Well, .net is exactly like that, if you go to a mission and select the right troops your coding experience will be best, if you don&amp;#8217;t you can expect problems, it&amp;#8217;s the same in ROR, PHP and others&amp;#8230; &lt;h3&gt;Conclusion&lt;/h3&gt; There are more myths, some of them aren&amp;#8217;t worth taking the time to answer and some I don&amp;#8217;t even remember but every myth can by busted especially with the rapid and ever developing .net.&lt;/p&gt;

&lt;p&gt;If you have a comment, feel free&amp;#8230;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">The (natural) combination between ROR and flex</title>
    
      <link href="http://kensodevkensodev.com/2009/11/06/the-natural-combination-between-ror-and-flex"/>
    
    <id>http://kensodevkensodev.com/2009/11/06/the-natural-combination-between-ror-and-flex</id>
    <updated>2009-11-06T23:40:14+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2009/11/06/the-natural-combination-between-ror-and-flex/istock_000009617085xsmall/' rel='attachment wp-att-275'&gt;&lt;img alt='Rails' class='alignleft size-thumbnail wp-image-275' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000009617085XSmall-150x150.jpg' title='Rails' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;I started thinking how does these 2 technologies combine together, Ruby on rails on the server side and flex on the client side, I found the combination to be very natural and easy, you can actually get quite a bit of satisfaction from combining these 2 together.&lt;/p&gt;

&lt;p&gt;I know I did, and in this post I will show you how to build a phone book application where you can create new records in your phone book and have an HTML client side and FLEX client side with only just about 10 minutes of work. &lt;!--more--&gt; &lt;h3&gt;What will we create over here?&lt;/h3&gt; Well, like I said, we will be creating a phone book application, we will store data on server side and we will consume this data via a flex application on the client side.&lt;/p&gt;

&lt;p&gt;The time-frame for creating this application ia about 10 minutes.&lt;/p&gt;

&lt;p&gt;So, let&amp;#8217;s begin.&lt;/p&gt;

&lt;p&gt;First, I&amp;#8217;m going to create a new rails project by using the rails command, the &amp;#8220;/projects/rails&amp;#8221; is just a folder on my computer while you can actually use whatever folder you prefer for this. Here&amp;#8217;s the command: &lt;script src='http://gist.github.com/228279.js' /&gt; Now we have a rails template project and we are in the folder. We will create a scaffold for our phone_book table like so: &lt;script src='http://gist.github.com/228282.js' /&gt;&lt;/p&gt;

&lt;p&gt;Notice I did not mess with database configuration or anything, I simply used the rails default configuration for this simple project, if you want to use mySQL or any other server you should edit the database.yml file.&lt;/p&gt;

&lt;p&gt;now, we have our database ready and because we created a scaffold we also have pages for creating, deleting, updating and listing the phones in our database. Let&amp;#8217;s start our server and go to the page.&lt;/p&gt;

&lt;p&gt;This is the command for it and the output from the terminal: &lt;script src='http://gist.github.com/228287.js' /&gt; Now that we navigate our browser to http://0.0.0.0:3000/phones/ we can see our list page, it is of course empty and we should create a number of sample records in order to have data to work with. I created 2 records in my phone book and this is what my page looks like: &lt;a href='http://www.kensodev.com/2009/11/06/the-natural-combination-between-ror-and-flex/screen-shot-2009-11-06-at-11-24-15-pm/' rel='attachment wp-att-281'&gt;&lt;img alt='Screen shot 2009-11-06 at 11.24.15 PM' class='aligncenter size-medium wp-image-281' height='187' src='http://www.kensodev.com/wp-content/uploads/2009/11/Screen-shot-2009-11-06-at-11.24.15-PM-300x187.png' title='Screen shot 2009-11-06 at 11.24.15 PM' width='300' /&gt;&lt;/a&gt; Now, this is of course our HTML client side, we can edit the code to make it look nicer and add CSS + &lt;a href='http://www.kensodev.com/tag/javascript/' title='JavaScript'&gt;JavaScript&lt;/a&gt;, because this application is just for learning how easy it is to create a rails back-end for a flex client side. We will not focus on making it look nicer, I promise to write more posts on this issue. OK, so for the flex to consume this list it has to be in a known format like XML or json, lets look at the phones_controller that was generated by the scaffold command we created earlier. Remmember I did not write a single line of code myself, I just used rails commands so this code was written for me. This is what it look like: &lt;script src='http://gist.github.com/228294.js' /&gt;&lt;/p&gt;

&lt;p&gt;What does that mean?&lt;/p&gt;

&lt;p&gt;Does it mean that if I type phones.xml instead of /phones I will get an XML representing my phones list, lets give it a go and see what is happening.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2009/11/06/the-natural-combination-between-ror-and-flex/screen-shot-2009-11-06-at-11-24-04-pm/' rel='attachment wp-att-282'&gt;&lt;img alt='Screen shot 2009-11-06 at 11.24.04 PM' class='aligncenter size-medium wp-image-282' height='187' src='http://www.kensodev.com/wp-content/uploads/2009/11/Screen-shot-2009-11-06-at-11.24.04-PM-300x187.png' title='Screen shot 2009-11-06 at 11.24.04 PM' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;Well, yes it does, we have an XML that represents the list of phones in our database, this is of course dynamic and every phone entry we will created in our database will be added to that XML.&lt;/p&gt;

&lt;p&gt;Believe it or not we are done with server side, we have created a phone book (basic) application where we can add, delete, update and list our phones, we created an XML file that can be consumed by a number of other applications. &lt;h3&gt;Client side&lt;/h3&gt; Now, let&amp;#8217;s create a client side for out application. I&amp;#8217;ll be using flex builder 3 to create a flex client side.&lt;/p&gt;

&lt;p&gt;We will start by creating a new project, just the old regular file&amp;#8211;&amp;#62;new&amp;#8211;&amp;#62;Project, select a location for you project and open up the main.mxml file of your application.&lt;/p&gt;

&lt;p&gt;First, let&amp;#8217;s see what we need. &lt;ul&gt;
	&lt;li&gt;HTTP service for getting the data out of the server&lt;/li&gt;
	&lt;li&gt;An XML object to cache the data inside the application&lt;/li&gt;
	&lt;li&gt;Datagrid to show this data&lt;/li&gt;
&lt;/ul&gt; Let&amp;#8217;s start&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s create a listner for the creationComplete Event, create the HTTP service and attach needed event to it, when the service return result let&amp;#8217;s fill our XML from that result.&lt;/p&gt;

&lt;p&gt;Your code now looks like this&lt;/p&gt;
&lt;script src='http://gist.github.com/228304.js' /&gt;
&lt;p&gt;As you can see our entire application is less then 50 lines of code.&lt;/p&gt;

&lt;p&gt;We get sorting, column ordering out of the box when using flex This is what our application looks like:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/2009/11/06/the-natural-combination-between-ror-and-flex/screen-shot-2009-11-06-at-11-37-27-pm/' rel='attachment wp-att-283'&gt;&lt;img alt='flex application on rails' class='aligncenter size-medium wp-image-283' height='187' src='http://www.kensodev.com/wp-content/uploads/2009/11/Screen-shot-2009-11-06-at-11.37.27-PM-300x187.png' title='flex application on rails' width='300' /&gt;&lt;/a&gt;
&lt;p&gt;That&amp;#8217;s it, our application is ready and working, you can go ahead and add some more phones, delete and see how it affects your flex client side.&lt;/p&gt;

&lt;p&gt;The options are huge when combining these 2 powerfull technologies together, I love working with these and you will as well, I promise you.&lt;/p&gt;

&lt;p&gt;Feel free to comment and let me know what you think, hope you enjoyed.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Stop chasing that green light</title>
    
      <link href="http://kensodevkensodev.com/2009/11/04/stop-chasing-that-green-light"/>
    
    <id>http://kensodevkensodev.com/2009/11/04/stop-chasing-that-green-light</id>
    <updated>2009-11-04T20:29:34+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2009/11/04/stop-chasing-that-green-light/istock_000009156726xsmall/' rel='attachment wp-att-270'&gt;&lt;img alt='Green light' class='alignleft size-thumbnail wp-image-270' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000009156726XSmall-150x150.jpg' title='Green light' width='150' /&gt;&lt;/a&gt;&lt;a href='http://www.mattcutts.com/blog/'&gt;Matt Cutts&lt;/a&gt;
&lt;p&gt;DO NOT break your head struggling with getting your code to validate, I will exaplain some more about my opinion in this post.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;Well, I&amp;#8217;m a clean code kinda guy. I like to write clean lean code both on server side and on client side, although I do not put all my efforts into getting that green light from the W3C validation. &lt;h3&gt;WHY?&lt;/h3&gt; Well, it&amp;#8217;s mainly because I believe (and now my beliefs are backed by Google) that valid code does not push you forward not in search results and not even in client flowing to your website.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve seen websites in the last 10 months or so that are build with tables but validate, these sites had the W3C valid icon on the footer and that is just plain stupid. &lt;h3&gt;WHY?&lt;/h3&gt; Because semantic code, not using tables for building the website, creating the proper tag for the right place and more are more important for me (and for you).&lt;/p&gt;

&lt;p&gt;Accesibility is a bigger issue in my opinion, I would love to see labels being coupled with a inputs and fieldset surrounding logical parts of your forms and more. &lt;h3&gt;SO?&lt;/h3&gt; Well, first let&amp;#8217;s say that I&amp;#8217;m not saying you should not validate your code, you should pass it through the validator, even to just check that the images you have are with alt tags and that you don&amp;#8217;t have duplicate tags and stuff like that. &lt;h3&gt;Balancing...&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/04/stop-chasing-that-green-light/balance/' rel='attachment wp-att-271'&gt;&lt;img alt='Balance' class='aligncenter size-full wp-image-271' height='293' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000003501724XSmall.jpg' title='Balance' width='410' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should really balance the amount of time you invest in getting your code to validate, take some of that time and put it into actually writing semantic code.&lt;/p&gt;

&lt;p&gt;Think about the accesibility of your website.&lt;/p&gt;

&lt;p&gt;What I do every single time is: I&amp;#8217;m using firefox to disable the css and js of my website, I take the time to see whether my website still remains in logical structure that I intended it to be.&lt;/p&gt;

&lt;p&gt;I check to see if I have the links in the right place, If I can navigate my way through the website using the keyboard.&lt;/p&gt;

&lt;p&gt;When I have the demand, I also check the website blind-folded (literally), I check the website with a screen-reader and listen to it.&lt;/p&gt;

&lt;p&gt;If I would have invested all of my time to see that green light I promised you, some of these checkpoints and tests would have been unlooked.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;d love to hear your opinion on this, feel free to comment or even reply to me via &lt;a href='http://www.twitter.com/KensoDev'&gt;Twitter&lt;/a&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Scaling a real life messaging application</title>
    
      <link href="http://kensodevkensodev.com/2009/11/03/scaling-a-real-life-messaging-application"/>
    
    <id>http://kensodevkensodev.com/2009/11/03/scaling-a-real-life-messaging-application</id>
    <updated>2009-11-03T01:11:09+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2009/11/03/scaling-a-real-life-messaging-application/istock_000009154776xsmall/' rel='attachment wp-att-259'&gt;&lt;img alt='server farm' class='alignleft size-thumbnail wp-image-259' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000009154776XSmall-150x150.jpg' title='server farm' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;Well, this was exactly the case with a client of mine, the client is a forex company, they had 2K concurrent users and they are currently in the process of redesigning the client application and plan to grow up to 20K concurrent users.&lt;/p&gt;

&lt;p&gt;This is a classic job for me, it&amp;#8217;s what I do. It&amp;#8217;s a different company with different needs, so, in this post I will give you the solution I gave the company without revealing details about the company of course&lt;!--more--&gt; &lt;h3&gt;What do you need to deal with?&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/03/scaling-a-real-life-messaging-application/planning_the_software_needs-2/' rel='attachment wp-att-261'&gt;&lt;img alt='planning the software needs' class='alignnone size-full wp-image-261' height='366' src='http://www.kensodev.com/wp-content/uploads/2009/11/planning_the_software_needs1.jpg' title='planning the software needs' width='550' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always, I started with a pen and a paper, sitting down with the company&amp;#8217;s CTO, understanding the need of the software from the hardware.&lt;/p&gt;

&lt;p&gt;This is a most important stage for me, learning to listen to the guys that hired you for the consulting is not always easy but let me tell you this, they know their product better then you, even if the design is not the best, even if it has flaws they know it better then you will ever do in the short time you are there for consulting.&lt;/p&gt;

&lt;p&gt;OK, after that being said, let&amp;#8217;s continue&amp;#8230;&lt;/p&gt;

&lt;p&gt;So, the software needs are like so: &lt;ul&gt;
	&lt;li&gt;messaging from server to client&lt;/li&gt;
	&lt;li&gt;latency is out of the question&lt;/li&gt;
	&lt;li&gt;custom load balancing based on decision (20% load is OK or 80%???)&lt;/li&gt;
	&lt;li&gt;amount of messages --&amp;gt; 2-4 messages a second per client&lt;/li&gt;
&lt;/ul&gt; As you probably understand, these demands are huge for a 20K concurrent users application. I accepted the challenge and went to designing the solution. &lt;h3&gt;planning&lt;/h3&gt; This application is based on high volumes, the volumes can vary at times. because this is a forex based application there are times that the messaging is dead. Meaning there is not much movement and there is time that the application should supply 2-4 messages a second to each client.&lt;/p&gt;

&lt;p&gt;And another surprise: The data is personal so you can&amp;#8217;t use a shared cached object. Delightful.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s attack it each section at a time, shall we? &lt;h4&gt;Messaging from client to server (push)&lt;/h4&gt; I chose to use MSMQ based application. Basically you push messages into a queue of messages, the messages are then pulled from the queue by the appropriate application or in our case (as you will see next) appropriate server. &lt;h4&gt;Custom load balancing based on decision&lt;/h4&gt; Well, this is a tricky one, usually what you do in the client application is hard-code a server URI inside your code, this means if you want to make proper scaling you should create different versions of the application for each server right? WRONG!&lt;/p&gt;

&lt;p&gt;The solution is like so&amp;#8230;&lt;/p&gt;

&lt;p&gt;Inside the server cluster there will be a &amp;#8220;decision server&amp;#8221;, this server will manage all the other servers in the cluster. Each time a user is trying to connect, the application first tries to connect to that &amp;#8220;decision server&amp;#8221;, this server looks at it&amp;#8217;s DB (you built) and sees the load on each server, the server then decides based on the allowed load which server he should lead you to and simply gives you the URI, the application takes this URI returned as a string and connects.&lt;/p&gt;

&lt;p&gt;No Worries, I will explain more, but this is exciting ain&amp;#8217;t it?? :-) &lt;h4&gt;Amount of messages --&amp;gt; 2-4 messages a second per client&lt;/h4&gt; Well, we will see about that in a second. &lt;h3&gt;The solution (Explained)&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/03/scaling-a-real-life-messaging-application/messaging_server_for_blog/' rel='attachment wp-att-262'&gt;&lt;img alt='messaging diagram' class='aligncenter size-medium wp-image-262' height='258' src='http://www.kensodev.com/wp-content/uploads/2009/11/messaging_server_for_blog-300x258.png' title='messaging diagram' width='300' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, let&amp;#8217;s explain this for you. &lt;h4&gt;The decision server&lt;/h4&gt; The decision server is just an HTTP service connected to an SQL server (can be express), this SQL server holds the servers it has in the cluster and a connection count.&lt;/p&gt;

&lt;p&gt;The connection count is calculated to decide on the load, this is just simple math and based on experience with the system, the system can learn and the system admin can teach it.&lt;/p&gt;

&lt;p&gt;If the server failed after 2000 connection then this is 100% load, the admin sets the system for 40%, that or whatever other number he wants.&lt;/p&gt;

&lt;p&gt;Hmm&amp;#8230; Interesting right?&lt;/p&gt;

&lt;p&gt;Right, this is a custom service and so simple it&amp;#8217;s unbelivable. Now, you are probably wondering that this is one server handling all the load right?&lt;/p&gt;

&lt;p&gt;Well, no, this server is kicked into action only the first time a user connects to the system per sessio. After the decision server returned the URI to the users, the user will never get to that server again unless he disconnects and tries to connect again. &lt;h4&gt;The messaging server&lt;/h4&gt; The messaging server is based on WebOrb.net excellent messaging application, this application can conect to a queue of messages, whether the queue is local or remote.&lt;/p&gt;

&lt;p&gt;This is actually a pretty intuitive ready solution for you, you don&amp;#8217;t have to custom program anthing, the WebOrb application is pretty solid and handlers a large amount of connections per server &lt;h4&gt;The client&lt;/h4&gt; The client application is stupid, it has no logic to select the server, it connects to the server (decision) and gets a URI, after that URI is in the application it holds it in cache or as a static variable so it won&amp;#8217;t have to go back to the service for it. &lt;h4&gt;Single point of failure?&lt;/h4&gt; As you noticed (or not) there is a single point of failure in the system right?&lt;/p&gt;

&lt;p&gt;Well yes, there is. The decision server is a single point of failure, if it fails to load or fails to return a URI the system won&amp;#8217;t work.&lt;/p&gt;

&lt;p&gt;To overcome this issue I simply added another server as a fallback, if you connect them with a load balance soltion you get also load control but that&amp;#8217;s (at least for my solution) is an over kill. &lt;h3&gt;Testing&lt;/h3&gt; When testing this cluster / server / client solution we got amazing results, the servers are at 20% load, the scaling is horizontal and you can connect another server any time you want, thus creating another place for your users to connect to and instantly enabling more connections to your service. &lt;h3&gt;Conclusion&lt;/h3&gt; This was a very good project for me, I succeeded with my mission and I hope you took some info from what I did.&lt;/p&gt;

&lt;p&gt;Feel free to comment.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">How to become a professioal developer (1)</title>
    
      <link href="http://kensodevkensodev.com/2009/11/02/how-to-become-a-professioal-developer-1"/>
    
    <id>http://kensodevkensodev.com/2009/11/02/how-to-become-a-professioal-developer-1</id>
    <updated>2009-11-02T20:18:15+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='' class='alignleft size-thumbnail wp-image-247' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000008873087XSmall.jpg' style='padding: 3px;' width='150' /&gt;
&lt;p&gt;I was very impressed and took great notes from &lt;a href='http://www.objectmentor.com/omTeam/martin_r.html' target='_blank'&gt;Uncle Bob&lt;/a&gt; before writing this post, but this post also comes from the heart after seeing more than a couple of teams struggling, freelancers loosing clients and more&amp;#8230;&lt;/p&gt;

&lt;p&gt;This post will be written point after point, I will explain each of these points in my language and give you examples from real life, where I saw things went wrong and how you can improve them in your own micro-cosmus.&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;OK, let&amp;#8217;s see, you are a developer. Freelance or you are working inside a team in a big company, this doesn&amp;#8217;t really matter, all you should do is follow these steps and I guarantee you will become better at whatever it is that you do.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s start shall we? &lt;h3&gt;Discipline&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/02/how-to-become-a-professioal-developer-1/istock_000005427466xsmall/' rel='attachment wp-att-251'&gt;&lt;img alt='iStock_000005427466XSmall' class='alignleft size-thumbnail wp-image-251' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000005427466XSmall-150x150.jpg' title='iStock_000005427466XSmall' width='150' /&gt;&lt;/a&gt;Uncle bob really talks about this a lot, I really agree with him and I think this is where it all starts, you should adopt a series of disciplines. Something like I write a test every day to get better at TDD (&lt;a href='http://weblogs.asp.net/ROsherove/'&gt;Roy Oshrove&lt;/a&gt; calls this TDD Kata).&lt;/p&gt;

&lt;p&gt;I personally have my own discipline wall in my home office, this wall contains post-it notes with stuff like &amp;#8220;I will always deliver on time&amp;#8221;, &amp;#8220;Answer every question like it&amp;#8217;s the first time you answer it&amp;#8221; and more.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m not saying any of these will fit you but I think you know what will fit you, whether it&amp;#8217;s a TDD Kata or notes to yourself or anything that pops into your mind. &lt;h3&gt;Short Iterations&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/02/how-to-become-a-professioal-developer-1/istock_000005971338xsmall-2/' rel='attachment wp-att-252'&gt;&lt;img alt='Short iterations' class='alignleft size-thumbnail wp-image-252' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000005971338XSmall1-150x150.jpg' title='Short iterations' width='150' /&gt;&lt;/a&gt;I always work in short iterations with my clients, I never take a 3 month project and deliver it after 3 month time it is due. A project schedule looks like this. SC &amp;#8211;&amp;#62; Sign contract&lt;/p&gt;

&lt;p&gt;SC + 4 &amp;#8211;&amp;#62; Detailed design document SC + 6 &amp;#8211;&amp;#62; Approval of design document SC + 12 &amp;#8211;&amp;#62; Admin system wireframe SC + 15 &amp;#8211;&amp;#62; Website wireframe&lt;/p&gt;

&lt;p&gt;It goes on like this until 3 months are due and the project is done and ready, the client is happy why???&lt;/p&gt;

&lt;p&gt;Well, the client is happy because he could and did give out comments about the progress at any point, he has the feeling (true) that this website is his and not done by an outsider, this website I created has the client&amp;#8217;s say in it and it shows.&lt;/p&gt;

&lt;p&gt;This of course is not only true for websites, I do this the same with Flex applications and API&amp;#8217;s I create.&lt;/p&gt;

&lt;p&gt;Note: This does not mean you overwhelm your client with details about what query method to use, using Nhibernate or Subsonic, keep the minor technical details to yourself :-) &lt;h3&gt;Don't get stuck&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/02/how-to-become-a-professioal-developer-1/istock_000001963185xsmall/' rel='attachment wp-att-253'&gt;&lt;img alt='Stuck developers' class='alignleft size-thumbnail wp-image-253' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000001963185XSmall-150x150.jpg' style='padding: 3px;' title='Stuck developers' width='150' /&gt;&lt;/a&gt;Sometime I see whole teams in a company sitting and telling me at a consulting meeting &amp;#8220;QA did not complete the report&amp;#8221; so we don&amp;#8217;t know what is wrong with the system and we can&amp;#8217;t continue.&lt;/p&gt;

&lt;p&gt;In other cases I see developers sit for hours waiting for another team of developers to finish a module they have to use to continue work.&lt;/p&gt;

&lt;p&gt;The only problem is that same developer / team of developers have hundreds of other things to do, from bugs in their bug tracking system to tests they still did not implement and more.&lt;/p&gt;

&lt;p&gt;Do not sit around doing nothing, whatever you do it will be better than doing nothing, even if you write an MVC application to learn MVC it&amp;#8217;s better than nothing.&lt;/p&gt;

&lt;p&gt;I swear to you I have seen developers email something like this: &lt;blockquote&gt;I cannot continue the work I'm supposed to do because XXX did not supply the API for the YYY module, I will continue work tomorrow, hopefully I will have the module ready by then.&lt;/blockquote&gt; Well, do you think after this module is ready this developer can notify &amp;#8220;finished&amp;#8221; on this project, I don&amp;#8217;t think so, in-fact, I consulted to that company for a couple of month&amp;#8217;s so I know that for a fact. &lt;h3&gt;Avoid Coupling&lt;/h3&gt; &lt;a href='http://www.kensodev.com/2009/11/02/how-to-become-a-professioal-developer-1/metal-puzzle-1/' rel='attachment wp-att-254'&gt;&lt;img alt='coupling' class='alignleft size-thumbnail wp-image-254' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000002005320XSmall-150x150.jpg' style='padding: 3px;' title='coupling' width='150' /&gt;&lt;/a&gt;Seperate yourself and your teams from other developers and other teams, do not allow for your work to be dependent on any one or anything else other then you and your team, if a software design from management includes module coupling between you and another team something is wrong, no good can come out of this, tests will not be written and work will never be done on time.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve seen a developer from a company that got help from an outsourced developer, he sent the developer the source code and then declared he cannot continue because the other developer must finish, that is not true, if this company would have used version control then they could have let the outsourced developer write a patch and then commit it into their application.&lt;/p&gt;

&lt;p&gt;This is also true when talking about programming but I will not get into that in this post.&lt;/p&gt;

&lt;p&gt;Well, chew on this for a day or two, I will publish the next post in the series in a couple of days, If you have any comment I would love it if you comment here on this blog or twit me &lt;a href='http://www.twitter.com/kensodev'&gt;@kensodev&lt;/a&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Synchronize Client Application using flex/WebOrb.net</title>
    
      <link href="http://kensodevkensodev.com/2009/11/01/synchronize-client-application-using-flexweborb-net"/>
    
    <id>http://kensodevkensodev.com/2009/11/01/synchronize-client-application-using-flexweborb-net</id>
    <updated>2009-11-01T22:50:55+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='iStock_000001422752XSmall' border='0' height='120' src='http://www.kensodev.com/wp-content/uploads/2009/11/iStock_000001422752XSmall.jpg' style='margin: 2px; float: left; border-width: 0px;' width='154' /&gt;
&lt;p&gt;Let&amp;#8217;s say you have a client that&amp;#8217;s requesting an application for his sales team. He wants a special screen displaying the calls from clients and the client&amp;#8217;s request taken by the secretary.&lt;/p&gt;

&lt;p&gt;In addition, the client does not want to &amp;#8220;refresh&amp;#8221; the page, he wants it displayed the second it happens. I will show you a way to do this in minutes using WebOrb.net / flex and visual Studio.&lt;/p&gt;
&lt;!--more--&gt;&lt;h3&gt;Planning (Equipment)&lt;/h3&gt;&lt;ol&gt;
	&lt;li&gt;WebOrb installed on machine (Go now and download from the link below)&lt;/li&gt;
	&lt;li&gt;&lt;a href='http://www.kensodev.com/tag/flex-builder/'&gt;Flex builder&lt;/a&gt; 3&lt;/li&gt;
	&lt;li&gt;Visual studio or visual web developer express&lt;/li&gt;
	&lt;li&gt;good mood :-)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you are not familiar with the amazing product called &lt;a href='http://www.themidnightcoders.com/products/weborb-for-net/overview.html' target='_blank'&gt;WebOrb.net&lt;/a&gt; you should really read about it some more.&lt;/p&gt;

&lt;p&gt;I already installed WebOrb newest version on my machine and I will simply start this post from the point that the server is installed and configured. I do plan to post a series of posts about this product - the first one will also include installation and configuration.&lt;/p&gt;

&lt;p&gt;If you need any help or explanations for now, please go to MidnightCoders website and have a look at this great tutorial &lt;a href='http://www.themidnightcoders.com/products/weborb-for-net/developer-den/technical-articles/installing-weborb-on-vista-iis-7-install.html' target='_blank'&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After installing the application and navigating to &lt;a href='http://localhost/weborb30'&gt;http://localhost/weborb30&lt;/a&gt; you see the weborb admin console.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009215336.png'&gt;&lt;img alt='01-11-2009 21-53-36' border='0' height='430' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009215336_thumb.png' style='display: inline; border-width: 0px;' title='01-11-2009 21-53-36' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;Now, the application is installed on the server. Lets move along and create our database shall we?&lt;/p&gt;

&lt;p&gt;I created a database called Sales, I will create a table called sales_leads like shown in this image here.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009215931.png'&gt;&lt;img alt='01-11-2009 21-59-31' border='0' height='380' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009215931_thumb.png' style='display: inline; border-width: 0px;' title='01-11-2009 21-59-31' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;By the way, I&amp;#8217;m using a sql express 2008 database, but you can use any database you may want.&lt;/p&gt;

&lt;p&gt;If you cannot understand from the picture, here is the table creation script so you can better understand and so you can copy+paste for your convenience.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;sql&lt;/span&gt; USE &lt;span&gt;Sales&lt;/span&gt; GO&lt;/p&gt;

&lt;p&gt;/****** Object: Table &lt;span&gt;dbo&lt;/span&gt;.&lt;span&gt;sales_leads&lt;/span&gt; Script Date: 11/01/2009 22:01:48 ***&lt;strong&gt;&lt;em&gt;/ SET ANSI_NULLS ON GO&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SET QUOTED_IDENTIFIER ON GO&lt;/p&gt;

&lt;p&gt;CREATE TABLE &lt;span&gt;dbo&lt;/span&gt;.sales_leadsleadID] &lt;span&gt;int&lt;/span&gt; IDENTITY(1,1) NOT NULL, &lt;span&gt;client_name&lt;/span&gt;(50) NULL, &lt;span&gt;client_phone&lt;/span&gt;(50) NULL, &lt;span&gt;comments&lt;/span&gt;(2550) NULL, CONSTRAINT &lt;span&gt;PK_sales_leads&lt;/span&gt; PRIMARY KEY CLUSTERED ( &lt;span&gt;leadID&lt;/span&gt; ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON &lt;span&gt;PRIMARY&lt;/span&gt; ) ON &lt;span&gt;PRIMARY&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;GO &lt;span&gt;/sql&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Now, we have our database ready, let&amp;#8217;s navigate our way inside the weborb admin console to Management –&amp;#62; Data Management&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009220617.png'&gt;&lt;img alt='01-11-2009 22-06-17' border='0' height='391' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009220617_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-06-17' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;In the &amp;#8220;Database&amp;#8221; section (red square) click the &amp;#8220;Add new Database&amp;#8221; icon &lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009220811.png'&gt;&lt;img alt='01-11-2009 22-08-11' border='0' height='36' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009220811_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-08-11' width='44' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next 2 dialogs are simple - Just enter your username, password, server URI and click OK. You will be prompted to select your database from the list of db&amp;#8217;s on the server.&lt;/p&gt;

&lt;p&gt;After selecting a db it should be inside the &amp;#8220;Database&amp;#8221; section (bottom left).&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221206.png'&gt;&lt;img alt='01-11-2009 22-12-06' border='0' height='244' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221206_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-12-06' width='159' /&gt;&lt;/a&gt;
&lt;p&gt;Now, this is the part where it gets to be magical :-)&lt;/p&gt;

&lt;p&gt;Select your table you want to create a model for (right now there&amp;#8217;s only one) and drag it into the main work surface&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221329.png'&gt;&lt;img alt='01-11-2009 22-13-29' border='0' height='433' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221329_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-13-29' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;A dialog will popup.&lt;/p&gt;

&lt;p&gt;Fill in the model name, server namespace, client namespace (these all are custom and you can fill in whatever naming conventions you are used to)&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s mine:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221535.png'&gt;&lt;img alt='01-11-2009 22-15-35' border='0' height='295' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221535_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-15-35' width='447' /&gt;&lt;/a&gt;
&lt;p&gt;Make sure you check the &amp;#8220;generate test drive&amp;#8221; checkbox, this will generate server side/client side code for you. After you click save, your screen should look like this:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221651.png'&gt;&lt;img alt='01-11-2009 22-16-51' border='0' height='357' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221651_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-16-51' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;Above the model name you see an icon for a zip file, click it and the code will be downloaded. This generated both server side and client side code for you.&lt;/p&gt;

&lt;p&gt;Click the build icon and then the download icon.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the file content:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221916.png'&gt;&lt;img alt='01-11-2009 22-19-16' border='0' height='446' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009221916_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-19-16' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;OK, we are half way there.&lt;/p&gt;

&lt;p&gt;Now, open the server project using visual studio, compile it, take the DLL and the config file it created and place it in the BIN folder inside weborb.&lt;/p&gt;

&lt;p&gt;Should be something like &lt;em&gt;c:\inetpub\wwwroot\weborb30\bin&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Create a flex project, place the files inside this project, build and watch the magic happen.&lt;/p&gt;

&lt;p&gt;Make sure you create a build reference to the weborb XML (Services) like so:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009223441.png'&gt;&lt;img alt='01-11-2009 22-34-41' border='0' height='412' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009223441_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-34-41' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;Here&amp;#8217;s a screenshot of the final result, every change you make, every record you add is immediately transferred to the other client.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/11/01112009224541.png'&gt;&lt;img alt='01-11-2009 22-45-41' border='0' height='446' src='http://www.kensodev.com/wp-content/uploads/2009/11/01112009224541_thumb.png' style='display: inline; border: 0px;' title='01-11-2009 22-45-41' width='554' /&gt;&lt;/a&gt;
&lt;p&gt;Usually, I publish source code with my posts, but this code was generated for me the same as it will be generated for you.&lt;/p&gt;

&lt;p&gt;Feel free to comment with questions, I will do my best to answer them. Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Bypassing the IE &amp;quot;onchange&amp;quot; bug with jQuery</title>
    
      <link href="http://kensodevkensodev.com/2009/10/20/bypassing-the-ie-onchange-bug-with-jquery"/>
    
    <id>http://kensodevkensodev.com/2009/10/20/bypassing-the-ie-onchange-bug-with-jquery</id>
    <updated>2009-10-20T19:46:00+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;a href='http://www.kensodev.com/2009/10/20/bypassing-the-ie-onchange-bug-with-jquery/internetexplorer_1/' rel='attachment wp-att-206'&gt;&lt;img alt='IE' class='size-thumbnail wp-image-206 alignleft' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/10/InternetExplorer_1-150x150.jpg' title='IE' width='150' /&gt;&lt;/a&gt;
&lt;p&gt;I absolutely love &lt;a href='http://www.jquery.com'&gt;jQuery&lt;/a&gt;! I use it daily with my client side work, putting the jQuery file into my JS library has become an automated thing I do.&lt;/p&gt;

&lt;p&gt;Well, after saying that, even jQuery can&amp;#8217;t fix all the IE bugs and quirks. Sometimes you have to bypass them with intelligence and some style&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;The bug I&amp;#8217;m talking about is the one that disables the &amp;#8220;onchange&amp;#8221; event from firing when the element still has focus.&lt;/p&gt;

&lt;p&gt;This phenomenon is absolutely frustrating when you have to react to a checkbox or a radiobutton.&lt;/p&gt;

&lt;p&gt;Well, like everything else in jQuery, after scratching my head for a second or two (or 20, or 200) I came up with this solution:&lt;/p&gt;
&lt;script src='http://gist.github.com/214459.js' /&gt;
&lt;p&gt;This works like a charm.&lt;/p&gt;

&lt;p&gt;Good luck! If you find it useful drop me a line in the comments below…&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Retrieve tweets using jQuery</title>
    
      <link href="http://kensodevkensodev.com/2009/09/27/retrieve-tweets-using-jquery"/>
    
    <id>http://kensodevkensodev.com/2009/09/27/retrieve-tweets-using-jquery</id>
    <updated>2009-09-27T12:03:00+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='Twitter Logo' class='alignleft size-thumbnail wp-image-211' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/09/Twitter_256x256-150x150.png' title='Twitter Logo' width='150' /&gt;
&lt;p&gt;As many of you out there, I&amp;#8217;m a &lt;a href='http://www.twitter.com' target='_blank'&gt;Twitter&lt;/a&gt; user too. As most of you have, I too have spent quite some time reading the Twitter API and understanding it.&lt;/p&gt;

&lt;p&gt;I stumbled upon a forum message (in Hebrew) asking how can you retrieve your (or anybody else&amp;#8217;s) tweets using JavaScript only and no server side.&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;Well, there&amp;#8217;s a way to accomplish that and it is not that complicated at all.&lt;/p&gt;

&lt;p&gt;Change the &lt;strong&gt;twitterUsername&lt;/strong&gt; var in the code to fit your username or the username you want to retrieve, please notice I took the &amp;#8220;text&amp;#8221; property only but the jSON result returns many more like:&lt;/p&gt;

&lt;p&gt;Application used, profile image, time and more.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the code, enjoy! &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;div id=&amp;quot;codeSnippetWrapper&amp;quot; style=&amp;quot;border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;&amp;quot;&amp;gt;
&amp;lt;div id=&amp;quot;codeSnippet&amp;quot; style=&amp;quot;border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum1&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   1:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;function&amp;lt;/span&amp;gt; getuserTweets() {&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum2&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   2:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;var&amp;lt;/span&amp;gt; twitterUsername = &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;KensoDev&amp;apos;&amp;lt;/span&amp;gt;;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum3&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   3:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;var&amp;lt;/span&amp;gt; twitCount = 50;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum4&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   4:&amp;lt;/span&amp;gt;     $.getJSON(&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum5&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   5:&amp;lt;/span&amp;gt;         &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;http://search.twitter.com/search.json?callback=?&amp;amp;amp;rpp=&amp;apos;&amp;lt;/span&amp;gt; + twitCount + &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;&amp;amp;amp;q=from:&amp;apos;&amp;lt;/span&amp;gt; + twitterUsername,&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum6&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   6:&amp;lt;/span&amp;gt;         &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;function&amp;lt;/span&amp;gt;(data) {&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum7&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   7:&amp;lt;/span&amp;gt;             $.each(data, &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;function&amp;lt;/span&amp;gt;(i, userTweets) {&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum8&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   8:&amp;lt;/span&amp;gt;                 &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;for&amp;lt;/span&amp;gt; (&amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;var&amp;lt;/span&amp;gt; tweet = 0; tweet &amp;amp;lt; userTweets.length; tweet++) {&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum9&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   9:&amp;lt;/span&amp;gt;                     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;if&amp;lt;/span&amp;gt; (userTweets[tweet].text !== undefined) {&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum10&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  10:&amp;lt;/span&amp;gt;                         $(&amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;body&amp;apos;&amp;lt;/span&amp;gt;).append(&amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;&amp;amp;lt;p&amp;amp;gt;&amp;apos;&amp;lt;/span&amp;gt; + userTweets[tweet].text + &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;&amp;amp;lt;/p&amp;amp;gt;&amp;apos;&amp;lt;/span&amp;gt;);&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum11&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  11:&amp;lt;/span&amp;gt;                     }&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum12&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  12:&amp;lt;/span&amp;gt;                 }&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum13&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  13:&amp;lt;/span&amp;gt;             });&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum14&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  14:&amp;lt;/span&amp;gt;         }&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum15&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  15:&amp;lt;/span&amp;gt;     );&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum16&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  16:&amp;lt;/span&amp;gt; }&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;You can of course change the tags being created, you can change the object the tags are being appended into, you can change the code to better suit your needs that&amp;#8217;s for sure.&lt;/p&gt;

&lt;p&gt;If you need any help feel free to comment on this post and I will help you as much as I can.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">xml.load problem with IE6</title>
    
      <link href="http://kensodevkensodev.com/2009/08/31/xml-load-problem-with-ie6"/>
    
    <id>http://kensodevkensodev.com/2009/08/31/xml-load-problem-with-ie6</id>
    <updated>2009-08-31T01:26:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='Flash' class='alignleft size-thumbnail wp-image-214' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/08/adobe_flash_1470_1470-150x150.jpg' title='Flash' width='150' /&gt;
&lt;p&gt;IE6 has been for a very long time an enemy for web developers because of the way it renders HTML and CSS.&lt;/p&gt;

&lt;p&gt;Fortunately, Flash has always been a rescue for me, because I develop RIA as well as HTML websites I have always enjoyed the way flash is always the same with IE6 as with other browsers.&lt;/p&gt;

&lt;p&gt;This has been the case until the first and persistent bug.&lt;!--more--&gt; &lt;h3&gt;The story&lt;/h3&gt; I created a flash player for a client using XML to load the song list, the XML is rendered from server side data.&lt;/p&gt;

&lt;p&gt;What was the problem? The problem was the XML object kept being null (undefined) even though the data came from the server. This problem appeared only in IE6, not in any other browser.&lt;/p&gt;

&lt;p&gt;I dug my code quite a bit till I figured out the solution.&lt;/p&gt;

&lt;p&gt;The &amp;#8220;Response Header&amp;#8221; for the file was not the right header and it was gZipped on demand.&lt;/p&gt;

&lt;p&gt;So, how can you solve this you ask?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;remove the gZip from this file, filter it out from the gZip of the other website&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;create the exact same response header as in this image:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/08/31082009022339.png'&gt;&lt;img alt='31-08-2009 02-23-39' border='0' height='462' src='http://www.kensodev.com/wp-content/uploads/2009/08/31082009022339_thumb.png' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='31-08-2009 02-23-39' width='492' /&gt;&lt;/a&gt;
&lt;p&gt;Remove any other HTTP header and verify that the file is not being cached at any way.&lt;/p&gt;

&lt;p&gt;As a validation I added a &lt;strong&gt;&lt;em&gt;cacheKiller&lt;/em&gt;&lt;/strong&gt; parameter at the end of the file call. &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;div id=&amp;quot;codeSnippetWrapper&amp;quot; style=&amp;quot;border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;&amp;quot;&amp;gt;
&amp;lt;div id=&amp;quot;codeSnippet&amp;quot; style=&amp;quot;border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum1&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   1:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;quot;player.asp?cacheKiller=&amp;quot;&amp;lt;/span&amp;gt;+Math.Random();&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">IsDBNull generic shortcut function</title>
    
      <link href="http://kensodevkensodev.com/2009/08/31/isdbnull-generic-shortcut-function"/>
    
    <id>http://kensodevkensodev.com/2009/08/31/isdbnull-generic-shortcut-function</id>
    <updated>2009-08-31T00:59:53+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='question-mark' class='alignleft size-thumbnail wp-image-216' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/08/question-mark-150x150.jpg' title='question-mark' width='150' /&gt;
&lt;p&gt;If you&amp;#8217;re working with data from an SQL database or from any other database for that matter you probably know the exception cause by calling the reader&lt;span&gt;&amp;#8220;columnName&amp;#8221;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This exception is exceptionally annoying because you cannot predict when it is going to happen, it depends on data from the database and can throw the exception at any time.&lt;/p&gt;

&lt;p&gt;So, while working on a code that&amp;#8217;s not mine, as you know I&amp;#8217;m a consultant so I work on other peoples code most of the time.&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;The way they worked around the issue is like so:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;csharp&lt;/span&gt; browserTarget = String.Empty;&lt;/p&gt;

&lt;p&gt;if (!currReader.IsDBNull(3)) browserTarget = currReader.GetString(3).Trim(); &lt;span&gt;/csharp&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Now, can you imagine this on every column in the DB which includes 30 columns?&lt;/p&gt;

&lt;p&gt;I had to figure out a way to make this generic and just pass it on to the other developers in the company.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/08/scrtch.jpg'&gt;&lt;img alt='scrtch' border='0' height='244' src='http://www.kensodev.com/wp-content/uploads/2009/08/scrtch_thumb.jpg' style='display: inline; border: 0px;' title='scrtch' width='196' /&gt;&lt;/a&gt;
&lt;p&gt;This is what I wrote for them&lt;/p&gt;

&lt;p&gt;and this is how you call the function&lt;/p&gt;

&lt;p&gt;&lt;span&gt;csharp&lt;/span&gt; public static class DbHelpers { public static objectType convertToGenericObject&amp;#60;objectType&amp;#62;(object readerColumn) { objectType returnValue;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;	if (!Convert.IsDBNull(readerColumn))
		returnValue = (objectType)readerColumn;
	else
		returnValue = default(objectType);
	return returnValue;
 }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;} &lt;span&gt;/csharp&lt;/span&gt;&lt;/p&gt;
&lt;strong&gt;&lt;em&gt;objectType&lt;/em&gt;&lt;/strong&gt;
&lt;p&gt;This function won&amp;#8217;t throw an exception even if the Db column is null.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Free tools for ActionScript Developers</title>
    
      <link href="http://kensodevkensodev.com/2009/08/22/free-tools-for-actionscript-developers"/>
    
    <id>http://kensodevkensodev.com/2009/08/22/free-tools-for-actionscript-developers</id>
    <updated>2009-08-22T23:28:28+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;img alt='kids-tools-05' class='alignleft size-thumbnail wp-image-218' height='150' src='http://www.kensodev.com/wp-content/uploads/2009/08/kids-tools-05-150x150.jpg' title='kids-tools-05' width='150' /&gt;
&lt;p&gt;As you know, on top of being a .NET developer and client side (HTML) developer I do quite a bit of RIA using Flash/Flex and of course ActionScript 3.&lt;/p&gt;

&lt;p&gt;Being the geek that I am loving new tools to make my life easier I found 2 tools that are free to use and work great with AS3 code.&lt;/p&gt;

&lt;p&gt;These tools can be used to develop a complete project or just classes for use with a Flash application.&lt;/p&gt;

&lt;p&gt;Here they are…&lt;!--more--&gt; &lt;h2&gt;Sepy –The ActionScript editor&lt;/h2&gt; &lt;img align='left' alt='Untitled-1' border='0' height='76' src='http://www.kensodev.com/wp-content/uploads/2009/08/Untitled1.jpg' style='margin: 0px 5px; display: inline; border: 0px;' title='Untitled-1' width='150' /&gt; Sepy is a minimal ActionScript editor, you can use it for editing .AS or .ASC files.&lt;/p&gt;

&lt;p&gt;The application is very light weight and easy to work with, it offers partial code hinting (intellisence) and code compiling but you have to download an ActionScript compiler for that.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/08/preview_project.gif'&gt;&lt;img alt='preview_project' border='0' height='399' src='http://www.kensodev.com/wp-content/uploads/2009/08/preview_project_thumb.gif' style='display: inline; border: 0px;' title='preview_project' width='520' /&gt;&lt;/a&gt;
&lt;p&gt;You can download it from &lt;a href='http://www.sephiroth.it/python/sepy.php'&gt;here&lt;/a&gt; &lt;h2&gt;FlashDevelop&lt;/h2&gt; &lt;a href='http://www.kensodev.com/wp-content/uploads/2009/08/flashdevelop.jpg'&gt;&lt;img align='left' alt='flashdevelop' border='0' height='77' src='http://www.kensodev.com/wp-content/uploads/2009/08/flashdevelop_thumb.jpg' style='margin: 0px 5px; display: inline; border: 0px;' title='flashdevelop' width='150' /&gt;&lt;/a&gt; FlashDevelop is a more advanced application.&lt;/p&gt;

&lt;p&gt;This application can create projects, search and replace in files, it offers full intellisence.&lt;/p&gt;

&lt;p&gt;The application &amp;#8220;lives&amp;#8221; in your code and knows all your classes thus can offer you code completion for properties or functions which can really make your life easier as a developer.&lt;/p&gt;

&lt;p&gt;It is also completely free.&lt;/p&gt;

&lt;p&gt;Another great feature of this app is the ability to edit .mxml (flex) files. You can edit them and export them as SWF (you should download the appropriate compiler).&lt;/p&gt;

&lt;p&gt;I use this application a lot when I&amp;#8217;m using a computer that does not have FlexBuilder installed and I need to make a quick change.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/08/23082009002305.png'&gt;&lt;img alt='23-08-2009 00-23-05' border='0' height='350' src='http://www.kensodev.com/wp-content/uploads/2009/08/23082009002305_thumb.png' style='display: inline; border: 0px;' title='23-08-2009 00-23-05' width='504' /&gt;&lt;/a&gt;
&lt;p&gt;You can download it from &lt;a href='http://www.flashdevelop.org/'&gt;here&lt;/a&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Tools for developers and power users (1)</title>
    
      <link href="http://kensodevkensodev.com/2009/08/14/tools-for-developers-and-power-users-1"/>
    
    <id>http://kensodevkensodev.com/2009/08/14/tools-for-developers-and-power-users-1</id>
    <updated>2009-08-14T23:26:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hey all,&lt;/p&gt;

&lt;p&gt;This blog post is the first out of three blog posts. These blog posts will be all about tools for developers and power users. These tools will be online services or desktop applications, most of them will have a free version or a trial version.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m working with every single one of these tools, so these recommendation are based on my own personal experience. which is always great no?&lt;/p&gt;

&lt;p&gt;Okay, let&amp;#8217;s begin. &lt;h2&gt;Online storage solution (1)&lt;/h2&gt; &lt;a href='http://www.getdropbox.com'&gt;&lt;img align='left' alt='dropbox' border='0' height='124' src='http://www.kensodev.com/wp-content/uploads/2009/08/dropbox.jpg' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='dropbox' width='170' /&gt;&lt;/a&gt; This service is a virtual &amp;#8220;box&amp;#8221; for storing your files, documents and other valuable digital data you may have.&lt;/p&gt;

&lt;p&gt;This service is different from all the other online drives in the way that it is actually a folder on your system. You don&amp;#8217;t have to log-in and log-out and there are no browsers involved here.&lt;/p&gt;

&lt;p&gt;You simply drag and drop files and those will be uploaded to your online drive.&lt;/p&gt;

&lt;p&gt;An extra thing which is also very important is that the same folder is visible on all your other computers, enabling it to be a sync solution too.&lt;/p&gt;

&lt;p&gt;All the documents you edit here will be updated everywhere else.&lt;/p&gt;

&lt;p&gt;The service comes free with 2GB of space, I am a pro user there and I enjoy it every day I use it.&lt;/p&gt;
&lt;a href='http://www.getdropbox.com'&gt;http://www.getdropbox.com&lt;/a&gt;&lt;h2&gt;Online storage solution (2)&lt;/h2&gt;&lt;a href='http://www.box.net'&gt;&lt;img align='left' alt='icon_boxlogo' border='0' height='111' src='http://www.kensodev.com/wp-content/uploads/2009/08/icon_boxlogo.jpg' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='icon_boxlogo' width='170' /&gt;&lt;/a&gt;
&lt;p&gt;The interface is very intuitive clean and neat and the upload process is made easy.&lt;/p&gt;

&lt;p&gt;You can share the link with your friends and simply email them the file you have for them online.&lt;/p&gt;

&lt;p&gt;This solution also has a free version.&lt;/p&gt;
&lt;a href='http://www.box.net'&gt;http://www.box.net&lt;/a&gt;&lt;h2&gt;Time Tracking&lt;/h2&gt;&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/08/toggl1.png'&gt;&lt;img align='left' alt='toggl1' border='0' height='84' src='http://www.kensodev.com/wp-content/uploads/2009/08/toggl1_thumb.png' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='toggl1' width='170' /&gt;&lt;/a&gt;
&lt;p&gt;I actually use it on project I don&amp;#8217;t get paid by the hour and that way I know exactly how much time I spent.&lt;/p&gt;

&lt;p&gt;The tracking solution is divided by clients which you can also defer the fee for each of them.&lt;/p&gt;

&lt;p&gt;The solution comes with a widget that you can install on every system and log hours without using the browser.&lt;/p&gt;

&lt;p&gt;This solution is free but if you need online client reports that the clients can view you have to pay a small fee every month.&lt;/p&gt;
&lt;a href='http://www.toggl.com'&gt;http://www.toggl.com&lt;/a&gt;&lt;h2&gt;Bug Tracking&lt;/h2&gt;&lt;a href='http://www.lighthouseapp.com'&gt;&lt;img align='left' alt='5x1llz-lighthouseapp-1' border='0' height='170' src='http://www.kensodev.com/wp-content/uploads/2009/08/5x1llzlighthouseapp11.jpg' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='5x1llz-lighthouseapp-1' width='170' /&gt;&lt;/a&gt;
&lt;p&gt;The requests/bug/enhancement requests are all very confusing and you can easily get lost in the mix.&lt;/p&gt;

&lt;p&gt;Well, the LightHouseApp guys have thought of that and made this solution for you.&lt;/p&gt;

&lt;p&gt;It is a bug tracking system for your use. This system will help you track all bugs with your clients and log every message and demand.&lt;/p&gt;

&lt;p&gt;You are probably thinking what I thought at first… Who has the time to activate the website, log-in and create a new bug, it takes time.&lt;/p&gt;

&lt;p&gt;Well, you&amp;#8217;re right but this is not the case here. Every project gets an email address so you can simply email yourself a bug and your client can email you with a bug straight into the system.&lt;/p&gt;

&lt;p&gt;Each member gets all the email copies and everything works great.&lt;/p&gt;

&lt;p&gt;When you get an email you can simply reply and the bug is updated.&lt;/p&gt;
&lt;a href='http://www.lighthouseapp.com'&gt;http://www.lighthouseapp.com&lt;/a&gt;
&lt;p&gt;That&amp;#8217;s it, this is part 1 of 3&lt;/p&gt;

&lt;p&gt;Please comment if you have anything to say.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Phase 1 - first consulting meeting.</title>
    
      <link href="http://kensodevkensodev.com/2009/07/19/phase-1-first-consulting-meeting"/>
    
    <id>http://kensodevkensodev.com/2009/07/19/phase-1-first-consulting-meeting</id>
    <updated>2009-07-19T03:00:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hey all,&lt;/p&gt;

&lt;p&gt;This is the second post in the upcoming long posts series. I thought it would be a great idea to post about my experiences as an independent consultant for companies. The posts will not be about personal experiences but instead about the knowledge I&amp;#8217;m getting and passing thoughts. Whether its in the shape of a meeting, researching or sample applications&lt;/p&gt;

&lt;p&gt;If you want to learn more about the series, please head &lt;a href='http://www.kensodev.com/2009/07/15/this-is-the-beginning/' target='_blank'&gt;here&lt;/a&gt; and read.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Okay, so this is the post about the first meeting.&lt;/p&gt;
&lt;img align='left' alt='BXP28324' border='0' height='240' src='http://www.kensodev.com/wp-content/uploads/2009/07/BXP28324.jpg' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='BXP28324' width='217' /&gt;
&lt;p&gt;However, this meeting was different, the client had many questions, he wasn&amp;#8217;t sure what he wanted and how he wanted to do it. Because the client is a start-up company that deals with a lot of money and has somewhere between 20-30K users, there is no rush in their behalf (unbelievable I know), they want it done in the best possible way.&lt;/p&gt;

&lt;p&gt;So, I had no preparations as to what they want. I knew the general idea though. They have an Html client and they want to transfer to flex. That&amp;#8217;s pretty much all I knew.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;When I got there, we started talking. The first question that popped into the room was what communication method they should use. Should they use AMF/xmlSocket/Http service or what&amp;#8230;.&lt;/p&gt;

&lt;p&gt;So, lets break it down. Each method has pro&amp;#8217;s and con&amp;#8217;s. Flex has the advantage of not limiting you into a single method, you can use a couple or more methods of server side communication in a single flex application. You will need a very good team of developers and a superman project manager, but it is totally not an impossible mission, it can and it has been done before.&lt;/p&gt;

&lt;p&gt;So, lets dig further in&amp;#8230; Before stepping into the pro&amp;#8217;s and con&amp;#8217;s lets handle what they want to achieve (again, without compromising any data or even the company name).&lt;/p&gt;

&lt;p&gt;They have users, the users are divided into groups, each group can contain X amount of users (x is a variable not a constant :-)) Above the group is an organization, an organization can have X amount of groups.&lt;/p&gt;

&lt;p&gt;The data in the group is personal and cannot be compromised to other groups or users. the same goes with users of course. No data should leak between users, groups or organizations.&lt;/p&gt;

&lt;p&gt;The calculated data is group specific. Meaning each group has their financial data, the calculations are based on their data and their data only.&lt;/p&gt;

&lt;p&gt;Calculations, ok we are getting there&amp;#8230; Question by me: Does the user/Group/Organization need to do an action in order for the data to be calculated? Answer: No. The calculations are done periodically (1 time per second in average) and need to be sent to the client without him even knowing about it, the data should be updated on his screen.&lt;/p&gt;
&lt;img align='right' alt='scratching_head' border='0' height='84' src='http://www.kensodev.com/wp-content/uploads/2009/07/scratching_head.jpg' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='scratching_head' width='100' /&gt;
&lt;p&gt;Lets move forward please, lunch is almost here&amp;#8230; :-)&lt;/p&gt;

&lt;p&gt;Question: What about other data on the screen, any other data needs this amount of crazy updating or should everything else be pretty standard? Answer: The rest of the screen, containing somewhere between 10-20 parts should not be updated in these time periods. The other data is sometimes the result of a user action or a group action.&lt;/p&gt;

&lt;p&gt;Question: Should an action from a group be alerted to all the users inside it? Answer: Yes. Sometimes the group did something that caused the users to loose/gain money so they should be alerted about it.&lt;/p&gt;

&lt;p&gt;Lunch :-)&lt;/p&gt;

&lt;p&gt;Client: The final thing we want to accomplish is the ability to reach every user/group/organization separately and send them admin messages about everything from a version update to a hosting change.&lt;/p&gt;

&lt;p&gt;Okay.&lt;/p&gt;

&lt;p&gt;Great, I have my data and asked my questions (I gave you a brief version of course). Now lets start talking.&lt;/p&gt;

&lt;p&gt;1st - 1s calculated data. Method of implementation.&lt;/p&gt;

&lt;p&gt;Server - 1 Calculating server based on SQL server 2005/2008 (we will not get into the configuration) a caching solution (sometimes the data is the same as before, why should the server sweat if the data has not changed). 2 - Messaging server connecting to that Calculation server. 3 - Windows service using an XMLsocket connection based on clientIP, groupID, organizationID, when the data for an entity of those that has changed you simply push the data to them. If the data has not changed you send out nothing. The GUI at the client will not change and the NET traffic will not overflow.&lt;/p&gt;

&lt;p&gt;This way you keep it simple. You calculate the data on server 1, you send the data using server 2, connection to server 1 using a windows service which you can monitor performance.&lt;/p&gt;

&lt;p&gt;Pro&amp;#8217;s: Very rapid communication, no overflowing the servers with requests, if the data has not changed nothing happens. Just for a reference, the client implemented the same feature in their current application using a 1 second JavaScript timer and a service.&lt;/p&gt;

&lt;p&gt;Can you guess what happened? (Hint: Guess who crashed first: the server or the client)&lt;/p&gt;

&lt;p&gt;Con&amp;#8217;s: Scale up in this solution is not always easy and it isn&amp;#8217;t done just in software. You need some hardware changing too. Though in the beasts they have over there, they have time to worry about that.&lt;/p&gt;

&lt;p&gt;2nd communication - Client or group does something and data should change in the GUI. For this solution I think the &lt;a href='http://www.themidnightcoders.com/products/weborb-for-net/overview.html' target='_blank'&gt;webOrb.net&lt;/a&gt; would be perfect, you get out of the box push in HTTP while the data changed and you don&amp;#8217;t have to write any custom code for it.&lt;/p&gt;

&lt;p&gt;The &lt;a href='http://www.themidnightcoders.com/products/weborb-for-net/overview.html' target='_blank'&gt;WebOrb.net&lt;/a&gt; is a solution that lets you use AMF3 or AMF0 or RTMP communication with a Flex client. It is very robust, easily configured and even has a built in monitoring solution.&lt;/p&gt;

&lt;p&gt;Pro&amp;#8217;s: The weborb solution is hosted on top of IIS6/7 so you can configure it with the flexibility of your choice. you can write custom code, use the classes you already have in an asp.net application or generate a new application from scratch using the code generation solution. Scale up is very easy, using a load balancer and 2 servers you multiply the users that can use the system at once. Clouding: you can pass this service into the cloud at AmazonEc2 or at any other clouding service and get out of the box scale up when needed.&lt;/p&gt;

&lt;p&gt;Con&amp;#8217;s: The push is not always in a heart beat, mainly when you are talking about 20-30K users. As always in a 3rd party solution, you can&amp;#8217;t actually do ANYTHING you want.&lt;/p&gt;

&lt;p&gt;3rd Method: Admin Messages Since the messages are not meant to be urgent, (urgent messaging will be sent on the socket already connected) the most efficient thing to do is by using FileSystem on the server for every group, user, organization and have the flex client check it once every 24 hours using an http request to the file it is using. That way, the solution is not using any database in real time and will not slow down the db which is well needed on other crucial actions.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it&amp;#8230; That wasn&amp;#8217;t all of the meeting, but that&amp;#8217;s enough to chew on for this post. On the next post I will continue with the questions and answers that came up on the same meeting at this client.&lt;/p&gt;

&lt;p&gt;Some of the subjects that we will discuss on the next post:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handling disconnect&lt;/li&gt;

&lt;li&gt;Multilanguage&lt;/li&gt;

&lt;li&gt;Skins&lt;/li&gt;

&lt;li&gt;Group work&lt;/li&gt;

&lt;li&gt;SVN&lt;/li&gt;

&lt;li&gt;Flex builder versions&lt;/li&gt;

&lt;li&gt;Graphic&amp;#8217;s team brief&lt;/li&gt;

&lt;li&gt;Graphic artist&amp;#8211;developer&amp;#8211;project manager. Why? How? When? Who???&lt;/li&gt;
&lt;/ol&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">This is the beginning&amp;hellip;</title>
    
      <link href="http://kensodevkensodev.com/2009/07/15/this-is-the-beginning"/>
    
    <id>http://kensodevkensodev.com/2009/07/15/this-is-the-beginning</id>
    <updated>2009-07-15T12:45:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hey all,&lt;/p&gt;

&lt;p&gt;This post is the beginning of a series of posts.&lt;/p&gt;

&lt;p&gt;What are the posts about?&lt;/p&gt;

&lt;p&gt;Well, I just started a consulting session at a major financial start-up company. This consulting session as many of my sessions are long, they include a variety of technologies, server, client and scalability issues.&lt;/p&gt;

&lt;p&gt;As a consultant in all projects but specific in this one, I do a lot of research. I write documents and applications that prove my points and just air tight my meetings with the company team with decisions regarding their needs.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/07/815985_69949281.jpg'&gt;&lt;img align='left' alt='Get to the Point 2' border='0' height='235' src='http://www.kensodev.com/wp-content/uploads/2009/07/815985_69949281_thumb.jpg' style='display: inline; margin-left: 0px; margin-right: 0px; border: 0px;' title='Get to the Point 2' width='304' /&gt;&lt;/a&gt;
&lt;p&gt;I never work with something I have used already from another session because then you are tempted to fit a solution that is not necessarily tailor made on your client. I hate doing that. The customer is paying for more then that and I should supply the materials that are right for him.&lt;/p&gt;

&lt;p&gt;So, you are probably wondering how can I write about it.. Well, it&amp;#8217;s because I signed an NDA right and since I will not mention the company name at any point, I will not be uncovering any details that might compromise data from the company nor the code.&lt;/p&gt;

&lt;p&gt;So what will I be doing?&lt;/p&gt;

&lt;p&gt;I will share all of the applications that I build to prove my point, such as socket connection between flex 3 and a windows service, AMF using webOrb.net and more.&lt;/p&gt;

&lt;p&gt;Also, I will be testing solutions such as BlazeDS or LCDS which are the interest to many of you who are building serious enterprise application.&lt;/p&gt;

&lt;p&gt;The user base This is a real treat. The application is meant to support up to 20,000 concurrent connections and concurrent users, so scale is a really big issue here, this will be a big part in my research and the solution I will deliver.&lt;/p&gt;

&lt;p&gt;The technology .Net (2, 3.5) SQL server (2005, 2008) Flex 3 (AS3) Html, Javascript 3rd party applications and solutions like webOrb.net or other solutions&lt;/p&gt;

&lt;p&gt;A maybe FMS (Flash Media Server)&lt;/p&gt;

&lt;p&gt;The post will be long with many examples, links and many more.&lt;/p&gt;

&lt;p&gt;Feel free to comment with questions or email me at avi AT kensodev DOT com and I will try to include all of the questions in the posts&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Add a parameter (or even more then one) to Flex event listener</title>
    
      <link href="http://kensodevkensodev.com/2009/07/14/add-a-parameter-or-even-more-then-one-to-flex-event-listener"/>
    
    <id>http://kensodevkensodev.com/2009/07/14/add-a-parameter-or-even-more-then-one-to-flex-event-listener</id>
    <updated>2009-07-14T20:45:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi All,&lt;/p&gt;

&lt;p&gt;Well, sometimes you find yourself needing a work around to a default framework or language behavior.&lt;/p&gt;

&lt;p&gt;I found myself needing exactly that on an application I’m building. No matter what I did I couldn’t find a “normal” way of doing what I did.&lt;/p&gt;

&lt;p&gt;This is actually a pretty efficient way of creating your own event listener.&lt;/p&gt;

&lt;p&gt;We will talk about the button and we&amp;#8217;ll add an event listener.&lt;/p&gt;

&lt;p&gt;By default the code looks like this:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt; &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;?&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt; &lt;span class='nx'&gt;version&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mf'&gt;1.0&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;encoding&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;utf&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;8&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;?&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
 &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Application&lt;/span&gt; &lt;span class='nx'&gt;xmlns&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;http&lt;/span&gt;&lt;span class='o'&gt;://&lt;/span&gt;&lt;span class='nx'&gt;www&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;adobe&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='sr'&gt;/2006/m&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;layout&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;absolute&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;creationComplete&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;initApp&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
         &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;!&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;CDATA&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;
             &lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;controls&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;Alert&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

             &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;initApp&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
             &lt;span class='p'&gt;{&lt;/span&gt;
                 &lt;span class='nx'&gt;cmdDoAction&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;addEventListener&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nb'&gt;MouseEvent&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;CLICK&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;showAlert&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
             &lt;span class='p'&gt;}&lt;/span&gt;
             &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;showAlert&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;e&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;MouseEvent&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
             &lt;span class='p'&gt;{&lt;/span&gt;
                 &lt;span class='c1'&gt;//do something here&lt;/span&gt;
                 &lt;span class='nx'&gt;Alert&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;show&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;txtInputText&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
             &lt;span class='p'&gt;}&lt;/span&gt;
         &lt;span class='p'&gt;]]&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Button&lt;/span&gt; &lt;span class='nx'&gt;x&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;y&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;55&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;label&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Do&lt;/span&gt; &lt;span class='nx'&gt;Action&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;cmdDoAction&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;TextInput&lt;/span&gt; &lt;span class='nx'&gt;x&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;y&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;txtInputText&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
 &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Application&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, the function listening to the click event can only accept one parameter passed to it. This parameter is the event the function is listening to.&lt;/p&gt;

&lt;p&gt;Now, what if I want to do another thing: I want to pass the function another parameter. This parameter can be anything - it can be hard coded or it can come from a runtime result of the code.&lt;/p&gt;

&lt;p&gt;In the same way, you can add more then 1 parameter of course.&lt;/p&gt;

&lt;p&gt;Let us see our code now:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;?&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt; &lt;span class='nx'&gt;version&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mf'&gt;1.0&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;encoding&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;utf&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;8&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;?&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Application&lt;/span&gt; &lt;span class='nx'&gt;xmlns&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;http&lt;/span&gt;&lt;span class='o'&gt;://&lt;/span&gt;&lt;span class='nx'&gt;www&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;adobe&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='sr'&gt;/2006/m&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;layout&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;absolute&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;creationComplete&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;initApp&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
    &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
        &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;!&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;CDATA&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;
            &lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;controls&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;Alert&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

            &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;initApp&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
            &lt;span class='p'&gt;{&lt;/span&gt;
                &lt;span class='nx'&gt;cmdDoAction&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;addEventListener&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nb'&gt;MouseEvent&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;CLICK&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;e&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;MouseEvent&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
                &lt;span class='p'&gt;{&lt;/span&gt;
                    &lt;span class='nx'&gt;showAlert&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;txtInputText&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;text&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;e&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
                &lt;span class='p'&gt;});&lt;/span&gt;
            &lt;span class='p'&gt;}&lt;/span&gt;
            &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;showAlert&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;s&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;e&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;MouseEvent&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;
            &lt;span class='p'&gt;{&lt;/span&gt;
                &lt;span class='c1'&gt;//do something here&lt;/span&gt;
                &lt;span class='nx'&gt;Alert&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;show&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;s&lt;/span&gt;&lt;span class='o'&gt;,&lt;/span&gt; &lt;span class='nx'&gt;e&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;target&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;toString&lt;/span&gt;&lt;span class='p'&gt;());&lt;/span&gt;
            &lt;span class='p'&gt;}&lt;/span&gt;
        &lt;span class='p'&gt;]]&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
    &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
    &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Button&lt;/span&gt; &lt;span class='nx'&gt;x&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;y&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;55&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;label&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;Do&lt;/span&gt; &lt;span class='nx'&gt;Action&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;cmdDoAction&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
    &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;TextInput&lt;/span&gt; &lt;span class='nx'&gt;x&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;y&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;10&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;id&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;txtInputText&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;/&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Application&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now, didn’t I make you happy?&lt;/p&gt;

&lt;p&gt;Good luck and happy coding!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Number of open connections SQL server</title>
    
      <link href="http://kensodevkensodev.com/2009/06/22/number-of-open-connections-sql-server"/>
    
    <id>http://kensodevkensodev.com/2009/06/22/number-of-open-connections-sql-server</id>
    <updated>2009-06-22T17:51:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;Normally, when you&amp;#8217;re coding on a website or a system you&amp;#8217;re probably using connection to an &lt;a href='http://www.kensodev.com/tag/sql-server/' target='_blank' title='Sql Server'&gt;SQL server&lt;/a&gt; database.&lt;/p&gt;

&lt;p&gt;When you are the coder or you are a consultant coming to a company to check the code or the server or anything else for that matter, you sometimes need to check the number of connections that are open right now.&lt;/p&gt;

&lt;p&gt;This can be done to check the quality of the code regarding connections. If the code does not close the connections, eventually the server will close the pool and the website will no longer work. I have seen people solving that by upping the number of allowed open connections. That of course is not the solution (not the best solution).&lt;/p&gt;

&lt;p&gt;OK, so if you are like me and you are running 1-9 servers that are dedicated to you, each running dozens or hundreds of DB’s, this is an absolutely great method to catch a glimpse on whats going on with your connections.&lt;/p&gt;

&lt;p&gt;Run this code on your server and see what happens: &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;div id=&amp;quot;codeSnippetWrapper&amp;quot; style=&amp;quot;border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;&amp;quot;&amp;gt;
&amp;lt;div id=&amp;quot;codeSnippet&amp;quot; style=&amp;quot;border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum1&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt; 1:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;SELECT&amp;lt;/span&amp;gt; DB_NAME(dbid) &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;as&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;DbNAme&amp;apos;&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;COUNT&amp;lt;/span&amp;gt;(dbid) &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;as&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;Connections&amp;apos;&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;from&amp;lt;/span&amp;gt; master.dbo.sysprocesses &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;with&amp;lt;/span&amp;gt; (nolock)&amp;lt;/pre&amp;gt;
&amp;amp;nbsp;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum2&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt; 2:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;WHERE&amp;lt;/span&amp;gt; dbid &amp;amp;gt; 0&amp;lt;/pre&amp;gt;
&amp;amp;nbsp;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum3&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt; 3:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;GROUP&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;BY&amp;lt;/span&amp;gt; dbid&amp;lt;/pre&amp;gt;
&amp;amp;nbsp;&lt;/pre&gt;&lt;/p&gt;
&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;This code will display a list of all the databases on your server with the open connections on each of them.&lt;/p&gt;

&lt;p&gt;For security reasons I can’t show the entire result set, but here’s a sneak peak:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/06/622200965136PM.png'&gt;&lt;img alt='6-22-2009 6-51-36 PM' border='0' height='94' src='http://www.kensodev.com/wp-content/uploads/2009/06/622200965136PM_thumb.png' style='display: inline; border: 0px;' title='6-22-2009 6-51-36 PM' width='240' /&gt;&lt;/a&gt;
&lt;p&gt;** This was checked on SQL server 2005/2008 both express and full versions.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Share your local drives over RDP - Windows 7</title>
    
      <link href="http://kensodevkensodev.com/2009/06/16/share-your-local-drives-over-rdp-windows-7"/>
    
    <id>http://kensodevkensodev.com/2009/06/16/share-your-local-drives-over-rdp-windows-7</id>
    <updated>2009-06-16T22:50:57+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi All,&lt;/p&gt;

&lt;p&gt;You probably work quite a bit with RDP connections to multiple servers around the globe. I’m currently running 6 servers in Israel, 4 in the US and some more around the world.&lt;/p&gt;

&lt;p&gt;Uploading materials or downloading is sometimes quite a mission to handle if you don’t know this crazy little method.&lt;/p&gt;

&lt;p&gt;You can share your local drives so that it will be visible to remote connections you manage, those drives are only mapped when you are connected and not someone else, so they are secure and easy to use.&lt;/p&gt;

&lt;p&gt;You probably are doing what I did when I discovered this method, grabbing and pulling hard on your hair.&lt;/p&gt;

&lt;p&gt;STOP!&lt;/p&gt;

&lt;p&gt;Here is how you do it.&lt;/p&gt;

&lt;p&gt;I’m using Windows 7 RC2, but it&amp;#8217;s the same in Vista, I can’t remember XP (OLD!), but I think you can do it in XP as well, it doesn’t seem like Microsoft did changes in this app.&lt;/p&gt;

&lt;p&gt;First, let’s open RDP connection:&lt;/p&gt;

&lt;p&gt;Start—&amp;#62;Run—&amp;#62;mstsc and click ENTER&lt;/p&gt;

&lt;p&gt;This dialog popped up right?&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/06/6162009114421PM.png'&gt;&lt;img alt='6-16-2009 11-44-21 PM' border='0' height='152' src='http://www.kensodev.com/wp-content/uploads/2009/06/6162009114421PM_thumb.png' style='display: inline; border: 0px;' title='6-16-2009 11-44-21 PM' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Type in your computer (remote) name or IP address and click the options arrow (bottom left)&lt;/p&gt;

&lt;p&gt;Once you do that a dialog opens up. Click “Local Resources”… as shown in this image&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/06/6162009114559PM.png'&gt;&lt;img alt='6-16-2009 11-45-59 PM' border='0' height='141' src='http://www.kensodev.com/wp-content/uploads/2009/06/6162009114559PM_thumb.png' style='display: inline; border: 0px;' title='6-16-2009 11-45-59 PM' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Then click the &amp;#8216;”More” button (bottom left), another dialog will pop open, and you will be able to check/uncheck the drives you want to share with the remote computer at the time of the connection.&lt;/p&gt;

&lt;p&gt;Let’s hit “Connect” and open up “My Computer” on the remote server.&lt;/p&gt;

&lt;p&gt;This is how my it looks now:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/06/6162009114944PM.png'&gt;&lt;img alt='6-16-2009 11-49-44 PM' border='0' height='184' src='http://www.kensodev.com/wp-content/uploads/2009/06/6162009114944PM_thumb.png' style='display: inline; border: 0px;' title='6-16-2009 11-49-44 PM' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;You can now download, Upload, copy, Paste and practically do whatever you want, it is like you are working on your local files.&lt;/p&gt;

&lt;p&gt;Keep in mind: If you leave a folder (local) open on the server and you don’t log off, this folder is now “read only” you won’t be able to delete the folder from your computer untill you log off the remote connection.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;

&lt;p&gt;I would love to hear and read your comments.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Delete all tables in sql database</title>
    
      <link href="http://kensodevkensodev.com/2009/05/25/delete-all-tables-in-sql-database"/>
    
    <id>http://kensodevkensodev.com/2009/05/25/delete-all-tables-in-sql-database</id>
    <updated>2009-05-25T14:04:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;Recently I encountered a bizarre request, I had to delete all the tables from an &lt;a href='http://www.kensodev.com/tag/sql/' target='_blank' title='Sql'&gt;Sql&lt;/a&gt; database. The reason is even more bizarre. The client had a system auto creating them without making sure if they exist first. Ao, I had to write some code to first delete all the tables.&lt;/p&gt;

&lt;p&gt;I thought maybe other people like me may encounter the same issue, so I wrote some code for it.&lt;/p&gt;

&lt;p&gt;The code can either print out the Drop statements for each table or execute it.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;

&lt;p&gt;Tested on sql server 2005 &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;div id=&amp;quot;codeSnippetWrapper&amp;quot; style=&amp;quot;border: 1px solid silver; padding: 4px; font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;
&amp;lt;div id=&amp;quot;codeSnippet&amp;quot; style=&amp;quot;padding: 0px; font-size: 8pt; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum1&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   1:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;DECLARE&amp;lt;/span&amp;gt; @dropSql nvarchar(1000)&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum2&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   2:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;DECLARE&amp;lt;/span&amp;gt; DropSequence &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;CURSOR&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;LOCAL&amp;lt;/span&amp;gt; FAST_FORWARD&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum3&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   3:&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum4&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   4:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;FOR&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum5&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   5:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;SELECT&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum6&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   6:&amp;lt;/span&amp;gt;         N&amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;DROP TABLE &amp;apos;&amp;lt;/span&amp;gt; + QUOTENAME(TABLE_SCHEMA) + N&amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;.&amp;apos;&amp;lt;/span&amp;gt; + QUOTENAME(TABLE_NAME)&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum7&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   7:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;FROM&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum8&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   8:&amp;lt;/span&amp;gt;         INFORMATION_SCHEMA.TABLES&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum9&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   9:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;WHERE&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum10&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  10:&amp;lt;/span&amp;gt;         TABLE_TYPE = &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;BASE TABLE&amp;apos;&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum11&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  11:&amp;lt;/span&amp;gt;             &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;AND&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum12&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  12:&amp;lt;/span&amp;gt;         OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) + N&amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;.&amp;apos;&amp;lt;/span&amp;gt; + QUOTENAME(TABLE_NAME)), &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;apos;IsMSShipped&amp;apos;&amp;lt;/span&amp;gt;) = 0&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum13&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  13:&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum14&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  14:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;OPEN&amp;lt;/span&amp;gt; DropSequence&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum15&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  15:&amp;lt;/span&amp;gt;     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;WHILE&amp;lt;/span&amp;gt; 1 = 1&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum16&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  16:&amp;lt;/span&amp;gt;         &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;BEGIN&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum17&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  17:&amp;lt;/span&amp;gt;             &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;FETCH&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;NEXT&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;FROM&amp;lt;/span&amp;gt; DropSequence &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;INTO&amp;lt;/span&amp;gt; @dropSql&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum18&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  18:&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum19&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  19:&amp;lt;/span&amp;gt;                 &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;IF&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #cc6633;&amp;quot;&amp;gt;@@FETCH_STATUS&amp;lt;/span&amp;gt; &amp;amp;lt;&amp;amp;gt; 0 &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;BREAK&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum20&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  20:&amp;lt;/span&amp;gt;                     &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;RAISERROR&amp;lt;/span&amp;gt; (@dropSql , 0, 1) &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;WITH&amp;lt;/span&amp;gt; NOWAIT&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum21&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  21:&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum22&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  22:&amp;lt;/span&amp;gt;             --&amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;EXEC&amp;lt;/span&amp;gt;(@dropSql )&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum23&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  23:&amp;lt;/span&amp;gt;             &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;PRINT&amp;lt;/span&amp;gt; @dropSql&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum24&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  24:&amp;lt;/span&amp;gt;         &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;END&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum25&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  25:&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum26&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  26:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;CLOSE&amp;lt;/span&amp;gt; DropSequence&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;
&amp;lt;pre style=&amp;quot;padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-style: none; line-height: 12pt; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white; text-align: left;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum27&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;  27:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;DEALLOCATE&amp;lt;/span&amp;gt; DropSequence&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Using jQuery tree for database data</title>
    
      <link href="http://kensodevkensodev.com/2009/05/22/using-jquery-tree-for-database-data"/>
    
    <id>http://kensodevkensodev.com/2009/05/22/using-jquery-tree-for-database-data</id>
    <updated>2009-05-22T17:42:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;This blog post is actually to answer a really nice guy from a forum (.Net) I run in Hebrew, but I thought it will be really nice to write about it in general.&lt;/p&gt;

&lt;p&gt;I get lots of questions regarding the concept of using &lt;a href='http://www.kensodev.com/category/jquery/' target='_blank' title='jQuery'&gt;jQuery&lt;/a&gt; (in general) with .net and database data.&lt;/p&gt;

&lt;p&gt;I actually blame Microsoft for having the tutorials in their website teaching only SqlDataSource, which I never used and recommend that you don’t use too.&lt;/p&gt;

&lt;p&gt;So, the majority of the questions I get are not at all about code. They are all about &lt;a href='http://www.kensodev.com/category/concept/' target='_blank' title='Concept'&gt;concept&lt;/a&gt;: How to communicate with data, How to retrieve data and more.&lt;/p&gt;

&lt;p&gt;Ok, so this tutorial is all about jQuery, LINQ to Sql, and the jQuery tree. The only difference is that I’m not going to display files in folders, but pages from a Sql table, every page has a “ParentID” fields, so it will be very easy to understand. This tutorial is also to clarify you can use the tree for any relational database or file data.&lt;/p&gt;

&lt;p&gt;So, Let&amp;#8217;s Start!&lt;/p&gt;

&lt;p&gt;First, let&amp;#8217;s go and download the 2 packages. &lt;a href='http://www.jquery.com' target='_blank'&gt;jQuery&lt;/a&gt; &lt;a href='http://abeautifulsite.net/notebook/58' target='_blank'&gt;jQuery File Tree&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After downloading the 2 packages, we&amp;#8217;ll open up a new website in Visual Studio. Our files should look like this: &lt;a href='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1726.png'&gt;&lt;img alt='2009-05-22_1726' border='0' height='244' src='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1726-thumb.png' style='display: inline; border-width: 0px;' title='2009-05-22_1726' width='105' /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;strong&gt;What do we have here?
&lt;/strong&gt;
&lt;p&gt;Well, we have all the &lt;a href='http://www.kensodev.com/tag/css'&gt;css&lt;/a&gt; from the jQuery file tree library, we have the Images also from this library, we have the js files from: jQuery, jQuery file tree and another js file which we created for our custom functions.&lt;/p&gt;

&lt;p&gt;Alright, now let’s create our page:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1728.png'&gt;&lt;img alt='2009-05-22_1728' border='0' height='157' src='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1728-thumb.png' style='display: inline; border-width: 0px;' title='2009-05-22_1728' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;We have all the script file and css files in our page. Also, we wrote a div called “myFirstTree” in our page, this div will hold our tree.&lt;/p&gt;
&lt;strong&gt;What else do we need?&lt;/strong&gt;
&lt;p&gt;Well, like I said, we are displaying database data here, so let&amp;#8217;s create a very simple database with one table, also we will create a LINQ mapping file for it. B.T.W, you can use any kind of data access, you can use nHibernate, or whatever you may find comfortable for your use. I use linq for this example, don’t ask why, just felt like it :-)&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1734.png'&gt;&lt;img alt='2009-05-22_1734' border='0' height='228' src='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1734-thumb.png' style='display: inline; border-width: 0px;' title='2009-05-22_1734' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;So, we have these fields: pageID – Identity field pageName pageParentID&lt;/p&gt;

&lt;p&gt;Let’s create our data, just randomly fill our table with some data, and then we can go back and retrieve it from the client side using some jQuery.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1738.png'&gt;&lt;img alt='2009-05-22_1738' border='0' height='229' src='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1738-thumb.png' style='display: inline; border-width: 0px;' title='2009-05-22_1738' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;So, we have our data. I don’t think i need to further explain this no? :-)&lt;/p&gt;

&lt;p&gt;Now, let&amp;#8217;s write some js code to retrieve the data from the server for us.&lt;/p&gt;

&lt;p&gt;Our js code should look like this:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;javascript&lt;/span&gt; $(document).ready(function() { $(&amp;#8216;#myFirstTree&amp;#8217;).fileTree({ root: &amp;#8216;0&amp;#8217;, script: &amp;#8216;jQueryTreeHandler.ashx&amp;#8217;, multiFolder: true, loadMessage: &amp;#8216;Tree loading&amp;#8230;&amp;#8217; }, function(file) { alert(file); }); }); &lt;span&gt;/javascript&lt;/span&gt;&lt;/p&gt;
&lt;strong&gt;Let’s explain this code a bit shall we?&lt;/strong&gt;
&lt;p&gt;First, we chose our pre crated div “myFirstTree”. Then we initialized the fileTree object with these parameters:&lt;/p&gt;
&lt;strong&gt;root&lt;/strong&gt;&lt;strong&gt;script&lt;/strong&gt;&lt;strong&gt;multiFolder&lt;/strong&gt;&lt;strong&gt;loadingMessage&lt;/strong&gt;&lt;strong&gt;fileFunction&lt;/strong&gt;
&lt;p&gt;All pretty straight forward up until now, let&amp;#8217;s go on and create our handler:&lt;/p&gt;

&lt;p&gt;The parameter we know is passed in is called “dir”, so that is what we will use here.&lt;/p&gt;

&lt;p&gt;So, this is what your handler code should look like:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;csharp&lt;/span&gt; &amp;#60;%@ WebHandler Language=&amp;#34;C#&amp;#34; Class=&amp;#34;jQueryTreeHandler&amp;#34; %&amp;#62; using System; using System.Web; using System.Linq;&lt;/p&gt;

&lt;p&gt;public class jQueryTreeHandler : IHttpHandler {&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public void ProcessRequest (HttpContext context) {
    context.Response.ContentType = &amp;amp;quot;text/plain&amp;amp;quot;;
    int parentID = Convert.ToInt32(context.Request.Form[&amp;amp;quot;dir&amp;amp;quot;]);

    string list = &amp;amp;quot;&amp;amp;quot;;
    jQueryTreeDataContext db = new jQueryTreeDataContext();
    var pages = from p in db.Pages
                where p.pageParentID == parentID
                select p;

    foreach (Page item in pages)
    {
        list += String.Format(&amp;amp;quot;&amp;amp;lt;li class=\&amp;amp;quot;directory collapsed\&amp;amp;quot;&amp;amp;gt;&amp;amp;lt;a href=\&amp;amp;quot;#\&amp;amp;quot; rel=\&amp;amp;quot;{0}\&amp;amp;quot;&amp;amp;gt;{1}&amp;amp;lt;/a&amp;amp;gt;&amp;amp;lt;/li&amp;amp;gt;&amp;amp;quot;, item.pageID.ToString(), item.pageName);
    }

    context.Response.Write(String.Format(&amp;amp;quot;&amp;amp;lt;ul class=\&amp;amp;quot;jqueryFileTree\&amp;amp;quot; style=\&amp;amp;quot;display: none;\&amp;amp;quot;&amp;amp;gt;{0}&amp;amp;lt;/ul&amp;amp;gt;&amp;amp;quot;, list));
}

public bool IsReusable {
    get {
        return false;
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;} &lt;span&gt;/csharp&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Comment: I didn&amp;#8217;t take care of a situation where a row has no children, it wasn’t necessary for my example. However, in real life code you should, and if a row does not have any children, you shouldn’t display a folder, but a file instead.&lt;/p&gt;

&lt;p&gt;And this is how our code looks like in the final result (Html output):&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1840.png'&gt;&lt;img alt='2009-05-22_1840' border='0' height='173' src='http://www.kensodev.com/wp-content/uploads/2009/05/20090522-1840-thumb.png' style='display: inline; border-width: 0px;' title='2009-05-22_1840' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Comment: I had to tweak the jQuery file tree code in order for it to work with database data. Normally it has a regullar expression validating the &amp;#8220;rel&amp;#8221; attribute actually contains data with &amp;#8221;/&amp;#8221;, that needed to be changes.&lt;/p&gt;

&lt;p&gt;I uploaded the file to here for you, so download away&amp;#8230; &lt;span&gt;download id=&amp;#8221;2&amp;#8221;&lt;/span&gt;&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Hebrew version is coming soon</title>
    
      <link href="http://kensodevkensodev.com/2009/05/12/hebrew-version-is-coming-soon"/>
    
    <id>http://kensodevkensodev.com/2009/05/12/hebrew-version-is-coming-soon</id>
    <updated>2009-05-12T10:41:33+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hello all,&lt;/p&gt;

&lt;p&gt;I know I know, a lot have asked me to open a hebrew version for my blog.&lt;/p&gt;

&lt;p&gt;Well, it is coming very soon (I believe in 2 weeks).&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll keep ya posted.&lt;/p&gt;

&lt;p&gt;10x&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">What is Kenso...?</title>
    
      <link href="http://kensodevkensodev.com/2009/05/10/what-is-kenso"/>
    
    <id>http://kensodevkensodev.com/2009/05/10/what-is-kenso</id>
    <updated>2009-05-10T20:26:02+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;A lot of people are reading my &lt;a href='http://www.kensodev.com/' title='Web Development Blog'&gt;Web Development blog&lt;/a&gt; or following me on twitter have been asking me, what is Kenso? What does that word mean? Well, I’ll tell you what it isn’t, It’s not my last name :-)&lt;/p&gt;

&lt;p&gt;Kenso is a word in Japanese meaning “economical and simple”.&lt;/p&gt;

&lt;p&gt;In case you don’t believe me, here’s a screenshot from a dictionary online.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/05/20090510-2124.png'&gt;&lt;img alt='2009-05-10_2124' border='0' height='18' src='http://www.kensodev.com/wp-content/uploads/2009/05/20090510-2124-thumb.png' style='display: inline; border: 0px;' title='2009-05-10_2124' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;That’s it :-)&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Interview Questions (flex) - What do you say?</title>
    
      <link href="http://kensodevkensodev.com/2009/05/10/interview-questions-flex-what-do-you-say"/>
    
    <id>http://kensodevkensodev.com/2009/05/10/interview-questions-flex-what-do-you-say</id>
    <updated>2009-05-10T20:07:32+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;as you know, I work as a full time freelancer in RIA and &lt;a href='http://kensodev.com/' title='Web Development'&gt;web development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once in a while like every service provider I have to meet with new clients to maybe start working with them on new projects, or work with the company as a consultant.&lt;/p&gt;

&lt;p&gt;Usually when I go to this kind of a meeting, my portfolio speaks for itself and we get down to business in no time.&lt;/p&gt;

&lt;p&gt;Today was different, I was in such a meeting and the guy sitting with me asked me to take a short test (3 questions test).&lt;/p&gt;

&lt;p&gt;It seemed odd, but I didn’t refuse and took it.&lt;/p&gt;

&lt;p&gt;Well, I passed :-) he said with flying colors (he’s words), but I wanted to see what you guys think and to see your answers.&lt;/p&gt;
&lt;strong&gt;&lt;span style='text-decoration: underline;'&gt;1st Question&lt;/span&gt;&lt;/strong&gt;
&lt;p&gt;Describe all the ways you can send paramaters into a flash object.&lt;/p&gt;
&lt;strong&gt;&lt;span style='text-decoration: underline;'&gt;2nd Question&lt;/span&gt;&lt;/strong&gt;
&lt;p&gt;You have an array of zeros and ones 0/1/1/1/1/0/1/0/1/0/1/1/1/0.&lt;/p&gt;

&lt;p&gt;Write a function that sorts this array without using the sort function (:-))&lt;/p&gt;
&lt;strong&gt;&lt;span style='text-decoration: underline;'&gt;3rd Question&lt;/span&gt;&lt;/strong&gt;
&lt;p&gt;You have an XML holding commercial data. Each XmlNode holds the t1 (time to start) and t2 (time to end).&lt;/p&gt;

&lt;p&gt;Write a function that takes the commercials and displays them on the canvas. No need to parse the XML.&lt;/p&gt;

&lt;p&gt;Time: &lt;strong&gt;15 minutes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I will publish my answers in a different post in a few days. You can either comment or send me the answer via email.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Add new website IIS 7 (Vista)</title>
    
      <link href="http://kensodevkensodev.com/2009/04/30/add-new-website-iis-7-vista"/>
    
    <id>http://kensodevkensodev.com/2009/04/30/add-new-website-iis-7-vista</id>
    <updated>2009-04-30T18:47:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hello all,&lt;/p&gt;

&lt;p&gt;For all of us programmers or web developers working with websites, you know the need to open more then one website (by default) on your development machine.&lt;/p&gt;

&lt;p&gt;Sometime you need all a website to stand on its own and not be a sub directory or a virtual directory (like: &lt;a href='http://localhost/your_webiste'&gt;http://localhost/your_webiste&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Why, well let’s say your using URL rewriting, then you need to use parent path’s like so:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='html'&gt;&lt;span class='nt'&gt;&amp;lt;img&lt;/span&gt; &lt;span class='na'&gt;alt=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class='na'&gt;src=&lt;/span&gt;&lt;span class='s'&gt;&amp;quot;/assets/images/avi.png&amp;quot;&lt;/span&gt; &lt;span class='nt'&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;If you try to do this while using a VD you will get errors and your images won’t be displayed, you have to use a standalone website for this.&lt;/p&gt;

&lt;p&gt;So, let me tell you how to do it with IIS 7 (I’m working with vista, it’s the same for IIS 7 on any other machine).&lt;/p&gt;

&lt;p&gt;For all of you guys with XP out there, you cannot do this, so please other upgrade to vista or windows 7 (:-))&lt;/p&gt;

&lt;p&gt;I have my own method of how to do this, that make me remember the web address easily.&lt;/p&gt;

&lt;p&gt;It goes like this: if I’m working on my website (&lt;a href='http://www.kensodev.com'&gt;http://www.kensodev.com&lt;/a&gt;) the local version of it will be (&lt;a href='http://local.kensodev.com'&gt;http://local.kensodev.com&lt;/a&gt; –&amp;#62; link not working).&lt;/p&gt;

&lt;p&gt;ok ok I’m getting there :-)&lt;/p&gt;
&lt;strong&gt;How to add a new website IIS 7 on Vista?&lt;/strong&gt;
&lt;p&gt;First, open IIS manager on vista (Start—&amp;#62;Administrative Tools—&amp;#62;IIS Manager)&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1927.png'&gt;&lt;img alt='2009-04-30_1927' border='0' height='183' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1927-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_1927' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;On the left you will see the “sites” folder, right click on it and select “add website”, you will get this dialog.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1933.png'&gt;&lt;img alt='2009-04-30_1933' border='0' height='236' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1933-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_1933' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Fill the text boxes just as I did, give it your own names of course and select the local folder where the files are located.&lt;/p&gt;

&lt;p&gt;This is just about it for IIS, don’t try to navigate to the website yet, you will get an error.&lt;/p&gt;

&lt;p&gt;Next step: Please open up notepad (with admin privileges), hit file—&amp;#62;Open (select &lt;em&gt;.&lt;/em&gt;) and navigate to the folder  C:\Windows\System32\drivers\etc&lt;/p&gt;

&lt;p&gt;You will see these files:&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1936.png'&gt;&lt;img alt='2009-04-30_1936' border='0' height='193' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1936-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_1936' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Click the “hosts” file and open it, If you didn’t define any website you will only see “localhost”&lt;/p&gt;

&lt;p&gt;Now, we will add a record at the end of this file.&lt;/p&gt;

&lt;p&gt;Type 127.0.0.1 and hit the TAB button on your keyboard, then type the name that you gave your website. In this case “local.kensodev.com” no need to type http:// or www.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1938.png'&gt;&lt;img alt='2009-04-30_1938' border='0' height='184' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1938-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_1938' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;Now, lets open up a browser an navigate to the website.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1942.png'&gt;&lt;img alt='2009-04-30_1942' border='0' height='163' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1942-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_1942' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Just to check that the browser isn’t routed to a remote website lets ping to it using the command line.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1943.png'&gt;&lt;img alt='2009-04-30_1943' border='0' height='125' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-1943-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_1943' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;And that’s the end, you have another website on your IIS, and you can browse to it.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Solo standalone mp3 player to embed in a page</title>
    
      <link href="http://kensodevkensodev.com/2009/04/29/solo-standalone-mp3-player-to-embed-in-a-page"/>
    
    <id>http://kensodevkensodev.com/2009/04/29/solo-standalone-mp3-player-to-embed-in-a-page</id>
    <updated>2009-04-29T23:39:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Client’s request: &lt;blockquote&gt;&lt;span style='color: #000000;'&gt; &lt;/span&gt;
I want an mp3 player on my website (html), a kind of player which the user can’t pause or stop the song, also I want it to work in all browsers with no problem.&lt;/blockquote&gt; After explaining to him this is not very common and urged him to think it over, he insisted and I had to do what he asked me to.&lt;/p&gt;

&lt;p&gt;Because of the cross-browser need, I had to use Flash/Flex for this job, but I also wanted to make this as reusable as possible for other project or for distribution as a component which I think a lot will want to use.&lt;/p&gt;

&lt;p&gt;So, the plan was a very small player 100x20 (px), white background to blend in with the website.&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-0036.png'&gt;&lt;img alt='2009-04-30_0036' border='0' height='169' src='http://www.kensodev.com/wp-content/uploads/2009/04/20090430-0036-thumb.png' style='display: inline; border: 0px;' title='2009-04-30_0036' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;I didn’t want to hard code the mp3 into the file, because this client is using a CMS application and he wanted to replace the file occasionally.&lt;/p&gt;

&lt;p&gt;Opened up flex and started writing some code.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='actionscript'&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;?&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt; &lt;span class='nx'&gt;version&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mf'&gt;1.0&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;encoding&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;utf&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;8&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;?&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Application&lt;/span&gt;
     &lt;span class='nx'&gt;xmlns&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;http&lt;/span&gt;&lt;span class='o'&gt;://&lt;/span&gt;&lt;span class='nx'&gt;www&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;adobe&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;com&lt;/span&gt;&lt;span class='sr'&gt;/2006/m&lt;/span&gt;&lt;span class='nx'&gt;xml&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='nx'&gt;layout&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;absolute&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='nx'&gt;width&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;100&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='nx'&gt;height&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mi'&gt;20&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='nx'&gt;creationComplete&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;init&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='nx'&gt;color&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='err'&gt;#&lt;/span&gt;&lt;span class='nx'&gt;FFFFFF&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='nx'&gt;backgroundColor&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='err'&gt;#&lt;/span&gt;&lt;span class='nx'&gt;FFFFFF&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt; &lt;span class='nx'&gt;backgroundAlpha&lt;/span&gt;&lt;span class='o'&gt;=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='mf'&gt;0.0&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
     &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
         &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;!&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;&lt;span class='nx'&gt;CDATA&lt;/span&gt;&lt;span class='p'&gt;[&lt;/span&gt;
             &lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;controls&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;Alert&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
             &lt;span class='kd'&gt;import&lt;/span&gt; &lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;messaging&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;Channel&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;

             &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;init&lt;/span&gt;&lt;span class='p'&gt;()&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;
                 &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;flashVars&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Object&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;Application&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;application&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;parameters&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
                 &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;mp3FileName&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;flashVars&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;mp3FileName&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
                 &lt;span class='k'&gt;if&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;mp3FileName&lt;/span&gt;&lt;span class='o'&gt;!=&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;quot&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
                 &lt;span class='p'&gt;{&lt;/span&gt;
                     &lt;span class='nx'&gt;playMp3File&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;mp3FileName&lt;/span&gt;&lt;span class='p'&gt;);&lt;/span&gt;
                 &lt;span class='p'&gt;}&lt;/span&gt;
             &lt;span class='p'&gt;}&lt;/span&gt;
             &lt;span class='kd'&gt;private&lt;/span&gt; &lt;span class='kd'&gt;function&lt;/span&gt; &lt;span class='nx'&gt;playMp3File&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;mp3&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;String&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;void&lt;/span&gt;&lt;span class='p'&gt;{&lt;/span&gt;
                 &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;snd&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;Sound&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='k'&gt;new&lt;/span&gt; &lt;span class='nb'&gt;Sound&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='k'&gt;new&lt;/span&gt; &lt;span class='nb'&gt;URLRequest&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nx'&gt;mp3&lt;/span&gt;&lt;span class='p'&gt;));&lt;/span&gt;
                 &lt;span class='k'&gt;var&lt;/span&gt; &lt;span class='nx'&gt;channel&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nb'&gt;SoundChannel&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='nx'&gt;snd&lt;/span&gt;&lt;span class='p'&gt;.&lt;/span&gt;&lt;span class='nx'&gt;play&lt;/span&gt;&lt;span class='p'&gt;();&lt;/span&gt;
             &lt;span class='p'&gt;}&lt;/span&gt;
         &lt;span class='p'&gt;]]&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
    &lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Script&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;lt&lt;/span&gt;&lt;span class='o'&gt;;/&lt;/span&gt;&lt;span class='nx'&gt;mx&lt;/span&gt;&lt;span class='o'&gt;:&lt;/span&gt;&lt;span class='nx'&gt;Application&lt;/span&gt;&lt;span class='o'&gt;&amp;amp;&lt;/span&gt;&lt;span class='nx'&gt;gt&lt;/span&gt;&lt;span class='o'&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;As you can see, the entire application is about 29 lines of code. &lt;h3&gt;Code explaination&lt;/h3&gt; 1. I declared an object that excepts the parameters passed into the FlashObject in the flashVars tag.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checked if the param passed in is not empty and filled a Sound class with this mp3 and whallah –&amp;#62; Start playing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is what the HTML embedding of this SWF inside the HTML looks like:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;js&lt;/span&gt; WriteFlashObj(&amp;#8216;/SoloPlayer.swf&amp;#8217;, &amp;#8216;100px&amp;#8217;, &amp;#8216;20px&amp;#8217;, true, &amp;#8216;mp3FileName={pageFileName}&amp;#8217;, &amp;#8216;SoloPlayer&amp;#8217;); &lt;span&gt;/js&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;It works like a charm.&lt;/p&gt;

&lt;p&gt;If you want the source code or the final SWF file, please contact me through the &lt;a href='http://www.kensodev.com/contact-avi-tzurel/' title='Contact Avi Tzurel'&gt;contact&lt;/a&gt; page of this website, I will email it to you with no problem.&lt;/p&gt;
&lt;!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, &quot;Courier New&quot;, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; } --&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Control caching of your RIA applications</title>
    
      <link href="http://kensodevkensodev.com/2009/04/27/control-caching-of-your-ria-applications"/>
    
    <id>http://kensodevkensodev.com/2009/04/27/control-caching-of-your-ria-applications</id>
    <updated>2009-04-27T21:44:00+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;For all of us working with RIA applications (&lt;a href='http://www.kensodev.com/tag/flex/' title='Flex'&gt;Flex&lt;/a&gt;/&lt;a href='http://www.kensodev.com/tag/flash/' title='Flash'&gt;Flash&lt;/a&gt;) we know the hell of having to worry about a user cache.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s actually a chance that a user won&amp;#8217;t see the latest version of your application, the chances are actually quite high for that to happen.&lt;/p&gt;

&lt;p&gt;Well, I have my own two methods that I use to control this. &lt;h4&gt;Method #1&lt;/h4&gt; The first way to control this is by the use of a parameter attached to the file name. Lets say your file name is kenso.swf (original name I must say :-) ). If you try embedding it into the HTML you will found out it is being cached. If you update the file on the server, you won’t see the changes.&lt;/p&gt;

&lt;p&gt;The solution for this is simply add a parameter to the file like so:&lt;strong&gt; kenso.swf?buildDate=29Jan2009&lt;/strong&gt;, this will cache as a file, if you change the &lt;strong&gt;buildDate&lt;/strong&gt; param you will see that the file is being pulled again from the server &lt;h4&gt;Method #2&lt;/h4&gt; This method is what I call overkill, but I did found myself using it a couple of times in the past. I won’t get into code (unless you ask me to…), but the idea is this. There’s a service managing the builds of the application. Each build of the application has an ID embedded inside the code like so: &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;div id=&amp;quot;codeSnippetWrapper&amp;quot; style=&amp;quot;border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;&amp;quot;&amp;gt;
&amp;lt;div id=&amp;quot;codeSnippet&amp;quot; style=&amp;quot;border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum1&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   1:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;var&amp;lt;/span&amp;gt; versionLabel:String = &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;quot;29Jan2009_01&amp;quot;&amp;lt;/span&amp;gt;;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, &quot;Courier New&quot;, courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --&gt;
&lt;p&gt;OK, so now we have the version label in the application. All we have to do is create a service, set the final version expected there say &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;div id=&amp;quot;codeSnippetWrapper&amp;quot; style=&amp;quot;border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;&amp;quot;&amp;gt;
&amp;lt;div id=&amp;quot;codeSnippet&amp;quot; style=&amp;quot;border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;
&amp;lt;pre style=&amp;quot;border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: &amp;apos;Courier New&amp;apos;,courier,monospace; direction: ltr; color: black; font-size: 8pt;&amp;quot;&amp;gt;&amp;lt;span id=&amp;quot;lnum1&amp;quot; style=&amp;quot;color: #606060;&amp;quot;&amp;gt;   1:&amp;lt;/span&amp;gt; &amp;lt;span style=&amp;quot;color: #0000ff;&amp;quot;&amp;gt;string&amp;lt;/span&amp;gt; finalVersion = &amp;lt;span style=&amp;quot;color: #006080;&amp;quot;&amp;gt;&amp;quot;30Jan2009_09&amp;quot;&amp;lt;/span&amp;gt;;&amp;lt;/pre&amp;gt;
&amp;lt;!--CRLF--&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;If the version passed into the service is not the latest, simply tell that to your user.&lt;/p&gt;

&lt;p&gt;This process can be with or without a database, can be with ExternalInterface and the use of JavaScript, it can really be whatever you want.&lt;/p&gt;

&lt;p&gt;I seriously recommend using the 1st way to do this unless you really want to make sure that the version your user is seeing is the latest.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Free flex uploader is coming along pretty great</title>
    
      <link href="http://kensodevkensodev.com/2009/03/28/free-flex-uploader-is-coming-along-pretty-great"/>
    
    <id>http://kensodevkensodev.com/2009/03/28/free-flex-uploader-is-coming-along-pretty-great</id>
    <updated>2009-03-28T00:09:36+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hello All,&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m developing an Uploader component, for free use in your website or blog. I&amp;#8217;m using Adobe flex builder 3 for it, so the final result will be an swf you can simply embed in your real life website.&lt;/p&gt;

&lt;p&gt;Well, this is not a release note, just an update.&lt;/p&gt;

&lt;p&gt;I have completely changed the way you will configure the uploader. It used to be a couple fo &lt;a href='http://www.kensodev.com/tag/javascript/' title='JavaScript'&gt;JavaScript&lt;/a&gt; predefined function you should have used. I changed it to an XML config file, it has all of the parameters I could think of.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m pasting the xml straight from the development environment, its really important to me to hear what you have to say, I want it to be as user friendly as possible.&lt;/p&gt;

&lt;p&gt;Please, if you think I should add another param or whatever, please drop me an email or send a contact through the &lt;a href='http://www.kensodev.com/contact/' target='_blank' title='Contact avi tzurel'&gt;contact&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the xml&lt;/p&gt;
&lt;!--

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, &quot;Courier New&quot;, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; } --&gt;&lt;div style='border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;
&lt;div style='border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   1:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;&amp;lt;?&lt;/span&gt;&lt;span style='color: #800000;'&gt;xml&lt;/span&gt; &lt;span style='color: #ff0000;'&gt;version&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;=&quot;1.0&quot;&lt;/span&gt; &lt;span style='color: #ff0000;'&gt;encoding&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;=&quot;utf-8&quot;&lt;/span&gt; ?&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   2:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;uploaderConfig&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   3:&lt;/span&gt;     &lt;span style='color: #008000;'&gt;&amp;lt;!--&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   4:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        Should be: http://www.your_domain.com/your_script.aspx/php/whatever :-) &lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   5:&lt;/span&gt; &lt;span style='color: #008000;'&gt;    --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   6:&lt;/span&gt;     &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;uploadScriptUrl&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;uploadScriptUrl&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   7:&lt;/span&gt;     &lt;span style='color: #008000;'&gt;&amp;lt;!--&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   8:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        Should be javascript funcion that gets a single param like so: progressEvent(progress)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   9:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        You can display this to the user, or do other things you want.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  10:&lt;/span&gt; &lt;span style='color: #008000;'&gt;    --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  11:&lt;/span&gt;     &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;progressEventListner&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;progressEventListner&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  12:&lt;/span&gt;     &lt;span style='color: #008000;'&gt;&amp;lt;!--&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  13:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        Same as before, javascript function that gets a single param &amp;gt; Error Message&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  14:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        errorListner(errorMessage)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  15:&lt;/span&gt; &lt;span style='color: #008000;'&gt;    --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  16:&lt;/span&gt;     &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;errorListner&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;errorListner&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  17:&lt;/span&gt;     &lt;span style='color: #008000;'&gt;&amp;lt;!--&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  18:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        What do you want your users to upload?&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  19:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        jpg;mpg;wmv;flv&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  20:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        all other file types you want type here will be disregarded and an error will be raised.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  21:&lt;/span&gt; &lt;span style='color: #008000;'&gt;    --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  22:&lt;/span&gt;     &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;fileTypeAllowed&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;fileTypeAllowed&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  23:&lt;/span&gt;     &lt;span style='color: #008000;'&gt;&amp;lt;!--&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  24:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        This is when i make your life easier.&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  25:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        You can pass me the file size in KB, the flex handles the translation to bytes :-)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  26:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        How?... like so:&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  27:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        KB:250&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  28:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        Please do not use a double.decimal the, thoug you won't get en Error the flex simply will disregard this&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  29:&lt;/span&gt; &lt;span style='color: #008000;'&gt;    --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  30:&lt;/span&gt;     &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;fileSizeAllowed&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;fileSizeAllowed&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  31:&lt;/span&gt;     &lt;span style='color: #008000;'&gt;&amp;lt;!--&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  32:&lt;/span&gt; &lt;span style='color: #008000;'&gt;        Javascript function for displaying the message to the user&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  33:&lt;/span&gt; &lt;span style='color: #008000;'&gt;    --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  34:&lt;/span&gt;     &lt;span style='color: #0000ff;'&gt;&amp;lt;&lt;/span&gt;&lt;span style='color: #800000;'&gt;completeListner&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;completeListner&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  35:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;&amp;lt;/&lt;/span&gt;&lt;span style='color: #800000;'&gt;uploaderConfig&lt;/span&gt;&lt;span style='color: #0000ff;'&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also download the file from here: &lt;span&gt;download id=&amp;#8221;1&amp;#8221;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This is what the uploader looks like, I tried keeping it A.S.A.P (as simple as possible :-) )&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/03/kenso-uploader.jpg'&gt;&lt;img alt='kenso_uploader' border='0' height='87' src='http://www.kensodev.com/wp-content/uploads/2009/03/kenso-uploader-thumb.jpg' style='border: 0px;' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;Waiting for your comments.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Strange flex bug - caching screens</title>
    
      <link href="http://kensodevkensodev.com/2009/03/27/weird-flex-bug-caching-screens"/>
    
    <id>http://kensodevkensodev.com/2009/03/27/weird-flex-bug-caching-screens</id>
    <updated>2009-03-27T16:13:28+03:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hello All,&lt;/p&gt;

&lt;p&gt;Thanks again for visiting my blog, &amp;#8220;From inspiration to realization&amp;#8221;. The blog covers lots of  information about &lt;a href='http://www.kensodev.com' title='Web Development'&gt;Web Development&lt;/a&gt;: &lt;a href='http://www.kensodev.com/category/ruby-on-rails/' title='Ruby On Rails'&gt;Ruby on Rails&lt;/a&gt;, &lt;a href='http://www.kensodev.com/category/java/' title='Java'&gt;Java&lt;/a&gt;, &lt;a href='http://www.kensodev.com/category/flex/' title='Flex'&gt;Flex&lt;/a&gt; and etc.&lt;/p&gt;

&lt;p&gt;The past week has been very frustrating for me. As you know (or not) I work quite a bit with flex development and AIR.&lt;/p&gt;

&lt;p&gt;The environment for developing these applications is &lt;a href='http://www.adobe.com/products/flex/' target='_blank'&gt;Adobe Flex Builder 3&lt;/a&gt;, I never had any problems with this peace of software, but this last week has been just horrible.&lt;/p&gt;

&lt;p&gt;I will explain my problem.&lt;/p&gt;

&lt;p&gt;As you know (again or not&amp;#8230;) I&amp;#8217;m not a designer and I don&amp;#8217;t wanna be one, so&amp;#8230; I got all of the designs from the designer of the project via PSD, cut all of the &amp;#8220;assets&amp;#8221; to use in my flex application and started off with building each screen.&lt;/p&gt;

&lt;p&gt;As always, I wrote some CSS (yeah.. Flex has css, same as HTML), build an swf file for holding all of the assets (swc), and started dragging in controls.&lt;/p&gt;

&lt;p&gt;All pretty basic so far, but&amp;#8230;&lt;/p&gt;

&lt;p&gt;Sometimes (well, all the time) the flex just refused to build with the recent changes, After the first time I build an swf from the flex IDE, no change I made to the application actually &amp;#8220;kicked in&amp;#8221;.&lt;/p&gt;
&lt;strong&gt;Action-Script
&lt;/strong&gt;
&lt;p&gt;The application just would not update. &lt;div style='border: 1px solid gray; padding: 4px; font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;
&lt;div style='padding: 0px; font-size: 8pt; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   1:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;private&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;function&lt;/span&gt; initScreen():&lt;span style='color: #0000ff;'&gt;void&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   3:&lt;/span&gt;     screenMainText.htmlText=&lt;span style='color: #006080;'&gt;&quot;Please Choose which of the Questionnaires below you would like to compile for your Survey&quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   4:&lt;/span&gt;     backButton.label = &lt;span style='color: #006080;'&gt;&quot;Back to control panel&quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   5:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt; What did I do to see the updated?&lt;/p&gt;

&lt;p&gt;I copied all of the code from the mxml file, deleted this file, created a new file, pasted in the copied code and WALLA, the updates &amp;#8220;kicked in&amp;#8221;&lt;/p&gt;

&lt;p&gt;Strangely though even a project cleaning would not help&lt;/p&gt;
&lt;a href='http://www.kensodev.com/wp-content/uploads/2009/03/flex-issue.jpg'&gt;&lt;img alt='flex_issue' border='0' height='148' src='http://www.kensodev.com/wp-content/uploads/2009/03/flex-issue-thumb.jpg' style='border-width: 0px;' width='244' /&gt;&lt;/a&gt;
&lt;p&gt;I emailed Adobe, but got no response so far, I will update here and tweet on the solution I hope they provide.&lt;/p&gt;

&lt;p&gt;** I tried importing another project to the flex builder, but the error did not exist in another project, only in this specific project.&lt;/p&gt;
      
    </content>
  </entry>
  
  <entry>
    <title type="html">Flex &amp;quot;Verbal Month&amp;quot; date</title>
    
      <link href="http://kensodevkensodev.com/2009/03/24/flex-verbal-month-date"/>
    
    <id>http://kensodevkensodev.com/2009/03/24/flex-verbal-month-date</id>
    <updated>2009-03-24T16:47:16+02:00</updated>
    <summary>Liquid error: undefined method `gsub' for nil:NilClass</summary>
    <content type="html">
      
        &lt;p&gt;Hi All,&lt;/p&gt;

&lt;p&gt;If you are working with Adobe &lt;a href='http://www.kensodev.com/category/flex/' title='flex'&gt;flex&lt;/a&gt;, you probably know that the framework does not have a function such as DateTime.Now().ToString().&lt;/p&gt;

&lt;p&gt;Because of that, displaying a friendly date to the user is impossible unless you write a small extension to the getDate() function in flex.&lt;/p&gt;

&lt;p&gt;This is The way to go &lt;div style='border: 1px solid gray; padding: 4px; font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;
&lt;div style='padding: 0px; font-size: 8pt; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   1:&lt;/span&gt; var todayDate:String = &lt;span style='color: #006080;'&gt;&quot;&quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   2:&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   3:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;private&lt;/span&gt; function INIT():&lt;span style='color: #0000ff;'&gt;void&lt;/span&gt;{&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   4:&lt;/span&gt;     getCurrentDate();&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   5:&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   6:&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   7:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;private&lt;/span&gt; var monthLabels:Array = &lt;span style='color: #0000ff;'&gt;new&lt;/span&gt; Array(&lt;span style='color: #006080;'&gt;&quot;Jan&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;   8:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Feb&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;   9:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Mar&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  10:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Apr&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  11:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;May&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  12:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Jun&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  13:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Jul&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  14:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Aug&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  15:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Sep&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  16:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Oct&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  17:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Nov&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  18:&lt;/span&gt;                                           &lt;span style='color: #006080;'&gt;&quot;Dec&quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  19:&lt;/span&gt;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  20:&lt;/span&gt; &lt;span style='color: #0000ff;'&gt;private&lt;/span&gt; function getCurrentDate():&lt;span style='color: #0000ff;'&gt;void&lt;/span&gt;{&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  21:&lt;/span&gt;     var date:Date = &lt;span style='color: #0000ff;'&gt;new&lt;/span&gt; Date();&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  22:&lt;/span&gt;     todayDate = date.getDate().toString() + &lt;span style='color: #006080;'&gt;&quot; &quot;&lt;/span&gt; + monthLabels[date.getMonth()].toString() + &lt;span style='color: #006080;'&gt;&quot; &quot;&lt;/span&gt; + date.getFullYear().toString();&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: white;'&gt;&lt;span style='color: #606060;'&gt;  23:&lt;/span&gt;     datePickerButton.label=todayDate;&lt;/pre&gt;
&lt;pre style='padding: 0px; font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; border-style: none; line-height: 12pt; font-family: consolas,&amp;apos;Courier New&amp;apos;,courier,monospace; background-color: #f4f4f4;'&gt;&lt;span style='color: #606060;'&gt;  24:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt; That&amp;#8217;s it, its that easy to get a date from flex.&lt;/p&gt;

&lt;p&gt;You can of curse extend it some more in order to get the day.&lt;/p&gt;
      
    </content>
  </entry>
  
</feed>
