Windsor featured on CodeBetter

Hurray!!!

It is about time that someone other than a Castle Project contributor bloged about Windsor!  David Hayden over at codebetter.com writes about Windsor.

I can’t think of very many applications that shouldn’t be written using Windsor, and I can think of scarcely few more which should not take advantage of Binsor.  The Meticulous Geek even says “I never want to configure my container with XML again.”

Yes, I realized I just linked Ayende again.  He blushed at my last post where I summarized what I thought were the best Active Record and NHibernate related posts of the past 8 months.  It was difficult to stay on topic.  There were many other great posts, but many were about other things.

Mcafee on Corporate computers

I hate antivirus software. I do not use it.
My prefered desktop is a Linux desktop. There is no antivirus there.
Even when I am on a Windows desktop, I prefer one with no antivirus software
installed, or at least no active antivirus software installed.

I’m working on my corporate laptop with its “enterprise” install of Mcafee
framework. It is hell. This ThinkPad T42 with its 2 year old,
5400(4800?,4200?) rpm 40G hard drive is slow enough. The fact that
every file write gets intercepted by the antivirus software makes this thing
feel slower than my P3-866 home computer. The “enterprise” install of
Mcafee disables the UI so that I cannot turn off the antivirus using the UI when
I click open the Console from the tray icon. I’ve created a desktop
shortcut that runs these commands, and I have named it “turbo.cmd”.


net stop mcshield
net stop mctaskmanager
net stop mcafeeframework
pause
net start mcshield
net start mctaskmanager
net start mcafeeframework

I run this and I ctrl-c at the pause if i want to disabled the Mcafee stuff.
I run it again and I let it continue if I want to enable the Mcafee stuff.
It works. My file writes speed up tremendously. I will typically use this when
I am unzipping a large archive, or even a medium sized archive with many small
files. The antivirus seems to eat tons of CPU when the system is writing many
small files.

The catch is that Mcafee somewhere hooks into the TCP/IP
stack in windows, or something. When in a stopped state, I cannot accept
incoming ssh connections. The client gives the old
ssh_exchange_identification:
Connection closed by remote host
Message. Its like Mcafee does tcp wrappers.
I hate it.

The solution: start the Mcafee services, and restart the cygwin ssh
daemon. I should add two more lines to my turbo.cmd above


net stop sshd
net start sshd

Now ssh works. Thank you Mcafee. Thank you for NOTHING.

Google hasn’t been a tech company for a while.

Deepak Sharma writes that Google no more a Tech Company If you have read their
annual report, you know that they have never been a technology company by
revenue. 99% of their revenue, and the same ammount of their profit comes from AD SALES. Google is an ad
company.

Saying that Google is not a tech company because they own YouTube is just
rediculous. I look forward to Google bringing the same awesome software
development practices to their newly aquired product.

ORM vs. your own DAL with everything in Stored Procedures

I was arguing in an instant message window today. I was trying to relay the awesomeness that is Castle Project’s Active Record. I realized I’m not a very good arguer. I found myself digging for URLs which I know I had read, which do the comparison of DAL vs. ORM and dispel the myths that “you must use stored procedures for all database access”.

As I was skimming reverse chronologically through Ayende’s blog, I realized that for someone starting off, reading these things in some kind of logical order would help. I’ve decided to try to put things in some kind of order. Regarding Ayende/Oren’s blog, his really is all you need. He links to many other sites with excellent information.
So first, I’d like to try to build a case for using ORM.  I don’t have to do much, it has been done for me:

Just because you are using ORM, doesn’t mean it is magic.  http://www.ayende.com/Blog/YouCantEscapeTheComplexity.aspx  You have to still understand what is going on under the hood.  This is definitely an area in which I am lacking.

It is probably best to read Clemens Vasters post, then read Ayende’s follow ups.  They are very enlightining.  It is great to get both sides of the issue.

  1. http://friends.newtelligence.net/clemensv/PermaLink,guid,0fbf07a9-9e7a-4db4-a305-58250ac57a73.aspx
  2. http://www.ayende.com/Blog/2006/03/07/ClemensOnORMappers.aspx
  3. http://www.ayende.com/Blog/MoreAboutObjectRelationalMappersVsCustomDAL.aspx
  4. http://www.ayende.com/Blog/ClemensOnORMapeersTakeII.aspx

Don’t think DLINQ is the answer, or that it does more.  Many DLINQ fans don’t realize that most ORMs have been able to do this stuff for years.  http://www.ayende.com/Blog/UsingORMProperly.aspx

A comparison of LLBLGen to NHibernate.  Now to be fair, Oren is a contributer to NHibernate so he may be a little biased.  I’ve not used LLBLGen, but I have browsed its documentation, and I’d also rather use NHibernate.  http://www.ayende.com/Blog/LearningAboutLLBLGen.aspx

On security of the stored procedure approach vs. ORM.  This is a great detailed description.  http://www.ayende.com/Blog/OneUponATimeInAnITOperationFarFarAway.aspx

For some reason there are LIES surrounding ORMs.  Know this:  They are lies.  http://www.ayende.com/Blog/PissedOffByVanatecOpenAccess.aspx
Some people have responded to others and said “I’ll write my own!”  Oren(Ayende) gives 25 reasons not to:

http://www.ayende.com/Blog/25ReasonsNotToWriteYourOwnObjectRelationalMapper.aspx

It turns out he was repeating himself, because he mentioned it a little less detailed months before: http://www.ayende.com/Blog/YouReallyShouldntWriteYourOwnORM.aspx

A common problem to run into once you start using an ORM, any ORM, is know as the SELECT N+1 Problem.  http://www.ayende.com/Blog/CombatingTheSelectN1ProblemInNHibernate.aspx

I’ve never done this, but I should probably keep it in mind.  I’ll bet I could use it, and it is a great example of how quickly you can get things done using these tools.  http://www.ayende.com/Blog/UnderusedNHibernateFeatureCreatingObjectsInTheSelectClause.aspx

I haven’t even read these yet. How could I have missed them?  They go into how it works.
All you wanted to know about Castle’s ActiveRecord – Part I
All you wanted to know about Castle’s ActiveRecord – Part 2

Finally, there is a whole series of posts building up a demo app, including using Brail for MVC.  This is ActiveRecord + MonoRail stuff, a great way to see the big picture.  http://www.ayende.com/Blog/CasleDemoAppMidwaySummary.aspx
A couple of items which I think are worth reading, but I couldn’t fit into this semi-ordered list of links.

  1. http://www.ayende.com/Blog/AFewWordsAboutTheDecoratorPattern.aspx
  2. http://www.ayende.com/Blog/AdvancedUsesForORM.aspx
  3. http://www.ayende.com/Blog/ComplexSearching.aspx
  4. http://www.codeproject.com/aspnet/NHibernateBestPractices.asp
  5. http://www.codeproject.com/cs/design/IntroducingCastle.asp
  6. http://www.codeproject.com/cs/design/introducingcastleii.asp

Once you are familiar with the ActiveRecord library, I highly recommend checking out the rest of CastleProject.  Windsor is awesome.  MonoRail is ASP.NET on steroids.

Locales, Postgresql and Ubuntu

Somewhere along the path of running Ubuntu unstable and its postgresql-8.1 packages, the locale which the main cluster was built with was en_US. But this was not the UTF8 variety of en_US, it was(is) the ISO-8859-1 variety of en_US. Well, somewhere along the way Ubuntu started defaulting to making ONLY the en_US.utf8 locale when the locale package is installed. This lead to some ugly strange errors when trying to start the postgresql server.

Error: The server must be started under the locale en_US which does not exist any more.

It is troubling because the en_US locale DOES exist, and the start scripts automatically set the locale properly. The issues is that en_US.ISO-8859-1 does not exist, but that en_US.UTF8 does exist. The solution is a simple command, but it wasn’t so simple to track down.

sudo apt-get install language-pack-en-base
sudo locale-gen en_US
sudo invoke-rc.d postgresql-8.1 start

Solaris Find Sucks.

Solaris hates efficiency.

OK, this isn’t entirely true, but it seems like everyone
I know who strives for efficiency in their work also finds that Solaris
userspace tools aren’t up to par. This usually translates to blanket
statements like “Solaris Sucks”. I’m not going to
argue any of this. I abstain please. Call me
Switzerland.

