Skip navigation

Monthly Archives: January 2009

I knew it

You know what’s annoying? Powerful API’s like .NET.

You know what’s even more annoying? When MSDN SUCKS~!!!!!

Formatting numbers in C#

Holy crap. I’ve had to rail on this again and again and every time I do.. I ask myself WTF is MSFT doing? I mean, they want people to use their API’s. Why don’t they get a crack team to document this stuff?

HOW IS this acceptable??? Don’t they have a QA team? I mean yes there’s a lot to document, but there’s also a lot of code to write to get the thing to work. If you’re going to get one thing right, you may as well get the other, otherwise all your effort probably is wasted because the vast majority of people (average developer I suppose, from what I see on these usenet and discussion board posts) won’t be able to use these nifty/neato functions that you’ve worked in here and they’ll be stuck creating crummy workarounds because no one uses these functions so nobody knows about them unless they really look..

    int x = 5;
    double y = 5;
    int z = 9492;
    string a = String.Format( "{0:00} {1:00} {2:00000}", x,y,z );
    Console.WriteLine( a );

    // outputs: 05 05 09492
    // 0:00 says:  The first 0 is which arg to match up with (in this case, x)
    // the :00 after that first 0 says "it must be 2 digits long, and if its not, pad it
    // with extra 0's.

msdn’s docs really blow.


I didn’t think it’d be any good, but I’m presently trying to use an XBOX 360 controller instead of a mouse

Its kind of good. Not THAT good. I guess its analogous to using that old time BALL that sat on the tip of some cone shaped “mouse” thing. Like, it was an inverted mouse with the trackball exposed and you rolled the trackball with yoru fingers to control the mouse.

This is like that in that its not as EASY to do fine control as with the mouse. The mouse uses your whole hand to control, this just the thumb, so you loose a good bit of dexterity naturally.

Configuring both the left and right joypads to control the mouse is a bit neat/weird. Its like connecting 2 mouses at the same time. YOu get a bit of extra control, but you seldom need it unless you’re playing a game with it. T hen you might as well just use a mouse, right?

Anyway, pretty cool.

Write to debug stream

System.Diagnostics.Debug.Write(“text”) ;


excellent article here. Also regarding the question code works without [Flags], so what’s the point of [Flags]?

Repeated here:

Flags indicates that the enum is intended to be used as a set of bit fields. The ony practical difference it makes is in the implementation of ToString on the enum. without the attribute it simply prints out teh symbolic equivelent of the value or the value uf there is no equiveleint. With teh attribute if it can’t find the exact match it tries to oassembly the value from the bitwise orable fields and if successful prints out teh list of fields comma separated.

Richard Blewett – DevelopMentor

C# gotchas

You are not allowed to remove something from a List if you’re iterating through that list using a foreach loop.

    List list = new List( new int[] { 3, 6, -9, 12, 15 } );

    foreach( int val in list )
      if( val < 0 )
        list.Remove( val ) ;  // ILLEGAL:  RUN-TIME ERROR!

Instead, you must be iterating using a vanilla for-loop. Keep in mind that this reduces the Count of your list when you do this

    List list = new List( new int[] { 3, 6, -9, 12, 15 } );

    for( int i = 0; i < list.Count; i++ )
      int val = list[ i ] ;
      if( val < 0 )
        list.RemoveAt( i );  // OK for List

You are not allowed to write directly to (i.e. overwrite) “foreach iteration variables”.

So for instance:

    foreach( int val in list )
      val = 0;  // ILLEGAL, can't overwrite value of a "foreach iteration variable"

However, this doesn’t mean that val is readonly. If val is an OBJECT with references to other things, e.g.:

  class Point
    public int x, y;
    public override string ToString()
      return "( " + x + ", " + y + " )" ;

  List points = new List( new Point[]{ new Point(), new Point(), new Point() } ) ;
  Console.WriteLine( points.Count );

  foreach( Point p in points )
    p.x = 5 ;  // Works fine, since we are not overwriting
    // p itself, but writing to something that p refers to

keyword yield

This is one of those things where you’re like “oh.. cool.. ah, but I can’t really use that..”

A couple of links that explain yield pretty well: The yield statement in C#,
Behind the scenes of the C# yield keyword
, Give way to the YIELD keyword!.

