Skip to content

Clever Code

Showcase your best code, your most elegant solution, or your most hard fought subtle bug you've found and fixed

This category can be followed from the open social web via the handle clever-code@forum.codeproject.com

361 Topics 3.2k Posts
  • Visual C++ 2008 - Compliance?

    c++ help testing beta-testing
    11
    0 Votes
    11 Posts
    6 Views
    E
    Thanks: now I've got the point. 2 bugs found. > recompile ... 65534 bugs found. :doh:
  • Oww...

    learning
    6
    0 Votes
    6 Posts
    3 Views
    B
    "En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása" Hi Luca, That fascinating quote compelled me to go a-google; I assumed it was a quote from some medieval Scandinavian skald sitting on a hill watching a battle (or a nice plundering raid on an English town) commence and making notes for his edda or saga :) Even more fascinating that it's a quote from a contemporary Icelandic ambient music group, and that song title translates as "A Good Day for Airstrikes." thanks, Bill "The greater the social and cultural distances between people, the more magical the light that can spring from their contact." Milan Kundera in Testaments Trahis
  • 1086 + 68 = 0? [modified]

    question
    16
    0 Votes
    16 Posts
    6 Views
    A
    Bah - going and spoiling it :) --------------------------- Blogging about SQL, Technology and many other things
  • Logging trouble [modified]

    help wcf data-structures debugging question
    3
    0 Votes
    3 Posts
    2 Views
    M
    If you see the code, this part stackTrace = new StackTrace(); stackFrame = stackTrace.GetFrame(2); is in a try-catch block that catchs all the exceptions, also, methodBase is checked for null, so the exception is not thrown there. Also, the exception is a null reference generated in the posted method, not in any method called by it, meaning that we tried to call methods on some variable or property that was null.
  • No, Visual Studio, you are wrong about that

    visual-studio help csharp com regex
    7
    0 Votes
    7 Posts
    2 Views
    J
    Please post your question with the proper information and in the proper forum. We will need complete error information and probably some sample code to determine the problem. Questions are answered on the forum, not through email. This way the entire community can benefit from the answer. "Quality Software since 1983!" See my personal web site for photos, info, and a really weird blog Want to fly model aircraft? Read my beginner site to find out how!
  • 0 Votes
    9 Posts
    3 Views
    J
    And the last page of story - I'm that unlucky friend who sits nearby him. :rolleyes: Regards, Jijo. _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
  • Who closed my datareader?

    help com tools question
    12
    0 Votes
    12 Posts
    4 Views
    T
    Not necessarily - Close() is often an alias for Dispose() and that never throws exceptions when called more times than necessary (as per the disposable pattern recommendations - Dispose() should under no circumstances whatsoever be dangerous to call - regardless of state). Any other method should throw an ObjectDisposedException, however. I may be wrong about DataReaders, but it's definitely so (Close and Dispose are the same - or actually, one calls the other) for Streams (as per the documentation). -- Peter
  • subst what?

    help question
    10
    0 Votes
    10 Posts
    4 Views
    T
    Neat! chroot in DOS... and MS hasn't figured that out for their FTP server YET! -- Peter
  • Not so subtle bug... [modified]

    help com security tools question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Internet Explorer (another?)

    help html css question
    12
    0 Votes
    12 Posts
    5 Views
    V
    Jasmine2501 wrote: the root problem here is that YOU gave the wrong extension to a file. Fix that issue and you won't have any problems. I don't understand why you consider this a problem in the first place. You are expecting Internet Explorer to figure out and fix your screw-up?! I'll remember this when you ever get in a similar situation... I don't really understand this harsh answer :confused: V. Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive
  • IE 7 Culture bug

    php visual-studio com help
    9
    0 Votes
    9 Posts
    5 Views
    L
    In my opinion you are 8 days late. I trust you will claim to be ahead a few gazillion years? Luc Pattyn [Forum Guidelines] [My Articles] This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
  • How about this one?

    question
    9
    0 Votes
    9 Posts
    4 Views
    G
    Premature EOF would do Bad Things, I would imagine. Software Zen: delete this; Fold With Us![^]
  • vsprintf crashes (only) in MFC project VC6.0

    c++
    9
    0 Votes
    9 Posts
    3 Views
    G
    "Benefits of a classical education."     - Hans Gruber (played by Alan Rickman), Die Hard Software Zen: delete this; Fold With Us![^]
  • Subtle Bug in Subtle Bugs system

    help announcement database sysadmin hosting
    13
    0 Votes
    13 Posts
    5 Views
    P
    Actually, that raises an issue with .NET that bugs me. Opening a text file for append is dog slow when the file is of any size, no matter what method you use. I think the .NET framework must use a very inefficient (character-at-a-time, probably) method to read through to the end of the file (when it could, of course, just do a simple seek). I suppose this was lucky for you though in a way in that the performance impact this causes made you go looking for your bug. Paul Sanders http://www.alpinesoft.co.uk
  • 0 Votes
    4 Posts
    3 Views
    D
    I've had simmilar issues with C# and VS2008.... Especially when adding new line characters, never easy to fix.... A simple debug tip is to do String debugString = theString.Replace("\r\n", "@@@"); and then breakpoint the line after.
  • Calender Chaos

    help question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    13 Posts
    4 Views
    N
    Better to add to your toolbox of utility/helper methods: static bool WaitForKeyPress() { return WaitForKeyPress( ConsoleKey.Escape ) ; } static bool WaitForKeyPress( ConsoleKey quit_key ) { ConsoleKeyInfo keypress ; bool fQuit = false ; FlushConsoleInputBuffer() ; WriteConditionalEOL() ; Console.Write( "Press ESC to quit or any other key to continue> " ) ; keypress = Console.ReadKey( false ); fQuit = ( keypress.Key == quit_key ? true : false ); WriteConditionalEOL(); return fQuit; } private static void FlushConsoleInputBuffer() { while ( Console.KeyAvailable ) { Console.ReadKey( true ); // true: don't echo input } return; } private static void WriteConditionalEOL() { if ( Console.CursorLeft > 0 ) { Console.WriteLine(); } return; }
  • A (not so subtle) leak...

    csharp question
    14
    0 Votes
    14 Posts
    8 Views
    E
    The OP said what was wrong up above. The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
  • Error calling VB6 DLL [modified*2]

    help com debugging question
    16
    0 Votes
    16 Posts
    25 Views
    B
    But wait, there's more! Casting Infinity to an int gives -2147483648. I can see some nasties happening down that little travelled path.
  • Weird delay in Firefox with Ajax request

    php visual-studio com question
    4
    0 Votes
    4 Posts
    2 Views
    R
    My old router at home was useless at forwarding ipv6 but did it in such a way that the connections didn't time out properly and it caused havok with my networking for a while. if you type about:config into the address bar and filter on network.dns.disableIPv6 you can stop firefox from using IPV6 Russ