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: http://blog.kjempekjekt.com/2008/12/28/a-bli-en-net-ninja/

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)
http://www.amazon.com/dp/0321125215

xUnit Test Patterns: Refactoring Test Code (Addison-Wesley Signature Series) (Hardcover) by Gerard Meszaros (Author)
http://www.amazon.com/dp/0131495054

Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series) (Paperback)
http://www.amazon.com/dp/0132350882

Code Complete: A Practical Handbook of Software Construction (Paperback)
http://www.amazon.com/dp/0735619670

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)
http://www.amazon.com/dp/0201633612

Debugging the Development Process: Practical Strategies for Staying Focused, Hitting Ship Dates, and Building Solid Teams (Paperback)
by Steve Maguire (Author)
http://www.amazon.com/dp/1556156502

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)http://www.amazon.com/dp/0321545613

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)
http://www.amazon.com/dp/0201485672

Working Effectively with Legacy Code (Robert C. Martin Series) (Paperback)
by Michael Feathers (Author)
http://www.amazon.com/dp/0131177052

Head First Design Patterns [ILLUSTRATED] (Paperback)
by Elisabeth Freeman (Author), Eric Freeman (Author), Bert Bates (Author), Kathy Sierra (Author)
http://www.amazon.com/dp/0596007124

POJOs in Action: Developing Enterprise Applications with Lightweight Frameworks [ILLUSTRATED] (Paperback)
by Chris Richardson (Author)
http://www.amazon.com/gp/product/1932394583

 

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)
http://www.amazon.com/dp/020161622X

Patterns of Enterprise Application Architecture (Addison-Wesley Signature Series) (Hardcover)
by Martin Fowler (Author)
http://www.amazon.com/dp/0321127420

tirsdag, desember 09, 2008

GeekBeer

Note to self, GeekBeer 18. of december:



Picture proudly stolen from:
http://iridescence.no/post/GeekBeer-in-Oslo-on-the-18th-of-December.aspx

(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:

http://interop.managed-vcl.com/netinterop_csharp.php
http://www.drbob42.com/examines/examin36.htm
http://www.blong.com/Conferences/BorCon2004/Interop2/COMNetInterop.htm#CCW

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:

http://webster.cs.ucr.edu/AoA/Windows/HTML/RealArithmetic.html

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:


http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/pascal.html


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

http://support.microsoft.com/kb/326219




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

Holmenkollen

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

DSC_7752

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

DSC_7803

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

DSC_7797

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

DSC_7827

lørdag, november 10, 2007

Makin' moin-moin

I have done some effort to try to make an Nigerian dish called moin-moin, a sort of bean-cakes, or in my case, an bean pudding :)

The basis of the recipe is as described at lots of places on the Internet, like here, here or here

For this, you need some dried black-eyed beans or cowbeans. But since the process of removing the skin for these are rather tedious, I prefer dried skin-free beans. The local Africa-store has some, but they are quite expensive, about 10-14€ for one kilo:

01_DriedCowBeansNoSkin

But in another store I have found an substitute, something called broad-beans, well, they are cheaper (about 2-3€ for one kilo), and for me, they seems to give the same taste and texture to the result, so for now I settle with this:

02_OtherBean

As you can see, they look a little different, but:

03_OtherBean

These need to be soaked some time, I have found the best result if I soak them for about 10-15 minutes first, rinse them thoroughly and then soak them, and leave them in the fridge some ours, or overnight: (If you leave them overnight, you really need to leave them in the fridge, or you can acquire an fancy stomach after eating the result :)

04_AfterSoaking

You should have an decent food-processor with some sharp knives, I have tried this with an blender, but difficult at best, and not so good result.

05_FoodProcessor

In the food-processor they go:

06_FoodProcessorBeans

After some grinding, I start adding stuff, like canned tomatoes, or fresh peeled tomatoes, and pepper, I use ether one red habanero, or some dried hot chili.

07_FoodProcessorAlmost

