<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>crunchlife: Tag Oops</title>
    <link>http://crunchlife.com/articles/tag/oops</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Samba Network Shares with Nautilus in Hardy Heron Part 2</title>
      <description>&lt;p&gt;&lt;img src="/files/ubuntu_logo.png" class="right"&gt;Nearly a month ago I wrote about my &lt;a href="http://crunchlife.com/articles/2008/04/28/samba-network-shares-with-nautilus-in-hardy-heron" target="_blank"&gt;problems connecting to the network shares&lt;/a&gt; of my &lt;a href="http://crunchlife.com/articles/2007/08/03/review-linksys-nas200" target="_blank"&gt;Linksys NAS200&lt;/a&gt; using Nautilus in Ubuntu, Hardy Heron. My fix was simple and it worked. Unfortunately, the solution&amp;#8217;s &lt;a href="http://en.wikipedia.org/wiki/Woman_acceptance_factor" target="_blank"&gt;WAF (Wife Acceptance Factor)&lt;/a&gt; was low. Apparently she didn&amp;#8217;t think it was easy enough to execute smbmount from a Terminal window. Whatever :) I have since written a small shell script that is called from Session Startup.&lt;/p&gt;

&lt;p&gt;Initially, the script failed to connect to my network shares because my wireless network connection hadn&amp;#8217;t finished negotiating before the script was executed. I coded around this by creating a while loop that &lt;a href="http://en.wikipedia.org/wiki/Grep#Usage_as_a_conversational_verb" target="_blank"&gt;greps&lt;/a&gt; the output of a ping to my router. If successful, the mount_shares function is called. Otherwise. the thread will sleep for 10 seconds and try again.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;#!/bin/bash

user=&amp;quot;thorbardin/ryan%password&amp;quot;
root_dir=&amp;quot;/home/ryan/Network Shares&amp;quot;

mount_shares() {
  public_dir=&amp;quot;$root_dir&amp;quot;/&amp;quot;Public on Thorbardin&amp;quot;
  home_dir=&amp;quot;$root_dir&amp;quot;/&amp;quot;Home on Thorbardin&amp;quot;

  [ -d &amp;quot;$public_dir&amp;quot; ] || mkdir -p &amp;quot;$public_dir&amp;quot;
  [ -d &amp;quot;$home_dir&amp;quot; ] || mkdir -p &amp;quot;$home_dir&amp;quot;

  smbmount &amp;quot;//192.168.1.105/public disk&amp;quot; &amp;quot;$public_dir&amp;quot; -o user=&amp;quot;$user&amp;quot;
  smbmount &amp;quot;//192.168.1.105/ryan&amp;quot; &amp;quot;$home_dir&amp;quot; -o user=&amp;quot;$user&amp;quot;
}

while [ 1 ]; do
  if ping -c2 192.168.1.1 2&amp;gt;&amp;amp;1 | grep ttl; then
    mount_shares

    exit 0   
  fi
  sleep 10
done

exit 0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I&amp;#8217;m already thinking about rewriting this script so that it scans my network using &lt;a href="http://www.menet.umn.edu/docs/software/samba/3.0.14a/help/smbtree.1.html" target="_blank"&gt;smbtree&lt;/a&gt; and automatically mounts all available network shares. That&amp;#8217;ll be Part 3!&lt;/p&gt;</description>
      <pubDate>Sun, 01 Jun 2008 16:07:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:d387ed9b-c3b3-469c-8052-8514021774bc</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/06/01/samba-network-shares-with-nautilus-in-hardy-heron-part-2</link>
      <category>Code Snippets</category>
      <category>NAS</category>
      <category>Ubuntu</category>
      <category>Oops</category>
      <category>Bash</category>
      <trackback:ping>http://crunchlife.com/articles/trackback/67</trackback:ping>
    </item>
    <item>
      <title>ASP.NET AJAX Control Toolkit: Transparent Tab Control Images</title>
      <description>&lt;p&gt;I&amp;#8217;ve found a use for the &lt;a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Tabs/Tabs.aspx" target="_blank"&gt;Tab Control&lt;/a&gt; that is included with the &lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=AtlasControlToolkit" target="_blank"&gt;ASP.NET AJAX Control Toolkit&lt;/a&gt;. The control&amp;#8217;s default style is passable for now, but I&amp;#8217;ve grown tired of looking at the white borders surrounding active tabs. If your background is not white, you&amp;#8217;ve probably noticed this too.&lt;/p&gt;

