Setting up a nas

A couple a weeks ago I bought some spare harddisk (2 500 Gig ATA). I had a spare computer lying around and wanted to build myself an small nas. I already knew 2 distros who’s idea it is to become an easy to use nas solution. Openfiler (Linux based) and FreeNas (BSD based), so I gave them a go. One of them crashed during gui installation when choosing the timezone. So I had to finish it in text mode. But that’s not a big problem only a shame you have to restart the installation.

But after installing it seems that OpenFiler doesn’t support a local user db. You have to setup an LDAP or AD, but for me on my own a LDAP or AD is a small overhead imho. So openfiler was a no go. Then FreeNas, this supported a local user db but after setting up and publishing an SMB share it seems that the security is isn’t that great. I can’t make a share private for my user. So if I wanted someone to copy something to my nas he would have access to my whole share. So FreeNas was no go as well.

Finally I installed the ubuntu server, apt-getted smb,ssh,… I created a software raid using the raid tools and made some shares on this raid folder. Now I have my own small NAS of 500 gig on the network.

So people who want a nas and are looking for a solution. Maybe just go with a normal distro and set it up like me. It only took 30 minutes max extra than using the formerly mentioned distros.

Most important setting when using Dojo

In our current application we use dojo. Only for a small amount of the application at this moment, but for the new version we are planning to include a lot more functionality using the dojo toolkit. I was testing this on an older machine (p3 1Gig) and the application took really long to display the page. So I asked around on irc #dojo and they pointed me to this really nice setting:

<script type="text/javascript">
	djConfig = {
		parseWidgets: false
	};
</script>

Dojo waits until page has loaded and then starts scanning for the dojoType attributes, you can imagine if you have a lot of data this will take a while. With this simple setting you tell dojo don’t do this.
Then for every dojo widget you want to use, just add

<script> dojo.hostenv.searchIds.push(id)</script>

Dojo keeps all the ids and only tries to create a widget out of the ones you push out. So no page analysis afterwards.

Sweet 2

Radeon Xinerama

Yesterday I put a new graphics card into my desktop machine (a CGA-P1652 RADEON X1650PRO 512MB) . I hooked my 2 big screens on it and rebooted. My ubuntu dapper couldn’t start gdm (ffcourse). So I apt-getted the ATI drivers and did a dpkg-reconfigure xserver-org, still couldn’t boot. So I started searching, after a while I found the aticonfig tool, one word sweet. I ran it witht he option for dual screen setup and he made a template xorg.conf file.

After adding the Xinerama option and setting the resolutions, I now have a nice widescreen view of my desktop and I can drag my windows over both of them. Life is great! I really believe that multiple screens do increase performance. I also liked the fact that my dapper box now has the ability to modify my screen resolutions using the gnome tool. The last time I did the dual screen setup with ubuntu, the app crashed, guess it wasn’t ready for dual screens. Now it works like a charm!

So people out there with radeon setup problems, one tool : aticonfig

Another thing I never thought off

A while ago a made a post on web standards saving money (ie for google). Today I was listening to another podcast, they had an interview with Chris Dibona He works over at google. He was talking about how google has its own team of kernel hackers. He explained how some small improvements in the linux kernel of this team could save google millions of dollars.
My first reaction was offcourse, your site will run faster you need a couple of computers less and that’s where your savings come from. Well he explained it somewhat different. Let’s say you have 100.000 computers (prolly google has much much more), your computers will stay a little bit cooler maybe even consume less power. So your airco could run a little bit slower. So a code optimization could result in a cut back in power usage. You would maybe even save some trees!

It shows how in each and every sector of the it you have to worry about different things. I have to admit, when I’m doing java development and I’m not sure if I should choose an int or a long, I’ll be choosing a long because memory is no problem for us and it’s only running on 2 or 3 severs. These guys will check,recheck and then check again if they instead of the int maybe even could use a smaller datatype.

Xsd nillable

In one of my current projects we are sending data to another company. Because xml is somewhat the standard for exchanging data these days I wrote a small java app using velocity to generate the xml files. Sure I could have used Oracle’s features to create an xml file but if you use that feature you could just as well give them an ASCII file imho.

So I started by creating the xml schema (xsd). Because some fields can be empty I some nullable fields. And that’s where the issues started. We have some dateTime fields that can be null so I thought spitting out a <date /> tag or <date></date> would do the trick!!! Biep error, after some googling and reading a lot I came to the conclussion that I had to output this : <date xsi:nil=”true”/> . Stupid if you ask me, but hey it now works.

