Wednesday 20 December 2006

MacBook - Dead Pixel ...Day1

Note: The RichText blog has moved to www.ricroberts.com

My MacBook arrived last night amid much excitement, only for me to have my glee quashed by a 'dead' pixel on the screen.

I called apple customer support with trepidation, thinking that I would just have to send it back and wait for a new one to come. But I spoke to someone very understanding who has arranged for a replacement to be sent out to an address of my choice. The best bit is that I get to keep the original MacBook for upto 5 days after the replacement comes (so that I can transfer my data), after which time a courier will come and pick up the defective one from another location of my choice.

This all sounds great in theory, but I'll reserve judgement until I've seen how smoothly it all goes - I'm not going to be in one place for very long over the Christmas period!

See this post for how it got resolved.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Sunday 17 December 2006

Apple MacBook

Note: The RichText blog has moved to www.ricroberts.com

So I finally gave in and ordered an Apple MacBook...

I have been in the market for a highly-portable notebook for a while, and I figured by getting a new Intel-based MacBook I would get the best of both worlds by being able to run both OSX and Windows on the same computer using either Bootcamp or Parallels.

Also, they're actually quite good value for a compact notebook of this spec. (I went for the 2.0GHz Core 2 Duo White MacBook with 1GB RAM, 1280x800 screen, DVD Super-drive).

I'll blog about any interesting things I find out about it, once it gets delivered.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Friday 15 December 2006

Sql Server 2005 Database Mirroring

Note: The RichText blog has moved to www.ricroberts.com

I was recently investigating disaster recovery techniques for Sql Server 2005, and for my needs Database Mirroring looked like a good candidate. (Note that Mirroring is only supported from Sql Server 2005 SP1).

Having looked into log-shipping and replication techniques in the past, this seemed like a good compromise between the two. The main down-point of Mirroring is that, like for log-shipping, the stand-by database must be kept offline. A big advantage that Mirroring has over replication is that changes to the structure of the Principal site are automatically applied to the Mirror.

Database mirroring in Sql Server 2005 lets you keep a "Mirror" of your live Sql Server database up to date in near real-time. In the event of your Main Site's database becoming unavailable, the Mirror can then serve the database clients.

Database Mirroring can be run in various modes. These can include using a "Witness" server to watch proceedings to see if a fail-over is required. You can also choose whether you want to wait until transactions have been applied at both Principal and Mirror sites before committing (High Safety Mode), or whether you want transactions to be applied asynchronously at the Mirror site (High Performance Mode).

For my situation, I went with no Witness server and High Performance mode, as the Mirror database was going to be in a remote location, with a relatively slow network link.

There are various performance counters and statuses associated with Database Mirroing, and various ways of being notified if any of these indicate a problem. For example, you can set up an email or net-send notification to certain people if the oldest unsent transaction is older than a certain age, or if the connection between Principal and Mirror is broken.

After a bit of fiddling most things seemed to work for me in a pretty obvious manner. However, there were a few little hurdles I had to get over.

1. If both machines are on the same domain then the security configuration is quite simple as long as the Sql Server services run under the same domain user account. If the server instances run under different user accounts, user logins on the Principal instance must be manually created on the Mirror (and vice-versa if you want the Mirror and Principal to be able swap roles). The thing that caught me out was if the machine account is used rather than a domain account, it must be added as a user on the other server instance.

2. If both machines are not on the same domain, then you need to use certificates instead. This msdn page tells you how. I'm not sure if this is because of some time-zone issue as I'm in the UK, but if I didn't specify a start date for my certificates then they didn't seem to work until a couple of hours later!

3. This technet article gave me a good starting point for figuring out how to setup alerts on Database Mirroring Events. However, when I was trying to set up an alert based on all state-change events using the WMI query SELECT * FROM DATABASE_MIRRORING_STATE_CHANGE, my alert didn't fire and I instead got a curious error in the Sql Server Agent Log with an error code pertaining to Namespace errors ( 0x8004100E ). I found out later that it works if you specify the database in the query e.g. SELECT * FROM DATABASE_MIRRORING_STATE_CHANGE WHERE Database = 'MyDatabase'