Which also gives it some color after when it is grinded well. At last, when the texture is fine and smooth, I add one finely chopped onion, and make sure I don't run it in the food-processor so long at it disappear, the grainines of the onion is fine.

Then I turn in some groundnut oil, some salt, pepper, and chicken stock powder to taste (not to salty, but still so you don't feel the beans to much)

08_FoodProcessorDone

Then I scoop the batter in bread-forms, which is previously prepared with groundnut oil. Make sure you leave some room for the batter to rise, and also some room for eggs, or fish if you like that. I often use hard-boiled eggs, and/or boiled salmon.

I use this type of forms, since I had an accident with using tin-cans earlier, and wrapping it into tinfoil was to messy for me, but these forms are very good to use, but only if you cook it as below.

09_BatterInForm

Put them in a water-bath in an preheated oven, approx 125 degrees celsius:

10_FormInOwen

You remembered to leave room for it to rice? they rice some, so it should be some room. Leave it into the oven until it is finished, for me it takes about 30-60 minutes, depending.

To check for done-ness I use an bamboo stick and poke the pudding gently, if the stick is clean when you take it out, it is ready. Otherwise some of the batter will stick on the stick :)

11_Almost

This one is done, take it out, and leave it for some minutes to make it settle.

12_DoneInForm

And then, turn it upside down, and with any luck you should be able to get it you without to much problems, depends on if you was to greedy with the groundnut oil in the forms :)

13_OutOfForm

Slice it, and taste.. should be yummy:). When I use the recipe with two cups (one cup is about 2.5dl) then I get two puddings, if it is to much, I freeze it, and it seems to be ok when I thaw it again, but others may disagree with that.

14_Sliced

 

Enjoy.

søndag, juni 17, 2007

Shopping for groceries and food in Nigeria

I haven't blogged much about my trip to Nigeria last year, maybe I should, but after reading an entry from Hobotraveller, I wantet to post these picutures:

This is streetfood, Suya, or Barbeque as we call it in europe, this was very good, I eat lot of it, but I think one should be careful about where you buy it:


This is my favorite suya-spot:


Food is ready, sign outside an shop selling drinks and soup, the "banana" is plantain, my girl did not allow me to taste the pepper soup, I think she worries to much about my tolerance to pepper :), but I got to taste the beer though:


Selling Gas in Lagos, there was several stores like this around, very clean and ok, and very "not-in-africa" experience:


Another Gas-store, here in europe we have "On the Rrun" signs on the Esso stations:


Woman selling biscuits and snacks in one of Lagos motorparks:



Selling fruit in Benin City, look at the size of the pineaple, very nice, I cannot find anything like this here:



Mr Bigs in Benin City, very similar to McDonalds etc, but they sells west-african food as fast-food, they also had burgers, but I would not recomend those, the chicken with rice and dodo is great though:


Inside Mr Bigs


Selling Gari, Tomatos, Yam, Water, Oil, Onions etc:


Woman selling lots of tin cans, I cropped her out of the photo, I think she was very proud of her collection, I bought Heinz Ketchup here :)

lørdag, mai 12, 2007

Computer Controlled Coffee Roasting

A friend of me pointed me to this. Surfing a bit lead me to others also doing things like this.


About three years ago, I was also geeking out and roasting my own beans, nothing can compare to fresh roasted beans, here is some pictures from that time:

First the equipment, and popcorn maker, slightly modified.
Based on experience, do not use that brown packing cellutape..
The tincan on top is a empty can of some corn or peaches, The reason for the tin-can, is to make an pipe, and that will make it hotter inside the popper:



Inside, the small holes in the bottom is where the hot air flow:


End result, I did not take a note of which beans this was, maybe I was a little to ecstatic about the fact that the result was looking good.:), and it tasted good also, but I had problem with timing, sometimes it was good for coffee, sometimes good for espresso..


Maybe it is time to pick it up again?:)

torsdag, september 28, 2006

Independent music: Saskia


This is an cd you should consider for your collection, very nice music if you like the pop electronic genre, I would guess that most do.

