Lorenz Cuno Klopfenstein

News

Nike+iPod sensor

Being a satisfied iPod touch owner, I've used it a lot of times to go jogging and listen to some music in the meantime (and to keep track of time using the standard iPod alarm clock). A couple of months ago I bought a very cheap Nike+iPod sensor but didn't have a chance to use it... and anyway, it was way too cold to go out running!  :)
Today I finally had the time (and incredible courage) to test it.

The iPod touch can directly connect to the sensor, since the receiver is already integrated (I guess it uses bluetooth) so there's no need to get the whole set (which you need if you have an iPod nano). Just get the sensor, which is really really cheap (like 12? or something).

Nike+iPod

Speaking of cheap, I didn't buy the expensive Nike+ shoes of course but still use the same ultra-cheap running shoes as always. The Nike+ shoes provide an apposite slot where you can put the sensor while running. For "normal" shoes, there are a couple of straps on Amazon that should do the same thing, but I figured that putting the sensor behind the shoe strings would be pretty much the same.

The Nike+iPod sensor on my running shoe.
The sensor firmly in place. Ignore the ugly silvery shoes.  :)

And in fact, it worked: just stick the sensor in a point where the strings cross twice and you shouldn't risk losing the precious electronic gadget. After my first test run the sensor apparently had moved a bit, but wasn't about to fall out. Even if that happens, the Nike+iPod should warn you when it loses contact with the sensor and you'll be able to go back and hunt for the thing...  :D

More...

Posted on Monday, January 25, 2010
Tagged as
31 Views
0 comments posted

A fondue prepared with Italian cheese.

Today's post is somewhat unusual: a cooking recipe for a tasty fondue prepared with italian cheese.  :)

Ingredients for 4 people:

  • 500g Asiago
  • 300g Parmigiano
  • 100g Gorgonzola
  • 3dl white wine
  • 2 soup spoons of potato starch
  • 2 spoons of grappa or Kirsch
  • One or two cloves of garlic and shallot onions
  • Some nutmeg
  • 400g of bread

First of all, prepare the caquelon and rub the garlic on it's whole surface (if you can't stand garlic, skip this step safely). Then start preparing the cheese: Asiago is a soft, mild cheese that can be easily cut in slices and thrown into the caquelon. Parmigiano on the other hand is extremely hard and will need some grating (this can take a lot of time if you're preparing fondue for many people).

Start melting the Asiago and Parmigiano by putting the caquelon on low heat. Keep stirring energetically and sprinkle the potato starch in the mixture. Add in the shallot if you like (just for flavor) and add the white wine. As soon as the cheese is fully melted (emulsified would be the right word), mix in the Gorgonzola and the grappa.

Keep stirring in order to make sure the cheese doesn't burn to the caquelon and keep on medium heat. Ensure the heat isn't too low, or the cheese will solidify in big clumps. When the cheese has reached the right density, grind some pepper and grate some nutmeg to add flavor. In the meantime, slice the bread in small cubes.

Serve the caquelon by placing it on a heater on the center of the table. Keep stirring while eating, but do not scrape the bottom of the pan because that might loosen parts of burnt cheese.
Enjoy!

The ingredients used for the fondue.
The ingredients: Asiago, Parmigiano and Gorgonzola.
Posted on Thursday, January 21, 2010
Tagged as
31 Views
0 comments posted

This is an update over an old post about running Lucene.Net on a medium trust web hosting service with NHibernate.Search.

Lucene logo

After more than one year, the full-text search library has changed a bit: most notably, Lucene.Net has exited the "incubation" stage and is now an officially featured project of the Apache foundation. That's great news. Unfortunately, the project's homepage hasn't been updated and that caused a bit of confusion on my part. The updated SVN repositories are now here:

https://svn.apache.org/repos/asf/lucene/lucene.net/

and the stable binary packages are way outdated. I suggest you build your Lucene.Net dll from source code.

The NHibernate.Search source code has changed as well and includes several improvements. For instance, the issue I was reporting in my original post has disappeared (I'm not sure if this depends on a fix in the library or in my code, but the deadlock is gone) and the Optimize() method actually performs the optimization of Lucene's index files.

More...

Posted on Wednesday, January 20, 2010
66 Views
0 comments posted

I have been tinkering around my "home brewed" dependency injection library, as I mentioned in my last post. Since most of the code revolves around instantiating objects (well, and keeping them orderly registered), I figured it couldn't hurt to check out which is the best (i.e. fastest) way to dynamically instantiate objects in .NET.

There are essentially two ways you can register objects to my IoC container: using a delegate or using the type. The delegate is a really nice method, also used by Autofac (any comparison between my library and Autofac is probably an insult to Autofac  :)). It works like this:

container.Register(c => new Implementor());

In this case the delegate simply instantiates an instance of a class that implements the IInterface interface. Pretty slick and also very fast: calling the delegate is exactly one method call slower than calling the new operator, so that shouldn't be a problem at all.

Problem is, sometimes you can't register a delegate (for instance when you're registering dynamically loaded plug-ins to the container). In that case you need to manually instantiate the objects: .NET provides a lot of different ways to do that, and some methods can be compiled to dynamic methods or to delegates which probably should improve their performance.

There's a pretty complete blog post by Haibo Luo, but it's 5 years old and might not be accurate (it also misses the methods that use System.Linq.Expressions).

More...

Posted on Monday, January 11, 2010
71 Views
0 comments posted

