- 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
Oh...
Admin
Fixed it
Admin
Fixed it, now approximated 2X fast, that will be $500 for my contractors fee.
Admin
Apparently. No.
Admin
I'm pretty sure the
src="' + url + '"
would prevent the browser's prefetch from downloading the script before the inline script is executed, since that expression can't be evaluated until the inline script is executed...Admin
Yeah, you're right. So it's a simple copy/pasta WTF...
Admin
What happens if telegramType = 90?
Admin
So nobody wants to point out that Chris' "fix" for that macro will break code that was expecting m_CalcOpt to be evaluated more than once?
Admin
And after the bug is finally noticed and reported it will be fixed accordingly:
Admin
That one can actually write that without noticing that there might be a reason why you shouldn't use a
<script>
or</script>
tag inside a script tag is TRWTF.But wait, I guess it went like this:
The embarrassment must be unbearable.
Admin
You have to avoid script-ception somehow, right? Otherwise, what's preventing you from
Admin
**Marcus M.’s```, Remy? I'm going to have to ask you to turn in your Markdown license....
Admin
For all anyone knows, that might actually have been valid Dick bb marks html.
Oh, I am not going to try to fix that.
Admin
How do you mean? The value for m_CalcOpt isn't updated (there is no assignment). CALCOPT_NOHITS is replaced with a statement that is equal to m_CalcOpt without the bits for CALCOPT_TRACEHITS or CALCOPT_TRACESUBHITS set, regardless of whether they were set previously (these are all integer bitmasks).
As the original submitter, I would like to add that unless I've made a mistake, the "fix" has the intended logic. Whether or not the original version has the same logic, I'm 99% sure it does, but it's not a fun task trying to prove it.
Admin
All operations are bitwise or logical operators, so that's not difficult. Just let a computer make a truth table.
I pasted the two #def lines into Visual C++, and called them with appropriate flag settings (so that each flag combination occurs exactly once in the lowermost bits).
(After getting the result, it was simple to see which simple bitwise operation is equivalent to the first expression; this is what I put into CALCOPT_NOHITS_3
(the result is btw "60 / 16 / 60" )
Admin
Fixed?
Admin
(Time estimate seems to be a bit more than a one-liner, though.)
Admin
Probably there's off-by-one error around 99, but I CBA to check.
Admin
There, now those pesky hackers trying to determine whether our telegram is of payment type won't be able to, just by observing execution time.
Admin
Was $condition a function with side effects?
Admin
No. It was a condition that the script used to use to decide if it should do a thing, and then there was a requirement to do the thing regardless of the condition. It apparently didn't occur to the developer to simply remove the if.
Admin
It was kind of a joke, involving the fact that parameterized macros with ?: in them evaluate the parameters multiple times.
Admin
This is actually a cargo cult from the days of 3rd and 4th generation browsers, when not only JS but the whole browser parsing was single-threaded and everything accordingly top down and linear. (The "document-stream" model.)
Some amazing facts: The
document
object was only created as the HTML parser hit thebody
tag. (So, no reference todocument
inside a script executed in the head section at start up. If you head to check some implementation, like Netscape 4'sdocument.layers
, you had to trigger this from a script inside or after the body.) HTML was also rendered in a strictly linear fashion. E.g., if the parser hit an image tag and there was a validheight
andwidth
attributed, the browser could reserve the space and go on rendering the following content. But, if the dimensional attributes where missing, the browser would pause – with all previous parsed content visible – wait for the image file to be loaded and decoded – and resume only after the image had been inserted. (Actually, it would resume as soon as the dimensions where to be extracted from the file header, still leaving the user to the wonders of the image filling line by line as it were received and decoded.) You could actually use this as a means of sequential story telling.And yes, the page would absolutely break, if there was a string containing the sequence
'<SCRIPT'
(well styled HTML was considered upper case then) found in a script. This is, because the HTML-parsing took precedence over script parsing. The string'<SCRIPT...'
would implicitly close the script to be executed, thus opening a new script that would be closed by the string'</SCRIPT>'
in thedocument.write()
, rendering the rest of the script as visible HTML content. (By this also inevitably breaking yourdocument.write()
statement.) Thus, you had to escape the string some way or the other.P.E., the code
would have been parsed as
Admin
Or (C#)
...
Admin
Admin
Next project:
class RomeoAndCleopatra
Filed under: I didn't mix up anything, did I?
(Maybe I'll edit this later; on mobile there are only the basic text input functions available)
Admin
You just have to learn Discodown and you'll be fine. Or committed to an asylum. ;) :hospital:
Admin
The proper enterprisey way is to store the value in an xml document and then use XPath to select it.
Admin
Most people say that it's bad coding to do that (assuming conditional is a boolean), but I think it can make sense sometimes.
For example, consider this code
Edit: OK, Discourse, that's just mean. What did I do wrong now?
[image]Admin
AAAAAAAAAAAAAAAAAAAA :takes_breath: AAAAAAAAAAAAAAAAAAA…
[spoiler](floating point equality comparisons are a personal bugbear)[/spoiler]
Admin
Obviously the equality operator is overloaded to return true if the difference is smaller than 0.001 :trollface:
Admin
Even more enterprisey is to use a homegrown XML parser. That has - among others - the great advantage of tolerating
not well-formedenterprisey XML.Admin
FTFY
An interesting approach - besides the clbuttic FILE_NOT_FOUND - is the last entry in this article
Let me play Captain Obvious: [spoiler]You used Discourse[/spoiler].Admin
Discasylum refuses to find "Discodown" for me: [image] Maybe the entry is really missing, though.
Admin
That would be just irresponsible, as such a scheme falls down for denormals :tropical_drink:
Admin
Does epsilon equal zero?
Admin
https://meta.discourse.org/t/code-fence-and-pre-formatting-require-preceding-blank-lines-to-render-correctly-in-cooked/31239/9?u=pjh
Admin
I don't know about epsilon, but Epsilon does in C# (in the Immediate Window):
Admin
...... why did you cast Double.Epsilon to type Single in that comparison?
Admin
Because I can, duh!
And because otherwise that Epsilon wouldn't equal zero (tried it).
Edit: And a bit because silly is the next state after tired. Has nothign to do with trying to increase my post count.
Admin
so..... what' you're saying is that Double.Epsilon doesn't actually equal 0, so you cheated to make it look like it equals 0?
or am i missing something here?
:rofl:
Admin
Tsk, tsk, what a harsh word!
I'm just trying to adapt mentally to the providers of the stuff that keeps this site running.
Admin
Epsilon's always greater than zero. Not much point otherwise.
Admin
that's actually rather my point.
Epsilon is a point that is positive and arbitrarily close to zero that is not zero. Sigma is a point that's smaller than Epsilon, but still not zero.
Admin
Except when it's a different variable.
Admin
Depends on what kind of Epsilon you mean. As an insect, it definitively is greater than nought.
In C#, a Point is something with X and Y coordinates, and by default no > (and thus, >=, <, <=) operator is defined for such a class. Can be called epsilon or Epsilon, if you like.
In mathematics, a point can be identified with a real number, but that's not very frequently done.
As floating point numbers, I've seen Epsilon used both as the smallest entity greater than zero, the smallest normal entity greater than zero, and the smallest number that added to 1 gives something that differs from 1, from the set of representable numbers of a class. Insofar you're right.
is used as the sum symbol (uppercase letter) or for the standard deviation (lowercase letter), mostly.Phew, after this pendantry I feel a bit better.
Admin
For float comparisons, epsilon is often best taken as an optional parameter so you can specify what you mean by “equal”. The general issue is that algorithms don't usually know the characteristic range of the data that you're feeding through them; you can't just say X significant figures since that gives unhelpful answers if you're close to zero.
I hate doing float math…
Admin
Somewhere I have a function that compares the difference of two floats to their "Euclidean sum". Something like (value1 - value2)^2 / (value1^2 + value2^2). Plus checking for very small and very large numbers. Luckily not needed in a loop.