Samba Network Shares with Nautilus in Hardy Heron Part 2
Posted by Ryan Baxter Sun, 01 Jun 2008 23:07:00 GMT
Nearly a month ago I wrote about my problems connecting to the network shares of my Linksys NAS200 using Nautilus in Ubuntu, Hardy Heron. My fix was simple and it worked. Unfortunately, the solution’s WAF (Wife Acceptance Factor) was low. Apparently she didn’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.
Initially, the script failed to connect to my network shares because my wireless network connection hadn’t finished negotiating before the script was executed. I coded around this by creating a while loop that greps 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.
#!/bin/bash
user="thorbardin/ryan%password"
root_dir="/home/ryan/Network Shares"
mount_shares() {
public_dir="$root_dir"/"Public on Thorbardin"
home_dir="$root_dir"/"Home on Thorbardin"
[ -d "$public_dir" ] || mkdir -p "$public_dir"
[ -d "$home_dir" ] || mkdir -p "$home_dir"
smbmount "//192.168.1.105/public disk" "$public_dir" -o user="$user"
smbmount "//192.168.1.105/ryan" "$home_dir" -o user="$user"
}
while [ 1 ]; do
if ping -c2 192.168.1.1 2>&1 | grep ttl; then
mount_shares
exit 0
fi
sleep 10
done
exit 0I’m already thinking about rewriting this script so that it scans my network using smbtree and automatically mounts all available network shares. That’ll be Part 3!
- Posted in Code Snippets
- Meta no trackbacks, 3 comments, permalink, rss, atom
ASP.NET AJAX Control Toolkit: Transparent Tab Control Images
Posted by Ryan Baxter Thu, 10 Apr 2008 15:18:00 GMT
I’ve found a use for the Tab Control that is included with the ASP.NET AJAX Control Toolkit. The control’s default style is passable for now, but I’ve grown tired of looking at the white borders surrounding active tabs. If your background is not white, you’ve probably noticed this too.
To fix this, I’ve edited the images and posted them here. I’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’t use these.
| Before | After | |
![]() |
![]() |
- Meta no trackbacks, no comments, permalink, rss, atom
Setting Focus in ASP.NET Ajax Pages
Posted by Ryan Baxter Mon, 31 Mar 2008 22:24:00 GMT

At the new job I’ve been using a lot of ASP.NET Ajax to help ease the transition of users from VB6 desktop applications to web applications on our company intranet. In doing this, the UpdatePanel has become my new best friend. Albeit charming, my old ASP.NET 2.0 friends were not as impressed.
With ASP.NET 2.0, came the long-awaited Focus 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.
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’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:
// 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);
}The above example is a two-fer. The ScriptManager’s SetFocus method is handy, but remember that only one ScriptManager is allowed per page and if you’ve put your ScriptManager in a MasterPage, then you’ll need to access it in code using the GetCurrent method of the ScriptManager class.
Two. The ASP.NET 2.0 UpdatePanel is not the only Ajax control. Download the ASP.NET Ajax Control Toolkit. With this toolkit, you’ll have access to dozens of controls and best of all – the SetFocusOnLoad method. Located in the Utility class, the SetFocusOnLoad method is the answer to your !Page.IsPostback problems.
- Posted in Code Snippets
- Meta no trackbacks, no comments, permalink, rss, atom
Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'
Posted by Ryan Baxter Thu, 28 Feb 2008 18:38:00 GMT
Just a quick fix. If you’re experiencing the error message, Cannot convert type ‘ASP.login_aspx’ to ‘System.Web.UI.WebControl, try renaming your page from Login.aspx to something else.
I ran across this earlier this morning when attempting to deploy an ASP.NET 2.0 WebSite project. My code worked great locally (isn’t that always the case). I haven’t had time to really dig into why this happens, but maybe someone else can provide an answer.
- Meta no trackbacks, no comments, permalink, rss, atom
Expect the Unexpected: Irony
Posted by Ryan Baxter Tue, 27 Nov 2007 05:45:00 GMT
- Posted in Expect the Unexpected
- Meta no comments, permalink, rss, atom
Code Snippet: Turning Oops into Ahah with Ruby.
Posted by Ryan Baxter Thu, 12 Jul 2007 15:49:00 GMT
Scrapbooking is my wife’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 yorkphoto.com, 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’m constantly amazed and secretly jealous of her improving sense of design.
The Oops:
The camera my wife uses is a Canon PowerShot A80. It names each digital image with a sequential number that starts at 1 with the very first picture taken. In exploring the camera’s settings, I managed to reset the picture count. So rather than her next picture having a file name of IMG_103995837284942 it was named IMG_1. No big deal. Wrong! This messed up her entire workflow. Apparently my wife used the image’s file name as a unique identifier. Copying newly taken pictures to her working directory would have overwritten hundreds of files. Oops!
The Ahah:
To fix my blunder, I planned on renaming all of her archived images with a UUID. 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’d been spending some time with Ruby I thought I’d take the opportunity to learn from my mistake. It worked! The code from my image renaming script can be found below.
#!/usr/bin/ruby
require 'rubygems'
require 'uuid'
file_path = '/home/wifename/Desktop/Pictures'
destination_path = '/home/wifename/Pictures'
file_types = ['jpg', 'jpeg', 'gif', 'png', 'xcf']
Dir[file_path + '/*.*'].each do |file|
file_extension = file.split('.').last.downcase
if file_types.include?(file_extension) then
file_name = UUID.new
File.rename(file, destination_path + '/' + file_name + '.' + file_extension)
end
end
puts 'Finished...'With the above script, I was able to undo my mistake and learn while doing so. Now if only she didn’t have to use the command-line to run the code. Does anyone have experience with widget toolkits in Ruby? If so, contact me.
- Posted in Code Snippets
- Meta 2 comments, permalink, rss, atom