As I said earlier, pretty much every thing else worked the way the documentation said it would.

This msdn page links to lots of useful articles. Happy Mirroring!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Tuesday 31 October 2006

IDNET Broadband

Note: The RichText blog has moved to www.ricroberts.com

I recently changed my ADSL ISP from Bulldog (who, in my humble opinion, weren't great and would only give me 2Mb/s) to IDNet.

I've only been using IDNet for a week or so, but they seem pretty good - I'm getting about 0.4Mb/s upload and 5Mb/s download speeds. Best of all however, is when I called for support out of working hours and left a message, they called me back within about 5 mins and were extremely helpful. Can't beat that for customer service. :)

Sorry for the lack of useful posts recently - been very busy. Hopefully I might write something of interest soon!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Thursday 19 October 2006

Technorati Schmechnorati?

Note: The RichText blog has moved to www.ricroberts.com

Has anyone else had problems with Technorati?

I registered this blog on there ages ago, but it took weeks before their embedded url thingy actually contained anything.

Also, I've posted several times since creating my Technorati account, but my profile still says that I last updated this blog 50-odd days ago!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

The C# is strong with this one...

Note: The RichText blog has moved to www.ricroberts.com

As I mentioned a while back, I am a .NET developer in my day job. My boss needed me to get MCP certified so that the company could get Microsoft Partnership status.

I've been revising for a the last week or two in the evenings (hence the lack of blogging). Today I took the exam (70 316 - C# Windows Apps) and got 100%.

So I am now an official certified professional. I don't know if this actually means much in real terms, but it felt good to get full marks!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Saturday 23 September 2006

let's get modal

Note: The RichText blog has moved to www.ricroberts.com

UPDATE 12 July 07: Check out this more recent post for more info on modal dialogs.

In the Ruby On Rails project on which I'm currently working, I felt the need to introduce the concept of a modal dialog box. This is a common requirement in traditional client-applications, in order to restrict a user's actions to a certain area of the screen. However, until the advent of Web 2.0 it has been tricky implement in internet-based applications.

I tried a few different approaches, but finally settled on using the Xilinus Prototype Window javascript libraries to help me out.

A bit of background...

In my project, I orginally had a table which contained links to allow the user to edit the (often complex) contents of some of the table-cells. The links would causethe user to be navigated away from the page, and so after they had finished doing their editing they would have to navigate back. This is all very well, apart from the fact that if we wanted the site to remember other values that the user had entered on the first page, it meant storing hoards of things in the session. I stuck with this approach for a while, but the more functionality I added to the page, the more work I had to put into maintaining state in the session. Something had to change!

My solution

1. First download the Prototype Window libraries from here. (I used version 0.96.2).

2. The download zip-file contains a bunch of folders. Put the window.js file from the javascripts folder into your rails project's public/javascripts folder. (You will also need the prototype.js file, but this should already be there for you if you generated your project from a skeleton). The stylesheets folder in the zip-file contains all the different themes that are demonstrated on the xilinus prototype window samples page. The styles that you want to use need to go into your rails project's public/stylesheets folder. (I made a window subfolder to keep things tidier).

3. So that your views can use the prototype window javascript, put a javascript include tag in the head of the appropriate layouts file. For the sake of this example, put it in the application.rhtml layout file.

<%= javascript_include_tag "prototype", "effects", "window" %>
Also put in a stylesheet link to the style of modal dialog log you want.
<%= stylesheet_link_tag "/stylesheets/window/default" %>
We're going to use some javascript later, so put a content_for_page_scripts tag in the head of the layout too.
<script type="text/javascript"><%=@content_for_page_scripts %></script> 

4. In the view from which you wish to launch the modal dialog, we need some javascript. Write a function, and put it inside a content_for page_scripts block. Here, the function launches a modal dialog containing the web page at the url passed in.
<% content_for("page_scripts") do -%>

function show_Array_Window(myUrl)
{
  win = new Window('window_id', {title: "Array", width:300, height:500, url:myUrl});
  win.setDestroyOnClose();
  win.showCenter();
}

<% end -%>

5. Now set up a link for the user to click on, and set the onclick event to the function we just wrote. In the example below, we're building up a table with a link to a different object in each row's cell. (If you just want a permanent link to a single modal dialog, you dont need to go to the trouble of building up a dynamic onclick string).
<table>
  <% for i in 0...@my_array.length do %>
    <tr>
      <td>
        <%=
          # other code here if you like
          "<a href = \"#\" onclick='show_Array_Window(
\"" + url_for(:controller => 'my_controller',
:action => 'my_Action', :id => i) + "\")'>
Go Modal!</a>"
        %>
      </td>
    </tr>
  <% end %>
</table>

6. You can now do whatever you want in the page that's shown. In my case, this involved allowing the user to edit the complex data structure that was represented by the object in the table.

... and that's it.

The advantage of using the Xilinus Prototype Window libraries over other modal dialog approaches like lightbox gone wild is that because you just point the dialog to a url, the page that is shown inside can include its own javascript. This allows you to do ajax stuff inside your dialog like it was any other rails page. (I wont go into the whole ajax thing here).



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Wednesday 20 September 2006

Update on debugging in RadRails

Note: The RichText blog has moved to www.ricroberts.com

In my last post I described how to get Rails debugging to work in RadRails. I've had some reaction to my instructions, and on the whole they seem OK.

However, I don't think I made it clear that you need to set the breakpoints before you start the server.

Also, someone said they couldn't get it to work with older versions of Ruby and RadRails - so make sure you're fully up to date!

Any more feedback appreciated.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Tuesday 19 September 2006

RadRails, all is forgiven!

Note: The RichText blog has moved to www.ricroberts.com

UPDATE 9 March 2007: If you're using a Mac, you might want to try TextMate with ruby-debug. See these more recent posts:
Fast Ruby Debugging
TextMate for Rails

UPDATE 7 May 2007: Aptana (formerly Radrails) now supports fast debugging. See this recent post: Aptana with fast debugging

UPDATE 12 Sep 2007: NetBeans is another debugging solution I've recently discovered (and one I'd heartily recommend trying).

