- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I'd do a find/Replace with a regex such as s/./$&'/g (in perl) or Find: . Replace: \0' in Visual Studio.
Admin
$ python -c 'orig = "To be sure, you should probably put an apostrophe before every letter. That way you'''re bound to be right some of the time!";print "".join([ "'''" + x if ord(x) in range(65,90) or ord(x) in range(97,122) else x for x in orig ])' 'T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e!
Admin
Nice tries. I gotta go now. If anyone cares, it was:
sed "s/([a-zA-Z])/'\1/g"
Admin
In addition to type casts, null conversions and the remnants of some offset strategy, there are a couple of other uses for such logic:
But I would vote for null handling. I can't tell how many times I have added 0 or "" to a database field value to scrub off the nullness.
Admin
Admin
Well, it was interesting seeing all the possible solutions, but I'm still intrigued as to why anyone would click and paste to do it, when typing would be much faster. Did you forget to mention an additional assumption, such as, 'I have no keyboard' or, 'My current keyboard layout does not have the apostrophe in a convenient location'?
Admin
So, it was actually quicker using Word on a Windows machine ;-)
Admin
(For the humor-impaired: I know I left a necessary apostrophe out of that first sentence. Lighten up a bit, okay?)
Admin
And it's also incorrect as putting an apostrophe before every letter doesn't solve all cases as Socrates' cat will tell you ;-)
Admin
Apostrophe's are often a warning to the reader that an 's' is a about to appear.
Admin
I've actually done this for a reason (ofc, I commented the code, unlike the above). In ColdFusion, a dynamically-typed language, I was having trouble with using some variables containing numbers in both an integer & string context (data was string coming out of the db and in the display, but needed to be an integer for an interim calculation). Using variable + 0 cast it into an integer when I needed it to be.
Admin
This reminds me of Commodore V2 BASIC. For some reason, it computed "." quicker than "0", so you had a lot of "A=." going on.
If you think some of the DailyWTF code is obfuscated, try 5 KB VIC programs that looked like this:
Up to 88 characters per BASIC line, no spaces required, and there were "tokenized" versions of almost every command (besides "?" for print, you could use <first letter><shift-second letter> for other commands).
Admin
Apostrophe's are often a warning to the reader that an 'butt' is a about to appear. Clbuttic!
Admin
Now that's the real WTF!
Admin
FTFY
Admin
As said before, this looks very much like C#, and it doesn't break an assignment check. Heck, even if it could do that, what check is this supposed to break? x = x?
Overriding Math.Min is a WTF in itself.
Slow down a loop? Are you kidding? The + 0 or - 0 is going to be discarded by the optimizer and the call to Math.Min will take the better part of a microsecond. Four of those to slow down a loop? Depending on CPU speed?
Null handling either, since the only null objects are this or this.rect. If either is null, an exception will be thrown. I know people add 0 or "" in databases or awk or whatever, but this just isn't the case here.
Admin
My dick itches.
Admin
It does nothing only for sufficiently small values of zero.
Admin
Don't laugh. I've had all sorts of nonsense like this work, and in fact help. Superstitious/shotgun debugging helps sometimes...
Example from my code yesterday (in windows driver source):
KdPrint(("argm->p[3]: %I64x\n", argm->p[3])); ULONGLONG returnval = (argm->p[3] >> 5) & 0xFFFFFLL;
The above code results in errors from MSVS: 1>c:\WINDDK\3790.1830\src\test.c(54) : error C2143: syntax error : missing ';' before 'ULONGLONG' 1>c:\WINDDK\3790.1830\src\test.c(58) : error C2065: 'returnval' : undeclared identifier
i.e. there is a missing semicolon before ULONGLONG, which obviously means at the end of the KdPrint line.
REMOVING the semicolon at the end of the KdPrint line results in it compiling properly: KdPrint(("argm->p[3]: %I64x\n", argm->p[3])) ULONGLONG returnval = (argm->p[3] >> 5) & 0xFFFFFLL;
If I swap the lines, it compiles WITH the semicolon. Note that the double parentheses on KdPrint are required as stated by msdn - either their compiler sucks at dealing with preprocessor macros or whoever wrote the macro in the first place was smoking something. In either case, if VS complains about a "missing" semicolon after a line containing a macro, and it's not missing, try removing it.
Admin
Since when did Windows come with sed? (Remember, the poster said "Windows" in his original challenge!)
Admin
Since when did Windows come with sed? (Remember, the poster said "Windows" in his original challenge!)
Admin
Read it again (and note the username):
Reading is fundamental.
Admin
I am a senior software desiger at a MAJOR corporation, and I require ALL my employees to code this way. It makes it easy to set up an offset later if we need to. The zeros are placeholders for the offset that will someday go there.
Besides, it took mathematicians thousands of years to invent the number zero, which exists for precisely this function: to serve as a placeholder.
TRWTF is that eveyone doesn't do this!
Admin
Must have been written on a hyperreal architecture. The programmer is trying to clear out infinitesimal quantities.
Admin
Admin
I hate people who comment out code. Its called source control, just delete it.
Admin
This is not a true WTF unless the program stopped working when Robert removed the code.
Admin
However if you dont use them at all, youre percentage of times being right is higher than you use the for every letter.
Admin
Their bedroom was developed with Microsoft(TM) Front Page(TM) an uses the obligatory Extra-Marital Hit-It Counter (TM) which reads: "You're wife's vagina has been visited by X - 0 partners."
Admin
Admin
Admin
Admin
Admin
Don't forget to put a few after letters too! That way you won't get caught on things like "Jonas'" and other such constructs.
Admin
#define OFFSET_TO_REMOVE 5
#define OFFSET_FUNC(x) (85 + x3 - xx*4)
#define REMOVE_OFFSET(x,y) x-=y
...
REMOVE_OFFSET(rect.X1, OFFSET_TO_REMOVE)
Admin
Here's the better one:
Admin
I worked on a Data General minicomputer on which integer subtraction of equals returned a negative zero. If testing for zero, it was best to take absolute value of the result. Adding zero would probably also work.
Admin
The poster required respondents to be Windows users, but did not claim to be a Windows user.
http://gnuwin32.sourceforge.net/packages/sed.htm
Admin
You typed an apostrophe between each letter?
Admin
i have to poo
Admin
Admin
My.Reply = Math.Min('T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e! + '0); My.Reply = Math.Min('T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e! + 1'); My.Reply = Math.Max('T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e! + '0); My.Reply = Math.Max('T'o 'b'e 's'u'r'e, 'y'o'u 's'h'o'u'l'd 'p'r'o'b'a'b'l'y 'p'u't 'a'n 'a'p'o's't'r'o'p'h'e 'b'e'f'o'r'e 'e'v'e'r'y 'l'e't't'e'r. 'T'h'a't 'w'a'y 'y'o'u''r'e 'b'o'u'n'd 't'o 'b'e 'r'i'g'h't 's'o'm'e 'o'f 't'h'e 't'i'm'e! - '0);
Admin
home, apostrophe, cursor right, apostrophe, cursor right, cursor right, apostrophe, cursor right, apostrophe, cursor right, cursor right, apostrophe, cursor right, apostrophe, cursor right, apostrophe, cursor right, apostrophe, cursor right, cursor right, cursor right, apostrophe, cursor right, apostrophe, cursor right, apostrophe, cursor right, cursor right...
Reminds me Tetris walkthrough
Admin
Well, it's alway's nice to warn reader's about an upcoming 's. They can be 'scary 'sometime's.
Admin
No, wait... that cat died. Or did it? Oh well, nevermind.
Admin
Admin
That would have been so much more ironic if you had used "you are" instead of the contraction....
Admin
Admin
Seems more likely that at some point they tried adding/subtracting various values other than zeo, found that those weren't handling all of the issues, tried some other stuff elsewhere in the code that did fix the issues, but now found that they were off by the non-zero amounts, so changed all of those amounts to zero, and just never went back and removed these lines of code. But... whatever.
Admin
A capture-replace expression on the alphabet character class. sed would do the trick but you're certainly not constrained to a 1 line shell script as any editor worth its salt has this functionality.