I love verbose code. I will gladly read yourFiveWordVariableNames //and
//Multi
//Line
//CommentsIf it explains your code!
In that case you should love the code in this article.
I love verbose code. I will gladly read yourFiveWordVariableNames //and
//Multi
//Line
//CommentsIf it explains your code!
In that case you should love the code in this article.
You have to worry about spaces and tabs and what happens when they're mixed. I'm sure seasoned python devs have honed their whitespace skills so they rarely need to worry about this, but it's bullshit that I don't want to have to deal with.In (ObPedanticDickweed:most?) other languages, there is no ambiguity. It's either whitespace or it isn't.
You make a good point.
Honestly, I can live with that, it's unlikely to ever be a problem. In fact source control can handle that problem automatically anyway.
And tabs cause problems wherever they're used.
There's nothing pointless about it. Python adds ambiguity and makes it more difficult to format code however the fuck I want to see it.
What do you mean by it "adds ambiguity"?
I forgot to ask about Python. How does python fare in all this?
Python seems to be rare here, so you probably won't get many responses. But I will say that I use Python and I can't think of any problems with it. Although that's Python 3 I'm talking about.
Aaawwwww.
No one got to see my masterpiece.
Well. It was fun while it lasted.
I think that bubble should probably have the word sexy in it somewhere.someone make it happen.
What should I change the text to? "I agree with whatever the sexy morbs just said"?
Does the quality of the standard libraries count or is it just the language itself?
I just wanted to point out that thanks to this topic, four people from today’s article have been adopted into the SEXY family.
"I'm kind of surprised to see these kinds of positive ratings for soundtracks that may or may not exist," writes Bobby S. SEXY
"Well, I guess it's a fair to block your shutdown so that the logoff
tune of the Microsoft Logoff Composing Team can be given its due
respect," writes Jens R.
SEXY
"While visiting the UPS Store I saw this clever message encouraging me to sign up for their email newsletter," writes James.
SEXY
"Ok, sure 'so what, it's an error', but you have to admit - a 283 million line JSP page is pretty impressive," wrote Scott S.
SEXY
Non-forumers are so going to say WTF! when they see this.
oh, they don't yet.I guess they will soon?
From what I can tell, the front page is cached, but is periodically refreshed. So yeah, soon.
You do realize that when people read the Nulltastic article later they'll see all those "WTF"s, right?
Nice find. Not sure it's a WTF, though. I'm not entirely clear on why do they have to load everything dynamically, but if they do, this seems like a clever way to do it.
Maybe, maybe not. However, this comment:
Those devious code hackers ;) . I hope they documented it well, before some smart guy deleted it 'since it has no use'. – Patrick Hofman
Points out a real problem with it.
I think a better way to handle it would be to put it in a javascript variable.
Beisdes, the processRaw
function was what I was focusing on.
<img src="/uploads/default/5967/07da38cb653ffe6e.png" width="197" height="97">
Nice.
Wait, that makes no sense. I though this XSS hole was already fixed. Or maybe it only works for <noscript>? That would be TRWTF...
Oh cool. Let's see what I can do. Any suggestions?
Someone found a <script> inside of a <noscript> tag.
<!-- Page is at: http://squarespace.com -->
...
...
<noscript id="inline-deps">
<link rel="stylesheet" type="text/css" href="//cloud.typography.com/7811972/758964/css/fonts.css" />
<script type="text/javascript" src="https://static.squarespace.com/static/ta/5134cbefe4b0c6fb04df8065/7400/assets/logomark/logomark.min.js?37"></script>
<link rel="stylesheet" href="https://static.squarespace.com/static/ta/5134cbefe4b0c6fb04df8065/7400/assets/logomark/logomark.min.css?37" type="text/css" />
</noscript>
...
...
So now you're probably thinking: "WTF! That script tag will never execute. Nice find Zacy, you're the best. Also we don't mind that you keep copying WTFs from StackExchange sites." But it gets worse.
Here's the top answer: (TL;DR comment below it.)
I did some searching through their code and found this snippet:
var DepLoader = function() {
function init() {
var a = document.getElementById("inline-deps");
if (!a || JS.hasClass(document.body, "deps--loaded"))
webfontsReady();
else {
var b = a.innerText || a.textContent;
JS.addClass(document.body, "deps--loaded"), processRaw(b)
}
}
function isListed(a, b) {
for (var c = !1, d = 0; d < b.length; d++)
if (-1 !== a.indexOf(b[d])) {
c = !0;
break
}
return c
}
function webfontsReady() {
JS.fireCustom("webfontsReady")
}
function processRaw(html) {
var el = document.createElement("div");
el.innerHTML = html;
for (var scripts = el.querySelectorAll("script"), styles = el.querySelectorAll("link"), common, signup, dialog, systemPage, commerce, others = [], inline = [], styleWhiteList = ["site.css", "dialog-", "signup-", "logomark"], scriptBlackList = ["management-", "ckeditor-"], style, l = 0; l < styles.length; l++)
style = styles[l], -1 !== style.href.indexOf("fonts.css") && load(style, webfontsReady), isListed(style.href, styleWhiteList) && load(style);
for (var script, src, s = 0; s < scripts.length; s++)
script = scripts[s], src = script.src, src || "dynamic-assets-loader" == script.getAttribute("data-sqs-type") || -1 === script.innerHTML.indexOf("SQUARESPACE_ROLLUPS") || eval(script.innerHTML);
if (window.SQUARESPACE_ROLLUPS)
for (var key in SQUARESPACE_ROLLUPS) {
var rollup = SQUARESPACE_ROLLUPS[key], js = rollup.js, css = rollup.css;
-1 !== key.indexOf("common") ? common = js : -1 !== key.indexOf("commerce") ? commerce = js : -1 !== key.indexOf("signup") ? signup = js : -1 !== key.indexOf("dialog") ? dialog = js : -1 !== key.indexOf("system-page") ? systemPage = js : key ? others = others.concat(js) : inline = inline.concat(js)
}
for (var s = 0; s < scripts.length; s++)
script = scripts[s], src = script.src, isListed(src, scriptBlackList) || (-1 !== src.indexOf("common-") ? common = script : -1 !== src.indexOf("commerce-") ? commerce = script : -1 !== src.indexOf("signup-") ? signup = script : -1 !== src.indexOf("dialog-") ? dialog = script : -1 !== src.indexOf("system-page-") ? systemPage = script : src ? others.push(script) : inline.push(script));
var loadOthers = function() {
for (var a = 0; a < inline.length; a++)
"dynamic-assets-loader" != inline[a].getAttribute("data-sqs-type") && load(inline[a]);
for (var b = 0; b < others.length; b++)
load(others[b]);
JS.fireCustom("dependenciesLoaded")
}, loadSystemPage = load.bind(this, systemPage, loadOthers, "system page"), loadSignup = load.bind(this, signup, loadSystemPage, "signup"), loadCommerce = load.bind(this, commerce, loadSignup, "commerce"), loadDialog = load.bind(this, dialog, loadCommerce, "dialog"), loadCommon = load.bind(this, common, loadDialog, "common");
loadCommon()
}
function load(tag, callback, label) {
var head = document.head;
if (Array.isArray(tag) && (tag = {nodeName: "SCRIPT",src: tag[0]}), !tag)
return void (callback && callback());
if (tag && (tag.src || tag.href)) {
var child;
"SCRIPT" === tag.nodeName ? (child = document.createElement("script"), child.src = tag.src, -1 !== child.src.indexOf("combo") && (callback = function() {
Y.Squarespace.FrontSite.Core.domReady(!0)
})) : "LINK" === tag.nodeName && "stylesheet" === tag.rel && (child = document.createElement("link"), child.href = tag.href, child.rel = "stylesheet", child.tyle = "text/css"), child && (child.onload = callback, head.appendChild(child))
} else
try {
eval(tag.innerHTML)
} catch (e) {
}
}
return {init: init,webfontsReady: webfontsReady}
}()
As you can see, the <noscript> tag has the ID #inline-deps, which is referenced in the code (line 3) to load dependencies asynchronously and on-demand.
>
> They probably use a <noscript> element as it
allows them to directly access DOM elements, instead of having to place
it in a string or a comment (which I consider particularly bad, as
comments are not meant for actual information) and then parse it. It
also prevents the execution of scripts and CSS styles until specifically
loaded.
>
I personally find this an abuse of the <noscript>
tag. I'm not even sure if it's valid HTML5 code. Using other methods
such as declaring dependencies in a JavaScript object with a script
loader should be used where practicable.
TL;DR comment:
> the whole thing is a bit complicated but
basically it checks that it needs to load scripts and/or stylesheets,
then gets them from the <noscript> element to be executed.
…Wow. That processRaw function…
I'm going to list the WTFs I spotted, but first the obligatory javascript "expert" who has just added this to his bag of job security tricks.
> That's a pretty nifty trick using `<noscript>` to store DOM elements, I must say. And a +1 and an accepted answer to you for diving into their minified JS before me and figuring it out! – Agent.Logic_
Agent.Logic_ is the guy who asked the question.
Also, cartman82:
@cartman82 <a href="/t/via-quote/2640/6">said</a>:<blockquote>Nice find. Not sure it's a WTF, though. I'm not entirely clear on why do they have to load everything dynamically, but if they do, this seems like a clever way to do it.</blockquote>
And now the WTFs:
- Creating a long list of variables in the for statement.
- Not using most of those variables in that for loop. (They're used later in the function.)
- Abusing the `,` and `&&` operators instead of just using braces. (I didn't know javascript could do that too.)
- Abusing the [conditional operator](http://thedailywtf.com/Articles/One-Bad-Ternary-Operator-Deserves-Another.aspx).
Edit: Dammit! Posted it early by accident.
Real programmers use cat >file <<EOF
.
Python did it the wrong way. After 8 years, they still have effectively zero Python 3 adoption.
The way forward is to make a new language with the best ideas, and slooooooowly migrate people to it.
Doesn't that second statement contradict the first? Breaking backwards compatibility is sort-of like making a new language, and the slowly migrating part fits as well.
Or that.....
I only know brainfuck, how am I supposed to know all the exotic languages?
There's a short list on the Wikipedia page.
Also see Esolang, the esoteric programming languages wiki.
By the way, I did not notice before, but the password reset form is only requiring a username, instead of the somewhat standard practice of using the email address (or both the username and email address). That makes sending spurious password resets a bit too easy IMO.
I never actually seen this so called standard practice. But then again, I never forget my password.
Okay so I know you're all dying to know how Fabrikam's toaster keyboard works.
You punch holes in slices of toast and insert them into the toaster. The toaster them uses them to determine whether the bits are set or not. The toaster keyboard supports 24 bits per slice. (bps)
It's an enterprise solution for upcoming businesses.
It's guaranteed to give your company synergy thingys.
This feels oddly familiar...
Well a least it isn't 1000 posts deep within a topic anymore.
You all seemed to enjoy my last StackOverflow post. (Until you started complaining that StackOverflow was cool before it went mainstream or something like that.) So I thought I'd share another one I just found.
This time it's from superuser, so you have no reason to complain about SO this time.
I've inherited an old PC from my girlfriend's dad and when setting up the printer I got a bit of a surprise:
Two questions spring to mind here:
Here's the top answer:
Reason 1
Because Microsoft made a toaster driver sample. In the sample there is the line <DeviceIconFile>Toaster.ico</DeviceIconFile> and there is a chance that your keyboard manufacturer took that sample.
Reason 2
Look at the back of the keyboard for some place to insert a slice of bread…
Siri, can you lead me to the nearest café?
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in
what? ketchup. The dove fly. Fly is in sky. The dove drop something. The
something on the pig. The pig disgusting. The pig rattle. Rattle with
dove. The dove angry. The pig leave. The dove produce. Produce is
chicken wing. With wing bark. No Quack.
…Thank you, Siri.
No one who has the capacity to makes decisions for themselves uses notepad.exe.
You'd think they could find a happier stock photo for their "demo"
I think that person has a Klingon forehead.
iPhones are such a technical debacle it's embarrassing. I know, let's tack a later of proprietary bullshit on top of the SMS protocol built specifically so that this would not be a problem! Let's fuck up the vcf formatting! (to be fair, everyone fucks up vcf though)Then you get all these kids praising Jobs like he's some sort of Technological Jesus, while they go and establish their startup to go and fuck up established standards even more.
I bet iPhone users think the book of Job is about Steve Jobs.
Seriously guys? 73 of you didn't know about that? And cared enough to click that link?!‽
Maybe it was just one person who clicked the link 73 times.
Wow.Though I suppose theoretically he could be right that while(1) IS faster than while(2), but only because while(1) MIGHT on some compilers be compiled to while(true) and either one could be optimized by the compiler directly for performance (where while(2) isn't because they aren't addressing that level of knuckleheadity)
But... That's an incredible stretch, even for stack overflow.
Good find.
Well the top answer on SO proofs that, on a practical level, there is no difference because it is compiled to an unconditional loop. Even with optimization turned off.
Although I don't know if MSCC also does that.
Here's an interesting tale from the interview at StackOverflow.
Since going to StackOverflow will no doubt trigger someone's PTSD, I'll post it here.
Interviewer: Which is faster?
while(1) {
// some code
}
or
while(2) {
//some code
}
Nikole: Both have the same execution speed, as the expression inside
while
should finally evaluate totrue
orfalse
. In this case, both evaluate to true and there are no extra conditional instructions inside the while condition . So, both will have the same speed of execution and I preferwhile (1)
.
Interviewer: Check your basics.
while(1)
is faster thanwhile(2)
.
I have no idea what "basics" he could be refering to.