I have been implementing a simple and easy to use IoC library: I need a simple solution and big frameworks like Spring.net offer way too much stuff (even Autofac is getting huge). My implementation is composed of some basic container, some simple instantiation logic and some stuff to do automatic property injection. Nothing more.

In order to keep a collection of all singleton instances registered in the IoC container, I needed a thread safe dictionary implementation. There are a lot of discussions about how to do it right: the agreed point is that it isn't simple, mainly because you're working at the wrong level of abstraction.

Either you get a lock on each single IDictonary method, that would result in tons of locking with potentially incoherent results between one call and the other. Or you expose a more complex interface, like they did with ASP.NET MVC's RouteTable collection, and leave locking to the user.

I decided to do something in between, using ReaderWriterLockSlim from .NET 3.5 instead of a simple lock{} and writing a fine grained IDictionary implementation while also exposing some high level methods to obtain coherent and really thread safe results.

More...

Posted on Friday, December 18, 2009
Tagged as
269 Views
28 comments posted

I recently updated the source code to my Babil project in order to port it to the new ASP.NET MVC 2 beta. I decided I could as well update all other libraries the project depends on, which have been updated too in the meantime.

This took some time, but if you want to create a new website project based on ASP.NET MVC and NHibernate, here's the latest bits:

  • Get the ASP.NET MVC 2 beta source code from Codeplex and compile it. Remember to also compile the Microsoft.Web.Mvc.dll library that contains some useful code.
  • Get NHibernate 2.1, the latest release of the popular O/RM library.
  • Get the latest MySQL .NET connector (6.1.3) if you use NHibernate against a MySQL database.
  • If you use NHibernate.Search for full text indexing:
  • If you use NHibernate.Validator, get the source code and compile that too against the latest NHibernate DLL.
  • For your dependency injection needs, you might use Autofac. In that case, you also need to download the latest stable Autofac library and the source code of the web integration library. This integration library must be compiled using the beta version of ASP.NET MVC 2.

That's it, now throw everything in the /Bin folder and - crossing fingers - you should be able to finally write some own code.  :)

Posted on Wednesday, December 16, 2009
132 Views
0 comments posted

While working on OnTopReplica I needed a way to constrain the aspect ratio of the "cloned" window. Since the live thumbnails created using the DWM API cannot be manipulated and always maintain the aspect of the original window, it makes sense to limit the user's choices in resizing the window, in order to fit the window to the cloned thumbnail automatically.

Much like in the case of media players, where video files have a certain aspect ratio (let's ignore that this ratio can usually be changed by the user). If the video doesn't fit inside the player window, black bars are added on top and bottom or on the sides. Limiting the user's resizing options in this case actually improves the interface experience because a tedious task is handled directly (like searching the right size of the window to reduce the black bars).

In Windows Forms you have two options to react to resize events of the window: the OnResize event and the couple OnResizeBegin and OnResizeEnd. The problem of those two methods is that they both run after the window has been resized. That is, after the window received the WM_SIZE message (in Win32 terms). You can force the window to adopt a correct size after receiving one of those events.

This would work, if it weren't for the option "Show window contents while resizing" (added a long way back in Windows 98, more or less). That option (which is usually on by default) causes the window to generate a lot of WM_SIZE messages while it is being resized. If you react by changing the size on each event, the result is an extremely jerky window that jumps back and forth while the users tries to resize it. And the contents of the window flicker awfully as a result.

More...

Posted on Sunday, November 08, 2009
Tagged as
162 Views
2 comments posted

In a previous post I outlined the method I used to rip multichannel surround audio from my DVD-A collection. As was pointed out in the comments, the method works but isn't entirely correct.

DVD Audio logo

As I discovered now, DVD-Audio discs usually contain both Video and Audio data. The audio data, which are the advertised high resolution 24 bit surround tracks, are located in the AUDIO_TS folder. For compatibility reasons (I guess), all DVDs also contain a standard VIDEO_TS folder that contains a normal DVD movie with compressed DTS sound. The video data is great if you want to playback the disc on a home theater (and show off your surround system, perhaps) or to access the bonus features.

But to get the full listening experience it is best to use the uncompressed PCM audio data. Here's an illustrated guide on how to rip the tracks.

More...

Posted on Saturday, November 07, 2009
Tagged as
273 Views
1 comments posted

Yesterday I went to the Porcupine Tree concert at the Atlantico in Rome, with Federico and Alessandro.

Atlantico in Rome
The venue: Atlantico in Rome.

More...

Posted on Friday, November 06, 2009
Tagged as
122 Views
0 comments posted
Last.fm logo

I've had an account on Last.fm for more than 3 years and liked it on the spot. I love to explore new music, discover new artists, listen to streaming radio (that is, until it was free) and especially scrobbling the music I listen!

The geek in me simply freaks out seeing the amount of stats you can get from your Last.fm "scrobbled" data: the music I listened the most this week? Last month? What is my favorite Porcupine Tree song? In fact there's also lot of external services that offer awesome visualizations of your data.

This was great up to the day when I decided to put my whole music collection on the Windows Home Server and listen to it via the built in UPnP media sharing in Windows Media Player. That day I discovered that the Windows Media Player plug-in doesn't scrobble songs on network shares! It doesn't work, neither from an SMB shared folder, nor directly through UPnP sharing (which in fact is HTTP streaming).

More...

Posted on Wednesday, November 04, 2009
1218 Views
10 comments posted
Back to Klopfenstein.net
Clemens Klopfenstein Serena Kiefer Lukas Tiberio Klopfenstein Lorenz Cuno Klopfenstein
English German