<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Steven S. Ross - Home</title>
  <id>tag:blog.stevensross.com,2009:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://blog.stevensross.com/feed/rss.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.stevensross.com/" rel="alternate" type="text/html"/>
  <updated>2009-04-15T15:58:21Z</updated>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-04-15:2368</id>
    <published>2009-04-15T15:57:00Z</published>
    <updated>2009-04-15T15:58:21Z</updated>
    <category term="Coldfusion"/>
    <category term="Internet Tech"/>
    <category term="dynamic sql"/>
    <category term="dynamic sql variable names"/>
    <category term="looping sql"/>
    <link href="http://blog.stevensross.com/2009/4/15/dynamic-sql-jumping-a-hoop-with-a-loop" rel="alternate" type="text/html"/>
    <title>Dynamic SQL jumping a hoop (with a loop)</title>
<content type="html">
            &lt;p&gt;Ok ignore the title, &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; is all business so lets get back to the &#8220;serious&#8221; &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; train.&lt;/p&gt;


	&lt;p&gt;So maybe you have a table that is very flat, someone did something like data1, data2, data3 as column names and you want to loop over it and insert it into a new table that can hold an infinite amount of meta-data with a relationship. Hey after all we are programming with relational databases these days.&lt;/p&gt;


So here are the basics, the loop (from 1 to 10):
&lt;pre&gt;&lt;code&gt;
DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag &amp;lt;11)
BEGIN
-- DO LOOP STUFF HERE
SET @intFlag = @intFlag + 1
CONTINUE;
END
GO
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;So that is useful and all but, how do we create some dynamic sql with lovely concatenations?&lt;/p&gt;


Like so:
&lt;pre&gt;&lt;code&gt;
Declare @SQL VarChar(1000)
Select @SQL = 'INSERT new_table_name(description, status, date_due, date_complete, date_start, ref_id)'
Select @SQL = @SQL + ' SELECT descrip' + CAST(@intFlag AS varchar) + ', status' + CAST(@intFlag AS varchar) + ', due' + CAST(@intFlag AS varchar) + ', complete' + CAST(@intFlag AS varchar) + ', start' + CAST(@intFlag AS varchar) + ', old_id'
Select @SQL = @SQL + ' FROM old_table_name'
Select @SQL = @SQL + ' WHERE required_column' + CAST(@intFlag AS varchar) + ' IS NOT NULL'
Exec ( @SQL)
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;So now we just combine it all:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
DECLARE @intFlag INT
SET @intFlag = 1
WHILE (@intFlag &amp;lt;11)
BEGIN
Declare @SQL VarChar(1000)
Select @SQL = 'INSERT new_table_name(description, status, date_due, date_complete, date_start, ref_id)'
Select @SQL = @SQL + ' SELECT descrip' + CAST(@intFlag AS varchar) + ', status' + CAST(@intFlag AS varchar) + ', due' + CAST(@intFlag AS varchar) + ', complete' + CAST(@intFlag AS varchar) + ', start' + CAST(@intFlag AS varchar) + ', old_id'
Select @SQL = @SQL + ' FROM old_table_name'
Select @SQL = @SQL + ' WHERE required_column' + CAST(@intFlag AS varchar) + ' IS NOT NULL'
Exec ( @SQL)
SET @intFlag = @intFlag + 1
CONTINUE;
END
GO

&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Ask away if there are any questions.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-03-13:2356</id>
    <published>2009-03-13T13:41:00Z</published>
    <updated>2009-03-13T13:42:13Z</updated>
    <category term="Coldfusion"/>
    <category term="Internet Tech"/>
    <category term="oop"/>
    <category term="oop vs. procedural"/>
    <category term="procedural programming"/>
    <category term="rob pike"/>
    <link href="http://blog.stevensross.com/2009/3/13/oop-it-s-not-perfect" rel="alternate" type="text/html"/>
    <title>OOP - it's not perfect</title>
<content type="html">
            &lt;p&gt;Ok, not trying to start a flame war but, I&#8217;m republishing this, it was from an interview with Rob Pike (works for google, really smart, had his hands in the early days of Unix). This is a great response to a question posed to him and for the record the original article is here &lt;a href=&quot;http://interviews.slashdot.org/article.pl?sid=04/10/18/1153211&amp;amp;#38;tid=189&amp;amp;#38;tid=156&amp;amp;#38;tid=130&amp;amp;#38;tid=11&quot;&gt;Rob Pike Responds&lt;/a&gt; but, I am just publishing one part of it. I&#8217;d encourage you to read it as we should always try to solve a problem the best way possible and that is what this is about.&lt;/p&gt;


	&lt;h2&gt;Question
