Martinicity: Category Create http://www.martinicity.net/articles/category/create en-us 40 Mike Blake New AppTrain Blog <p>I&#8217;ve created a new <a href="http://blog.apptrain.com">AppTrain blog</a> to focus on my <a href="http://www.apptrain.com">Web Application Company</a>&#8217;s efforts. I&#8217;ll try to keep posts about Ruby, Rails, and Web Application Development there, and keep Martinicity as what it was originally, my personal blog. Martinicity is a state of mind man.</p> Wed, 17 Sep 2008 17:45:18 +0000 urn:uuid:68bc392e-3ddf-4d6d-b5aa-abb5150d5d32 Mike Blake http://www.martinicity.net/articles/2008/09/17/new-apptrain-blog Create Geeking Out in Orlando <p>At some point in my childhood, one of my four younger siblings coined the phrase <a href="http://www.urbandictionary.com/define.php?term=geeking+out">geeking out</a> to call attention to someone was uncontrollably excited. If one of us started geeking out the rest of us would be quick to call them on it. The only known cure was to hurl the offender into a pile of freshly raked leaves, a snow bank, or a sprinkler.</p> <p>Gregg Pollack, head of the <a href="http://www.orug.org">Orlando Ruby User&#8217;s Group</a> has now captured me geeking out in this video to promote <a href="http://www.barcamporlando.org/">BarCampOrlando</a>.</p> <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/DsGWuXywZ6o"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/DsGWuXywZ6o" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> <p>Well I can&#8217;t deny it, I am very excited about attending <a href="http://www.barcamporlando.org/">BarCampOrlando</a>. Come geek out with us at <a href="http://www.tastecp.com/">Taste</a> on Sunday September 23rd and discover why Orlando is quickly becoming one of the top technology centers in the country. And no worries; there will be no leaves, sprinklers, and certainly no snow anywhere near Taste. Just a full bar, awesome food, and great presentations from some of the leading minds in Orlando (and me).</p> Thu, 26 Jul 2007 19:10:00 +0000 urn:uuid:4968de19-0f44-4a2c-bcaf-7a727126dc0b Mike Blake http://www.martinicity.net/articles/2007/07/26/geeking-out-in-orlando Create barcamporlando geeking out The Philanthropic Programmers <p>Something fantastic is happening in the <a href="http://www.rubyonrails.org/">Ruby and Rails</a> World.</p> <p>![](/images/ruby_shades.jpg)</p> <ol> <li>Do unto others</li> </ol> <p>Open source developers know from experience that what goes around comes around. Contributions to projects like Rails invariably come back to benefit everyone, including the contributor. The community is now thinking on a larger scale. Frameworks come and go, but <a href="http://pragdave.pragprog.com/pragdave/2007/05/rails_is_love.html">love</a> is timeless .</p> <ol> <li>The Summer of Love <p>is focusing his power on <a href="http://hacketyhack.net/">Hackety Hack</a> an amazing application that teaches children programming. And it&#8217;s likely more zeitgeist than coincidence that a professor from <span class="caps">MIT</span>, where the generous open source license originated, has started the noble project called <a href="http://laptop.org">One Laptop per Child</a> . Developers everywhere like <a href="http://slash7.com/articles/2006/4/17/teaching-rails-for-charity-in-d-c">Amy Hoy</a> are giving back in order to share the passion.</p></li> </ol> <p>![](/images/rails_logo_heart.png)</p> <p>Chad Fowler has challenged the entire community to harness our newfound passion to do <a href="http://www.chadfowler.com/2007/5/19/changing-the-world">great things</a>. And the community has only just begun to respond. During RailsConf over <a href="http://www.clarkware.com/cgi/blosxom/2007/05/22#RailsConf07">$33,000</a> was raised for <a href="http://pragmaticstudio.com/donate/">charity</a>.</p> <h3><a href="http://www.lse.co.uk/ShowbizNews.asp?Code=WV31893G&#38;headline=paris_hilton_shortlisted_for_nun_role">Witness the Transformation</a></h3> <p>Software evolves rapidly. Humanity seems to evolve at a slower pace, but if you watch carefully, with ruby colored glasses , you can see it happening.</p> Tue, 22 May 2007 21:16:00 +0000 urn:uuid:5cbbdb9a-35d6-4c26-aed0-fdf039d89942 Mike Blake http://www.martinicity.net/articles/2007/05/22/the-philanthropic-programmers Create Pray ruby rails love The RailsEnvy Guys <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/PQbuyKUaKFo"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/PQbuyKUaKFo" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> from our local <a href="http://www.orug.org">Orlando Ruby Users Group</a> have really outdone themselves, and created a series of four Mac vs. PC like ads just in time for <a href="http://conferences.oreillynet.com/rails/">RailsConf</a>. Wed, 16 May 2007 12:32:02 +0000 urn:uuid:ff49b852-dd49-4edb-af0f-cbae77164c58 Mike Blake http://www.martinicity.net/articles/2007/05/16/the-railsenvy-guys Create Hibernate 3.x Migration Guide #### Update 4/30 <code> I finally did find the real [Hibernate 3 Migration Guide](http://www.hibernate.org/250.html). My fun with Hibernate is over though, I've found an easier persistence solution with the clients homegrown method. I believe every single java project I've worked on in the past 10 years has used a different and unique Persistence mechanism. My favorite was [Francois'](http://www.eclipsecon.org/2007/index.php?page=presenters/#Francois_Granade) PersistentEntity at ViaFone. </code> <p /> <hr /> I&#8217;ve been strugling for the last day trying to get a Java application working, mainly, trying to get Hibernate to see a DataSource. Now I&#8217;m at a point where I get this error message: <blockquote> <p>[junit] (cfg.Configuration 1312) configuring from resource: /hibernate.cfg.xml</p> </blockquote> <blockquote> <p>[junit] (cfg.Configuration 1289) Configuration resource: /hibernate.cfg.xml</p> </blockquote> <blockquote> <p>[junit] (util.DTDEntityResolver 30 ) Don&#8217;t use old DTDs, read the <b>Hibernate 3.x Migration Guide!</b></p> </blockquote> <p>A quick search does not turn up a Hibernate Migration Guide, so I decided to create this one.</p> <ol> <li>The Hibernate 3.x Migration Guide</li> </ol> <p>1. Get <a href="http://www.ruby-lang.org/en/">Ruby</a></p> <p>1. Install <a href="http://www.rubyonrails.org/down">Rails</a></p> <p>1. Rebuild your application.</p> <p>1. Have fun again!</p> Thu, 26 Apr 2007 11:30:00 +0000 urn:uuid:4211efe2-2393-422e-af13-478696806a85 Mike Blake http://www.martinicity.net/articles/2007/04/26/hibernate-3-x-migration-guide Create ruby rails hibernate migration http://www.martinicity.net/articles/trackback/889 Testing a Non-Rails Application Using Rails <p>Rails developers working on enterprise software projects are suprised to discover the lack of automated tests in many mature web applications. As frustrating as this can be, A lack of automated tests is also a tremendous opportunity to </p> <pre><code>1. <b>Learn your non-rails applications underlying database structure.</b> 2. <b>Demonstrate to a devlopment team the power of The Rails Framework.</b> 2. <b>Encourage automated testing.</b></code></pre> <p>Rails may be the quickest path to automate some basic test of your non-rails applications data model. These steps will get you all set up to write your automated tests in Ruby.</p> <p>1. <a href="#connect">Connect to Your Enterprise Database</a> 2. <a href="#conventions">Set DB Conventions</a> 3. <a href="#safety">Safety Net</a> 4. <a href="#schema">Duplicate the Schema</a> 4. <a href="#extract">Extract Development Data</a></p> <h4 id='connect'>I. Connect to Your Enterprise Database from Rails.</h4> <p> <p>Download and install any os driver, ruby gems, and rails adapters needed to connect to your database:</p> <blockquote> <p><a href="http://wiki.rubyonrails.com/rails/pages/MySQL">MySQL</a> <br><a href="http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0606dumbill/?ca=dgr-lnxw01DB24RubyonRails"><span class="caps">DB2</span></a> <br><a href="http://www.oracle.com/technology/pub/articles/saternos-ror-faq.html">Oracle</a> <br><a href="http://wiki.rubyonrails.org/rails/pages/HowToSetupSybaseAdapterOnRails">Sybase</a> <br><a href="http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServer">SQLServer</a> <br><a href="http://wiki.rubyonrails.org/rails/pages/PostgreSQL">PostgreSQL</a> <br><a href="http://wiki.rubyonrails.org/rails/pages/Firebird">Firebird</a></p> </blockquote> <h4 id='conventions'>II. Set Your Existing Database Conventions </h4> <p> <p>, Recipie #16 can walk you through this very quickly.</p> Identify any conventions used by your legacy database. Application wide conventions can be set in the <code>config/environment.rb</code> file. They are specified by calling the appropriate class methods available on <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html">ActiveRecord::Base</a>. The methods you need to call depend on how your database is configured: <pre> ActiveRecord::Base.table_name_prefix 'myapp_' ActiveRecord::Base.table_name_suffix = '_def' ActiveRecord::Base.sequence_name = 'dev_company' ActiveRecord::Base.pluralize_table_names = false ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore # or :table_name </pre> <h4 id='safety'><span class="caps">III</span>. Safety Net</h4> <p> <p>Load the <a href="http://agilewebdevelopment.com/plugins/safety_net">SafetyNet Plugin</a> into your rails app to prevent from destroying your development database.</p> <h4 id='schema'>IV. Duplicate Your Database Schema</h4> <p> <p>OK , with your dev and test development databases set correctly, let&#8217;s try duplicting the schema.</p> <code>rake db:test:clone</code> If this works right off the bat, you&#8217;re one of the lucky ones. Skip to <a href="#extract">Extracting Development Data</a> <p> <p>If you recieved errors from the clone command, do steps A through C .</p> <p>A. You can now correct any errors you may have had by manually modifying schema.rb . See <a href="/articles/2007/03/29/rails-on-oracle">Oracle Errors</a> for some problems I had with the Oracle Database. Since schema.rb is generated, it&#8217;s a good idea to rename it when you modify it manually.</p> B. The clone command above may have started loading data; you need may to purge the test db. <code> rake db:test:purge </code> <p>C. Tell rake to load your new schema file by passing the new name, relative to <span class="caps">RAILS</span>_ROOT in the <span class="caps">SCHEMA</span> environment variable:</p> <code> rake db:schema:load RAILS_ENV=test SCHEMA=db/oracle\_schema.rb </code> <h4 id='extract'>V. Extracting Development Data</h4> <p> <p>Copy the code from Rails Recipe #42: <a href="http://media.pragprog.com/titles/fr_rr/code/CreateFixturesFromLiveData/lib/tasks/extract_fixtures.rake">extract_fixtures.rake</a> to your <span class="caps">RAILS</span>\_ROOT/lib/tasks directory.</p> <blockquote> <p><b><span class="caps">TIP</span>: If your develoment database has lots of data, Modify the <span class="caps">SQL</span> Select in this code to limit the amount of data you copy using the <span class="caps">SQL</span> limit statement:</b></p> </blockquote> <blockquote> <code>sql = "SELECT * FROM %s limit = 100"</code> </blockquote> <blockquote> <p>Or for a proprietary database, the equivalent command:</p> </blockquote> <blockquote> <code>sql = "SELECT * FROM %s WHERE ROWNUM&lt;=100"</code> </blockquote> Then run <code> rake extract_fixtures </code> <p> <ol> <li>You&#8217;ve made your testbed so you can lie in it.</li> </ol> <p>You now have and exact copy of your development database, and a collection of sample data in Yaml format, and are ready to begin writing some Unit Tests. Stay tuned for some examples. Rail on! <span> <script type="text/javascript"> digg_url = &#8216;http://martinicity.net/articles/2007/03/31/testing-a-non-rails-application-using-rails&#8217;; digg_title = &#8216;Testing a Non-Rails Application Using Rails&#8217;;</script> <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script> </span></p> Sat, 31 Mar 2007 13:11:00 +0000 urn:uuid:ae1917e2-4a47-4fa2-be71-d57109445b46 Mike Blake http://www.martinicity.net/articles/2007/03/31/testing-a-non-rails-application-using-rails Create rails ruby unit tests database yml rake Rails on Oracle <p>When rails on jruby and connecting to Oracle via <span class="caps">JDBC</span> ,the following error eventually appears:</p> Update: <code> java.sql.SQLException: Io exception: Broken pipe </code> <p><b>Fix:</b></p> You need a dedicated connection from Oracle. Change the url: line in database.yml from <code> url: jdbc:oracle:thin:@localhost:1521:XE to url: jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA =(SERVER = DEDICATED) (SID = XE))) </code> <ol> <li>Workarounds</li> </ol> <p>Duplicating an existing Oracle Database using the build in task <code>rake db:test:clone</code> presented a few problems. Here&#8217;s what I did to work around them.</p> <ol> <li><span class="caps">ORA</span>-01727: numeric precision specifier is out of range</li> </ol> <code> OCIError: ORA-01727: numeric precision specifier is out of range (1 to 38): CREATE TABLE employee (id NUMBER(38) NOT NULL PRIMARY KEY, created_date DATE DEFAULT NULL, start_date DATE DEFAULT NULL, job_id DECIMAL DEFAULT NULL, total_hours NUMBER(126) DEFAULT NULL) </code> <p><b>Fix:</b></p> <p>For some reason whne rails dumps the schema, it reports Oracle type <span class="caps">FLOAT</span> as <acronym title="126">NUMBER</acronym>, so you just need to changed that back to <span class="caps">FLOAT</span> if you want to import that schema.</p> ###OCIError: <span class="caps">ORA</span>-00972 identifier is too long: <code> OCIError: ORA-00972: identifier is too long: CREATE SEQUENCE gametime\_responsibility\_ref\_seq START WITH 10000 </code> <p><b>Fix:</b></p> <p>Rails tries to create sequences in Oracle to handle <span class="caps">AUTOINCREMENT</span> id fields. It uses <span class="caps">TABLE</span>_NAME = &#8216;_SEQ&#8217; for the sequence name. If a sqequence name is too long then you have to shorten it in schema.rb .</p> <h3>OCIError: <span class="caps">ORA</span>-00907: missing right parenthesis</h3> <code> OCIError: ORA-00907: missing right parenthesis: CREATE TABLE board (id NUMBER(38) NOT NULL PRIMARY KEY, name VARCHAR2(150) NOT NULL, name VARCHAR2(150) NOT NULL, parent VARCHAR2(150) DEFAULT NULL, log_level DECIMAL DEFAULT NULL, modified_date DATE(6) DEFAULT NULL, token DECIMAL DEFAULT NULL) </code> <p><b>Fix:</b></p> <p>For some reason Rails assigns Date fields a size in schema.rb . You&#8217;ll need to change all occurances of <acronym title="6">DATE</acronym> to <span class="caps">DATE</span> .</p> Thu, 29 Mar 2007 21:15:00 +0000 urn:uuid:1fd946dc-17d2-40fd-abf8-2b4dd3474377 Mike Blake http://www.martinicity.net/articles/2007/03/29/rails-on-oracle Create rails oracle schema rb Columbia City Paper and Mephisto <ol> <li>Ideas from the Margins</li> </ol> <p>My brothers alternative news weekly in <a href="http://www.columbiacitypaper.com">Colombia, SC</a> focuses on stories no one else would write about including a regular feature called <a href="http://columbiacitypaper.com/bum-of-the-week">Bum of the Week</a>, or and occasional <a href="http://columbiacitypaper.com/2007/2/14/s-c-nazi-for-president">interview with a Nazi</a>.</p> <p>![](http://columbiacitypaper.com/assets/2007/2/26/cover_thumb.jpg)</p> <ol> <li>Content Management</li> </ol> <p>He asked me to help him find an open source Content Management System, and after exploring a few, we choose <a href="http://mephistoblog.com/">Mephisto</a>. I was impressed with Mephistos usability and <a href="http://mephisto.stikipad.com/help/show/Step+by+Step+Tutorial">online documentation</a>. I also noticed that there we&#8217;re several integration tests written for it&#8217;s caching system, and used them as an example in a recent presentation. It has slickly designed <a href="http://mephistoblog.com/screenshots">admin interface</a>, and the writers at City Paper love it. My brothers not afraid to edit some <span class="caps">HTML</span> or <span class="caps">CSS</span>, so he quickly got comfortable with the design templates.</p> <ol> <li>Surprise</li> </ol> <p>But the best surprises came after we went live with the site last week. First the visitors to the site began commenting on stories like never before. For some reason the Ocadia template we chose with it&#8217;s subtle use of color was inviting.</p> <p>![](http://themes.benlog.org/screenshots/19/preview.png)</p> <p>Ironically one commenter who said</p> <blockquote> <p>I&#8217;m not going to make this a forum for debate. Those who want to debate me can come onto a regular white website &#8230;</p> </blockquote> <p>went on and on after that to post the largest comment posted by anyone, and made that article a forum for debate. It turns out that integration of color is much more appealing to him than he ever knew.</p> <ol> <li>College Football Frenzy</li> </ol> The second surprise came just 2 days later. Editor Todd Morehead published a story early Friday about <a href="http://columbiacitypaper.com/2007/3/2/usc-quarterback-stephen-garcia-accused-of-vandalizing-car-under-investigation"><span class="caps">USC</span>&#8217;s quarterback</a> keying a car in the school library parking lot. The story was index by Google&#8217;s news bot, and went on to get picked up by the the local daily paper that night, hit the Associated Press wire, and was then published on <a href="http://sportsillustrated.cnn.com/2007/football/ncaa/03/03/bc.fbc.scarolina.garcia.ap/index.html">Sport&#8217;s Illustrated&#8217;s</a> site along with dozens of sites nationwide. received a record number of unique visits over the weekend. Mephisto&#8217;s caching performed beautifully. It was a great weekend here in <a href="http://www.paulgraham.com/marginal.html">the margins</a>. Congratulations to City Paper for breaking a national new story, and to Mephisto for not breaking. <p> <span style='float:right'> <script type="text/javascript"> digg_url = &#8216;http://www.martinicity.net/articles/2007/03/05/columbia-city-paper-and-mephisto&#8217;; digg_title = &#8216;Columbia City Paper and Mephisto&#8217;;</script> <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script> </span> Mon, 05 Mar 2007 17:35:00 +0000 urn:uuid:1decf1fc-29b6-4b7a-8e41-250d404c132b Mike Blake http://www.martinicity.net/articles/2007/03/05/columbia-city-paper-and-mephisto Write Create Columbia City Paper Mephisto usc content management system cms marginal How Do You Get to Silicon Valley? # Practice. <p> <ol> <li>Music When <a href="http://www.beefstewdios.com">Tony Macaluso</a> invites me to play bass at a gig, I need to prepare. Before I even start rehearsing songs, I break out my <a href="http://en.wikipedia.org/wiki/Rickenbacker">Rickenbacker</a> and warm up with some scales.</li> </ol> <p>![](http://beefstewdios.com/images/433_IMG_0146.jpg)</p> <ol> <li>Programming When I&#8217;m invited to help out with a software project I&#8217;m expected to hit the ground running. Each project might require a different area of expertise. How do I warm up? I usually have reserched the problem domain beging even before interviewing for the gig. But now there&#8217;s a more precise method analogous to playing scales. <p><a href="http://pragdave.pragprog.com/">Dave Thomas</a> has begun a blog called <a href="http://www.codekata.com/">CodeKata</a> . He already has about 15 different exercises created to help us programmers <a href="http://redsquirrel.com/dave/work/a2j/patterns/PracticePracticePractice.html">practice our craft</a>.</p></li> </ol> <p>The Kata touch on a variety of common problem domains in software development. There are the standard programming 101 issues including <a href="http://codekata.pragprog.com/2007/01/kata\_eleven\_sor.html">Sorting it Out</a> and <a href="http://codekata.pragprog.com/2007/01/kata_two_karate.html">Karate Chop</a>. And there are several design exercises like <a href="http://codekata.pragprog.com/2007/01/kata_ten_hashes.html">Hashes vs. Classes</a> and <a href="http://codekata.pragprog.com/2007/01/code_kata_one_s.html">Supermarket Pricing</a>.</p> Thu, 22 Feb 2007 14:50:00 +0000 urn:uuid:5824f9b9-4acf-4b15-8308-1b778b2def35 Mike Blake http://www.martinicity.net/articles/2007/02/22/how-do-you-get-to-silicon-valley Create CodeKata Dave Thomas Programming Musician Tony Macaluso Undefined method assert_select <p>The <a href="http://blog.labnotes.org/2006/09/04/assert_select-cheat-sheet/">assert_select</a> method for testing views was added in <a href="http://weblog.rubyonrails.org/2006/11/26/1-2-new-in-actionpack">Rails 1.2</a>, so the first thing to check if you&#8217;re getting the error below is that you&#8217;ve upgraded to 1.2</p> <pre> &gt; 2) Error: &gt;test_expire_old_ads(AdExpirationTest): &gt;NoMethodError: undefined method `assert_select' for #&lt;ActionController::Integration::Session:0x378ae98&gt; &gt; c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_process.rb:432:in `method_missing' </pre> <p>Now I upgraded to 1.2 and still kept getting the above error. The problem was that my application was set to use Rails 1.1.6 in the config/environment.rb file:</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="comment"># Specifies gem version of Rails to use when vendor/rails is not present</span> <span class="constant">RAILS_GEM_VERSION</span> <span class="punct">=</span> <span class="punct">'</span><span class="string">1.1.6</span><span class="punct">'</span></code></pre></div> <p>So the solution is to comment out that line, or alternatively ,set it to the latest version. Also make sure you&#8217;re not frozen to a specific Rails version in the vendor directory.</p> Mon, 19 Feb 2007 18:23:00 +0000 urn:uuid:6ddf5409-4a21-4502-a1d6-b9dc8733aedc Mike Blake http://www.martinicity.net/articles/2007/02/19/undefined-method-assert_select Create rails testing assert_select NoMethodError