In August, I made a couple of posts (RoR debugging, Gleaming Steel) regarding Ruby on Rails IDEs and debugging. Since then I've come across something which made me realise I hadn't been giving Radrails its due praise.

While browsing the RadRails community pages for news of any updates, I found a link to this article by Steve Midgley which explains how to set up Eclipse for inline debugging with Rails. Steve was using something called EasyEclipse, but RadRails is based on Eclipse so I gave his instructions a go, and hey-presto!... rails debugging.

It's a bit slow, but no slower than RubyInSteel or Komodo. I think the RadRails team should make more of an effort to publicise their app's ability to debug rails code, as other products make a big deal of this feature. (apparently "fast debugging" is coming in version 0.8 of RadRails).

Steve's instructions, although very informative, are quite "wordy" and somewhat oriented towards EasyEclipse - so I thought I would write my own instructions specifically for RadRails with some screenshots. (click on the screenshots to zoom in).

(I'm using RadRails 0.7.1 with Ruby 1.8.5 and Rails 1.1.6 on Windows XP SP2.). I've also got debugging going in Mac OS X see this post.

1. First, get your installation of RadRails set up properly (here are some good instructions for this).

2. Set a breakpoint somewhere (such as a controller method) by double clicking in the margin.

2. Open your rails project, and have the Rails Navigator View open. Go to the Run menu and choose 'Debug...'





3. You will be presented with the Debug dialog. Make a new configuration for your project and on the File tab, specify the file as script/server.



4. On the Arguments tab, enter -I"[path_to_rails]", like in the example below. (There is no space between the -I and the path). You can also specify program arguments too if you like, such as which port to start on (not shown below).



5. On the Environment tab, select your ruby interpreter.



6. On the Common tab, ensure that the "Allocate Console" checkbox is checked, and the "Launch In background" checkbox is unchecked.



7. Click Apply to apply all your changes. Clicking "Debug" should start the debugger. After a short wait, You should see something like the screenshot below in your RadRails Console window. If not, review the steps above as you've gone wrong somewhere.

8. Now open a browser and navigate to the relevant page to trigger your controller method.

9. (This step was updated 20th Nov 2006) Go to the Debug Perspective (Window -> Open perspective... ). You should see execution stopped at your breakpoint. You are now able to step in/out/over. You can inspect variables by highlighting a variable currently in scope, right clicking and choosing inspect. The variable will appear in the Expressions window (I think this shows in the top-right of the Debug Perspective by default).



To debug again later, you can simply go to Run -> Debug History, and choose the name of the debug configuration you set up earlier.

All of this is essentially the same idea as setting up debugging in RubyInSteel or Komodo, so I knew it must be possible somehow, I just couldn't figure out the configuration options - my thanks go out to Steve Midgley!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Monday 28 August 2006

netstat

Note: The RichText blog has moved to www.ricroberts.com

Yesterday, I was having problems starting my Ruby on Rails server on port 3000. This morning, I discovered the netstat utility that comes with windows.

netstat -a -b
gives you a list of all running programs along with what port they're using and their process id.

This helped me to find out what was hogging port 3000. In my case the offending process was wcescomm.exe, which is to do with the Windows ActiveSync program, and just removing my PDA from it's dock released the port.

If this doesn't solve it for you, you can use taskkill to forcibly terminate a process. For example, to kill off process id 2420:
taskkill /f /pid 2420



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Sunday 27 August 2006

Errno::EBADF

Note: The RichText blog has moved to www.ricroberts.com

Sometimes, when trying to start my rails server with the usual command:

ruby script/server
I get the following error:

=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-08-27 15:10:09] INFO WEBrick 1.3.1
[2006-08-27 15:10:09] INFO ruby 1.8.4 (2006-04-14) [i386-mswin32]
[2006-08-27 15:10:09] WARN TCPServer Error: Bad file descriptor - bind(2)
c:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Bad file descriptor - bind(2) (Errno::EBADF)
from c:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
from c:/ruby/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
from c:/ruby/lib/ruby/1.8/webrick/server.rb:75:in `listen'
from c:/ruby/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
from c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:59:in `dispatch'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:3