Hello!&lt;/h2&gt;


	&lt;p&gt;Maybe this is an overly-asked question, but I still often ponder it. Does object-oriented design negate or diminish the future prospects of Unix&#8217;s continuing popularity?&lt;/p&gt;


	&lt;p&gt;I&#8217;ve developed in C (which I still love), but lately, I&#8217;ve been doing a lot of purely object-oriented development in Java. Using things like delegation and reusable classes have made life so much easier in many respects. Since the *nixes are so dependent upon C, I was wondering what future you see in C combined with Unix. Like I said, I love C and still enjoy developing in Unix, but there has to be a point where you build on your progress and the object-oriented languages, in my opinion, seem to be doing that.&lt;/p&gt;


	&lt;p&gt;Thank you for all your contributions!!!&lt;/p&gt;


	&lt;h2&gt;Pike:&lt;/h2&gt;


	&lt;p&gt;The future does indeed seem to have an OO hue. It may have bearing on Unix, but I doubt it; Unix in all its variants has become so important as the operating system of the internet that whatever the Java applications and desktop dances may lead to, Unix will still be pushing the packets around for a quite a while.&lt;/p&gt;


	&lt;p&gt;On a related topic, let me say that I&#8217;m not much of a fan of object-oriented design. I&#8217;ve seen some beautiful stuff done with OO, and I&#8217;ve even done some OO stuff myself, but it&#8217;s just one way to approach a problem. For some problems, it&#8217;s an ideal way; for others, it&#8217;s not such a good fit.&lt;/p&gt;


	&lt;p&gt;Here&#8217;s an analogy. If you want to make some physical artifact, you might decide to build it purely in wood because you like the way the grain of the wood adds to the beauty of the object. In fact many of the most beautiful things in the world are made of wood. But wood is not ideal for everything. No amount of beauty of the grain can make wood conduct electricity, or support a skyscraper, or absorb huge amounts of energy without breaking. Sometimes you need metal or plastic or synthetic materials; more often you need a wide range of materials to build something of lasting value. Don&#8217;t let the fact that you love wood blind you to the problems wood has as a material, or to the possibilities offered by other materials.&lt;/p&gt;


	&lt;p&gt;The promoters of object-oriented design sometimes sound like master woodworkers waiting for the beauty of the physical block of wood to reveal itself before they begin to work. &#8220;Oh, look; if I turn the wood this way, the grain flows along the angle of the seat at just the right angle, see?&#8221; Great, nice chair. But will you notice the grain when you&#8217;re sitting on it? And what about next time? Sometimes the thing that needs to be made is not hiding in any block of wood.&lt;/p&gt;


	&lt;p&gt;OO is great for problems where an interface applies naturally to a wide range of types, not so good for managing polymorphism (the machinations to get collections into OO languages are astounding to watch and can be hellish to work with), and remarkably ill-suited for network computing. That&#8217;s why I reserve the right to match the language to the problem, and even &#8211; often &#8211; to coordinate software written in several languages towards solving a single problem.&lt;/p&gt;


	&lt;p&gt;It&#8217;s that last point &#8211; different languages for different subproblems &#8211; that sometimes seems lost to the OO crowd. In a typical working day I probably use a half dozen languages &#8211; C, C++, Java, Python, Awk, Shell &#8211; and many more little languages you don&#8217;t usually even think of as languages &#8211; regular expressions, Makefiles, shell wildcards, arithmetic, logic, statistics, calculus &#8211; the list goes on.&lt;/p&gt;


	&lt;p&gt;Does object-oriented design have much to say to Unix? Sure, but no more than functions or concurrency or databases or pattern matching or little languages or&#8230;.&lt;/p&gt;


	&lt;p&gt;Regardless of what I think, though, OO design is the way people are taught to think about computing these days. I guess that&#8217;s OK &#8211; the work does seem to get done, after all &#8211; but I wish the view was a little broader.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-03-12:2354</id>
    <published>2009-03-12T13:57:00Z</published>
    <updated>2009-03-12T14:12:20Z</updated>
    <category term="csv import"/>
    <category term="fastercsv"/>
    <category term="mysql"/>
    <category term="mysql import csv"/>
    <category term="rails"/>
    <link href="http://blog.stevensross.com/2009/3/12/fast-csv-import-mysql-in-rails-or-any-language" rel="alternate" type="text/html"/>
    <title>Fast csv import mysql in rails or any language</title>
<content type="html">
            &lt;p&gt;Been working a lot with rails lately and I needed to import a large dataset (almost 3200 records). If you do something like this in rails you have to use the fastercsv gem, as, well it is faster. The thing is though, ActiveRecord isn&#8217;t. So although I can read the csv file in about 2-3 seconds creating the records ends up taking about 10-12. I didn&#8217;t really like this performance wise so I poked around on the web and found this method using &#8220;LOAD &lt;span class=&quot;caps&quot;&gt;DATA INFILE&lt;/span&gt;&#8221; &#8211; a feature in mysql that lets you specify a csv to load and map to columns and boy, it is fast. The whole process takes about as long as it takes fastercsv to read the file (2-3 seconds now).&lt;/p&gt;


So here is the method:
&lt;pre&gt;
&lt;code&gt;

def fast_import
    csv_string = FasterCSV.generate do |csv| 
      FasterCSV.foreach( absolute_path, {:headers =&amp;gt; true, :return_headers =&amp;gt; false, :header_converters =&amp;gt; :symbol} ) do |row|
        csv &amp;lt;&amp;lt; [row[:firstname],row[:lastname],row[:doctor_name],row[:homephone],self.id,row[:insurance],row[:mi],row[:dob],row[:address1],row[:address2],row[:city],row[:state],row[:zip],row[:id],row[:salutation],row[:survey_result_code] ]
      end
    end
    tmp_file = absolute_path + '.tmp'
    File.open(tmp_file, 'w') {|f| f.write(csv_string) }
    ActiveRecord::Base.connection.execute(load_data_infile(tmp_file))
    system(&quot;rm&quot;, tmp_file) # remove the temp file
  end

