fredag, juni 25, 2010

Missing pictures

Was a bit clever the other day, and moved around on my various PicasaWeb accounts, and thereby most, if not all blogpictures went down the toilet.
Probably going to fix that sometime..

onsdag, juni 10, 2009

Plantain Chips

After my trip to Africa, from time to time I crave for plantain chips, since maybe some don’t know what that is, I took some photos of parts of the process.

This is the unripe plantains, looks like green banana, but not same, they have lot of starch, and are not good to eat like this. When they get ripe, they have an different sweetness than bananas, and because of the amount of starch, you can easily get an mouthful of these.


The skin is very thick, and strong, so to peel them, cut into the skin along lengthwise of the plantain, and then use your thumb to split it open and peel it off.


Then I use the fantastic Norwegian invention called Cheese Slicer, normally used for hard cheese, but it is perfect for this job. :)


After slicing, put them on some greaseproof paper, toss some salt on them (careful), and heat some oil. Preferably use groundnut oil. (Alternatively you can use sunflower or corn oil, but do not use olive oil.. ). Make sure the oil is good and hot, to see if the oil is hot enough, you can stick an wooden utensil into the oil, and if it fizz a little, then the oil is about right.

Toss them in the hot oil, careful, the salt will extract some water, so it will splatter a bit, so lower them easily down into the pot, or get burned. Your choice.

Do not fill the pot, you only will cool down the oil to much, thus, boiling instead of frying, which will make the plantain to such the oil into it instead of getting fried.


Leave the computer, TV, or whatever, the chips will be ready fairly fast. I have too often burned thing because of other distractions.. Always when using oil, pay attention!

After they get nice tan color, take them out, using some mesh-spoon or the like, and put them on some greaseproof paper again, spread them out on the paper, making the oil drip off. After a bit, turn, and move them, so they don’t soak into the oil.


Then, take them of the paper, collect into an bowl, or whatever, and eat.

Do I need to tell you that you should not eat too much of this? :)

torsdag, januar 22, 2009

Starting from “scratch”, books to read..

Lately I’m finding myself in an big puddle of mud, and feeling that I’m getting outdated really fast, everyone around me are talking POCO’s, IoC, DI, TDD, DDD, BDD etc.

Even though, I know what the acronyms are, I feel more an more uncertain about when to use what, how to apply, etc. I still feel that I can call myself an good developer, having good grasp of what is going on, I have to agree to lot of what Torbjørn writes here:

So, for starters, I have been bugging my twitter colleges about where should I start, what books to read, I have so far, come up with this list:  (no order yet)

Domain-Driven Design: Tackling Complexity in the Heart of Software (Hardcover)
by Eric Evans (Author)

xUnit Test Patterns: Refactoring Test Code (Addison-Wesley Signature Series) (Hardcover) by Gerard Meszaros (Author)

Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series) (Paperback)

Code Complete: A Practical Handbook of Software Construction (Paperback)

Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series) (Hardcover)
by Erich Gamma (Author), Richard Helm (Author), Ralph Johnson (Author), John M. Vlissides (Author)

Debugging the Development Process: Practical Strategies for Staying Focused, Hitting Ship Dates, and Building Solid Teams (Paperback)
by Steve Maguire (Author)

Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition) (Microsoft .NET Development Series) (Hardcover)
by Krzysztof Cwalina (Author), Brad Abrams (Author)

Refactoring: Improving the Design of Existing Code (Addison-Wesley Object Technology Series) (Hardcover)
by Martin Fowler (Author), Kent Beck (Author), John Brant (Author), William Opdyke (Author), Don Roberts (Author)

Working Effectively with Legacy Code (Robert C. Martin Series) (Paperback)
by Michael Feathers (Author)

Head First Design Patterns [ILLUSTRATED] (Paperback)
by Elisabeth Freeman (Author), Eric Freeman (Author), Bert Bates (Author), Kathy Sierra (Author)

POJOs in Action: Developing Enterprise Applications with Lightweight Frameworks [ILLUSTRATED] (Paperback)
by Chris Richardson (Author)


These two I have read, and I own the PoEAA, but I need to restock the PP book I guess:

The Pragmatic Programmer: From Journeyman to Master (Paperback)

Patterns of Enterprise Application Architecture (Addison-Wesley Signature Series) (Hardcover)
by Martin Fowler (Author)

tirsdag, desember 09, 2008


Note to self, GeekBeer 18. of december:

Picture proudly stolen from:

(aw, but not proud of the looks, gotta do some changes to this layout.. )

fredag, oktober 10, 2008

FPU issues when interoping Delphi and .net

In a project recently, we needed to do some interop between Codegear Delphi and MS .Net, that is, we have .net code that needed to be wrapped as an COM object so it can be called from native code or Delphi.

The developer of the .net library created an C++ client to test the library and everything working fine.
Then we develop the Delphi client, and after some googling etc we are good to go. Here are some articles describing the details:

But then... one method throws an exception:

Project TestClient.exe raised exception class EOleException with message 'Overflow or underflow in the arithmetic operation'.

What is this?, the method are doing some serious calculations, but it works fine from C++, and from other .net clientes that have been usiing the library for years, newer a hitch, so what gives?
I did not VisualStudio on the computer where I run Delphi, so I could not debug it in a proper fashion, and if I had, I guess I would struggle a bit to get it working, but anyway, I started to pepper the code in the library with some loggingstatement, to see what was happening, and surely, I found one point in the code that throwed the exception.
It was just one problem.. We do not get any exception at that point in the code...