I don’t like keyword yield. Its not that useful to me, and I find the very idea a lot like using a static variable in C++. You know about it, and you hardly ever use it unless you’re like WOW, I COULD use one here. I’ve only really usefully used a static variable in C++ about once or twice to my recollection.

[ May 15/09 ]: These may be useful yet. There’s an article in GameDeveloper May 2009, page 15 that talks about using coroutines in C++. Also, Using Coroutines for Asynchronous Programming.

Two types of Arrays

This is a weird one. In C#, you can create two types of 2D arrays: the “normal” kind that you are probably used to new string[2][2] is a 2×2 array of strings. And the MUST BE SQUARE kind: new string[2,2]. The comma separated arrays are weird in more ways than one as I’ll show here.

    int[] normal1D = { 2, 5, 7 };   // probably already know this

    int[][] jagged2D = { new int[] { 5, 2, 9 }, new int[] { 7, 5 } };
    // 0:  5 2 9
    // 1:  7 5

    int[ , ] square2D_1 = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
    // 0:  1 0 0
    // 1:  0 1 0
    // 2:  0 0 1

    // So this last array type with the int[,] type specifier
    // is actually a SQUARE 2D array.  It HAS to be square.

    // For example, this next array is illegal:
    //int[ , ] square2D_wrong = { { 1, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; // X!!!!!!
    // You can't have a JAGGED array when you use [,] syntax.

    // You could also write the above array like:
    int[ , ] square2D_2 = new int[ , ] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };

    // Or even:
    int[ , ] square2D_3 = new int[ 3, 3 ] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };

    // Ok so how else do the [ , ] square type arrays differ from "normal"
    // 2d arrays?  Well, their length property measures the length of the
    // ENTIRE array!  Talk about weird.

    Console.WriteLine( square2D_3.Length ) ; // PRINTS 9 !  (not 3!)
    Console.WriteLine( square2D_3[ 0 ] ) ;   // X ILLEGAL!!

    // You can't seem to access an "individual" array that makes up
    // this 2D array.  In general then, the [,] arrays are somewhat
    // more restrictive than "normal" 2D arrays which is probably why
    // they aren't seen in common use.  However, you COULD find
    // a use for them like as a z-buffer or something.

Eval in C#

Not easy to get .. a few hacks..

i just found this vintage girly mags thing. This is awesome!

just a note:

  /* a sortable element */
  border: solid 1px #aaa;
  font-weight: bold;
  height: 2.2em;
  text-align: center ;
  width: 8em;
  background: 0% 50% no-repeat; 

  background-color: #000000;
  color: #ffffff;
  border: solid 1px #ffaaff;

trips up when I

// using jquery
$('#SomeTextarea').addClass( 'pivot' ) ;
// where SomeTextarea already has class="sortingElement"

but works if you change the textarea part in front of the css class def

.sortingElement /* removed textarea from in front,
even though this is being applied to a textarea, it seems
to trip up jquery. */
  /* a sortable element */
  border: solid 1px #aaa;
  font-weight: bold;
  height: 2.2em;
  text-align: center ;
  width: 8em;
  background: 0% 50% no-repeat; 


a while ago i got the friends boxed set.

it was around the time the show ended and it was all reruns on tv.

so i decided to get the boxed set and watch them all.

here are my notes on my favs

1-05: The East German Laundry Detergent
– ross runs into the open washer door

1-18: All The Poker
– generally a good one

1-24: Where Rachel Finds out
– a good one

2-03: TOW Heckles Dies
– this one is funny – can’t remember why
– one on the intro screen w/ stamping the floor

– the one where the monkey is in the movie –

the one where dr. romorea dies b/c of the water splashing

2-23: TOW the chicken pox
– this is the one where Joey gets a job at Chandler’s office. very funny.

3-1: TOW princess leia
– “I said share, not scare!”

4-??: TOW where ross plays his piano

4-11: tow joey gets a job at the museum

4-13: TOW rachel’s crush
– driver’s licenses at the end

4-14: TOW joey stinks and chandler is getting over kathy

4-19: “morning’s here” and ross says he will marry emily (british girl). this one is funny.

the whoopah one is funny

4-23: ross’s wedding (parts 1 & 2)
– part 2 has “I could kill you with my thumb”

5:05: where joey finds out
– “rules help control the fun”

5:12: the one with chandler’s fake laugh

