I've been playing with
CouchDB a little recently. Its a "schema-free document-oriented database", which sounds pretty weird when all you've ever known is relational databases. At work, we're considering what architecture we want to go with for a new product that needs to be very flexible - the users need to be able to add fields, remove fields, and do all sorts of crazy things with the application.
One of the options we have, is to use something like CouchDB to be able to create an uber-flexible database that can evolve over time, and be very scalable. because our new product will be a SaaS one. Its pretty clear to see why CouchDB fits the bill.
Anyway, its pretty cool, and I wanted to see if I could get started creating a little application in Rails using CouchDB on the back end... It was pretty slow going until I came across this fantastic
PeepCode Screencast This screencast goes through the basics of CouchDB, and then goes on to build a nifty notes-esque web application using a CouchDB gem called
CouchRest.
Its a quality peepcode, and the CouchRest gem looks like its really going to help me :)
It'll be interesting to see what kind of take up CouchDB or other schema-free cloud computing databases get in the .NET world, I don't see much happening out there at the moment.
Anyway, watch out for my killer CouchDB-based rails application, coming soon (yeah right!)
AKA: "Why am I getting 'ActiveX can't create component' when I try to access my COM DLL's"
AKA: "Why am I getting 'Service Unavailable' when I've set IIS to run in 32 bit compatibility mode.
AKA "Why do I get 404 errors when I browse to my ASPX pages"
Man that's a long title :)
So, I recently had to spend some time looking into getting my companies web application working in 64 Bit Windows (2003 R2 to be exact). I eventually got this working, but found the information scattered and incomplete on the interweb, so this little guide should see you through. I hope someone out there finds it useful.
Starting Point.
You have windows 2003 R2 64 bit SP1. You have the 64bit version of the .NET framework (V2 or higher) installed. No other changes have been made to IIS - it seems to run just fine for serving .NET and HTML. You install your web application that includes COM, try to run it, and BANG...
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object
The cause? Its because those COM objects are 32 bit components, and by default IIS won't work with 32 components. You need to tell IIS to run in 32 bit compatibility mode (WOW64). To do this, you need to configure IIS to run in 32 bit compatibility mode, as explained by this link.
But wait! Its not quite that easy! If you do this, then you're telling IIS to run in 32 bit mode, but then you've already got the 64 bit ASP.NET DLL's registered with IIS, so the first time you hit your app, you'll probably see a big fat "Service Unavailable" Error message. If you look in the event log, you'll see your application pools are crashing with this error:
A process serving application pool 'DefaultAppPool' reported a failure.
The process id was '4156'. The data field contains the error number.
So, you need to register the 32 bit ASP.NET DLL's with IIS. But wait! You can't do that before you un-register the existing 64 bit ones.
Enough waffling. Here's the step-by-step :-
- Un-register the 64 bit ASP.NET DLL's. In a command prompt, navigate to C:\Windows\Framework64\v2.0.50727\ and from there run "aspnet_regiis -u"
- Set IIS to work in 32 bit compatibility (WOW64) mode:
cscript c:\inetpub\AdminScripts\adsutil.vbs set w3svc/AppPools/Enable32BitAppOnWin64 1
- Register the 32-Bit ASP.NET DLL's. Navigate to C:\Windows\Framework\v2.0.50727\ and from there run "aspnet_regiis -i"
- Finally, in IIS, Navigate to "Web Service Extensions", and make sure that ASP.NET is "allowed".
You're done!
Rails makes such a nice change from coding in .NET. I mean, I do like .NET and C#, but sometimes its very bloated and can be quite cumbersome to do things.
Rails, on the other hand, isn't big. Or cumbersome. In fact, its downright lean and to-the-point, unlike my blog posts (what there are of them!).
Anyway, today we're talking category trees, surely one of the most exciting concepts that there is to talk about. One thing that made me smile recently was the need to list all the categories that a company was tagged to. So, this happens with code that looks like this :-
<%for cat in @Categories %>
<%= cat.name + "<br>" %>
<% end %>
.. Where @Categories is a collection of categories from the controller, and is generated like this:
@Categories = Company.find(params["id"]).Category.find(:all)
So, this noddy code just lists all cats that the company was tagged to. After deploying this, I was asked to change it so that the full hierarchy of categories was displayed. So instead of "Cat 1", the user wants to see "Root -> Services -> Cat 1". Hmmm, I thought, perhaps I need to write a little recursive method to go and get the parent nodes of each selected category... Turns out that because I was using acts_as_tree in the model (google it!), I was able to solve this with a really simple bit of code added to the category model :-
def fullcategoryname
self.ancestors().each() { |parent| fullname += parent.name + " / " }
fullname += self.name
end
Thats nice! :) Gotta like Ruby.
Our software has been around for a long time. It started life as an ASP application, with all the database logic tucked away in VB6 components, and lots and lots of ASP pages.
Because we invested so much into these VB6 components and also the ASP UI infrastructure, we're still using it today - so we have ASP pages that call VB6 components. Obviously, as we move more and more of the code into .NET, we are relying on Interop more and more to allow us to make use of "new" stuff from existing ASP pages... It was all working well until recently we needed to implement new features that rely on getting data out of the application config file... thats where it all goes bad :(
If you interop from unmanaged code to .NET, .NET will look for an app config that matches the executing process's filename + ".config".
.. which sucks for us. We implemented a cool new permissions checking infrastructure in .NET, and as part of this I wanted to use the SQL Cache Dependency to be able to auto-remove cache data when the underlying data changes. But...SQL Cache dependency relies on configuration data being set in the app config, so when we call through from a VB6 app - it aint gonna work! If called from COM like our .NET code is, the .NET assembly you execute is being executed from the process DLLHOST.exe, which lives in the System32 folder. Therefore the CLR looks for a config file called "DLLHost.Exe.Config" - try pursuading your clients to create that :)
This is a real shame and it stops us from using the SQL Cache Dependency stuff and some other things that are configured using the app config. We can get round it for simple settings like the connection strings, because we create our own classes to process the web.config that we actually do want to use, and that works, but for a lot of stuff that relies heavily on config setup, we can't use it... its a bummer!
Testing from Windows live writer :)
I recently decided to play around a bit with Ruby on Rails, its had so much hype so I thought it would be interesting to see how it fares up against ASP.NET programming!
Anyway, I'm only just starting out, but first impressions are very very good indeed! Ruby seems to be a very intuitive language, although I wouldn't say I preferred it to C#. However, the rails framework that deals with all the agile web framework side of things seems awesome!! Really easy to use and get a reasonably complex web site up and running.
I'm going to waffle on a bit more about this in the future, but in the meantime if you're interested in giving it a go on a windows box, its ridiculously easy - you don't even have to "install" any software!! Just do this:
1) Download "InstantRails".
http://instantrails.rubyforge.org/wiki/wiki.pl
From the website:
Instant Rails is a one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL, all pre-configured and ready to run. No installer, you simply drop it into the directory of your choice and run it. It does not modify your system environment.
2) Get a "development environment setup"
If you're used to being spoilt/abused by Visual Studio and want something all nice and integrated, then you need to get RadRails. RadRails is a free plugin for the excellent-if-sometimes-a-little-too-slow-for-me Eclipse devenv from Sun. It needs the java runtime to work. Anyway, get it from
www.radrails.org
Alternatively, use VIM with ruby plugins, or something else :)
3) Follow some tutorials.
Start here....
instantrails.rubyforge.org/tutorial/index.html
Then here....
www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials
Installing the Visual Studio 2005 Service Pack and you get this.....

Well, its another new year (did I mention that?) I'm going to make a big attempt to update my blog more often than I did towards the end of last year, that was pitiful to be honest.
So, what better way to start the new year than installing some free software to make your development/computing life that bit easier.... Here's my top 5 list of "Stuff I always install when I rebuild my machine":
- Notepad2. Its my fave notepad replacement, with all the usual syntax highlighting and cool features. Check it out: http://www.flos-freeware.ch/notepad2.html
- TaskSwitchXP. Its a fantastic Alt-Tab replacement with loads of cool features. http://www.ntwind.com/software/taskswitchxp.html
- Firefox with extensions. The best browser gets even better when you start playing with extensions. There's so many good ones, but AdBlock and AllInOneSideBar always make my list. For web developers, check out FireBug (http://www.getfirebug.com/)
- Omea Reader. Its a free RSS reader and much more. I only use it for RSS feeds, and I really like it for that. I used to use SharpReader until I paid attention to the amount of memory it was consuming! http://www.jetbrains.com/omea/reader/
- Foxit Reader. For the love of God don't use that horrible piece of bloated tat known as Adobe Reader. There is a better way, and its here: http://www.foxitsoftware.com/pdf/rd_intro.php
I could go on for another 20 entries here, but these are probably my top ones... Oh, and "Query Express" (http://www.albahari.com/queryexpress.html)... oh and LLBLGen, but thats not free!
I'm just "touching base" with my blog, which basically means if you convert the management speak crap to normal, that I have nothing in particular to say of interest to the world in general.
What I will say is that I'm happily on Firefox 2 now. It seems to boot a lot faster in windows, and I like the subtle changes to the UI (improved tabs etc). I also think that the improved RSS support is pretty cool, those Live Bookmarks are damn useful!
I'm just waiting for the next release of Ubuntu (6.10) to be released, then I'll boot back into Linux and get FF2 installed in that too.
Cool Javascript/CSS Sidebar reference
Almost forgot to mention it, check this cool AJAX powered sidebar refernence for CSS/JScript (and MySQL/PHP too if you're that way inclined)
http://ql.aonic.net/info.php
After years and years of my reasoably fast but error prone self-taught four-six fingered typing, I've decided that I really should learn to type properly (i.e. touch type).
Its driving me mad though!! I think it would be much much easier if i hadn't already programmed my brain to use certain fingers for certain keys - I'm loads faster "old stylee" and still very slow (and error prone) new style... I've been at this for a few weeks now and its getting no easier :(
Programming is the worst, just when you get your fingers in the "starting blocks" you have to reach over for the arrow keys or hit some whacky key combination that you can only do by moving your hands somewhere else....
Fingers crossed (or not ;))
Greetings all. I'm testing out windows live writer as an alternative to w.bloggar for creating blog posts...
First impressions are good... I like the way that it gives me a proper preview as it will look in the web. I also like the UI (very Word-esque), and the fact that I can save drafts etc...
I think I'll be using this from now on! :)
I've been a windows user since the days of windows 3.1... windows at college and Amiga Workbench at home :) Windows 95 was a big improvement, and XP another big step. But I always wondered how life was as a Linux user. I've also been plagued with XP annoyances recently - spyware, anti-virus software and all the security add-ons have been driving me mad! So, recently I "took the plunge", and discovered how much linux has progressed recently. This post is basically just me waffling about my Linux experience.
So....Ubuntu?
Ubuntu is a linux distribution. Its become a very popular one recently - and I like it too! Wikipeadi will tell you more: WikiPedia link
I googled for a while to find the distribution that sounded good to me, and this one stood out to me - loads of people were raving about it, it had a nice firendly website, and just looked pretty cool. So...on to the installation...
Installation.
I was pretty scared about installing Ubuntu. I have an XP system and I wanted to keep hold of it, and I was worried that I would do something badly wrong and lose my xp partition! I prepared my hard disk by freeing up some space and creating an unformatted partition (40 gig) ready for a linux install. I used windows software to do this, but have since discovered a cool tool called GParted, which can be downloaded as a live CD and used to help you resize your partitions without losing data! All I did was to resize my windows partition to leave to "spare room" on the disk.... sorted.
Anyway, once I had that sorted, I downloaded an ISO of Ubuntu, booted into it, and clicked the icon to install it properly. Thats pretty much all I had to do! The scariest thing was when it asked me where to put the installation, its default suggestion if I remember correctly was to delete the entire hard disk. However I simply told it to use the free space, and off it went. It didn't ask me if I wanted to install a boot loader to allow me to boot windows or linux - this worried me, but it turns out that it did it anyway, I guess linux is always going to be more aware of windows because theres a high chance that windows will be on the system already !! OK, so installation done, I booted into Ubuntu to see what worked..... this is the best bit....
Everything worked!
Yep, I had sound (XP wont find my sound card without drivers), I had the right resolution, I had USB support (insert a memory stick and voila!), I had CD/DVD burning support, l ife was good :) Well apart from my printer, but apparently I can blame Canon for releasing very bad drivers (shame on you!).
The UI, and XGL/Compiz
Something I had heard loads about recently was XGL and compiz in linux. I've watched some video's showing off xgl/compiz effects, and thought that it looked incredibly cool and potentally useful, so I was looking to find out more. If you have no idea what I am talking about, check out this video and then you'll see what I mean.
Google video link
Anyway, I followed the "howto" guide on compiz.net but theres a lot of guides floating around on this now (e.g.
Link)... To cut a long story short, I struggled at first but soon got the problem sorted and now have very fun (I'm not yet decided how productive) 3d effects on my desktop that frankly make Vista look a bit lame :) The only problem is that my ATI card struggles a bit but thats because ATI have very poor drivers for linux. I'm hoping that will change soon since AMD bought ATI.
Using It
I like using Ubuntu - I can get lost quite quickly but its nice to experience a different operating system. I think if I wasn't computer savvy it would have been a hell of a struggle - you can get to a point where things can get difficult to set up and need to delve into forums for help - even installing some software can be a challenge, when all I want to do is download something and make it install! That said, any packages (software) that are in the "repositories" are very easy to install - you can use a UI front-end to browse all available software in the repositoriesand then choose what you want - and theres loads of cool stuff in there... For example I found a media player called amaroK, which IMHO is better than even the latest beta of media player in windows - it just works and does everyhting I want really nicely :) Its just less "popular" stuff that might not be in the repository that can get difficult. Luckilly theres a really popular and helpful forum called UbuntuForums.org which will pretty much sort you out or head you in the right direction.
Programming in Ubuntu is an interesting experience. I installed Mono and MonoDevelop for developing in .NET in linux. To be fair to them its incredible what they have accomplished and what you can do, but I'm coming from a background of Visual Studio 2005 here, and to be honest once you get used to the tools and features of that IDE its hard to get excited about other ones. Anyway, I quickly got bored of that and am currently toying with the idea of playing with "Ruby On Rails" a little......who knows what will happen with that.
Anyway, I waffled on too long now. In summary I think I can safely say I'm quite impressed with Ubuntu. I'm using a fair bit at home and as I get more familiar I might even start to use it more than windows for non .NET tasks... .but I'm not about to jump ship on Windows... at least not yet :-)
We have a lot of old COM code we interop with, and its ugly debugging the contents of a recordset from within .NET.... but now theres a much nicer way to do it in 2005 :)
All you need to do is load your ADO Recordset into a DataSet, and then use the new visualizer stuff in visual studion 2005 to have a proper look at the contents of that recordset...
Heres how to get the recordset into a DataSet:
DataSet ds = new DataSet();
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
adapter.Fill(ds,rs,"ADODB.RecordSet");
Having had to code the same regular expression code in 3 different languages today, this post shows how the syntax differs for a fairly simple regular expression task. I'm posting it here for so I can look it up iin teh future, and it
might be useful to someone out there - I'm simply looking for 2 parts of a frequency code string (in the format of [number][code] e.g. "15M"), which I want to capture and store in 2 variables...
VBScript code
Dim m As Match
Dim matches As MatchCollection
Dim re As RegExp
Set re = New RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern = "(\d*)([DWMQY])"
Set matches = re.Execute(sStringToSearch)
If matches.Count > 0 Then
Set m = matches(0)
nIntervalNumber = CInt(m.SubMatches(0))
sIntervalCode = m.SubMatches(1)
End if
Javascript code
var regExpression = new RegExp("(\\d*)([DWMQY])", "gi");
var regExMatch = regExpression.exec(sStringToSearch);
if (regExMatch)
{
nIntervalNumber = regExMatch[1];
sIntervalCode = regExMatch[2];
}
c# Code
Regex regex = new Regex(@"(\d*)([DWMQY])", RegexOptions.IgnoreCase);
Match match = regex.Match(stringToSearch);
if (match.Success)
{
intervalNumber = Convert.ToInt32(match.Groups[1].ToString());
intervalCode = match.Groups[2].ToString();
}
.. so there you have it. Very boring code, but at least it shows the same code in different languages!
Just came across this site recently:
http://www.gotapi.com/http://www.gotapi.com/
Its very useful! If you need a quick reference for HTML, CSS, XSL, XPATH, and Javascript, then bookmark it now!