&lt;p&gt;To fix this, I&amp;#8217;ve edited the images and posted them &lt;a href="/files/new_tab_images.zip"&gt;here&lt;/a&gt;. I&amp;#8217;m not sure why the two active tab images were missed when all of the other images have transparent borders. Here are the before and after shots. Please don&amp;#8217;t use these.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;
  &lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;strong&gt;Before&lt;/strong&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;img src="/files/tab_before.jpg"&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&lt;img src="/files/tab_after.jpg"&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 10 Apr 2008 08:18:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:627c5337-e4af-4ad3-a252-daee75d87df0</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/04/10/asp-net-ajax-control-toolkit-transparent-tab-control-images</link>
      <category>ASPNET</category>
      <category>Ajax</category>
      <category>Oops</category>
      <enclosure type="application/x-zip" length="468" url="http://crunchlife.com/files/new_tab_images.zip"/>
      <trackback:ping>http://crunchlife.com/articles/trackback/53</trackback:ping>
    </item>
    <item>
      <title>Setting Focus in ASP.NET Ajax Pages</title>
      <description>&lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/B000YJ2OJ2?ie=UTF8&amp;amp;tag=crunchlife-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B000YJ2OJ2"&gt;&lt;img border="0" src="/files/316ZntjzQ2L._AA_SL160_.jpg" class="photo right"&gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=crunchlife-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B000YJ2OJ2" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;At the new job I&amp;#8217;ve been using a lot of &lt;a href="http://www.asp.net/ajax/" target="_blank"&gt;ASP.NET Ajax&lt;/a&gt; to help ease the transition of users from &lt;a href="http://en.wikipedia.org/wiki/VB6" target="_blank"&gt;VB6&lt;/a&gt; desktop applications to web applications on our company &lt;a href="http://en.wikipedia.org/wiki/Intranet" target="_blank"&gt;intranet&lt;/a&gt;. In doing this, the UpdatePanel has become my new best friend. Albeit charming, my old ASP.NET 2.0 friends were not as impressed.&lt;/p&gt;

&lt;p&gt;With ASP.NET 2.0, came the long-awaited &lt;a href="http://aspnet.4guysfromrolla.com/articles/111506-1.aspx" target="_blank"&gt;Focus&lt;/a&gt; method that allowed developers to set the page focus without having to write any JavaScript. Developers loved it and all was right with the world. That is until ASP.NET Ajax showed up.&lt;/p&gt;

&lt;p&gt;I recently spent way too much time trying set the page focus on a page that contained just a few TextBox controls and an UpdatePanel. My site&amp;#8217;s ScriptManager was located in a MasterPage, but more on that later. My obligatory googling turned up many work arounds, but none as simple as the following:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;// Example