private
def load_data_infile(temp_path)
           &amp;lt;&amp;lt;-EOF
                 LOAD DATA INFILE &quot;#{temp_path}&quot; 
                          INTO TABLE attendees
                          FIELDS TERMINATED BY ','
                             (first_name, last_name, doctor_name, home_phone, event_id, insurance, middle_initial, date_of_birth, address, address_continued, city, state, zip_code, barcode_id, salutation, survey_result_code)
                            SET created_at = '#{Time.current.to_s(:db)}',
                            updated_at = '#{Time.current.to_s(:db)}';
            EOF
        end

&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Ok all we are doing is using fastercsv to parse the uploaded file, read it and then write it back to the disk so that mysql can import it. The first method is rails specific but the second could be used in any language as it is really just some mysql code. It is pretty self explanatory. If you need some help getting it working, just leavea  comment!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-03-09:2349</id>
    <published>2009-03-09T23:54:00Z</published>
    <updated>2009-03-09T23:56:02Z</updated>
    <category term="fountain"/>
    <category term="savannah"/>
    <category term="st. patrick's day"/>
    <link href="http://blog.stevensross.com/2009/3/9/savannah-dying-of-the-fountains" rel="alternate" type="text/html"/>
    <title>Savannah - dying of the fountains</title>
<content type="html">
            Well St. Pats is officially on its way and just in case you haven't heard Savannah is crazy for St. Patrick's Day. Check out the video of the fountain being dyed green.
&lt;br /&gt;
&lt;br /&gt;

&amp;lt;embed src=&quot;http://services.brightcove.com/services/viewer/federated_f8/1184614610&quot; height=&quot;412&quot; width=&quot;486&quot;&gt;&amp;lt;/embed&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-02-24:2344</id>
    <published>2009-02-24T14:25:00Z</published>
    <updated>2009-02-24T14:25:39Z</updated>
    <category term="Coldfusion"/>
    <category term="Productivity"/>
    <category term="git"/>
    <category term="osx"/>
    <category term="subversion"/>
    <link href="http://blog.stevensross.com/2009/2/24/learning-git-this-might-help" rel="alternate" type="text/html"/>
    <title>Learning git? This might help.</title>
<content type="html">
            &lt;p&gt;I stumbled upon this after browsing some podcasts on rails the other day. The learning rails podcast has an episode on git (a distributed version control system). If you have heard the buzz (git is basically the new &lt;span class=&quot;caps&quot;&gt;SVN&lt;/span&gt;, at least in hype). &lt;a href=&quot;http://www.buildingwebapps.com/podcasts/6894-version-control-with-git/show_notes&quot;&gt;Go check it out&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-02-23:2343</id>
    <published>2009-02-23T15:55:00Z</published>
    <updated>2009-02-23T15:59:57Z</updated>
    <category term="Internet Tech"/>
    <category term="mysql"/>
    <link href="http://blog.stevensross.com/2009/2/23/quick-tip-for-mysql-speed" rel="alternate" type="text/html"/>
    <title>Quick tip for mysql speed</title>
<content type="html">
            &lt;p&gt;I was doing some query tuning the other day (live search on a page and I needed it to go as fast as possible) I was searching about 3000 records and seeing how much performance I could squeeze out of mysql and a simple &lt;span class=&quot;caps&quot;&gt;LIKE&lt;/span&gt; search. Put it simply if you want the most fastest (yes I just said that) you need to switch your tables from InnoDB to MyIsam because MyIsam doesn&#8217;t use transactions. Could be a no go for you but, if you need to do a fast search against the db it is your best bet. I saw my searches improve in speed about 2-3 times (however your mileage may vary).&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-02-12:2336</id>
    <published>2009-02-12T15:10:00Z</published>
    <updated>2009-02-12T15:23:58Z</updated>
    <category term="kiteboarding"/>
    <category term="kitesurfing"/>
    <category term="time management"/>
    <link href="http://blog.stevensross.com/2009/2/12/kitesurfing-where-do-you-get-the-time" rel="alternate" type="text/html"/>
    <title>Kitesurfing: where do you get the time?</title>
