Click here to Skip to main content
15,885,546 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: You're already late Pin
Richard A. Dalton26-Aug-10 0:21
Richard A. Dalton26-Aug-10 0:21 
JokeRe: You're already late Pin
Fernando Padoan26-Aug-10 2:29
Fernando Padoan26-Aug-10 2:29 
GeneralRe: You're already late Pin
peterchen27-Aug-10 21:26
peterchen27-Aug-10 21:26 
GeneralRe: You're already late Pin
BillW3326-Aug-10 5:52
professionalBillW3326-Aug-10 5:52 
GeneralRe: You're already late Pin
Dr.Walt Fair, PE26-Aug-10 8:46
professionalDr.Walt Fair, PE26-Aug-10 8:46 
GeneralRe: You're already late Pin
Fernando Padoan26-Aug-10 17:30
Fernando Padoan26-Aug-10 17:30 
GeneralRe: You're already late Pin
Matthew Dennis3-Sep-10 11:06
sysadminMatthew Dennis3-Sep-10 11:06 
GeneralCase closed: NULLs are somehow valid in strings now? Pin
djdanlib25-Aug-10 10:03
djdanlib25-Aug-10 10:03 
I was beating my head on the desk all day over a stupid issue of a perl script not getting all of its arguments.

You see... .NET strings can happily contain arbitrary NULL characters. (I didn't know that until today. Beware of this behavior.) Microsoft decided in their infinite wisdom that we programmers would just love to abandon the old NULL termination method where NULL signaled the end of a string. So that means .NET considers NULL a valid character in our strings, even though the definition of NULL is "THIS DATA DOES NOT EXIST and cannot be compared or evaluated." I was compiling a command line by concatenating multiple strings together. You can probably guess where this is going. Yes, an interop issue! Command lines ARE in fact NULL terminated. I use a WINAPI call that gets the short name for a long filename because somebody wrote a Perl script that can't handle filenames with spaces. Being a venerable old WINAPI function that's still with us since the Win95 days, it returns the result as a NULL terminated char array. So I said "return new string(buf)" to get the result as a string, and good old .NET said "Oh, that's okay, we can have NULLs in strings now!" So guess what happened? After I appended that short name to the argument string, everything after it got truncated when I passed it to a command line, and it rained on elementary school playgrounds around the world. Oh, the sadness was overwhelming. So I had to do a .Replace("\0", "") on that string before giving it to the ProcessInfo and all was golden and happy and the birds sang and rainbows issued forth from the heavens.

Case closed.
GeneralRe: Case closed: NULLs are somehow valid in strings now? PinPopular
AspDotNetDev25-Aug-10 10:35
protectorAspDotNetDev25-Aug-10 10:35 
GeneralRe: Case closed: NULLs are somehow valid in strings now? Pin
PIEBALDconsult25-Aug-10 15:10
mvePIEBALDconsult25-Aug-10 15:10 
GeneralRe: Case closed: NULLs are somehow valid in strings now? Pin
Luc Pattyn25-Aug-10 16:59
sitebuilderLuc Pattyn25-Aug-10 16:59 
GeneralRe: Case closed: NULLs are somehow valid in strings now? Pin
PIEBALDconsult25-Aug-10 17:44
mvePIEBALDconsult25-Aug-10 17:44 
GeneralRe: Case closed: NULLs are somehow valid in strings now? Pin
CDP180226-Aug-10 1:02
CDP180226-Aug-10 1:02 
GeneralRe: Case closed: NULLs are somehow valid in strings now? Pin
Dave Calkins26-Aug-10 11:15
Dave Calkins26-Aug-10 11:15 
GeneralRe: Case closed: NULLs are somehow valid in strings now? Pin
Stephen Hewitt27-Aug-10 20:30
Stephen Hewitt27-Aug-10 20:30 
GeneralBeginner's Shame: Manually Draw Characters Pin
AspDotNetDev25-Aug-10 8:26
protectorAspDotNetDev25-Aug-10 8:26 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
josda100025-Aug-10 9:34
josda100025-Aug-10 9:34 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
AspDotNetDev25-Aug-10 10:30
protectorAspDotNetDev25-Aug-10 10:30 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
Dave Calkins26-Aug-10 11:18
Dave Calkins26-Aug-10 11:18 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
Luc Pattyn25-Aug-10 11:34
sitebuilderLuc Pattyn25-Aug-10 11:34 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
AspDotNetDev25-Aug-10 12:52
protectorAspDotNetDev25-Aug-10 12:52 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
Luc Pattyn25-Aug-10 13:23
sitebuilderLuc Pattyn25-Aug-10 13:23 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
Baconbutty26-Aug-10 3:17
Baconbutty26-Aug-10 3:17 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
BillW3326-Aug-10 5:42
professionalBillW3326-Aug-10 5:42 
GeneralRe: Beginner's Shame: Manually Draw Characters Pin
Stefan_Lang31-Aug-10 6:42
Stefan_Lang31-Aug-10 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.