<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>jhannah @ Mutation Grid</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/jhannah_mutation_grid/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/jhannah_mutation_grid//542</id>
    <updated>2010-12-16T18:18:27Z</updated>
    <subtitle>Mutation Grid, Inc. &quot;Controlled software evolution.&quot;</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Migrating 76 tables out of MS-SQL. Thanks DBIx::Class!</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/12/dbixclass-quote-char-dbicsl-column-accessor-collisions.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1253</id>

    <published>2010-12-16T17:47:04Z</published>
    <updated>2010-12-16T18:18:27Z</updated>

    <summary>Just another day at the office moving databases into MySQL. 10 lines of DBIx::Class::Schema::Loader make_schema_at() and I&apos;m done. :) Usually. Unfortunately today the table names &quot;Order&quot; and &quot;Service-tier2&quot; blow up: Bad table or view &apos;Order&apos;, ignoring: DBIx::Class::Schema::Loader::make_schema_at(): DBI Exception: DBD::mysql::st...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    <category term="dbixclass" label="dbix-class" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>Just another day at the office moving databases into MySQL. 10 lines of DBIx::Class::Schema::Loader make_schema_at() and I'm done.   :)</p>

<p>Usually.</p>

<p>Unfortunately today the table names "Order" and "Service-tier2" blow up:</p>

<pre><code>Bad table or view 'Order', ignoring: DBIx::Class::Schema::Loader::make_schema_at(): DBI Exception: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Order WHERE ( 1 = 0 )' at line 1 [for Statement "SELECT * FROM Order WHERE ( 1 = 0 )"] at refresh_schema.pl line 9
</code></pre>

<p>Apparently "Order" is semi-reserved by MySQL, and dashes are trouble:</p>

<pre><code>SELECT * FROM Order              # syntax error
SELECT * FROM `Order`            # works
SELECT * FROM Service-tier2      # syntax error
SELECT * FROM `Service-tier2`    # works
</code></pre>

<p>Another point for irc.perl.org #dbix-class, as ilmari pointed me to quote_char as the cure for what ailed me. </p>

<pre><code>use strict;
use DBIx::Class::Schema::Loader qw( make_schema_at );
make_schema_at(
   "P3::Schema", {
      dump_directory     =&gt; ".",
   },
   [ "dbi:mysql:protec", $user, $password, {
      quote_char =&gt; '`'
   } ],
);
</code></pre>

<p>Beauty. I'm still hitting this new warning because the column name 'can' (Client Access Number) collides with UNIVERSAL::can():</p>

<pre><code>Column can in table ClContact collides with an inherited method.
See "COLUMN ACCESSOR COLLISIONS" in perldoc DBIx::Class::Schema::Loader::Base .
</code></pre>

<p>Oops!   :)  But that's an easy work-around in my Result/ class. I just have to pick anything that's not reserved:</p>

<pre><code>"can",
{ accessor =&gt; "cant", data_type =&gt; "varchar", is_nullable =&gt; 0, size =&gt; 10 },
</code></pre>

<p>So to access that column I now call <code>$clcontact->cant()</code>. Why? Because now I can.   :)</p>
]]>
        

    </content>
</entry>

<entry>
    <title>FIXED: DBICSL can&apos;t &apos;can&apos; </title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/12/fixed-dbicsl-cant-can.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1221</id>

    <published>2010-12-02T20:36:08Z</published>
    <updated>2010-12-02T20:49:16Z</updated>

    <summary>One of my client&apos;s schemas contains a table which contains a column named &apos;can&apos;. In his context this is a convenient abbreviation for &apos;Client Access Number&apos;. In Perl however, -&gt;can() is already spoken for. Since DBIx::Class::Schema::Loader creates an accessor method...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    <category term="dbixclass" label="dbix-class" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>One of my client's schemas contains a table which contains a column named 'can'. In his context this is a convenient abbreviation for 'Client Access Number'. In Perl however, <a href="http://perldoc.perl.org/UNIVERSAL.html"><code>->can()</code></a> is already spoken for. Since DBIx::Class::Schema::Loader creates an accessor method for each column of each table in your database, things went sideways on me today when I tried to <a href="http://search.cpan.org/~nekoya/DBIx-Skinny-Schema-Loader-0.18/lib/DBIx/Skinny/Schema/Loader.pm#make_schema_at%28_$schema_class,_$options,_$connect_info_%29">auto-generate classes</a> for all tables in that database.</p>

<p>Luckily irc.perl.org #dbix-class came to the rescue again, and Caelum was quick to <a href="http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class-Schema-Loader.git;a=commitdiff;h=6947b5d664d1e4136dfe8d410f821e0a4bdaba31">patch the bug</a>. So if you have clients like mine, rest assured the next push to CPAN will cure what ails ya.  :)</p>]]>
        
    </content>
</entry>

<entry>
    <title>Another Catalyst website goes live (ActivityMD)</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/11/another-catalyst-website-goes-live-activitymd.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1179</id>

    <published>2010-11-17T21:39:24Z</published>
    <updated>2010-11-17T21:45:03Z</updated>

    <summary>Another client launch: ActivityMD.com. The front content was WYSIWYG&apos;d by their previous ISP. Prolific position:absolute CSS makes that content painful to edit. But links to the shiny new backend are all Catalyst, Template Toolkit, and lots of jQuery. It&apos;s an...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    <category term="catalystttjquery" label="Catalyst TT jQuery" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>Another client launch: <a href="http://activitymd.com">ActivityMD.com</a>.</p>

<p>The front content was WYSIWYG'd by their previous ISP. Prolific <code>position:absolute</code> CSS makes that content painful to edit. But links to <a href="http://online.activitymd.com">the shiny new backend</a> are all Catalyst, Template Toolkit, and lots of jQuery.</p>

<p>It's an alpha release. Feedback welcome.   :)</p>]]>
        
    </content>
</entry>

<entry>
    <title>Javascript scoping != Perl&apos;s</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/11/javascript-scoping-perls.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1153</id>

    <published>2010-11-04T18:13:07Z</published>
    <updated>2010-11-04T18:31:37Z</updated>

    <summary>I&apos;m doing a lot of jQuery of one of my current clients. Along the way I&apos;m learning fun Javascript gotchas. Here&apos;s a demonstration of one scoping difference. Below the .change() event tied to bar works as I expected, but baz...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    <category term="javascriptjquery" label="javascript jQuery" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>I'm doing a lot of jQuery of one of my current clients. Along the way I'm learning fun Javascript gotchas. Here's a demonstration of one scoping difference. Below the  <code>.change()</code> event tied to bar works as I expected, but baz is a global variable.</p>

<pre><code>function addARow() {
   var i = $('#next_id').val();
   var d = $("div"),                                      //COMMA then foo
   foo = $("&lt;input&gt;",{id:"foo" + i,size:"3"}).appendTo(d)
   .change(function() { bar.val($(this).val() * 2); })
   .change(function() { baz.val($(this).val() * 2); }),   //COMMA then bar
   bar = $("&lt;input&gt;",{id:"bar" + i,size:"3"}).appendTo(d);//SEMICOLON then baz
   baz = $("&lt;input&gt;",{id:"baz" + i,size:"3"}).appendTo(d);
   $("&lt;br&gt;").appendTo(d);
   $('#next_id').val(i - 1 + 2);   // + 1 would concat 1 onto the string  :)
};
</code></pre>

<p>See it in action <a href="http://jsbin.com/oxewa/13/edit">here</a>. jQuery creates a set of 3 input fields (foo, bar, baz) on each click of "add". When foo is changed by the user, bar and baz are updated. But the wrong baz gets the update. </p>