<content type="html">
            &lt;p&gt;Ok, this is directed at a fan, well 3 comments to my dribble, I consider that a fan, hah! Anyway, Diane posed the question in response to my kitesurfing experience: &#8220;Where do you get the time?&#8221; So I thought heavily about the question (really I didn&#8217;t, I immediately knew the answer). The answer is simple, I consider my free time more valuable than anything else and one day while I was working on-site in Cleveland, &lt;span class=&quot;caps&quot;&gt;OH I&lt;/span&gt; was telling someone about kiteboarding. Then it just struck me, why haven&#8217;t I taken lessons? It was something that I wanted to try the first time I saw it and I just let it fester in the back of my mind. So I did it, I made a call and scheduled a lesson, end of story.&lt;/p&gt;


	&lt;p&gt;So the long and short of it is that I just figured that at the end of my life I don&#8217;t want to say &#8220;I wish I had tried that&#8221; so I don&#8217;t, I just try it and man am I ever glad that I did. Well there is one drawback, kiteboarding is like crack apparently and I am hooked!&lt;/p&gt;


	&lt;p&gt;So here is an update from my kiteboarding experience: I can now jump, do back rolls (sort of an off axis flip/360) and this cool thing called a &lt;a href=&quot;http://www.youtube.com/watch?v=ADPZsruKdiw&quot;&gt;railey&lt;/a&gt;. Ok, now when I say jump I really mean fly, because a jump is probably a few feet off the water and with the kite attached to you on a windy day (like yesterday) my &#8220;jumps&#8221; were 20-30 feet off the water.&lt;/p&gt;


	&lt;p&gt;I&#8217;m also on twitter now so give me a follow if you want. Adios!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-02-06:2332</id>
    <published>2009-02-06T20:22:00Z</published>
    <updated>2009-02-06T20:28:15Z</updated>
    <category term="Internet Tech"/>
    <category term="Productivity"/>
    <category term="installing ruby ee"/>
    <category term="passenger"/>
    <category term="phusion passenger"/>
    <link href="http://blog.stevensross.com/2009/2/6/now-running-on-passenger-and-ruby-ee" rel="alternate" type="text/html"/>
    <title>Now running on passenger (and ruby EE)</title>
<content type="html">
            &lt;p&gt;If you use rails, or are considering it, it just got a whole lot easier to deploy using apache and mod_rails a.k.a &lt;a href=&quot;http://www.modrails.com/&quot;&gt;Phusion Passenger&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;I think the best part of the experience was the installer, if you have ever compiled anything on linux you know it can be a pain when you don&#8217;t know if you have the required libraries. So the Phusion Passenger folks wrote their installer in ruby and it tells you what is missing (if there is anything). Sweet stuff.&lt;/p&gt;


	&lt;p&gt;Its much easier than running on mongrel, especially dealing with restarts and reboots (if you ever have to reboot, typically apache is already configured to start on startup). So how to restart an app? no shutdown you just navigate to the rails directory and issue a &#8220;touch tmp/restart.txt&#8221; next request the app will restart. Slick, wish everything was that simple.&lt;/p&gt;


	&lt;p&gt;So all in all (with out ruby enterprise) it took me 15 mins to install it and switch all my apps over from Mongrel to Phusion Passenger.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-02-03:2331</id>
    <published>2009-02-03T19:47:00Z</published>
    <updated>2009-02-03T19:52:49Z</updated>
    <category term="Internet Tech"/>
    <category term="application development"/>
    <category term="design"/>
    <category term="zerium"/>
    <link href="http://blog.stevensross.com/2009/2/3/new-site-launched-http-zerium-com" rel="alternate" type="text/html"/>
    <title>New site launched: http://zerium.com</title>
<content type="html">
            &lt;p&gt;Just thought I&#8217;d put this out there that my company, zerium Interactive, has a new site: &lt;a href=&quot;http://zerium.com&quot;&gt;http://zerium.com&lt;/a&gt; and is geared toward helping small business eliminate some of their website issues. Each web package contains most of the tools you need to help your business succeed on the web.&lt;/p&gt;


	&lt;p&gt;We also do custom application design, development and hosting, so if you don&#8217;t just need the basics we can get it done.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-01-29:2329</id>
    <published>2009-01-29T15:20:00Z</published>
    <updated>2009-01-29T15:22:39Z</updated>
    <category term="Mac OS X"/>
    <category term="Productivity"/>
    <link href="http://blog.stevensross.com/2009/1/29/linux-os-x-shell-scripting-with-sudo" rel="alternate" type="text/html"/>
    <title>Linux / OS X - shell scripting with sudo</title>
<content type="html">
            &lt;p&gt;Ever need to create a shell script and use the sudo command? here is how you do it:&lt;/p&gt;


	&lt;p&gt;read $passwd&lt;/p&gt;


	&lt;p&gt;echo $passwd | sudo -S touch test&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-01-20:2323</id>
    <published>2009-01-20T19:31:00Z</published>
    <updated>2009-01-20T19:31:27Z</updated>
    <category term="Coldfusion"/>
    <category term="Productivity"/>
    <category term="codfusion configuration"/>
    <category term="instances"/>
    <category term="management"/>
    <link href="http://blog.stevensross.com/2009/1/20/wddxconfig-replaces-simpleconfig-cfc-now-with-more-simple" rel="alternate" type="text/html"/>
    <title>WDDXConfig - replaces SimpleConfig.cfc now with more simple!</title>
<content type="html">
            &lt;p&gt;Well I know I just released the SimpleConfig.cfc but, I didn&#8217;t think it was as flexible as some might need. The new version uses one config file and can load any datatype that ColdFusion will understand in &lt;span class=&quot;caps&quot;&gt;WDDX&lt;/span&gt; format, so if you already have configuration variables in your App Scope you can just write them out as a &lt;span class=&quot;caps&quot;&gt;WDDX&lt;/span&gt; file and copy the values into &#8220;config.wddx&#8221; under the &#8220;Base&#8221; node and then just add your instances under the &lt;span class=&quot;caps&quot;&gt;INSTANCES&lt;/span&gt; node in &#8220;config.wddx&#8221;&lt;/p&gt;


	&lt;h2&gt;Click to &lt;a href=&quot;http://blog.stevensross.com/assets/2009/1/20/wddxConfig.zip&quot;&gt;download source files&lt;/a&gt;&lt;/h2&gt;


	&lt;p&gt;I think this is pretty self explanatory when you take a peek at the code, I even simplified the required application.cfc code to be as easy as possible:&lt;/p&gt;


	&lt;h2&gt;Application.cfc:&lt;/h2&gt;


