Showing posts with label Fun. Show all posts
Showing posts with label Fun. Show all posts

Sunday, February 14, 2010

Awesome nostalgia trip!

Do you remember the good old Sierra Quest games? Well – I do. I loved those games. Especially police quest I->IV which could run on my dad’s old PC. I’d play them again and again during the late 80’ies / early 90’ies and to this day I hold them responsible for me learning english (although my english teacher in primary school did give it a nice try as well). Of course, Space Quest, Kings Quest and the immortal Leisure Suit Larry were classics I played as well.

Anyway, yesterday sitting in Philadelphia airport waiting for my flight back to civilization (Chicago) made me think: If only someone would port those old abandon-ware classics so I could run them on my iPhone. And guess what – Martin Kool has. And not just to the iPhone – they have been converted to javascript and can run on pretty much any modern browser. And now they even have multiplayer mode.

Check out the great web site here – but be prepared that it will take you hours before you can once again escape from nostalgia land.

Martin: I’m a great fan of your work. Keep it up – can’t wait to see more classics out there.

Sunday, January 4, 2009

Fun with card games

I just published one of my holiday pet projects on Codeplex. It's a very basic framework for building your own card games in .net.

With time, I'll also publish some sample projects, and hopefully even expand the project to include some basic AI logic as well.

Check it out: http://www.codeplex.com/CardGameLib

Even though it's still missing a lot of parts, I've already begun to use it for 2 other pet projects. One is a code competition I plan to put out soon - just looking for price-sponsors now, the other is a web-edition of the classic 500-Rummy card game, a game that I really enjoyed growing up - and still play when I'm vacationing with my family. Card games are an excellent form of entertainment - and remember, there's more than poker and blackjack to life.

Drop me a line - or leave a comment, if you want to contribute to the project, sponsor a price for the upcoming code-competition or just have an opinion to share :-)

Wednesday, October 22, 2008

Flash Rss Reader

Another little flash gadget I just made... An RSS reader. Yes, I know it's an original idea - but it seemed like a good, comprehensible, and to some degree useful thing.

For fun I made iPhone style navigation - in the sense that you need to drag right or left to move between items.
It lists the blog feed from labs.episerver.com.

The trickiest thing was to handle all the security around loading a URL in flash. Flash can only load data from the same domain as it is located on (or another domain that has a crossdomain.xml file in the root, allowing flash access). Anyway, the simple solution was to make a small rss proxy in c# (around 3 lines of code) and put it on my test-domain together with the flash app.





Monday, October 20, 2008

Oh, the power of DHTML

I spend Sunday visiting Copenhagen's Zoological museum with my wife and son. Great museum, even my 14 months old son loved it - all the stuffed animals to look at and pet! Nevertheless, I came across some stuffed lemmings there and quickly found myself floating back memory lane to that wonderfully 90-something game that I used to spend so many hours enjoying.

I figured someone probably had put it online by now - but I hadn't imagine a DHTML+Javascript only version of it. Check it out! Very cool.

Monday, October 8, 2007

Off to Stockholm

After a terrific first week at EPiServer Denmark, I'm off for a 3-day introduction tour to the swedish HQ.
In the first week I accomplished most of what I set out to do: I got my laptop up and running, with a decent dev. environment, almost learned my way around Vista (still don't know if I like it) and got started on a couple of really interesting projects.

I've also started an episerver-based blog on the Research site, r.ep.se - but don't worry, I plan to crosspost a lot so you shouldn't be missing out on anything here.
So far EPiServer seems to be both a great product and a really nice company - I certainly can't complain about the way I've been received so far.

So, now all thats left to do is to look forward to some of the famous swedish cuisine in the next 3 days to come...

Thursday, September 13, 2007

An oldie but a goldie

Just came across this old story that pretty much explains why so many software companies have trouble surviving after moving from pioneers to "real software company".
It's quite a laugh.

Thursday, September 6, 2007

Google Earth Rules!

A couple of days ago I read that Google Earth had introduced a new awesome feature and I hurried to download the latest version.
No, I'm not talking about the wannabe astronomical function where you can browse the sky as well as the earth - thats cute, but no were near as cool as their new "secret" Flight Simulator.

What a great idea to build in a flight-sim in Google earth! It's awesome to cruise around in 10.000 ft in a makebelieve airplane seeing the ground as it really looks.
All we need now to make it even more realistic is some clouds, radio-chatter, more 3d buildings and a bunch of hot stewardesses!

"Ladies & Gentlemen, Captain Allan has turned on the Fasten Seat Belt sign, so please buggle up and turn off any electronic devices"

Tuesday, July 17, 2007

NXT: My first 'bot

As I mentioned earlier I recently got a cool Lego MindStorms NXT to play with.
Now, with the help of Jesper, we managed to build the basic humanoid robot - and it's awesome!

I've coded it to do a few things:
  • Whenever the light is on, Mr. Bot will say "Goodmorning" and start walking.
  • When the light is turned off he'll say "Goodnight" and stop walking
  • When he's 12 cm from an obstacle he'll say "Please" (...move) and stop.
  • When he hears a noise (like somebody clapping their hands) he'll look around to see whats going on
  • If he's hand-button is pushed he'll greet you with the words "Have a nice day".
Of course I also made a simple C# Win Forms application that can remote control him.
My initial idea was to build in some simple learning mechanism (perhaps reinforcement learning) but I havn't gotten around to that yet. So far I'm just blinded by all the possibilities :-)

As handsome as Mr. Bot is now, you better take a good look, cause now he's being taken apart. Jesper suggest a really funny use for the NXT - something that every household needs: So now I'm going to build a machine that can automatically color-sort M&M's - and perhaps send out maydays if Olga comes too close to the candy!

Tuesday, July 10, 2007

Code Challenge: Michael the Math Maniac

Time for another summer code-challenge. Hopefully this one is a bit easier than the last one :-)

Mr. Michael was a lucky man, cause today, 20070710 (ISO standard) was his birthday!
But Michael wasn't your average lucky birthday boy. He was a Math Maniac. And on this special day, he was wondering: How many of the numbers between 0 and 1.000.000.000 contains the ciphers "20070710" (in that order) somewhere within the number?

Design a method int CountNumbers(int min, int max, int SequenceToFind); that returns the count of numbers which contains the SequenceToFind.
1st prize goes to first valid entry, 2nd prize to best performing entry.
The prizes are still "honour & mocking rights".
May the best developer win.

Friday, July 6, 2007

Zattoo is awesome!

Yesterday I came across Zattoo which is a really cool p2p live-tv service. A bit the same concept as Joost, but with zattoo it's not on demand. Instead you get high-quality streaming of live channels..And quite a lot already! It's easy to get started and it work surprisingly well.
I'll definetly remember that I have it installed next time my wife wants to watch "America's next top model" when I wanna watch the news!
Speaking of news and online TV, I've already become a regular viewer of DR Update (sorry, danish only news). Good quality and nice to see news-videos produced specificly to the web. Way to go DR!

Monday, July 2, 2007

Code Challenge: Fun with Hash

No, this is not what you expected, crackhead. This post doesn't include getting high on anything stronger than your coding skills. It's time for another code challenge!

The challenge
Sometimes it can be very handy to make a small fingerprint of a piece of textual information so you can easily compare it to other pieces of text and check if they are identical without doing a full textual comparison.
The friendly folks at Microsoft have even been kind enough to include a "ToHashCode()" method in the .NET framework, but in this challenge I kindly ask you to ignore that.
The challenge is to code your own method that returns an integer hashcode for any string, so that two identical strings will have the same hashcode and that probability of two different strings sharing the same fingerprint is as small as possible.
So, write a method with the signature: static int MakeHash(string s); in C# and post it as a comment here.
Any posts that use ToHashCode(), MD5, or any other build-in hashing mechanism is disqualified along with posts that is almost identical to prior entries.
Post before friday and I'll make comparisons between the submissions on two different parameters:
  • Performance
  • Duplicate Hashcodes for non-identical strings

Good luck, Gentlemen!

Sunday, July 1, 2007

Happy birthday to me!

Today is my birthday. I love birthdays..lots of cake and many presents. The last couple of years (okay...ever since I lost my childhood innocense) the presents have gotten more and more "boring" (= practical and nice but not really play-toys).
Being the eternal kid that I am, I was naturally extremly pleased this year when my wonderful wife (!!!) gave me Mindstorms NXT.
I can't wait to start playing around with it and code C# applications to it.
A quick googling showed that this could be a good place to start!

Thursday, June 28, 2007

Code Challenge: "John the courier"

Yet another brillian idea popped into my mind today: Why not celebrate the rainy summer with a nice indoor competition - a Code Challenge!


Through the next couple of weeks I intend to publish a couple of challenges like the one below.

Think fast, solve the problem and post it as a comment!

The various challenges will have different winning criterias. These could be: "First valid solution posted", "Valid solution with fewest code-lines", "Funniest approach", "Best Performance", etc.

The Winner will win ... well... the honour along with mocking rights over all other coders in the world (at least those who read this blog and who didn't win).

We'll start off with an easy one...



Challenge #1 "John the courier"

In John's little world there is n cities, named by numbers starting at 0. In every city there is a parcel that's supposed to go to another city in John's world.

John live in City no. 0 and starts by picking up a package there. Then, whenever he delivers a package in a city he takes the package from that city and takes it to where it should go.

The distance between the cities is oddly enough the same as the difference in their names (e.g. the distance between city 10 and city 7 is 10-7=3).

John starts off his day with receiving a list of where the parcels in each city should be delivered. Now, John wonders: How far will I have to travel before I get back to my home (City 0).

Suggest a method that takes an int-array where the city is the index and the value is the destination of the package in the city (like this: int CalculateDistanceToHome(int[] CityPackages);) that returns the distance John must travel before he gets home. You can assume that the packages are distributed in such a way that John will always eventually get home.
First valid solution posted is the winner. Bonus points for recursive solutions.
Let the games begin!

Friday, June 8, 2007

ShotCode - Let's reinvent barcodes!


About a year and a half ago I was amazed at some of the new java applications for cameraphones I saw at the NeXT conference, among others were a reinvention of barcodes where the idea was that if a special 2d barcode was put on a poster, everybody with a cameraphone could scan it and get someinformation contained in the barcode, typically an ID number which an online service could translate to a URL or something else meaningful.
Of course I hurried home, downloaded the software and tried, but it almost never worked as it should so I gave up.

Today I found another similar service that actually seems to work quite well. And on top of storing your urls in a smart looking circular barcode they even offer to convert the webpage to a format more suitable for the phone that requests it (admitted, that specific part of their service doesn't seem to work too well, but anyway).

I saw the service in use at getjar.com - my favourity source for java apps for my nokia 6380 and there it worked quite impressive...Just start the shotcode application on the phone, take a picture of the barcode on the screen and begin downloading the java-application. Then I checked out Shotcode.com and after a quick registration I found it quite easy to create my own shotcodes....Now I suppose I'll just sit back and wait until this becomes an industry standard so everybody has it on their phones!

Sunday, June 3, 2007

The Meaning of Life

If I were a religious man I might believe that there's one truth in this world, known only to God (and perhaps Knuth also figured it out, but I digress).
If there really was such a one single truth, it should be possible (although perhaps not economical) to let a computer figure out what it is.
Someone once said that if you fill a room with monkey's and typewriters and give it enough time (and bananas!), eventually they will have written the collected works of shakespeare - I suppose this is the idea behind any brute force algorithm (although some might argue that given enough time the monkeys will have evolved into Shakespeare, but again I digress).
But it must be possible to speed up such a process....What if I custom-built the typewriters so they could only write real words that shakespeare used? And what if I had the almighty inspire the monkeys to which words should come in sequence? Perhaps I could shorten down the production time of my shakespeare - or the meaning of life...
So, eager to learn the true meaning of life (okay, who said "42" ?? shut up!) I devised the following plan:

  1. Gather a collection of quotes from some of the most clever men I can think of (e.g. Einstein, Decartes, Voltaire, Vonnegut & Twain).
  2. Calculate a Markov Chain over the bigrams in their sentences
  3. Fill in Divine interaction (in the shape of a random generator)
  4. Start to generate the meaning of life as random quotes

Now, the only problem I face is to determine when my generator actually comes across the meaning of life.... Good proposals can be posted here!



My "Meaning of Life" Random Quote Generator.

If you want to have a "quote of the day" on your website, feel free to use this javascript:

<SCRIPT TYPE="text/javascript"
SRC="http://www.mizar.dk/QuoteGenerator/Javascript.aspx">
</
SCRIPT>

Wednesday, May 16, 2007

Playing around with Embedded Objects in IE

Yesterday I felt like playing around a bit with embedded objects in IE - you know, showing Windows Forms in a browser. An old .NET trick that I've used a couple of times.

For some reason it has never quite become the market standard it was supposed to (probably because it's ugly, inefficient and very browser specific) - but it would have been nice with a good alternative to java applets!

I made a quick adaptation of the SudokuSolver from my previus post to see how it would work as an embedded object. This is what I did:
  1. Made a Windows Forms Library project
  2. Made a Windows Forms User Control
  3. Moved the UI from the Sudoku application to the new User Control (as well as the Code Behind)
  4. Compiled and put on a web-server
  5. Made a HTML Page that includes it as an embedded object, and put the page on the same webserver (this is important)
This is the HTML I used, notice how you provide it with the URL to the Windows Forms DLL, and then the full path (including namespace) to the control to display:


<object id="SudokuControl" height="240" width="206"
classid="http://www.thraen.dk/Download/SudokuWinLib.dll#SudokuWinLib.Sudoku">
</object>


If you are watching this blog in IE, and you have .NET 2.0 installed, and your security settings is just right, there is a chance that you might actually see the Sudoku Solver here:


Sunday, January 28, 2007

Zip Online

I was just briefly playing around (again) with ICsharpCode's SharpZipLib and I made this little tool that I figured might come in handy some day.

It's an online zip opener. It's handy in the cases when you are asked to download a zip file, but you really don't feel like filling up your desktop with yet another zip when all you need is a single file for the content. Or perhaps for the cases where you'd like to link directly to a file within a zip. Or for when you want to index a zip file (as always I think in search) :-)

It's basically a web app, that takes two parameters: "zip" with a url to the zip file you want to examine and "file" for the file name/path within that zipfile that you want to extract.
In case you only give the "zip" parameter it will list the content of the zip file.

The most important method is this (and yes, I realize the code isn't pretty - it's just a simple poc):



protected void LoadZip(string url, string file)
{
Error.Text = "";
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
if (resp.ContentType == "application/x-zip-compressed")
{
if (resp.ContentLength < 2000000)
{
BinaryReader br = new BinaryReader(resp.GetResponseStream());
byte[] buf = br.ReadBytes((int)resp.ContentLength);
br.Close();

System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);
ZipFile zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(ms);

if (file != null)
{
ZipEntry ze = zf.GetEntry(file);
Stream filestream = zf.GetInputStream(ze);
BinaryReader br2 = new BinaryReader(filestream);
byte[] newbuf = br2.ReadBytes((int)ze.Size);
br2.Close();
Response.ClearContent();
Response.ContentType = MimeType(file);
BinaryWriter bw2 = new BinaryWriter(Response.OutputStream);
bw2.Write(newbuf);
bw2.Close();
Response.End();

}
else
{
GridView1.DataSource = zf;
GridView1.DataBind();
}
zf.Close();
}
else
{
Error.Text = "Zip file too big";
resp.Close();
}
}
else
{
Error.Text = "Wrong content type: " + resp.ContentType;
resp.Close();
}
}

A couple of parts was a bit tricky. First the part that loads the external zip into a memorystream for easy access by the sharpziplib. It turns out that the BinaryReader was quite necessary in order to load it without corrupting the data. Also determining which mimetype a given document in the zip file is, before sending it out wasn't all that easy, but in the end I found a solution online. This solution looks up mimetypes in the registry so it does require registry access for the aspnet user - that can potentially be a problem.
There's several known problems with this implementation, but I'll leave it to you guys to figure them out :-)

Download the code here.
Try it here (note that my "playground" server where this is on might be closed down pretty soon - enjoy while you can).

What to watch.......KISS EPG

For the last year and a half I've been the proud owner of the ultra-cool (nevermind the bugs) KISS DP-558 harddisk recorder.
The really cool thing about the dp-558 is it's ability to go online and retrieve program guides, so you easily can see what's on the telly, and ask it to record it. It's even possible to schedule it to always record your favourite show every time it's on. If you download 3rd party software for the kiss it's also possible to use it as a webserver/ftp-server and much much more. All in all a cool product in spite of it's flaws.
But after KISS technology got aquired by Linksys it has really been going downhill. Recently they changed the provider of the Electronic Program Guide (EPG) to a service called TVTV. This new implementation is so filled with bugs and problems that I'm surprised it passed through their QA dept.

Check out this part of today's program guide for instance. I do admit that typically the DR2 channes has a lot of reruns....but comon 5 reruns of the same movie at the same time?! Well..not to worry. If I get frustrated watching all 5 movies at the same time, I can always switch to KAN4 or TV3 that apperantly doesn't broadcast today after all...Oh how I look forward to the tranquility of a black screen :-)

Saturday, January 27, 2007

Clever minds think alike

Just as I was checking the google rank on my posts about the upcoming Poker challenge, I found this article on codeproject. Isn't it typical that whenever you get a great idea somebody else has already gotten the exact same idea and implemented it?
In fact even the implementation of code is somewhat similar to what I've already coded.
Well - this just goes to show that clever minds do think alike :-)

And of course this doesn't make me change my plans - I'll keep going with this little poker challenge - I'm sure I can put a new twist to it!