<p>Live and learn.  :)</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Large Hadron Collider - data crunching in Nebraska</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/10/large-hadron-collider.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1131</id>

    <published>2010-10-25T18:49:40Z</published>
    <updated>2010-10-25T20:48:38Z</updated>

    <summary>Last week The Linux Journal published this excellent article written by Carl Lundstedt of the University of Nebraska, Lincoln which details many ways Linux / open source is used around the world by scientists working on cutting edge physics. The...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>Last week The Linux Journal published <a href="http://www.linuxjournal.com/content/the-large-hadron-collider">this excellent article</a> written by Carl Lundstedt of the University of Nebraska, Lincoln which details many ways Linux / open source is used around the world by scientists working on cutting edge physics.</p>

<p>The computer cluster he details is the same cluster I ran large stacks of Perl on for my "mutation grid" project whose name I stole when I formed Mutation Grid, Inc. A little trip down memory lane for me, and a good read for curious minds.  :)<br />
</p>]]>
        <![CDATA[<p><br />
<img alt="10847f4.jpg" src="http://blogs.perl.org/users/jhannah_mutation_grid/10847f4.jpg" width="550" height="344" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></p>]]>
    </content>
</entry>

<entry>
    <title>Perl, Selenium, and ASP.NET</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/10/perl-selenium-and-aspnet.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1091</id>

    <published>2010-10-06T20:46:11Z</published>
    <updated>2010-10-07T02:12:46Z</updated>

    <summary>I&apos;ve done a lot of web scraping with Perl over the years, but I hadn&apos;t experienced anything quite like the &quot;Next page&quot; link that ASP.NET threw at me this week. The opposite of REST, ASP.NET&apos;s ctlPagePlaceHolder makes the simplest navigation...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>I've done a lot of web scraping with Perl over the years, but I hadn't experienced anything quite like the "Next page" link that ASP.NET threw at me this week. The opposite of REST, ASP.NET's <code>ctlPagePlaceHolder</code> makes the simplest navigation beyond the reach of <a href="http://search.cpan.org/perldoc?WWW::Mechanize">WWW::Mechanize</a> as far as I can tell. Luckily <a href="http://seleniumhq.org">Selenium</a> came to my rescue. </p>

<p>If you haven't experienced Selenium automation, it's quite impressive. From a normal shell window (OS X Terminal.app in my case) you launch a Java server</p>

<pre><code>selenium-remote-control-1.0.3/selenium-server-1.0.3
$ java -jar selenium-server.jar
</code></pre>

<p>and then use <a href="http://search.cpan.org/perldoc?WWW::Selenium">WWW::Selenium</a> in your Perl program. As your Perl program runs it launches Firefox on your local workstation and performs whatever commands you issue. In my case this was simply "click 'Next Page'".   :)    </p>

<p>The Selenium IDE Firefox plugin is great for quickly mocking up what commands you need. Once it's working, drop those commands into your program to get the job done.</p>

<p>It's disturbing to me that ASP.NET is so convoluted by default that I <strong>need</strong> Selenium for some operations. (I can't imagine anyone went out of their way to make automation of their site this difficult intentionally.) But I sure am glad it's available when I need it. What should have been <code>?page=2</code> turned into me harnessing untold volumes of source code (Selenium + Firefox!) to get the job done.</p>

<p>Oh well. Such is the way of the world sometimes.   :)</p>

<p>The nice weather is holding out here in Omaha, Nebraska, USA. Still motorcycle weather, and the trees are pretty in the light industrial park Mutation Grid now calls home.
<img alt="trees.jpg" src="http://blogs.perl.org/users/jhannah_mutation_grid/trees.jpg" width="636" height="375" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></p>
]]>
        

    </content>
</entry>