I realised that if I started the server on a different port, it worked (although I can't see how the error relates to this) e.g.
ruby script/server -p8000
Sometimes even restarting the computer doesn't solve the problem. Something must be running on port 3000 somtimes, but I can't figure out what! At least using a different port for my server lets me continue working.

UPDATE: See my next post for a way to get round this problem.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Tuesday 22 August 2006

Gleaming steel

Note: The RichText blog has moved to www.ricroberts.com

UPDATE (19 Sept 06): Radrails included debugging all along - check out my latest blog entry.

Last week I posted an entry about RoR IDEs and debugging. Since that was written, I have tried out the latest version (0.75) of the free RubyInSteel plug-in for Microsoft Visual Studio from the chaps at SapphireSteel software.

Using the simple articles in their website's online user guide, I successfully managed to import my rails project, and debug rails server methods. (For the record, I am using VS2005 Professional).

Running the server in debug mode was considerably slower than running it normally, taking 3-4 seconds to load each page, but it was much quicker than running Komodo's debugger. My only complaint is that my rails server seemed to randomly stop a couple of times while debugging.

I also managed to successfully install and use the VisualSvn SVN plug-in for Visual Studio. This is not free but cheap at $19, and I found it much better than ankh, which I had previously tried.

To use VisualSvn, you also need to install the Tortoise SVN client, which is available from the VisualSvn download page. Everything was a dream to set up and use - All I did was install everything and it just worked. (It seems to just go off the .svn folders in the directory structure, as I assume all svn clients do. These folders were already there for me, after using RadRails).

Visual Studio 2005 itself has its down-points, such as being RAM-hungry and a little bit buggy in places, but its a mature, effective editor with lots of good features. I also had almost zero learning curve to overcome before starting to edit my RoR code, with me already being very familiar with this IDE.

I think I will use the VS2005-RubyInSteel-VisualSVN combo as my main environment for a while - at least until RadRails includes rails debugging.

Stay tuned to find out if I still feel the same love after using it in anger for a bit!



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Wednesday 16 August 2006

Ruby on Rails IDEs and debugging

Note: The RichText blog has moved to www.ricroberts.com

UPDATE: You might want to have a look at this post for details of using TextMate for Ruby On Rails development, or this post for NetBeans.

I'm primarily a .NET developer in my job but in my spare time I've recently been dabbling in a bit of Ruby on Rails (RoR) development. If you've never heard of it, check out www.rubyonrails.org - Its basically a new-ish web development framework based on the ruby scripting language.

To develop in RoR you don't need an IDE - you can get by with notepad and a console window but I've grown up on Microsoft Visual Studio so I felt the need for one.

So far, I've mainly been using RadRails, which is a pretty neat, free, open-source Ruby On Rails IDE based on Eclipse. This does most things I've needed, such as integrated Subversion source control support, syntax highlighting and various other Rails specific bits and bobs such as starting/stopping the Rails server etc (LightTPD, Mongrel and WEBrick Servers are supported).

However, at the time of writing RadRails is still missing rails debugging capabilities. Rails does come with a console "breakpointer" tool which lets you interrogate variables at certain points in the code, but there's no way of stepping-through rails server code (specifically the "controller" classes), while making requests from a browser, like Visual Studio does for ASP.NET. Apparently debugging will be included in Radrails 0.8, but 0.7 has only just been released and as a relative rails novice I've felt the need for a debugger quite frequently recently.

UPDATE (19 Sept 06): Radrails included debugging all along - check out my latest blog entry.

So, over the last few weeks I've been on a quest to find a decent RoR IDE with debugging, but with which I don't lose anything I've become accustomed to with RadRails, and which doesn't break the bank. This has proved not to be an easy task.

RubyInSteel is a free plug in for Visual Studio, which promised debugging, but after installing it I found that although it can debug ruby script, there is no support for rails debugging. Besides, the only SVN plug in I found for Visual Studio was ankh, which I couldn't get to work very well with my remote SVN repository.
(UPDATE: Since this was originally written, I've tried out the new version of RubyInSteel which does support rails debugging - see my next blog entry).

Arachno is a commercial standalone IDE which supports ruby on rails. This too claims to support rails debugging, and I found instructions in the ruby on rails wiki which detail how to set it up. I followed these instructions to the letter on my trial version of arachno, but to no avail. Maybe it was just lack of familiarity with this app, but I couldn't figure out why debugging wasn't working. The general feel of this IDE is a bit clunky and although it seems like there are lots of features, I wouldn't like to use it as an everyday editor. I never got as far as trying to get SVN to work with this one. Maybe if I can find out where I went wrong with the debugging, I'll give it a go, as arachno is pretty cheap at $49 for the personal version.

Komodo is another commercial standalone IDE supporting RoR, and I actually got this one to debug a controller method by following these very simple instructions. However, running your rails app in debug mode through komodo is very sluggish. For example, my rails server which normally fielded page requests almost instantaneously on my dev-PC sometimes took 30 or more seconds per page under debug mode in komodo.... but, when a breakpoint was actually hit, the IDE seemed to respond fairly well to clicking the step-over/in/out buttons. I also got SVN to integrate OK too, although I had to install a separate svn client - something which you don't need to do in RadRails - and accessing SVN functions caused the IDE to crash on me once. All in all, komodo is quite slick and if it wasn't for the weighty price tag of $295 for the professional edition (you don't get SVN support in the personal edition), I would be very tempted. The jury (me) is still out on this one.

So after all that I think that, in the short term, I'll have a bit more of a play with komodo during my free trial to see if it really justifies spending over 150 pounds. I might just sit it out and wait for RadRails 0.8, as it does everything else so well (and its free!).



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog

Tuesday 15 August 2006

Hello

Note: The RichText blog has moved to www.ricroberts.com

Hello! Rich here. Welcome to the Rich Text blog. In here you will find rants and musings mainly on computing and technology but other things may creep in too. Stay tuned.



Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Please also visit the Swirrl blog