Archiv der Kategorie ‘Information Technology‘
StarCraft Bot in F#
Sonntag, den 21. März 2010Shure you remember the game StarCraft! I know the game is really old but still played in the community. Ever wondered how to write a StarCraft bot (especially in F#)? Go check out this link:
Stop the internet printers
Montag, den 4. Mai 2009I found this really cool website:
http://www.politiker-stopp.de/
The idea behind this page is to protest against politicians which are making new laws without understand the ways and meanings of the internet. The site claims that politicians often don’t know how to use computers so their only seeing websites as imprints of their employees. Therefore the site suggests to introduce the following CSS code into your site:
<style>
#print {display:none;} @media print {
a,abbr,acronym,address,applet,area,b,base,basefont,
bdo,big,blockquote,br,button,caption,center,cite,code,
col,colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,
form,frame,frameset,h1,h2,h3,h4,h5,h6,hr,i,iframe,img,
input,ins,isindex,kbd,label,legend,li,link,map,menu,meta,
noframes,noscript,object,ol,optgroup,option,p,param,pre,
q,s,samp,select,small,span,strike,strong,sub,sup,table,
tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var {display:none;}
#print,#print img {
left:0;top:0;padding:0;margin:0;height:250mm;width:170mm;display:block !important;}
}
</style><div id="print">
<img src="http://www.politiker-stopp.de/gfx/politiker-stopp-print.png" />
</div>
This is a really cool idea although completly useless
Have fun by protecting your sites.
Part II: Mimic SynchronizationContext behaviour on .NET CF
Sonntag, den 15. Februar 2009I just posted the second part of the article Part I: Mimic SynchronizationContext behaviour on .NET CF on planetgeek.ch! On the article I try to show how the basic behavior of the SynchronizationContext can be achieved on the .NET compact framework platform. Please refer to the article under:
http://www.planetgeek.ch/2009/02/15/part-ii-mimic-synchronizationcontext-behaviour-on-net-cf/
LaCie LaCinema Black Max
Dienstag, den 10. Februar 2009I must admit that I’m not an owner of the LaCie LaCinema Black Max but I’m a proud owner of the popcorn hour A110. The popcorn hour A110 is a small media box which plays almost every video and audio format on the market. The media box includes portal services for youtube, google video, shoutcast and many more platforms. Although I’m very pleased with this box I want to present to you the latest news about LaCie LaCinema Black Max.
The LaCinema Black Max is shipped with the video codecs for MPEG-1, MPEG-2, MPEG-4, DIVX, XVID, H.264, MKV and WMV9 HD and is able to play video material up to 1.920 x 1.080p. VOB- or IFO structures without protection can be played directly on the media box without converting. The LaCinema Black Max is also able to upscale videos with less resolution up to 1080i.
The most exciting feature of the LaCinema is the integrated DVB-T module. The DVB-T module contains an integrated program guide which allows to use the black max as a video recorder with time shifting.
LaCinema supports the following audio codecs: MP3, WMA, AAC, OGG, AC3, MP4 and WAV. Pictures in the format JPEG, PNG, GIF, BMP and TIF can be directly viewed on the screen via the integrated photo viewer.
Unfortunately the integrated DVB-T module makes the LaCinema quite an expensive product. The current list prices for the LaCinema with 500 GB hard disk are about 650 swiss francs. This makes the LaCinema about 200 swiss francs more expensive than the popcorn hour A110 with integrated samsung F1 hard disk with 1 TB disk space.
But for those who want an all-in-one player and recorder which supports the latest and greatest high definition codecs the LaCinema Black Max is a “must buy”!
Here are some pictures (copyright by Lacie):
planetgeek.ch to the rescue
Montag, den 9. Februar 2009As some of you may already have noticed some of my blog entries are now cross-posted on tracelight.ch and planetgeek.ch. A few weeks ago we decided to start a new blog project called planetgeek.ch. The goal of this blog is to provide geeky information to all ICT interested people. The language of the blog is English. We hope that we can provide some valuable and interesting information to you guys (both male and female!) out there in the world.
Please have a look and join us on planetgeek.ch! I can especially recommend the page “Ask a geek”!
Part I: Mimic SynchronizationContext behaviour on .NET CF
Sonntag, den 8. Februar 2009Before I got into the details of the problem I want to briefly describe what the SynchronizationContext class really does and what it’s main purpose really is in the first part of the article. From that perspective I’m going to show how the basic functionality of the SynchronizationContext class can be implemented for the .NET compact framework in the second part of the article..
The msdn library documentation states:
Provides the basic functionality for propagating a synchronization context in various synchronization models.
I must admit the first time when I read this definition I didn’t really get the key point behind the SynchronizationContext class. Detailed look into the implementation of SynchronizationContext and its base classes provided me the following information:
The SynchronizationContext class is a class belonging to the System.Threading namespace. The SynchronizationContext provides a model to make the communication between threads easier and more robust especially if multiple threading contexts/apartments such as “UI threading context” etc. are present.
To get a deeper understanding of the definition above I want to give you a short example. Imagine if you have a separate thread performing an intense calculation such as calculating the n-th Fibonacci number. When the separate thread has finished its long running operation you want to display the n-th Fibonacci number on a user interface. Normally (without using the SynchronizationContext class) you would need to do the following (or at least something similar):
private delegate void FibonacciResultDelegate(long fibonacciResult); private void MethodCalledByTheFibonacciThread(long fibonacciNumber) { if( fibonacciResultTextBox.InvokeRequired) { FibonacciResultDelegate fibonacciDelegate = MethodCalledByTheFibonacciThread; fibonacciDelegate.Invoke(this, new object[] { fibonacciNumber }); return; } fibonacciResultTextBox.Text = fibonacciNumber.ToString(); }
With the SynchronizationContext class we can invoke delegates in the context of a different thread. For the example above we could do the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | public class FibonacciPresenter { private readonly Thread workerThread; private readonly SynchronizationContext context; private readonly IFibonacciView fibonacciView; public FibonacciWorker(IFibonacciView view) { fibonacciView = view; context = SynchronizationContext.Current; workerThread = new Thread(new ThreadStart(FibonacciCalc)); workerThread.Start(); } private void FibonacciCalc() { long result = CalculateFibonacciNumber( ... ); context.Post(new SendOrPostCallback(delegate(object state) { fibonacciView.DisplayResult(result); }), null); } // details omitted... } |
In code line 13 we can see how the SynchronizationContext is retrieved. The SynchronizationContex.Current property points to the SynchronizationContext of the thread where the FibonacciWorker was created (in my example the FibonacciWorker would be created in a control). Then the FibonacciCalc method can post (asynchronous) or send (synchronous) a SendOrPostCallback delegate containing the “job” which needs to be marshaled over the SynchronizationContext. Therefore the line fibonacciView.DisplayResult(result) would be invoked on the UI thread which allows us to remove the “invoke required” code parts and directly set the fibonacci calculation result to the textbox text property.
We can briefly summarize that the purpose of the SynchronizationContext is to post (asynchronous) or send (synchronous) SendOrPostCallback delegates in the correct threading context which simplifies marshaling.
Windows Mobile 6.5 information leaked
Samstag, den 24. Januar 2009We don’t have to wait for the official announcements of Windows Mobile 6.5 to get the latest news about the mobile operating system. Yesterday a beta version of Windows Mobile 6.5 hast been leaked to the public which everyone can install on his qtek 9090.
Let me describe what is new in Windows Mobile 6.5 in counterpart to the Windows Mobile 6.1:
- No finger friendly user interface
- No multi touch
- Internet Explorer Mobile 6 with flash support
- Sliding Panels
- Scroll without scrollbars
- New screen lock
- New applications such as market player, my phone
You can have a quick look at Windows Mobile 6.5 in the following two videos:
As you can see Windows Mobile 6.5 is a major disappointment. Hopefully Windows Mobile 7 will knock us out of the chair!
Rumors about Windows Mobile 6.5
Mittwoch, den 21. Januar 2009There are rumors going around on the internet about the release of windows mobile 6.5. Some say that windows mobile 6.5 is never going to be released but other strongly believe that the new windows mobile 6.5 will be released soon.
Not long ago people were blogging on the internet that Microsoft is probably going to focus on windows 7 and it’s integration into the newest mobile devices. But that has not been approved by Microsoft.
And today some screenshots about windows mobile 6.5 came up out of never on the following blog:
http://wmpoweruser.com/?p=2536
Nobody can approve if these screenshots are real or just another horrible fake. We are staying put and watching the latest news on this topic. We’ll keep you guys posted!
Delegate.DynamicInvoke for .NET Compact Framework
Sonntag, den 18. Januar 2009As you might already know I’m a certified windows mobile application developer. My speciality is hybrid application development for applications which target both the full .NET framework platform and also the mobile platform. Of course nobody wants to write the same code for each platform again so you have to come up with some tricks and solutions to overcome some limitations on the compact framework.
One such limitation is the missing Delegate.DynamicInvoke method. The Delegate.DynamicInvoke method allows to dynamically invoke delegates late-bound. That means normally when you are invoking a method via a delegate you actually need to have knowledge about the target type where the delegate gets executed. With Delegate.DynamicInvoke this is not longer necessary. The beauty of this is, that you can have base code like the following:
// Elsewhere RegisterDelegate(SomeClass.SomeMethod); RegisterDelegate(SomeOtherClass.SomeOtherMethod); FireForAllWith(1, 2, 3, 4); // Code in some utility public void FireForAllWith(params object[] args) { someGenericCollection.ForEach(dlg => dlg.DynamicInvoke(args)); } public void RegisterDelegate(Delegate dlg) { someGenericCollection.Add(dlg); }
But if you try to use Delegate.DynamicInvoke in the compact framework your infrastructure code will not compile because for some obscure reasons microsoft decided not to implement Delegate.DynamicInvoke for .NET compact framework. Here is my solution to this problem:
I created an extension method for the delegate class with the name DynamicInvoke. This extension method uses a small trick to implement the DynamicInvoke behaviour of the full framework platform.
public static class DelegateExtensions { public static object DynamicInvoke(this Delegate dlg, params object[] args) { return dlg.Method.Invoke(dlg.Target, BindingFlags.Default, null, args, null); } }
As you can see I’m using the delegates method property which returns a MethodInfo object. On the MethodInfo I’m able to call Invoke and pass the arguments to the bound method. But the problem here is that Invoke requires a target where the method gets executed. This is where the delegates target property comes into play. That’s the whole magic and you’re able to dynamically invoke late bound methods via Delegate.DynamicInvoke.
Download DelegateExtensions for the source code.
