Shame on you, Microsoft engineers, for not being able to verify that a function has no side effects! I mean, this cannot be an unsolvable or hard problem, can it?
Posts made by IMil
-
RE: Fabs has side effects
-
RE: I ARE ANGERED (YouTube and their coddling of fraudulent copyright trolls)
It's not clear to me what you are complaining about.
Some bot checked your video for copyrighted material and gave a false positive. Oh, the humanity!
You would like each such case to be rechecked by a human being? Yeah, and I would like the traffic lights to turn green when I approach them. -
RE: SQL injection as a feature
What exactly do you find surprising? Parameters are used to substitute values, not arbitrary query parts. Otherwise they would not protect against injection, would they?
So, each one of the following "prepared statements" is invalid:
SELECT * FROM ? WHERE ANSWER = 42
SELECT ? FROM QUESTIONS WHERE ANSWER = 42
SELECT * FROM QUESTIONS WHERE ANSWER ? 42 ;;hoping to replace with "=" or "<"Only the next one is correct:
SELECT * FROM QUESTIONS WHERE ANSWER = ?
-
RE: .net parameters
@dhromed said:
Because strained, swiss-cheese prosaic metaphors are the best way of getting a point across.
Sorry for not coming up with a more original one.Anyhow, I apologize to the OP if it seems that I was mocking him. His question is actually quite reasonable for a person starting to learn .NET. It's his colleagues "with several years of .NET experience" who surprise me by not knowing the fundamentals.
-
RE: .net parameters
In order to hang a picture on the wall, you have to insert a long hard object in the wall, as expected.
However, you need to be aware of the object type.
There are nail type and screw type objects. A nail type object has to be hit hard with a hammer. A screw type object has to be rotated with a screwdriver (which seems quite an inefficient and slow method to me).My roommates didn't believe me when I told them (they have been doing room repairs for several years already).
I'm not sure I understand the reasoning for doing it this way. Is this just to avoid hitting myself on the thumb?
-
RE: I know Google Maps wtfs are lame, but...
I guess the pathfinding algorithm became a bit... superstitious.
-
RE: Excel 2007's Undo Feature
@bstorer said:
@Jaime said:
Try opening two spreadsheets with the same file name someday.
God that fucking annoys me. If that isn't fixed in 2010, I'm going to burn down the universe.It won't be fixed neither in 2010, nor in 2100. Get a lighter, you'll need it.
The reason is that VBA programs may reference data in other spreadsheets by file name only, without path and extension. So allowing to open multiple files with the same name would screw up thousands of existing VBA programs in most exciting ways. The current limitation, however inconvenient it may be, is relatively easy to work around, so the choice is pretty obvious.
UPD: seems I was wrong about extensions, book.xls may coexist with book.xlsx . However, for the files in different folders you still have to fire up a second Excel instance.
-
RE: Betterwhois. Whois of SATAN
@danixdefcon5 said:
I thought 666 was read-write perms for everyone!
And isn't it pure evil from security point of view?
-
RE: What's the for loop for?
@ammoQ said:
Now get rid of the useless variable, and we are done.bool TestAlignment()
{
return TestAlignment(0) && TestAlignment(1);
}
Nice code; the only problem is that it isn't correct. In the original post, the SetAlignment() procedure was called for both 0 and 1; your code may skip the second call. -
RE: Close setup before continuing with setup
@Eternal Density said:
"Close setup before continuing with setup" messages are a dime a dozen.
Yes, it's almost as exciting as "Error: operation completed successfully".
-
RE: Recursion in C# Properties
@SlyEcho said:
Of course it's overkill, but if you're a programmer, you need to look further ahead and find a more generic solution (you don't always have time for this though). The original problem was finding Excel column names, and Excel 2007 has at least three letter columns (It took some time to scroll that far).
Sorry, my mistake. I didn't work with Excel that much and thought ZZ was the last one. Then recursion IS the way to go, just not in the crazy way of the OP.
@SlyEcho said:
@IMil said:
And is changing the value of function input (bonus points for making it in the head of the 'if' operator) considered harmful only by me?
It may seem a little unnatural, but perfectly valid since it's not a reference, only a copy on the stack.
It's valid, just confusing. For example, when I enter the debugger, I usually may hover the cursor over the function parameters and see their values. But in your case the initial value would be lost; I'd have step back and examine the caller and that's not always possible.
@SlyEcho said:
The "improvement" here was to make it not recursive. Lots of people seem to be afraid on stack overflows, but in reality that only happens when your recursions don't terminate properly. The recursive function I wrote originally would only need a maximum of 7 recursions for any positive Int32, for smaller values, even less.
Well, that's what I meant by <irony>. A stack overflow is the last thing to worry about with a strictly limited recursion depth. If there's an error that leads to an infinite recursion, the same error in the iterative code would lead to an infinite loop. So I think the recursive version was more readable and thus better (were it correct). I'd even remove the whole StringBuilder thing and just concatenate the strings - for a small number of strings this will be unimportant.
-
RE: 'for' loops and time
+1 for the 'while' loop.
I wonder what would this manager say to such code:foreach (DateTime date in getAllDates()) { ... } ... private IEnumerable<DateTime> getAllDates() { for (DateTime date = StartDate; date <= EndDate; date = date.AddDays(1)) yield return date; }
-
RE: Recursion in C# Properties
@SlyEcho said:
private static readonly int AbcMax = (int)Math.Ceiling(Math.Log(int.MaxValue, ABC.Length));
...
if ((num = num / ABC.Length - 1) < 0) break;
My eyes!
I mean, it's probably correct (if you took the time to actually test this thing; otherwise it's certainly not), but the task was to generate a TWO-LETTER combination, not a generic one.
And is changing the value of function input (bonus points for making it in the head of the 'if' operator) considered harmful only by me?
Sorry if I missed the <irony> tags around the words 'improved version'. -
RE: Recursion in C# Properties
@morbiuswilters said:
The best way to write it would be to not use fucking recursion to handle base conversion. Seriously, I think 95% of TDWTF readers are probably WTF factories themselves.
OK, how about making a better WTF than the original one? Here's my almost-one-liner that should be taken out and shot:
public string ColumnName { get { return ( (number / ABC.Length > 0 ) ? ABC[number / ABC.Length - 1] : '') + ABC[number % ABC.Length - 1]; } }
All off-by-one and compilation errors are intended for the reader's amusement.
-
RE: Recursion in C# Properties
Well, I may imagine a situation where a property could be represented using recursion...
For example:class MultipleFileSearcher { //...... public SearchResult Result { get { if( IsResultInCurrentFile() ) { return GetResultInCurrentFile(); } else { AdvanceToNextFile(); return Result; } } } }
However, I would certainly extract the logic into a private method, just to avoid confusion.
As for the original code, it's a huge WTF indeed. Still, the coder knows recursion; it should be possible to teach him to use it sparingly. The character lookup table is also a good sign - it's not a 'switch' statement after all. So I wouldn't call the guy hopeless.
-
RE: Amish and technology
I recall that the original Prince of Persia had several positive reviews of itself embedded in the executable file.
They never appeared during the gameplay or after. Must have been a magic ritual.
-
RE: Blank line exception handling
@dlikhten said:
@IMil said:
100.times { puts "I'll never skip <irony> tags again" }
Damn you with your ruby-goodness! Don't infringe on our java cult!
Oh, shut up. The real WTF is that Java was used in the original sample.
In Ruby, the same could have been achieved with metaprogramming in one line or even less!
-
RE: Blank line exception handling
100.times { puts "I'll never skip <irony> tags again" }
-
RE: Blank line exception handling
Probably the application is expected to work in a multithreaded environment.
Thus, an exception may occur in some other part of the program while the blank line is being executed.
And who knows, maybe this exception is so huge as to occupy several threads at once? In fact, it would be safer to write
catch (Exception[ ] theWholeBunch)
or
while( catch( Exception) ) { /*don't panic*/ }
to rescue other threads as well.
-
The WTF from 1726
His lordship ... desired me to observe a ruined building, upon the side of a mountain about three miles distant, of which he gave me this account: “That he had a very convenient mill within half a mile of his house, turned by a current from a large river, and sufficient for his own family, as well as a great number of his tenants; that about seven years ago, a club of those projectors came to him with proposals to destroy this mill, and build another on the side of that mountain, on the long ridge whereof a long canal must be cut, for a repository of water, to be conveyed up by pipes and engines to supply the mill, because the wind and air upon a height agitated the water, and thereby made it fitter for motion, and because the water, descending down a declivity, would turn the mill with half the current of a river whose course is more upon a level.” He said, “that being then not very well with the court, and pressed by many of his friends, he complied with the proposal; and after employing a hundred men for two years, the work miscarried, the projectors went off, laying the blame entirely upon him, railing at him ever since, and putting others upon the same experiment, with equal assurance of success, as well as equal disappointment.”
Jonathan Swift, Gulliver's Travels
Looks oddly familiar, doesn't it?
-
RE: Free Download Manager WTF
@Lingerance said:
@IMil said:
@asuffield said:
It's WFP. Due to an inexcusable bug in one of the APIs used by this fundamentally flawed misfeature, in order for WFP to be able to 'protect' certain files that can be placed in that directory when frontpage is installed, it has to force the directory to exist all the time, even when frontpage is not installed.
I wouldn't call this a bug. The reason to monitor 'program files/xerox' folder is not clear to me; let's assume that Xerox screwed up and released drivers that sometimes hang up the OS. So, WFP has to replace the drivers in 'xerox' folder as soon as they appear.
There are two options to do this:
1) Monitor changes of the 'program files' folder, waiting for the 'xerox' folder to appear
2) Create the 'xerox' folder and monitor changes to it.
Obviously, the first option would consume more resources; the only problem with the second is irritation of some 0.001% of users. The choice isn't hard to make.
Alter the sys-calls that make directories and trigger whenever something starts with C:\Program Files\xerox would IMO be alot less CPU intensive and considering how fast other operations on MS usually are there wouldn't be much of a performance impact.Do you really think that would be better than to create the folder?
-
RE: Free Download Manager WTF
@asuffield said:
It's WFP. Due to an inexcusable bug in one of the APIs used by this fundamentally flawed misfeature, in order for WFP to be able to 'protect' certain files that can be placed in that directory when frontpage is installed, it has to force the directory to exist all the time, even when frontpage is not installed.
I wouldn't call this a bug. The reason to monitor 'program files/xerox' folder is not clear to me; let's assume that Xerox screwed up and released drivers that sometimes hang up the OS. So, WFP has to replace the drivers in 'xerox' folder as soon as they appear.
There are two options to do this:
1) Monitor changes of the 'program files' folder, waiting for the 'xerox' folder to appear
2) Create the 'xerox' folder and monitor changes to it.
Obviously, the first option would consume more resources; the only problem with the second is irritation of some 0.001% of users. The choice isn't hard to make.
-
RE: In response to "Life of an I.T. Grunt"
@CodeWhisperer said:
I note that his site is no longer there. When you go to the page you just see:
Looking For Me?
Try Google or WTF
Go figure.
Well, aren't you just looking at the second of the mentioned locations?
-
RE: More unfortunate websites
I thought one needs opposable thumbs for that.
Have ferrets moved up the evolution ladder?
-
RE: Another really bad translator used - WTF
@petvirus said:
one of the funnier things from this menu is the fact that in russian the word for "crab" is the same word as the word for "cancer", and they have lots of things made with crabs in this menu...
To be more precise, the homonym to "cancer" is "crawfish".
But if you like this sort of fun, you'd better go to China. The name "Pirate Bar" where someone managed to interpret "bar" as "the profession of lawyers" was the most absurd sign I have ever seen.
-
RE: Sometimes I leave presents for myself to find later:
const string[] DaysOfWeek = { "Monday", ... "Sunday", "Bugday" };
const string[] Months = { "January", ... "December", "Faultember" };
-
RE: Keyboards - the Bread and Butter of Computers?
The point is that most keyboards may accumulate large amounts of bread crumbs (see http://www.xkcd.com/c237.html ).
This keyboard obviously doesn't have enough storage space, hence the need for a special device.
-
RE: "Where are my files?"
@ComputerForumUser said:
I remember a quote of somebody who believed yellow actually meant "go faster").
It sure does mean "go faster to pass the crossroads before lights turn red", doesn't it.