<entry>
    <title>One-liner XML / Perl / JSON</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/09/one-liner-xmlperljson.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1058</id>

    <published>2010-09-29T13:04:44Z</published>
    <updated>2010-09-29T13:26:52Z</updated>

    <summary><![CDATA[castaway blew my mind this morning in irc.perl.org #axkit-dahut. Convert an XML file to Perl data structure: perl -MXML::Simple -MData::Dumper -le'print Dumper XMLin("foo.xml")' Convert an XML file to JSON: perl -MJSON::Any -MXML::Simple \ -le'print JSON::Any-&gt;new()-&gt;objToJson(XMLin("foo.xml"))' "How do I do X?"...]]></summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p><code>castaway</code> blew my mind this morning in <code>irc.perl.org #axkit-dahut</code>.</p>

<p>Convert an XML file to Perl data structure:</p>

<pre><code>perl -MXML::Simple -MData::Dumper -le'print Dumper XMLin("foo.xml")'
</code></pre>

<p>Convert an XML file to JSON:</p>

<pre><code>perl -MJSON::Any -MXML::Simple \
   -le'print JSON::Any-&gt;new()-&gt;objToJson(XMLin("foo.xml"))'
</code></pre>

<p>"How do I do X?" Like this! Poof! </p>

<p>Some days Perl feels like a Las Vegas magic show.  :)</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Using blogs.perl.org</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/09/using-blogsperlorg.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1056</id>

    <published>2010-09-28T14:02:17Z</published>
    <updated>2010-09-29T13:36:03Z</updated>

    <summary>I stumbled into blogs.perl.org last night. Here&apos;s a couple &quot;quick start&quot; tips for using this install of Movable Type Pro: (1) Code blocks. If you choose Format: Markdown, leave a blank line, indent text with 4 spaces, then another blank...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p>I stumbled into blogs.perl.org last night. Here's a couple "quick start" tips for using this install of Movable Type Pro:</p>

<p>(1) Code blocks. If you choose Format: Markdown, leave a blank line, indent text with 4 spaces, then another blank line</p>

<pre><code>you will get code blocks like this
# with some
$rudimentary = "syntax highlighting";
</code></pre>

<p>(2) Blog subtitle. <a href="http://blogs.perl.org/users/erez_schatz/">Erez Schatz</a> was kind enough to point out how to set your blog subtitle (e.g.: Mutation Grid, Inc. "Controlled software evolution." above): From the blogs.perl.org page, click on Post, then, on the top menu bar: Preferences - General, the subtitle is "description".</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Overlapping regex matches</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/jhannah_mutation_grid/2010/09/overlapping-regex-matches.html" />
    <id>tag:blogs.perl.org,2010:/users/jhannah_mutation_grid//542.1055</id>

    <published>2010-09-28T07:48:30Z</published>
    <updated>2010-09-28T08:18:28Z</updated>

    <summary>irc.perl.org #perl-help posed a good question tonight. Why does this only find some of the matches? my $sequence = &quot;ggg atg aaa tgt tcc cgg taa atg aat gcc cgg gaa ata tag cct gac ctg a&quot;; $sequence =~ tr/...</summary>
    <author>
        <name>Jay @ Mutation Grid</name>
        <uri>http://mutationgrid.com</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/jhannah_mutation_grid/">
        <![CDATA[<p><code>irc.perl.org #perl-help</code> posed a good question tonight. Why does this only find some of the matches?</p>

<pre><code>my $sequence = "ggg atg aaa tgt tcc cgg taa atg aat gcc cgg gaa ata tag cct gac ctg a"; 
$sequence =~ tr/ //d; 
print "Input sequence is: $sequence \n";  
while ($sequence =~ /(atg(...)*?(taa|tag|tga))/g) {print "$1 \n";}
</code></pre>

<p>Because, by default, regex /g begins each subsequent search after the end of the last match, so overlapping hits are not found. As <a href="http://linuxshellaccount.blogspot.com/2008/09/finding-overlapping-matches-using-perls.html">this blog post</a> explains, a <strong>negative lookahead assertion</strong> is the key to finding all of them. This works great:</p>

<pre><code>while ($sequence =~ /(?=(atg.*?(taa|tag|tga)))/g) {
   print "$1\n";
}
</code></pre>

<p>I'm partial to bioinformatics homework after 4 years of hacking on the stuff.   :)</p>
]]>
        

    </content>
</entry>

</feed>