&lt;pre&gt;
&lt;code&gt;
&amp;lt;cffunction name=&quot;OnApplicationStart&quot;&amp;gt;
        &amp;lt;cflock type=&quot;exclusive&quot; scope=&quot;Application&quot; timeout=&quot;60&quot;&amp;gt;
            &amp;lt;cfset WDDXConfig = createObject(&quot;component&quot;,&quot;org.ross.WDDXConfig&quot;) /&amp;gt;
            &amp;lt;!--- optional parameters to WDDXConfig are as follows:
                 WDDXConfig.init(&quot;/config/&quot;, &quot;config.wddx&quot;, &quot;config&quot;)
                &quot;/config/&quot; is the mapping where your config files are
                &quot;config.wddx&quot; is your configuration file name
                &quot;config&quot; is the name of your Application variable where your configuration options are going
                 ---&amp;gt;
            &amp;lt;cfset WDDXConfig.init() /&amp;gt;

        &amp;lt;/cflock&amp;gt;
    &amp;lt;/cffunction&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;

	&lt;h2&gt;config.wddx&lt;/h2&gt;


	&lt;p&gt;This file is pretty simple, if you need some help understanding what it will translate to when you run the app, just run it and see the dump of &#8220;Application&#8221;&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;
&amp;lt;wddxPacket version=&quot;1.0&quot;&amp;gt;
    &amp;lt;header/&amp;gt;
    &amp;lt;data&amp;gt;
        &amp;lt;struct&amp;gt;
            &amp;lt;var name=&quot;INSTANCES&quot;&amp;gt;
                &amp;lt;!-- don't for get to iterate the length below as you add instances --&amp;gt;
                &amp;lt;array length=&quot;1&quot;&amp;gt;
                    &amp;lt;struct&amp;gt;
                        &amp;lt;var name=&quot;instanceType&quot;&amp;gt;&amp;lt;string&amp;gt;QA&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                        &amp;lt;!-- because you could be running multiple instances on the same machine
                         and thus the physical name could be the same (and we can't rely on CGI variables to be clean)
                         we use an identifying directory name here and the identifier will be placed
                         into the app scope as &quot;ACTUALPATH&quot; incase you are unsure of the physical path to your Application.cfc
                         C:\mysites\steve\appname\Application.cfc or mac: /mysites/steve/appname/Application.cfc --&amp;gt;
                        &amp;lt;var name=&quot;identifier&quot;&amp;gt;&amp;lt;string&amp;gt;/Volumes/Case Sensitive/www/simpleconfig/html/&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                        &amp;lt;var name=&quot;OVER_RIDE&quot;&amp;gt;
                            &amp;lt;struct&amp;gt;
                                &amp;lt;!-- override your base settings here --&amp;gt;
                                &amp;lt;var name=&quot;DSNs&quot;&amp;gt;
                                    &amp;lt;struct&amp;gt;
                                        &amp;lt;var name=&quot;marketing&quot;&amp;gt;&amp;lt;string&amp;gt;marketingDSNLocal&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                                    &amp;lt;/struct&amp;gt;
                                &amp;lt;/var&amp;gt;
                            &amp;lt;/struct&amp;gt;
                        &amp;lt;/var&amp;gt;
                    &amp;lt;/struct&amp;gt;
                &amp;lt;/array&amp;gt;
            &amp;lt;/var&amp;gt;
            &amp;lt;!-- all of your base configuration data will go here --&amp;gt;
            &amp;lt;var name=&quot;BASE&quot;&amp;gt;
                &amp;lt;struct&amp;gt;
                    &amp;lt;var name=&quot;instanceType&quot;&amp;gt;&amp;lt;string&amp;gt;Development&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                    &amp;lt;var name=&quot;DSNs&quot;&amp;gt;
                        &amp;lt;struct&amp;gt;
                            &amp;lt;var name=&quot;marketing&quot;&amp;gt;&amp;lt;string&amp;gt;marketingPROD&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                        &amp;lt;/struct&amp;gt;
                    &amp;lt;/var&amp;gt;
                    &amp;lt;var name=&quot;additionalConfigFiles&quot;&amp;gt;
                        &amp;lt;array length=&quot;1&quot;&amp;gt;
                            &amp;lt;!-- as an example I'm just reloading the config.wddx file into another struct,
                             you can do as many additional wddx based config files as you want
                              (structName is the substruct name and fileName is the file name)--&amp;gt;
                            &amp;lt;struct&amp;gt;
                                &amp;lt;var name=&quot;structName&quot;&amp;gt;&amp;lt;string&amp;gt;sample&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                                &amp;lt;var name=&quot;fileName&quot;&amp;gt;&amp;lt;string&amp;gt;config.wddx&amp;lt;/string&amp;gt;&amp;lt;/var&amp;gt;
                            &amp;lt;/struct&amp;gt;
                        &amp;lt;/array&amp;gt;
                    &amp;lt;/var&amp;gt;
                &amp;lt;/struct&amp;gt;
            &amp;lt;/var&amp;gt;
        &amp;lt;/struct&amp;gt;
    &amp;lt;/data&amp;gt;
&amp;lt;/wddxPacket&amp;gt;

&lt;/code&gt;
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-01-16:2322</id>
    <published>2009-01-16T22:08:00Z</published>
    <updated>2009-01-20T17:31:08Z</updated>
    <category term="Coldfusion"/>
    <category term="Productivity"/>
    <category term="Coldfusion"/>
    <category term="coldfusion"/>
    <category term="configuration"/>
    <category term="multiple-instances"/>
    <link href="http://blog.stevensross.com/2009/1/16/simpleconfig-cfc-manging-multiple-instances-of-your-application-in-coldfusion" rel="alternate" type="text/html"/>
    <title>SimpleConfig.cfc - Managing multiple instances of your application in Coldfusion</title>
<content type="html">
            &lt;p&gt;When it comes time to deploy your application it is often difficult to manage application variables that change per instance. SimpleConfig aim&#8217;s to reduce the pain in running different environments. It does this by reading two xml files and taking those variables and placing them into your application scope for you to reference by using the prefix: Application.Configuration anywhere in your application.&lt;/p&gt;


	&lt;p&gt;source files: &lt;a href=&quot;http://blog.stevensross.com/assets/2009/1/16/simpleconfig.zip&quot;&gt;click to download&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;Setup and Configuration&lt;/h2&gt;


	&lt;p&gt;Ok so lets dig into the file structure. When you download the zip file you will find a few directories listed as such:&lt;/p&gt;


	&lt;p&gt;/simpleconfig/config_files&lt;/p&gt;


	&lt;p&gt; /simpleconfig/html&lt;/p&gt;


	&lt;p&gt;The &#8220;html&#8221; directory is where you want to point Apache/IIS as the web root of your application. All you need to do is add a mapping of “/config” and point it to wherever you want to put the “config_files” directory and you are ready to start tweaking your config files.&lt;/p&gt;


	&lt;p&gt;Ok so on to configuring this puppy. Point Apache/IIS to the extracted directory /simpleconfig/html as your web root (again you can skip that step for demonstration purposes and just drop the contents of the directory &#8220;simpleconfig&#8221; onto your existing web root).&lt;/p&gt;


	&lt;h2&gt;Defining your environments&lt;/h2&gt;


Now go take a look at the file: /simpleconfig/config_files/config-instances.xml:   
&lt;pre&gt;
&lt;code&gt;
&amp;lt;configuration&amp;gt;
     &amp;lt;option&amp;gt; 
        &amp;lt;description&amp;gt;Local Instance&amp;lt;/description&amp;gt;
         &amp;lt;name&amp;gt;&amp;lt;![CDATA[simpleconfig.local]]&amp;gt;&amp;lt;/name&amp;gt;
         &amp;lt;value&amp;gt;&amp;lt;![CDATA[config-dev.xml]]&amp;gt;&amp;lt;/value&amp;gt; 
    &amp;lt;/option&amp;gt; 
    &amp;lt;option&amp;gt;
         &amp;lt;description&amp;gt;Configuration Files that pertain to all instances&amp;lt;/description&amp;gt;
         &amp;lt;name&amp;gt;&amp;lt;![CDATA[BASE_CONFIGURATION_FILES]]&amp;gt;&amp;lt;/name&amp;gt; 
        &amp;lt;value&amp;gt; 
            &amp;lt;key&amp;gt;
                 &amp;lt;name&amp;gt;&amp;lt;![CDATA[Base Config File]]&amp;gt;&amp;lt;/name&amp;gt;
                 &amp;lt;value&amp;gt;&amp;lt;![CDATA[config-base.xml]]&amp;gt;&amp;lt;/value&amp;gt; 
            &amp;lt;/key&amp;gt; 
        &amp;lt;/value&amp;gt;
     &amp;lt;/option&amp;gt;
 &amp;lt;/configuration&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;As you can see there is just some xml in here that defines each environment that you will be running. When you want to add an environment you simply add another node with the appropriate details. So to edit this for your own local machine you probably want to change the node to the host name of your machine, because &lt;span class=&quot;caps&quot;&gt;CGI&lt;/span&gt; can be mucked with too easily on the client side I opted to use the java way at getting the machine name, most likely you will just have to run the app and see the dump to get your machine’s name so you can put the appropriate name in the config-instances.xml file. Next after that is the config file that pertains to your local instance. In this case we have &#8220;config-dev.xml&#8221;.&lt;/p&gt;


	&lt;p&gt;The idea here is to use this configuration file to define any differences from your base-config for your application. So say you have an email address that you want to use in your application, you probably don&#8217;t want to use your production account info while you are developing locally. However you probably do want the same &lt;span class=&quot;caps&quot;&gt;DSN&lt;/span&gt; name and that would be put in your config-base.xml and not overridden in your config-dev.xml.&lt;/p&gt;


	&lt;p&gt;You should also note that the first word in the description will be the name of that environment type. So if you put into the description &#8220;QA&#8221; the &#8220;CurrentMode&#8221; variable in the configuration would become &#8220;QA&#8221; instead of &#8220;Local&#8221;. This is useful when you have to add more environments that you didn&#8217;t account for initially.&lt;/p&gt;


	&lt;p&gt;Also, this gives you the ability to quickly switch and test configurations by simply changing the xml file that you are loading for that instance. So if you had a &#8220;config-qa.xml&#8221; you could easily test that configuration locally by specifying that xml file instead of the &#8220;config-dev.xml&#8221;&lt;/p&gt;


h2. Configuring each environment
The config-base.xml file:
&lt;pre&gt;
&lt;code&gt;
&amp;lt;configuration&amp;gt;
    &amp;lt;option&amp;gt;
        &amp;lt;description&amp;gt;Application Status Struct&amp;lt;/description&amp;gt;
        &amp;lt;name&amp;gt;&amp;lt;![CDATA[applicationStatus]]&amp;gt;&amp;lt;/name&amp;gt;
        &amp;lt;value&amp;gt;
            &amp;lt;key&amp;gt;
                &amp;lt;name&amp;gt;&amp;lt;![CDATA[isAvailable]]&amp;gt;&amp;lt;/name&amp;gt;
                &amp;lt;value&amp;gt;&amp;lt;![CDATA[true]]&amp;gt;&amp;lt;/value&amp;gt;
            &amp;lt;/key&amp;gt;
            &amp;lt;key&amp;gt;
                &amp;lt;name&amp;gt;&amp;lt;![CDATA[unAvailableMessageHeader]]&amp;gt;&amp;lt;/name&amp;gt;
                &amp;lt;value&amp;gt;&amp;lt;![CDATA[Website Unavailable]]&amp;gt;&amp;lt;/value&amp;gt;
            &amp;lt;/key&amp;gt;
            &amp;lt;key&amp;gt;
                &amp;lt;name&amp;gt;&amp;lt;![CDATA[unAvailableMessageBody]]&amp;gt;&amp;lt;/name&amp;gt;

                &amp;lt;value&amp;gt;&amp;lt;![CDATA[Application is temporarily unavailable.]]&amp;gt;&amp;lt;/value&amp;gt;
            &amp;lt;/key&amp;gt;
        &amp;lt;/value&amp;gt;
    &amp;lt;/option&amp;gt;
    &amp;lt;option&amp;gt;
        &amp;lt;description&amp;gt;An application variable&amp;lt;/description&amp;gt;
        &amp;lt;name&amp;gt;&amp;lt;![CDATA[somevariable]]&amp;gt;&amp;lt;/name&amp;gt;
        &amp;lt;value&amp;gt;&amp;lt;![CDATA[something you need in the app scope]]&amp;gt;&amp;lt;/value&amp;gt;
    &amp;lt;/option&amp;gt;
    &amp;lt;option&amp;gt;
        &amp;lt;description&amp;gt;Some struct that you want in the app scope&amp;lt;/description&amp;gt;
        &amp;lt;name&amp;gt;&amp;lt;![CDATA[theStructName]]&amp;gt;&amp;lt;/name&amp;gt;
        &amp;lt;value&amp;gt;
            &amp;lt;key&amp;gt;
                &amp;lt;name&amp;gt;&amp;lt;![CDATA[structkeyOne]]&amp;gt;&amp;lt;/name&amp;gt;
                &amp;lt;value&amp;gt;&amp;lt;![CDATA[~now()]]&amp;gt;&amp;lt;/value&amp;gt;
            &amp;lt;/key&amp;gt;
            &amp;lt;key&amp;gt;
                &amp;lt;name&amp;gt;&amp;lt;![CDATA[structKeyTwo]]&amp;gt;&amp;lt;/name&amp;gt;
                &amp;lt;value&amp;gt;&amp;lt;![CDATA[some string]]&amp;gt;&amp;lt;/value&amp;gt;
            &amp;lt;/key&amp;gt;
            &amp;lt;key&amp;gt;
                &amp;lt;name&amp;gt;&amp;lt;![CDATA[structKeyThree]]&amp;gt;&amp;lt;/name&amp;gt;
                &amp;lt;value&amp;gt;&amp;lt;![CDATA[some other string]]&amp;gt;&amp;lt;/value&amp;gt;
            &amp;lt;/key&amp;gt;
        &amp;lt;/value&amp;gt;
    &amp;lt;/option&amp;gt;
&amp;lt;/configuration&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;
This file is a bit bigger and it contains some interesting stuff. Basically you can put pretty much anything into your application scope. You can even put calls to coldfusion functions in your xml that will be called when the xml is read and placed into your application scope. You can see a few lines up where there is the coldfusion function &#8220;now()&#8221; being called on &#8220;structKeyThree&#8221;. You tell SimpleConfig to evaluate the function by placing a tilde (~) before the function. I think the other huge advantage here is being able to define a struct that will go into your Application.Configuration object. 

	&lt;p&gt;You can see a struct being defined in the applicationstatus node. You see that the first node contains a node then what will be created is a struct. The first node will be the struct name ie: Application.Configuration.MyStruct and then the additional nodes under the nodes will be the key in the struct and the will be the value for that key. This is much easier to see in action. So make a change to one of the struct keys or their values and you can see it work.&lt;/p&gt;


	&lt;h2&gt;About the applicationstatus node&lt;/h2&gt;


	&lt;p&gt;I built this node into the guts of the application. If for some reason you need to take your application offline (some back-end system is down perhaps). You can edit the applicationstatus node and set the isAvailable node to false and the Application.cfc will throw an exception (for every request) which you can then catch and display to your users on your own custom error page. Granted you don&#8217;t have to go this route but, it is there for you to use.&lt;/p&gt;


	&lt;h2&gt;Reloading your configuration files&lt;/h2&gt;


	&lt;p&gt;To reload the application you simply tack on a ?reload to the query string. Note that this only works when the application is not in production mode and also when trusted cache is off.&lt;/p&gt;


	&lt;h2&gt;SimpleConfig.cfc&lt;/h2&gt;


	&lt;p&gt;If you take a look at org/ross/SimpleConfig.cfc there are two places for you to add in your own methods that can be called when the application is starting up. The first place is the setup() method and the second is the start() method. The setup method is designed to be used when you need to call some other code before variables are placed into the Application scope and the start() method is designed to be used after those variables have been placed into the Application scope. Both of these methods are called each time the Application is reloaded (which you can see in the Application.cfc).&lt;/p&gt;


	&lt;p&gt;I hope this is enough to get you started. It really is a simple and elegant way to handle configuration variables. I will be adding additional text as I get time that will explain how you can add more configuration data into the application scope just by adding your own xml files and editing the config-instances.xml. Here is a hint: The SimpleConfig.cfc will keep loading any of the defined xml files in the &lt;span class=&quot;caps&quot;&gt;BASE&lt;/span&gt;_CONFIGURATION_FILES node, just make sure you structure them exactly like the other config files.&lt;/p&gt;


	&lt;p&gt;This software is licensed under the CC-GNU &lt;span class=&quot;caps&quot;&gt;GPL&lt;/span&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2009-01-02:2290</id>
    <published>2009-01-02T14:50:00Z</published>
    <updated>2009-01-02T14:59:59Z</updated>
    <category term="ajax"/>
    <category term="Coldfusion"/>
    <category term="coldfusion"/>
    <category term="contract"/>
    <category term="js"/>
    <category term="ruby on rails"/>
    <link href="http://blog.stevensross.com/2009/1/2/available-for-hire-coldfusion-ruby-on-rails-ajax-js-css-flex-even-design-work" rel="alternate" type="text/html"/>
    <title>Available for Hire: Coldfusion, Ruby on Rails, AJAX / JS, CSS, Flex, even Design work.</title>
<content type="html">
            &lt;p&gt;With things a bit slow right now I&#8217;m putting myself out there for any contract work. You can view my resume here:&lt;/p&gt;


	&lt;p&gt;Here are a few things that I can help you with:
Debugging / Tuning,
Architecture,
Linux Administration, 
UI, layout, and site implementation (templatizing)&lt;/p&gt;


	&lt;p&gt;http://blog.stevensross.com/resume&lt;/p&gt;


	&lt;p&gt;If you just need a few hours help on a problem to a full blown site please don&#8217;t hesitate to contact me, my rates are reasonable.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2008-11-03:1203</id>
    <published>2008-11-03T16:17:00Z</published>
    <updated>2008-11-03T16:18:20Z</updated>
    <category term="Internet Tech"/>
    <category term="Productivity"/>
    <category term="mysql"/>
    <category term="ssh tunnel"/>
    <link href="http://blog.stevensross.com/2008/11/3/open-an-ssh-tunnel-to-administer-mysql-or-anything-else" rel="alternate" type="text/html"/>
    <title>Open an ssh Tunnel to Administer MySQL (or anything else)</title>
<content type="html">
            &lt;p&gt;Pretty simple stuff, say you are using mysql administrator and you want to point it at a server that you have ssh access to but the firewall prevents you from making a direct connection over the internet (which it should).&lt;/p&gt;


	&lt;p&gt;Here is what you do (if mysql is running on its default port):&lt;/p&gt;


&lt;code&gt;
ssh -N -L3306:localhost:3306 username@server.com
&lt;/code&gt;

	&lt;p&gt;You can also pass in a port variable if you are running ssh on a non-starndard port (which you should also do) all you do is add &#8221; -p 1234&#8221; (1234 would be the port number where ssh is wanting you to connect)&lt;/p&gt;


	&lt;p&gt;Now just point mysql administrator at 127.0.0.1 and supply your credentials. Bang. You&#8217;re in.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.stevensross.com/">
    <author>
      <name>Steven Ross</name>
    </author>
    <id>tag:blog.stevensross.com,2008-10-23:967</id>
    <published>2008-10-23T14:06:00Z</published>
    <updated>2008-10-23T14:06:39Z</updated>
    <category term="Mac OS X"/>
    <category term="Productivity"/>
    <link href="http://blog.stevensross.com/2008/10/23/sync-google-contacts-with-your-mac-iphone" rel="alternate" type="text/html"/>
    <title>Sync Google Contacts with your Mac/iPhone</title>
<content type="html">
            &lt;p&gt;Just passing this along. Found this article at google and yay! Sync&#8217;ing is cool! &lt;a href=&quot;http://googlemac.blogspot.com/2008/05/mac-os-x-1053-sync-google-contacts.html&quot;&gt;read&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
</feed>