I wrote a small velocity macro that I called:

#macro( xmlempty $value $tag $cdata)
#if ($!value == "" || !$value)
< $tag xsi:nil="true"/>
#elseif ($cdata == "true")
< $tag>< ![CDATA[$!value]]>
#else
< $tag>$!value
#end
#end

Works nice I have to say. The program was straight forward, a file that contains key value pairs. The key was the velocity template, the value was the query. I ran the query, retrieved the ResultSet cursor and while iterating it for every iteration I called upon the template that merged with my UTF-8 filewriter.

What kinde surprised me was the lack of good xsd/xml editors in the opensource. I tried the ones that were bundled with our myeclipse environment but they were more a pain than a gain. (omg lame!) So in the end I installed xmlspy and asked for a testing license. I have to say they have a really good product, but who wants to pay 600 รขโ€šยฌ for an xml editor. People come on, even ms visual studio .net 2005 pro only costs 750. They also have xml support built in, for that I’m willing to pay because of the added value but not for an xml editor. There are only a couple of things I need from an xml editor.

  • xsd code completion
  • Is my xsd valid
  • Why not, with linenumber error
  • Xml code completion using the provided xsd
  • Is my xml valid
  • Why not, with linenumber error
  • Maybe an xpath,xquery and xsl features

That should be sufficient. Hmm looks like a project for the future ๐Ÿ™‚

Python Commandline

Mostly when I code, I use java,c# or sometimes php. But now and then I use python. Today I wanted to download some podcasts that I hadn’t listen to in a while. (Read the other posts to know why) So I wanted to do a bulk download, the mp3z were named like xxx010.mp and I wanted to download up to 30 or so.
I gave the pyhton commandline an go (been a while). How could I forget such a nice feature.

i=10
for x range(20):
	print "xxx0"+str(i+x)+".mp3"

copy paste it into a textfile and wget -i thefile.txt

Sweet

asp.net issues

Yesterday I was building a small webapplication for a client. The user had to enter a code to retrieve some data. So I added a Label, a TextBox and a Button. I wrote my code tested it and it worked. I wanted to show it to the customer and suddenly it didn’t work??
Hmmm strange, I tried it a couple of times, still the same. Then I did it step by step. I filled in the code, pressed the button and voila there was the desired effect?
What was the problem? Well it seems that in the internet explorer version I had, when I filled the TextBox and pressed the enter button instead of clicking on the mouse button, the event of the login button pressed didn’t get fired. Firefox on the other hand tends to do press the submit button if you do the same actions. So you are on a textfield, enter some data and then hit the enter button. It will press the real form button, if there are more than one (like you have in asp.net appz) you have to take notice that the right ones backend action gets submit.
How did I fixed this, simple just hooked op the OnTextChange event with the same EventHandler of the ButtonPressed.
So if you do asp.net dev, please do check your browsers and don’t only trust the debugging sessions with your iexploder.

Also if haven’t heared about it yet, you should really checkout the firebug beta plugin for firefox (It wasn’t available on my ubuntu using apt-get, so you should install it from the xpi!)

a downside of offshoaring I never thought off

First off sorry if the title has spelling errors, English is not my mother tongue ๐Ÿ™‚

I’ve got my new car radio installed and I can again listen to my precious podcasts. I can even connect a usb stick with podcasts on it \o/.
Yesterday I was listen to a binrev show. They were discussing security aspects and offshoaring. They were talking about an offshoaring to china that wen’t horribly wrong. A well known US car builder wanted to offshoar the assembly line to China. They contacted a Chinese company to handle this. They sent all the data for building the shops. The chinese company took the data and created there own assembly line and started producing their own cars, they were almost an exact copy of the cars they were building in the US, because the didn’t have to do any research they had cut a lot of costs. Combine that fact with the low wages and you can imagine why the car was incredibly cheap.
They tried to sue the Chinese company but the (Chinese) judge ruled in favor of the Chinese company (what would you expect).