Boiled down to basics, this is the code in C#:

double x = Double.NaN;
bool b = Double.IsNaN(x);

At this point, it's the IsNaN that throws, so modified a bit:

double x = Double.NaN;
bool b = (x==2.0);

And now it is the x==2.0 that throws??
Then I try:

double x = 3.2;
bool b = (x==2.0);

This worked..., and this:

double x = 3.2;
bool b = Double.IsNaN(x);

that worked to..... hm.. firing up Lutz Roeder's Reflector (yes, I know, it's Red-Gate now, but for me, it's always Lutz's Reflector..), and searching for the Double.NaN I find:

public const double NaN = (double) 1.0 / (double) 0.0;

WHAT?, but, isn't 1/0 an divide by zero?, so why does this work in C# plain, but not when called from Delphi?
At this point I remembered some years ago, when Delphi was the tool of choise.. there have always been some funky stuff going on in the RTL package of Delphi, but what could this be..

I started to toss some ideas to a friend of me, mashi, who is an serious bitfiddler, out of the blue,
he just asked me:

"maybe you need to flip a bit or two int the FPU's control register"

I was stoked.. the FPU??, why is that?, and then he could tell me that some DirectX libraries also changes the FPU settings to give more juice when doing some calculations..

Whoha, that's funny, but after looking at this article:

I find that there are 6 bits in the FPU's control register that actually controls exception handling by the FPU..

image (It’s the yellow one’s whe are after..)

So, to confirm, we need to find the current state, and luckily both Delphi and Visual Studio have debug-windows, that show us the value of the CTRL register, and they have very different values, in Delphi it’s 1272, and in C# it’s 027F (both number is hex), so, if we look at them as binary numbers:

.Net   027F = 0000 0010 0111 1111
Delphi 1272 = 0001 0010 0111 0010

For us, bit number 2 (it's zerobased so for you nongeeks (which lost this before reading this far anyway’s) it's bit 3 from the right), this bit is set to 1 in .net, and zero in Delphi..

After some more googling, I found this:

Which also say something abut this under the title Preserving Registers:

The only problem that is likely to arise is with the floating point processor (FPU) registers. Some versions of Delphi change the FPU control word upon entry to a DLL (but this is not true of Delphi 5);

Yeah, I know, the R thingy that that article is about, is probably some other thing that is far away from thiw, but it told me what I needed to hear. :)

So, armed with knowledge, I wanted to change the CTRL registers to see what would happen, and what do you know, even MS have an Q article about this very problem, but in an little bit different context:

PRB: System.Arithmetic Exception Error When You Change the Floating-Point Control Register in a Managed Application

So, after implementing this simple line in C#:

_controlfp(_CW_DEFAULT, 0xfffff);

everything works..

What we still don't know though.. will this have any sideeffects?, I guess time will tell..

I'm guess we should save the currect CTRL word, and restore it when we return from our method, but I'm not yet sure if Delphi also does it, so we need to do some test before we conclude, but at least, the NaN code is not giving us any problems now.

onsdag, oktober 08, 2008

I guess you could call this an developers wet dream...

Or something.. :D

So, I got this room filled with computers, geeks needs something to give credit for their geekness :), so atleast 4-5 is needed, but this is noisy, costly in terms of power consumption, and today we want to be a little greener than yesterday.. (ah, well, let’s see about that)

So, after some dealing with my boss, I got this nice home-computer, so I can do some serious work from home, atleast, it’s the plan :)

Dell offered me this thingy, called T7400, which I can say, it’s a pure monster. The weight alone was about to kill me, carrying this thingy 4 floors..

Some geeky details:
- 2 x Xeon E5440, 4 core, 12MB cache, 2.84Ghz
- 8 x 2 GB Fully Buffered RAM (with 8 sockets to spare)
- 2 x 750 GB SATA’s in RAID (stripe of course, who’s scared?)
- Nvidia Quadro FX 570 gfx card
- Powerhouse of an PSU, 1KW.. (the not so green thing)
- And ofcourse, and Dell 24” monitor, wish it was 30”.. (Sponsors??)

Later adjusted a bit, an extra 1TB harddrive, and an 150GB 10RPM RaptorX drive as an system drive.
All my drive, except the Raptor is 7200RPM, but my computer is quiet as, uhm, an bee… :)

Some pics:

Some memory, this is like 16GB of memory, Fully Buffered kind, wish they choosed some cheaper drugz, I need more soon:), however, I have 8 slots available…

And a few cores, conveniently wrapped in lots of four in each tower, the towers are hiding my Xeon E5440, 2.83Ghz, 4core, It’s not the worst computing towers money can buy, but they will suffice fine..
Even developers need some gfx, As an dev, I hardly can justify hardcore shit, I even don’t spend time with games, so I only got this Quadro FX570, but it seems to be good enough for me:

søndag, august 31, 2008


Well, had to go visit the skijump here in Oslo, as they are going to start to tear it down in an months time.


Quite nice view from the top also, but the glasses was dirty, and did not help in taking pictures.


Looks like it somewhat steep way down, glad I'm not an skijumper :)


In the museum, which I havent been visiting for about some 28 years, they also have a bit of Norwegian history regarding snowboards, nice: