18 March 2009

Silverlight: the simpliest master pages ever (plus links to subpages)

I gave a presentation about Silverlight today at school. It went great and benefited me as well, as it took me away from all the wedding preparations and made me look at some old code and notes (well, some new too, I'm staying in the Cream's 'Light).

So, two things tonight. First, master pages. You probably have read Jesse Liberty's and Gerard Leblanc's articles - they're great and full of useful information, but I'll try simplifying things as much as possible.

Now, let's say you have your subpages as controls and you want to have a header/footer/sidebar.

  1. Start with a Grid layout, (Grid is the best one in general, more on that maybe someday), fill the right cells with that common header/footer/whatever.
  2. In the biggest cell, the one for subpages, place a ScrollViewer.
  3. Now, tell me, what is a ScrollViewer? A ContentControl. It means it has a Content property. It means it hosts a single control. What control could it be, hum?
  4. theScrollViewer.Content = theSubpage; - that's the whole navigation code!
Ok, now the subpages. I used to think until today that this was impossible, and that it was one of the main reasons using Silverlight for building typical websites wasn't a great idea. But the guys from SilverlightShow proved me wrong with their recent article about Interaction between Silverlight and the Browser:


I won't post any code here, just refer you to that article, my excuses being the lack of time and that the idea is not mine. As for translationg the idea into a working solution, I'm sure you'll do it easily.

Now we just need a way to handle the "back" button and the whole navigation history (thanks to one of today's listeners for bringing that up). However, my Silverlight sites don't go over 10 content pages, so tracking navigation history doesn't really have a point. And hey, it's Silverlight, it's super easy to do!

12 March 2009

Geek plays home, starting with the WC

I'm getting married, moving out, then moving in, all that stuff, and today, shopping on-line for cool home items.

Turns out every room in your home can be cool, and the coolest of all can be the toilet.

The Sudoku toilet paper deserves an honorable mention for making it possible:


The toilet seat can bring a lot of fun to the bathroom as well. Well.. sometimes, "WTF was the designer thinking" is more appropriate than "fun". Let this picture speak for itself (or forever hold its peace):

I guess "Pharaoh's treaures" sounds better than "WC content", doesn't it?


This one just feels wrong, and not in a forbidden fruit kind of way:



However, the best toilet ever was posted today by Gizomodo:


This one definitely takes the art of toilet designing to new heights. Or lows, depending on the point of view.

On my wishlist: *that*

That is definitely on my wishlist:


Can you guess what it is? The answer (and picture credit) is here.

10 March 2009

A projection pro: Fred Eerdekens

In linear algebra and functional analysis, a projection is a linear transformation P from a vector space to itself such that P2 = P, says Wikipedia. Sweet. Can you understand that? (I can, but I study math, so I have to.)

I will show you today someone who definitely can, though he's not a mathematician: Fred Eerdekens. Proof? The pictures below:




Aren't they impressive?

09 March 2009

CD's 30th birthday - let's celebrate!

I just learned from Gizmodo that the Compact Disc celebrated its 30th birthday yesterday.


Happy birthday, then CD! Let's celebrate (I know, it was yesterday, but I had a life yesterday).

Since I'm getting married in April, I'm moving out, and for that occasion, I'm getting rid of as much stuff as possible. Uncluttering by me usually means:

  1. opening a random drawer
  2. looking at the whole bunch of stuff I haven't used for years
  3. finding the reasons why it's okay to throw it away (and beating all the "but it's a gift", "but I might use it",...)
And since I'm not good at doing this one huge organizing day, I declutter piece by piece. Piece of the day: tapes. My old and not really working sound system is not going with me (fiance has a much better one). New sound systems don't read tapes. Besides, tapes have low quality and use storage space and it's way better to re-buy everything as mp3. Or even CDs.

Bottom line, I'm celebrating the CD's birthday by throwing my tapes away. How geek.

05 March 2009

Lego food

What geek doesn't love Legos? Legos are the one and only toy I'm never-ever gonna give away - all my bricks are for my kids. But that's not the point of today's post. I just came across some cool Lego food stuff, and there's enough of it to throw a Lego-themed party. Check it out!

First, Apartment Therapy show us how to make an Anatomically Correct Lego Cake:


Betty Crocker also has great Lego block cakes:


... and Hello Naomi has these fabulous cupcakes:


Joe Reid found some Lego fruit snacks, lucky guy:


However, it's much more fun to make them yourself:


Anything else can be packed in Lego lunch boxes:


Lastly, the dinks! The Lego store used to have a Lego block ice cube tray:

Now, who feels like throwing a Lego-themed party?

28 February 2009

Ocaml: using Big_int, operator overloading and functors for dummies

I'm working on a functional programming project. I have encountered a few difficulties, so I will post here a few things that took me quite a while (and a lot of luck) to find. Especially operator overloading, where Google lead me only to endless discussions about wether it should exist or not and why it doesn't, when it actually does.

I will write a code snippet that will allow us to use integers and Big_ints the exact same way, for instance doubling them using one function named "twice". (In other words, putting two and two together with 4 modules and a functor - can something be more fun?)

First, let's get to the Big_ints:


    1 #load "nums.cma";;


    2 open Big_int;;




So far so good. Now, we'll declare two modules that can add numbers, one for integers, one for the Big_ints, but first, they'll need a signature:

    4 module type Add_sig =


    5   sig


    6     type t;;


    7     val (+): t -> t -> t


    8   end;;




Now, the modules. Notice how cool functional programming is, you can assign functions like other values:

   10 module Int_modl=


   11   struct


   12    type t = int


   13    let (+) = (+);;


   14  end;;


   15 


   16 module BigInt_modl =


   17   struct


   18     type t = big_int


   19     let (+) = add_big_int;;


   20  end;;



The "let (+) = (+)" looks stupid, but is required.

Now we'll write a functor to transform these two modules in two new modules that have a richer functionality (okay, "twice" is not "rich", but that's just an example and I hope you can see the big picture), that we will implement only once, though int and Big_int are two completely different data types and have completely different additions ("+" and "add_big_int") - again, notice how cool functional programming is.

   22 module Add =


   23  functor (Modl : Add_sig) ->


   24   struct


   25     type t = Modl.t


   26     let (+) = Modl.(+)


   27     let twice t = t + t;;


   28   end;;




Nice functor. Let's use it to create the previously mentioned modules and we're almost there:

   30 module Ints = Add(Int_modl);;


   31 module Bigs = Add(BigInt_modl);;




Okay, time to see if that works:

33 Ints.twice 2;;


34 int_of_big_int (Bigs.twice (big_int_of_int 2));;



We have a bit of hassle with creating and printing the Big_ints (thus the longer code), but in the end, we defined one function "twice" that uses the same operator "+" to perform technically completely different operations (with an emphasis on technically - you could use this technique to make "+" mean subtraction or multiplication for the integers and that would be nasty).

Finally, the entire code, ready to copy, paste and... run!

#load "nums.cma";;


open Big_int;;


 


module type Add_sig =


  sig


    type t;;


    val (+): t -> t -> t


  end;;


 


module Int_modl=


  struct


   type t = int


   let (+) = (+);;


 end;;


 


module BigInt_modl =


  struct


    type t = big_int


    let (+) = add_big_int;;


 end;;


 


 module Add =


 functor (Modl : Add_sig) ->


  struct


    type t = Modl.t


    let (+) = Modl.(+)


    let twice t = t + t;;


  end;;


 


module Ints = Add(Int_modl);;


module Bigs = Add(BigInt_modl);;


 


Ints.twice 2;;


int_of_big_int (Bigs.twice (big_int_of_int 2));;


18 February 2009

On my wishlist: "Fashion Geek" by Diana Eng

Diana Eng was a Project Runway contestant (that's means she's a fashion designer) famous (and adored by me) for involving geek/tech/etc. stuff in her creations. She won top honors at Yahoo! Hack day for a thingy that takes pictures as you walk and blogs them, and now she wrote a book with DIY projects! (More info here.)

I just *have* to have it.

16 February 2009

I knew I forgot to blog about something

I knew I forgot to blog about something: I passed the70-536 exam!

I got 841 points and 700 was the passing score, so I was pretty well prepared. And they had good coffee at the center.

What's next? The asp.net one, as I have a bit of experience in that. And then maybe WPF, as it's the closest thing to Silverlight - or is there a Silverlight certificate coming up? I don't know about any so far.

15 February 2009

Geek does chick stuff

I'm getting married soon, my exams are over and I should be writing my funk project. There couldn't be a better day for chick stuff.

I started with a bit of cardio. I had Carmen Electra's Striptease Aerobic vol. 2 lying around for months, so I decided to try it.


Well, it wasn't what I expected. It had no vulgarity (no, no disappointment here), but not much fitness either. The girls were walking around and caressing their tights, but I wished for some more dance, more jumping, more challenge. (Though the clothes were great - if only the crew put as much effort to the choreography as to the styling...) Well, judge for yourself:



So I ended up doing what I usually do for cardio: put Bomfunk MC's CD loud and improvised. And that was great.

Another thing lying around (but only for weeks) was Philips' Satinelle Premium:

In one word: ouch. This was my first try to epilation with that kind of hardware and the pain was a bit hard to bear at first, but I got used to it pretty quickly. (I guess I should have RTFMed and kept the cooling thingy for 4 hours in the freezer and not 20 minutes in the fidge. I'll try that next time.) Plus, the powerfulness of that thing made the whole process a bit fun. Still, my skin doesn't look as smooth and shiny as Carmen's. And I'm not as fit. Go figure.

[Picture credit, credit]