Some information and pictures here, and you can buy it, and listen to it here.

Ginger Candy

Ginger is supposedly healthy, but wonder how healthy this kind of candy is, it tastes very good indeed.



The bonbon's are chewy, good strong ginger taste, the things in the back of the picture are pickled ginger, good sweet taste, but not strong as the bonbons.

tirsdag, september 26, 2006

Windows Explorer gone bad...

This is something that happens to all of my installation, right after an fresh installation this happens, and it rides me forever.. what is the problem?.

When the browser looks like this, I have to shut down all Windows Explorer instances and reopen so I can use it.. after a few hours, I need to repeat..

This is from the top of the folderlist:

And this is from the bottom of the list:

søndag, september 24, 2006

Spjeldnes vinner av NM i roadracing

Helge Spjeldnes vant NM i standard 600 på vålerbanen, 17.09.06, her er noen bilder derifra.


(foto: Steinar Tullut)

torsdag, september 14, 2006

Camera Image Sensor Sizes

There are lots of SLR's popping out on the market today, but the size of the ImageSensor was a bit confusing, i.e. what size do I have on my compact camera?, what is that size compared to SLR's?

This article gives discusses the sizes between fullformat and APS-C which is the common size for SLR's today (consumer, pro-sumer cameras)

This article shows you the differenses for common sensor sizes that are, or has been in use.

So, my camera, an Canon Powershot S60 has something called 1/1.8 inch, and is 7.176 x 5.319mm, compare that to an APS-C, which is about 22 x 15 mm (I see there are some small variations there), and an fullformat imagesensor is an whopping 36 x 24, but that costs an fortune compared to APS-C.

tirsdag, september 12, 2006

Exit open programs...

Software from MS is really annoying from time to time.. was about to update MSN Live Messenger (or what they call it today), and this came up:



What is the point with this??
It's okay if I need to shutdown the program to be updated, that is just normal, but what's the point with Internet Explorer, Mozilla, Visual Studio, Outlook, Query Analyzer etc??

Geez.. gimme a break..

tirsdag, august 01, 2006

MSDN Library

Microsoft has made MSDN library available for free download, I think that is great, the library are always an good source of information.
Just wonder why they didn't release the DVD version while they where at it?

Anyway, it's here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=373930CB-A3D7-4EA5-B421-DD6818DC7C41&displaylang=en

Building ConnectionStrings

In an email from SQLServerCentral today I got this tips about using the new ConnectionStringBuilder in .NET 2.0:
http://www.sqlservercentral.com/columnists/rVasant/connectionstringbuildersinnet20.asp

Well, looks okay, but I still prefer this one:
http://www.connectionstrings.com/

There you will find the syntax for about any connectionstring you ever need to build.

tirsdag, juli 25, 2006

I'm lazy...

So I don't go to the forrest to harvest the fruits of nature.. So I bought some instead, but that has it's price.. 170 grams of blueberry's for NOK 40,-

THAT is way expensive..

GMail it is..

So, after to much happenings with my emailhandling from webhost4life's part, I decided to test GMail Hosted, after all, it's free, so it was an easy decision to make :)

After I got my invitation mail, I was up and running in about 15 minutes, looks like this is also working very well.

Recomended: https://www.google.com/hosted

onsdag, juni 28, 2006

Sandbox Da IE

Why did it take so long time before anyone did something about this?, For long time ago, a Norwegian (Normann Antivirus?) company made such kind of Sandbox to isolate applications before running things in the wild.
Anyhow, now you can sandbox your IE: http://www.greenborder.com/consumer/

MS should have done this for long time ago.. oh, well..

Edit: And then Google bought them, another alternative:

http://www.sandboxie.com/

 

For those who don't know what an sandbox is:
http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29

E.T. err XP Phone home...

Everyone know about WGA by now, and the XP phone home facility, someone probably has put the squece on MS:

http://support.microsoft.com/kb/921914

Other also provide tools for this:
http://www.firewallleaktester.com/removewga.htm