I ran into a limitation of Solaris userspace tools
recently. The find command does not support -printf like the GNU find
command. I need to output the date of a file in a numeric format so
that I can send the output to sort.
This angered me at first, but then I remembered that I was once
quiet profficient in Perl.

#!/usr/bin/perl sub f {
$d=shift;
print "openning $dn";
opendir(DIR,$d);
while( $f=readdir(DIR) ) {
print "$f $d/$fn";
if( $f eq "." || $f eq ".." ) {
print "$f nextn";
next;
}
if ( -f "$d/$f" ) {
@s=stat("$d/$f");
$fs{$s[11].$d.$f}=push @s,"$d/$f";
print "$d/$fn";
} if ( -d "$d/$f") {
print "calling f $d/$fn";
f("$d/$f");
}
}
}

f(".");

foreach (sort { $a <=> $b } keys %fs ) {
print $_, join(" ",@{$fs{$_}}),"n"; }

Yes, it works, but anyone who knows perl a little better knows that it is
WAY too long. I should have use File::Find.

#!/usr/bin/perl use strict;
use File::Find;

find({ wanted =>&data, follow=>1 }, $ARGV[0]);

sub data {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime) = lstat($_);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)=localtime($ctime);
$year=$year+1900;
print "$ctime $year-$mon-$mday+$hour:$min:$sec $uid $gid $File::Find::namen";
}

This just outputs the data I need and in true UNIX fashion, I use sort to do the actual sort

Using Perl always makes me feel guilty, mostly because
I frequent MichiPug, and its a python group, not a perl group.
So I wanted to try the same thing using python.

import os, sys
from datetime import datetime
from os.path import join, getsize
for root, dirs, files in os.walk(sys.argv[1]):
print os.stat(root).st_ctime, datetime.fromtimestamp(os.stat(root).st_ctime), root

I don’t know about you, but I know which of these I find most readable. 🙂

Burning CDROMS (or DVD) from ISO in Windows XP for free.

I hate buying software.  I’m a fan of Linux and Open
Source more for the price than for the philosophy.  I’m cheap.

Open Source on Windows is great.  Freeware is OK.  But the strange
hidden gems are the ones that have existed for years and I just don’t know
about.  Well, this one I have know about for a few years, but it has been
around for as many as 6.

The Windows Resource Kit comes with CDBURN.EXE.  It burns ISO files to
disc.  I am all for command line, but sometimes toggling between windows
explorer and command line is just not as efficient as it could be.  It is
also a hassle to click all the way through Start->Programs->Windows
Resource Kit Tools->Command Shell.  This stuff should be at my
fingertips!

I make this little file and call it cdburn-d.cmd and place it on my
desktop.  Now I can drag an iso to it and it immediately burns.  No
right click, no next button, no “are you sure” prompt.  This is efficient
🙂

"C:\Program Files\Windows Resource Kits\Tools\cdburn.exe" D:
%1

pause

Now as a Gnome and Ubuntu user I am sad to admit that I have no idea how I
can do the same thing in Gnome.  Could I create a shell script and do the
same thing?


cdrecord dev=/dev/hdc -dao $1

echo press enter to continue...

read


It pains me to admit that I don’t know if such a simple thing will work.
Especially since I’ve been using Gnome since before the 0.30 release.
That was pre-Nautilus, so I guess what may have worked then wouldn’t work
now, but it still pains me.

Agile good vs. bad. I win!

I honestly can’t tell if Stevey is serious or not, but I
love this post anyway.

I was chuckling inside the whole read, but this made me laugh out loud.
“I
was really curious, in part because I’d consented to try Agile last Christmas
(“hey, it can’t hurt”), and wound up arguing with a teammate over exactly what
metadata is allowed on index cards before giving up in disgust.”

http://steve-yegge.blogspot.com/2006/09/good-agile-bad-agile_27.html

By the end of the read I could tell that he is indeed serious and he raises
some awesome points.  This is the first writing I’ve ever read that said no
to Waterfall, Cowboy and Agile.  YEEHAW!!!