Samstag, 25. Dezember 2010

Collection was modified exception

I saw some pretty strange solutions for this problem, most of all, ones which involve a "helper" list to store the items to remove... this of course is overkill (memory and cpu wise - think of collections with a million items ...)

Here's how to do it:
for (int i = pageList.Count; i-- > 0; )
{
    if (itemsToRemoveList.Contains(mainList[i]))
        mainList.RemoveAt(i);
}

Sonntag, 19. Dezember 2010

Antonia Jane Chords

Hello Everybody :-)

Maybe you know the canadian Rock-Band Lightning Dust... If not, I guess you've seen the great video on youtube where brian fallon of The Gaslight Anthem performs this song. If you don't know who Lightning Dust is, check them out and if you like it - also give Balck Mountain a try (Lightning Dust - Amber Webber and Joshua Wells - are both core members of this GREAT band).

Oukey, here are the chords (and I really, really hope there's not gonna be any whining about copyright shit. Music is art, art is culture and culture belongs to the society).

Support the artist: Go to the shows, buy your CD's there (and from Indie Labels).

Intro: Play around D

D
Did you ever come close to home?

Bm
Riding the tide of the silver line,

D
Maybe dress them up in ribbon and golds,

Bm
Never fall back into the one you love,

D
Pick pocket lady with her mind on you,

Bm
She'll break a million hearts until she makes it through,

    G            D       A
But I declare a war on you,

        D    A
Someday soon

D
Hiding with the border skies,

Bm
Lead down ditches on the side of the road,

D
Be careful you don't look to the sun,

Bm
Lazy head lions you'll get fed to the wolves,

D
So rally up the soldiers there's a war to win,

Bm
If hearts can't be alarmed I can't let em win,

    G                D        A
But I would give it all for you,

        D    A
Someday soon

        D    G
Someday soon

        D    A
Someday soon

D
Bury all the silver and gold, 

Bm
We can walk to the top and look down at it all,

D
What happens when the feelings gone?

Bm
It's a love angel with the wings cut off,

D
So the parents tell the children 'That's no way to live'

Bm
So we capture what we're after left of the rest of them,

  G                  D       A
Antonia Jane will rise again

Edit:
Give them a watch on youtube, they seem to be quite a fun bunch :-)

Sonntag, 5. Dezember 2010

Public Signage

Here are some pictures of public signage (since they're taken in switzerland, they're either german or french).


Samstag, 4. Dezember 2010

Winter's Heart

Hey everyone, well if your not as lucky as everyone on the southern hemisphere, you're stuck in winter right now. Here are some pictures (go one and use them as wallpaper or whatever ...) of this icy menace.

Uuuuultra high-res download:




Smaller 'previews'











Wallpaper Saturday

And here are some (well, there are exactly six) wallpapers (photos I took last summer). I hope you like them.

It's Mikee hanging out.

An ear of corn (at least I hope it's really called an "ear").

A flower. Yay.

 Another flower, with a drop of water on it.

I have no idea what those are called (in english).

 Aaand another flower (a rose this time).

Donnerstag, 25. November 2010

If programming languages were music albums - Part 1

Hey all you programming music fans out there. Yes, we (that is, programmers) are rockstars trapped in offices. I like to play the guitar or the piano while thinking on problems such as how to make that damn piece of code faster, better or obsolete. Later on, while writing the code, I really need to listen to some music. Now, what if my favourite albums were programming (or scripting) langauges? So here we go...

PHP
Ok, this one was really hard, since i have to choose an album I actually like, which I can't say about PHP. Well PHP got better over the time (Version 5 and up) but not like wine does. It kinda got less bad. While PHP may be ok to use for small projects hosted on a cheap (standard apache) server like personal websites or blogs, it should NEVER EVER be used for anything bigger. Code maintainability is a bitch. If you know what a binary tree is, I think you'd prefere an abacus over PHP.

So, which album does fit?

It's Stoner Witch by (the) Melvins. It was released in 1994. And like PHP you look at it and think, what the fuck. It's strange, doesn't seem to fit - there's grunge, metal and stoner rock and a dog.

I grabbed this album a few years back and didn't like it. But after some time it, like PHP, got less bad.

But as I said, my dislike of this language can't be described (productive) by any album I own.

Maybe some electro album would serve better. Fast, not deep and boring after two weeks. If someone has a better idea, just give it a comment.



C / C++
I really don't have to talk about those. They're here. They always have and always will, at least until quantum computing or what ever there will come and make those good old electrical transistors go away. Motörhead!

Mötrhead? Ace Of Spades! Yes, say what you want, it's the best album of Motörhead there is, was and ever will be. Just like C / C++, its hard, brute force and ugly. Not really ugly as in Visual Basic ugly. Since C / C++ is to Motörhead as Visual Basic is to a 59 year old, crack whore.

But it's so basic without bells and whistles, it's one step above assembler so you can dug your hands in and get dirty (well you could do this too with Visual Basic, but just not in a good way).

The same is Ace Of Spades, its beautiful trash, it's - I don't know - Tank Girl, beer in the morning and drunk sex.


Javascript
It will die with human civilization as we know it. Period. Javascript is woven into the Internet like veins thorugh a body. While any language which is bound to a technology you can actually grab or replace like microchips and harddrives, Javascript is the Internet. The Internet will live forever and so will Javascript.

London Calling by The Clash. Just as Javascript will stay and not go (hope you get the hint) so will this album. Charismatic, simple yet deep, emotional and easy.

Joe Strummer will live forever.

Stay tuned for part 2.

Montag, 19. Juli 2010

C# selective clone with a generic extension method

Hey guys, ever had to clone an object - but only duplicate the properties you actually needed. Or maybe you don't want to copy the id property... Something like that, well then take a look at this.

public static class ObjectExtensions
{
 public static T SelectiveClone(this Object obj, string[] properties)
  where T: new()
 {
  T temp = new T();
  PropertyInfo[] propertyInfos = typeof(T).GetProperties();
  foreach (PropertyInfo pi in propertyInfos)
  {
   if(properties.Contains(pi.Name))
    pi.SetValue(temp, pi.GetValue(obj, null), null);
  }

  return temp;
 }
}

Well you can then do something like the following.
/* 
 Product is a class with the properties
 "title", "titleAlias", "subTitle", "description", 
 "price", "stock" and "id"
 "original" is an existing object of the class Product
*/

// The following copies all properties except "id"
Product product = original.SelectiveClone(new string[] {
 "title", "titleAlias", "subTitle", "description", "price", "stock"
});

Socialize!