|
Just reading through some javascript the other day when I found this gem.
function GetCursorPosition(node)
{
if (navigator.userAgent.toLowerCase().indexOf("opera") != -1) return 0;
Would now be a bad time to say that I found it here at CP?
+5 to the first person to correctly identify where!
|
|
|
|
|
enhzflep wrote: found it here at CP
Well, someone doesn't like Opera!
I wonder when this will be solved.
(Or if)
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
Are you talking about this[^]?
|
|
|
|
|
Nope, sorry.
hint: its neither an article nor a user submitted post...
|
|
|
|
|
YOu found it right here[^]
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
CDP1802 wrote: I found it right here[^]
I don't know where you found it
Nope, ftfy too.
You've both had it in your browsers today...
|
|
|
|
|
enhzflep wrote: You've both had it in your browsers today...
Then it must be on the 'Reply to Message' page.
...
Yes, I found it.
|
|
|
|
|
Yep, tracks cursor position inside the textarea where i'm writing now (hm, i'm feeling watched). At first glance, seems to be responsible for checking if cursor position is inside a tag when copying and pasting code. I may be wrong, but this is what I got in 1 min or so
EDIT: Now, thanks to Jochen I actually took his suggestion, so the 5 should go to him
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
That's close enough for me.
It's line 1,618 of Edit.aspx
|
|
|
|
|
Yep - that's exactly what it does. With the evolution of "security" in browsers, handling Paste events has become more and more painful, so much so that the only way I can reliably handle it is to watch every elephanting keystroke in order to work out when a Paste event has happened and what was Pasted.
Except that Opera totally screws it up. I gave up.
You should see the server-side comments...
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
What hasn't Opera screwed up?
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
That's close enough for me.
It's line 1,618 of Edit.aspx
|
|
|
|
|
Condensed and renamed to protect the guilty...
Public Sub TestThis(bFlag as Boolean, objVar as Object)
If (Not bFlag) And (bFlag <> Not CBool(objVar Is Nothing)) Then
End If
End Sub
I know the CBool is completely unneeded. But I'm having a heck of a time understanding what this little snippet was supposed to be testing for, or how it even came into existence in the first place. It seems like it would be cleaner to just test:
(Not bFlag) And Not (objVar Is Nothing)
There are actually several other instances of this kind of test that I think are just there for a confusion factor. They all follow the same basic pattern of:
(Not boolean1) And (boolean1 <> boolean_test_condition)
In order for the whole test to be True, the first Boolean must be False, so boolean test condition on the right side MUST be True. Why even bother comparing the test condition result against the first value?
(Not boolean1) And boolean_test_condition
I'm so ripping my hair out every time I have to dive into legacy code like this. Good thing it's Friday!
|
|
|
|
|
public void WriteCode(ICodeContext ctx)
{
throw new BrainNotFoundException();
}
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
That's called obfuscation.
Theoretically, it could be intended (protection against reverse engineering, or just abuse of the colleagues who have to maintain that code).
But more often, it happens due to other factors. E.g. the law of thermodynamics: things get worse under pressure. Or medical conditions like hypocaffeinemia.
|
|
|
|
|
Select Case ListIT
Case 1: nList = oArti.List1
Case 2: nList = oArti.List2
Case 3: nList = oArti.List3
Case 4: nList = oArti.List4
Case 5: nList = oArti.List5
Case 6: nList = oArti.List6
Case 7: nList = oArti.List7
Case 8: nList = oArti.List8
Case 9: nList = oArti.List9
Case Else
nList = 1
End Select
I think, array is a vulgar word for someone. Funny thing, I didn't understood what in the name of lord does that (variables were not descriptive about content they have) Also, funny comments! (code was originally written in spanish)
|
|
|
|
|
CocusArg wrote: 'in theory, it should never came here
I've learned that placing such a comment will make your code go to any lengths (apparently even changing variable values out-of-the-blue) to take that path...
Also, speaking of funny comments, my colleague found this little gem in a PHP script:
$i = $i + 1;
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
What do you have against PHP? It's soooo easy to learn and it has been used for soooo many big projects.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
Yes, and at the same time, it makes it awwwwwwfully easy to code badly.
You can code badly in absolutely any language, but bad code written in PHP just.has.that.special.flavor.
[rant start]
Now, assume we have some code (PHP) along the lines of:
$invoice_no = 1;
$invoice_no = $invoice_no . 'INV_123#';
return $invoice_no;
Now, try to do this in Java for instance:
int invoice_no = 1;
invoice_no = invoice_no + "INV_123#";
return invoice_no;
The compiler would be all over the place, screaming like a newborn baby. And that's just off the top of my head.
And speaking of compiler and autocomplete, how about contructs like:
$invoice_no = 'Whatever';
return $invoiceno;
Or that you can't really enforce a type parameter on a method (of course, there's get_class, but you'll only know about it at runtime).
Or autocomplete. I'a big fan of autocomplete. Now, I've done PHP with both Eclipse and Netbeans. Try to get autocomplete for something like:
$db = DatabaseService::getInstance();
$line = $db->getPoLineById($line_id);
$product = $db->searchProduct('id', $line->getProductId());
Or debugging. var_dump, really? Now, I know there's XDebug, but try using that in a 4GB PHP project (I'm talking about a Magento website). Good luck with that.
[rant end]
Now, I do believe your remark was sarcastic. For being sarcastically funny, have a 5!
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
Andrei Straut wrote: Now, I do believe your remark was sarcastic
Thanks. Indeed I don't jump off bridges just because it's especially easy on this particular bridge or many people have done so before. Not even the lemmings really do that.
I have started to ignore languages which are interpreted or are advertised as being especially noob-friendly on 8 bit machines. Especially the 'noob-unfriendly' things (like type safety) usually are supposed to help you and I have no interest in learning how to bypass them or constantly discussing why it's a bad idea to bypass them.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
CDP1802 wrote: Especially the 'noob-unfriendly' things (like type safety) usually are supposed to help you and I have no interest in learning how to bypass them
So true. Now, please do go and convince everyone of this.
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
Hopeless. Those who go for 'easy' usually don't see the need for any pesky constraints and want to keep on going without them.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
Just unearthed the following gem to display a progress bar:
switch(uiBattBarPosition)
{
case(0):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"");
break;
case(1):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff");
break;
case(2):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff");
break;
case(3):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff");
break;
case(4):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff");
break;
case(5):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff");
break;
case(6):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff");
break;
case(7):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff");
break;
case(8):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(9):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(10):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(11):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(12):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(13):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(14):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(15):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(16):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(17):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(18):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(19):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
case(20):
DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
break;
}
Makes you wonder if these people were getting paid by the line.
|
|
|
|
|
Is 20 cases optimum for this approach or he was wrong there as well?
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
We were using a 2x20 character display, so the "gas gauge" went from 0 to 20 bars.
|
|
|
|
|