if (Page.IsPostback)
{   
    // Use the GetCurrent method if your ScriptManager is located
    // in a MasterPage. Word.
    ScriptManager.GetCurrent(this.Page).SetFocus(TextBox1);
}
else
{
    // Here is the money.
    AjaxControlToolkit.Utility.SetFocusOnLoad(TextBox2);
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The above example is a two-fer. The ScriptManager&amp;#8217;s SetFocus method is handy, but remember that only one ScriptManager is allowed per page and if you&amp;#8217;ve put your ScriptManager in a MasterPage, then you&amp;#8217;ll need to access it in code using the GetCurrent method of the ScriptManager class. &lt;/p&gt;

&lt;p&gt;Two. The ASP.NET 2.0 UpdatePanel is not the only Ajax control. Download the &lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=AtlasControlToolkit" target="_blank"&gt;ASP.NET Ajax Control Toolkit&lt;/a&gt;. With this toolkit, you&amp;#8217;ll have access to dozens of controls and best of all &amp;#8211; the SetFocusOnLoad method. Located in the Utility class, the SetFocusOnLoad method is the answer to your !Page.IsPostback problems.&lt;/p&gt;</description>
      <pubDate>Mon, 31 Mar 2008 15:24:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:a059a73f-ed79-457f-9df5-24ab32e0fdd7</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/03/31/setting-focus-in-asp-net-ajax-pages</link>
      <category>Code Snippets</category>
      <category>ASPNET</category>
      <category>Ajax</category>
      <category>Oops</category>
      <enclosure type="image/jpeg" length="9085" url="http://crunchlife.com/files/316ZntjzQ2L._AA_SL160_.jpg"/>
      <trackback:ping>http://crunchlife.com/articles/trackback/52</trackback:ping>
    </item>
    <item>
      <title>Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'</title>
      <description>&lt;p&gt;&lt;img src="/files/brick.jpg" class="right"&gt;Just a quick fix.  If you&amp;#8217;re experiencing the error message, &lt;strong&gt;Cannot convert type &amp;#8216;ASP.login_aspx&amp;#8217; to &amp;#8216;System.Web.UI.WebControl&lt;/strong&gt;, try renaming your page from Login.aspx to something else.&lt;/p&gt;

&lt;p&gt;I ran across this earlier this morning when attempting to deploy an ASP.NET 2.0 WebSite project. My code worked great locally (isn&amp;#8217;t that always the case). I haven&amp;#8217;t had time to really dig into why this happens, but maybe someone else can provide an answer.&lt;/p&gt;</description>
      <pubDate>Thu, 28 Feb 2008 10:38:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:dfb541d1-36a9-49d2-ae21-d2f6078645c1</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/02/28/cannot-convert-type-asp-login_aspx-to-system-web-ui-webcontrols-login</link>
      <category>ASPNET</category>
      <category>Oops</category>
      <enclosure type="image/jpeg" length="46540" url="http://crunchlife.com/files/brick.jpg"/>
      <trackback:ping>http://crunchlife.com/articles/trackback/50</trackback:ping>
    </item>
    <item>
      <title>Expect the Unexpected: Irony</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;a href="http://news.bbc.co.uk/2/hi/americas/7108835.stm" target="_blank"&gt;&lt;img src="/files/explorer.jpg"&gt;&lt;/a&gt;&lt;/center&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 26 Nov 2007 21:45:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:d8feb3c5-21bf-4ff7-b9dc-0accb5468303</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2007/11/26/irony</link>
      <category>Expect the Unexpected</category>
      <category>Oops</category>
      <enclosure type="image/jpeg" length="40598" url="http://crunchlife.com/files/explorer.jpg"/>
    </item>
    <item>
      <title>Code Snippet: Turning Oops into Ahah with Ruby.</title>
      <description>&lt;p&gt;&lt;a href="http://www.creativememories.com/" target="_blank"&gt;Scrapbooking&lt;/a&gt; is my wife&amp;#8217;s favorite hobby (stay with me). To fuel her passion, she takes hundreds of pictures at each family function with her digital camera. She edits the pictures, uploads them to &lt;a href="http://www.yorkphoto.com" target="_blank"&gt;yorkphoto.com&lt;/a&gt;, and then checks and rechecks our mailbox daily for the printed pictures. With the pictures finally in hand, she manages to combine the photos, bits of paper, stickers, and collected mementos to create a beautifully designed scrapbook page. Each page in her album is an original work. I&amp;#8217;m constantly amazed and secretly jealous of her improving sense of design. &lt;/p&gt;

&lt;p&gt;The Oops:&lt;/p&gt;

&lt;p&gt;The camera my wife uses is a &lt;a href="http://www.usa.canon.com/consumer/controller?act=ModelInfoAct&amp;amp;fcategoryid=145&amp;amp;modelid=9449" target="_blank"&gt;Canon PowerShot A80&lt;/a&gt;. It names each digital image with a sequential number that starts at 1 with the very first picture taken. In exploring the camera&amp;#8217;s settings, I managed to reset the picture count. So rather than her next picture having a file name of IMG&lt;em&gt;_&lt;/em&gt;103995837284942 it was named IMG_1. No big deal. Wrong! This messed up her entire workflow. Apparently my wife used the image&amp;#8217;s file name as a unique identifier. Copying newly taken pictures to her working directory would have overwritten hundreds of files. Oops!&lt;/p&gt;

&lt;p&gt;The Ahah:&lt;/p&gt;

&lt;p&gt;To fix my blunder, I planned on renaming all of her archived images with a &lt;a href="http://en.wikipedia.org/wiki/Universally_Unique_Identifier" target="_blank"&gt;UUID&lt;/a&gt;. That way none of her images would be overwritten when adding the new pictures. Normally I would have written a bash script to handle this, but since I&amp;#8217;d been spending some time with Ruby I thought I&amp;#8217;d take the opportunity to learn from my mistake. It worked! The code from my image renaming script can be found below.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;#!/usr/bin/ruby&lt;/span&gt;

&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rubygems&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;uuid&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;file_path&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/home/wifename/Desktop/Pictures&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;destination_path&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/home/wifename/Pictures&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;file_types&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;['&lt;/span&gt;&lt;span class="string"&gt;jpg&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;jpeg&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;gif&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;png&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;xcf&lt;/span&gt;&lt;span class="punct"&gt;']&lt;/span&gt;

&lt;span class="constant"&gt;Dir&lt;/span&gt;&lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;file_path&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/*.*&lt;/span&gt;&lt;span class="punct"&gt;'].&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
    &lt;span class="ident"&gt;file_extension&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;split&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;.&lt;/span&gt;&lt;span class="punct"&gt;').&lt;/span&gt;&lt;span class="ident"&gt;last&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;downcase&lt;/span&gt;
    &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="ident"&gt;file_types&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;include?&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;file_extension&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;then&lt;/span&gt;
        &lt;span class="ident"&gt;file_name&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;UUID&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;
        &lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;rename&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;file&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;destination_path&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;/&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="ident"&gt;file_name&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;.&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;+&lt;/span&gt; &lt;span class="ident"&gt;file_extension&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Finished...&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With the above script, I was able to undo my mistake and learn while doing so. Now if only she didn&amp;#8217;t have to use the command-line to run the code. Does anyone have experience with widget toolkits in Ruby? If so, contact me.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Jul 2007 08:49:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:5e210883-0419-446b-baa1-f223a21475e3</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2007/07/12/code-snippet-turning-oops-into-ahah-with-ruby</link>
      <category>Code Snippets</category>
      <category>Oops</category>
      <category>Ruby</category>
    </item>
  </channel>
</rss>