Maybe call me narrowminded, but I see this as another good reason not to do offshoaring (or do it,but don’t move everything). If I’m not mistaken more and more companies are offshoaring their it development to other countries. I’ve got no problem with that, but if you do, make sure that you know what you are doing. If you offshoar everything those companies know exactly how your company works. If they manage your email systems, I bet they have almost enough data to create an exact copy of your local company and produce all the products you produce. They didn’t even have to do any research. Ok, if they did it theirselves you would know. But what if one of their employees has a usb stick of 10 gig and they take the data and sell it to a small competitor over there. You can be sure that some big supermarket in the western world will notice and start importing it.

I haven’t noticed the offshoaring of IT development that much. But I know some companies are doing it, offcourse it’s cheaper. But did they ever think about what impact this could have? Just imagine that google had offshoared the actual writting of their search engine to a Chinese company? Would they still be in the position they are in at the moment? I really doubt it!

In short, think before you do something (as always)

Javapolis

I went to javapolis, I have to say, I’m glad I went. I saw a lot of old friends there. Nice to catch up what they had been doing the last couple of years. Someone even called me ‘The enemy’ because I also did dotnet. But hey I like programming and don’t want to be bound to 1 language, why constrain yourself. We as developers are so openminded, why not about the language we do it in then???

I saw some demos of flex2. Well, Adobe / Macromedia have built a nice tool, I really have to admit. I’ll be given it a test drive. I’ll also give openlaslo a go, but according to one of their ‘sales/consultants’. It is not as far yet as flex2. And I’m pro opensource, but I’m not anti closed source. There’s a big difference and if the product is worth it, I’ll pay for it. In the future I will pay for a copy of Visual Studio if I’m the express edition doesn’t furfill my needs. If you do dotnet development on windows I’ve tried sharpdevelop (on linux monodevelop) and for oss development its ok, but If I’m doing work for a client I calculate the hours it takes. Well If I can buy a product that makes me work faster why not?? For doing java development I use eclipse because thats somewhat the standard and I can work very fast in it! So there’s no problem! But for dotnet windows client development the situation is different!

Topreader Desktop Development (2)

This weekend and this evening I did some more TopReader development. I got stuck on the right mouse click popup (context menu) for creating folders,adding feeds, … I asked #gnome and Murray pointed me to the UIManager class. I have to say this is a nifty thing!!

For those out there who (like me) didn’t know about this Factory, it reads an xml file like the following

<ui>
  <popup name="channelpopupmenu" action="channelpopup">
    <menuitem name="MarkRead" action="MarkRead"/>
  </popup>
  <popup name="folderpopupmenu" action="folderpopupmenu">	
    <menuitem name="CreateFolder" action="CreateFolder"/>	
    <menuitem name="AddFeed" action="AddFeed"/>
  </popup>
</ui>

In your code you just do this for initializing it

uim = new UIManager ();
uim.AddUiFromResource("FeedMenu.xml");

And if you want to show a context menu, you intercept the right mouse click event on your widget and do this little piece of code

Menu w = (Menu)uim.GetWidget("ui/channelpopupmenu");
w.Popup();

The widget is retrieved by the tagname or its actual name
As easy as that!!!

Now we take it a step further. During initalisation we do this

uim = new UIManager ();
uim.InsertActionGroup (group, 0);
uim.AddUiFromResource("FeedMenu.xml");

Where the action group represents a group of Action objects (Duh)

ActionEntry[] entries = new ActionEntry[] {
    			new ActionEntry ("MarkRead", Stock.Cut, "MarkRead", null,
                     "MarkRead",
                     new EventHandler (OnMarkRead)),
                new ActionEntry ("CreateFolder", Stock.Cut, "CreateFolder", null,
                     "CreateFolder",
                     new EventHandler (OnCreateFolder)),
                new ActionEntry ("AddFeed", Stock.Cut, "AddFeed", null,
                     "AddFeed",
                     new EventHandler (OnAddFeed))
                   };

I haven’t configured them as you can see, all are the Cut Stock item.
So we linked the selection of the context menu item with the designed EventHandler.

One word: SWEET

What can I do so far with my app, well I can create folders, add feeds, read feeds, mark a whole feed as read. In the backend the feeds get updated automatically. As I mentioned everything is stored in a small sqlite3 database, for 318 items it’s 600 k, not tho much if you ask me. I wonder how much feeds I can archive before I reach the limit of sqlite (thought that was 2 gigs,but not sure)

I’ll keep you posted (offcourse it’s gonna be opensourced, LGPL probably as I like it more than the GPL)