5-14: the one where everyone finds out
5-15: the one with the girl who hits joey
– chandler asks monica to marry him

5-16: the one with the cop
– is the one with the couch moving

6-04: where ross is going to give a lecture, practices

6-06: where rachel moves out

6-07: “running from satan”

// the middle of the season here kind of drags…

then from 6-14 on, its really good

6-14: The one where chandler can’t cry

6-16: The One Where It Could Have Been

6-17: The One With Unagi
– this is very funny

7-14: The One where they all turn 30
– joey says “why God why”

7-15 – shows flat out refusal is funny
– not a fav

7-16: The one with the truth about London
– has Joey’s giving and sharing speech
– has the ross doll at the end.. very funny

8-3: The one where rachel tells ross
– this has chandler’s airport bomb scene at the end

8-4: The one with the video tape
– europe story
– “it was like flying with the riddler”
– “was that another joke?”
– “was that another question?”

8-13: The one where Ross takes a step forward
– “oh what the.. B+”

8-22-8-23: both really use the whole 180 degree shift in attitude for comic effect

// in the eps after brad pitt appears, Rachel is REALLY on the spot/bang on
// with her acting and exhibited interpersonal skills/witty cleverness

9-2: The one where Emma cries is kind of funny.. it has
the acting is a bit off.. this is the first of a new season
ross breaks his thumb on a punch

9-16: in the latter half of season 9, chandler’s really coming out as a funny character

9-17: the one with the memorial service

9-19: is some well done acting by joey – at the end with rachel
TOW All The Resiloustions
TOW Princess Consuela
TO In Vegas
TOW No One Proposes
TO After Ross Says Rachel
TOW No Ones Ready

Some dude says about Warcraft 3:

“…it feels like 100 pots boiling at the same time.”

Bang on! I think THAT is what makes it fun. Once you learn to control those 100 pots. Keeps boredom FAR at bay.

A boring game is exactly the opposite. Nearly nothing to do except watch..

Well, sometimes it doesn’t work as you’d like:

html like:

<div style=”overflow: scroll”>
i want this text to force a horizontal scrollbar if it overflows at the right yeaaaaaaaaaaaaaaaaaaaaah

On firefox at least, it doesn’t give a nice horizontal scrolly.

To force it, surround the <div> in a <pre> tag.

<pre style=”font-family: arial”> <– you aren’t forced to use monospace just because in pre –>
<div style=”overflow: scroll”>
i want this text to force a horizontal scrollbar if it overflows at the right yeaaaaaaaaaaaaaaaaaaaaah

I really like virgin mobile.

I mean really.

Calling their customer service is the complete opposite of what you get with most other companies.

Its warm human contact. I love their agents. They’re nice, charming, cool, and fun to talk to. They’re really eager to help. I have never seen this level of customer service in my life.

Its the complete opposite of what you get with Bell (foreign accent that doesn’t seem to know what the product). I’m sorry if that sounds racist, but that really is the case. There’s something about being given a guy with an indian accent to talk to that feels short-end-of-the stick (note this isn’t racist: I didn’t say anything bad about Indian people, I only said I didn’t like being given a guy with an Indian accent). You just know they’re offshoring and its just so cheap.

I really hope Virgin becomes like the de-facto cell phone provider in the world and also keeps their ways. With the just.. stark, sheer differences in the services Virgin should be killing Bell in every sense of the word.

I’m just so .. at a loss for words at how much BETTER Virgin is then Bell and for all the years I stayed with Bell I really .. just regret it.. its real regret man. All the mistreatment, waiting, just abuse, really that’s what it is, and there’s virgin right there, better services and all..

OH AND before I froget, their voice answering system is the cleanest shit i’ve ever saw in my fucking life. they don’t bother you with Bell’s BULLSHIT “say your phone number” — WTF. Bell should know by now that people HATE voice recognition bullshit and its ANNOYING to have to SAY what you want. I think the Bell marketing people don’t have it. They really don’t. I mean really don’t. Virgin GETS IT. Bell doesn’t.

Pardon the verbage in the title fo this post, but ITS ABOUT DAMN WELL TIME.

I mean come on, HOW HARD COULD IT BE?

some shiny article page

download, x86 (32-bit machines – most use this)

download, x64 (64 bit machines only!)

downloadsquad article

I was really tired one night. i found scrawled on a piece of paper

if i sleep now, i can get up later