Catch and release is common among sport fishers, why shouldn't it be among coders?
eBusiness
@eBusiness
Best posts made by eBusiness
Latest posts made by eBusiness
-
RE: Why yes, yes I am.
-
RE: JavaScript translation - BTW or WTF?
One can multiclass: class="text6438 romanstyle toosmallfortheaveragesighted" (and indeed I already use that feature).
I used a translation method for the title and button texts, since that saved me the trouble of marking them. For the HTML text it's not so easy, since the readout of innerHTML is not consistent across browsers.
-
RE: Why yes, yes I am.
@dogbrags said:
3) Someone who don't know a lot about programming, yet make decisions about programming, decided that all exceptions must be caught.Normally, you catch exceptions for one of two reasons;
1) logging the exception at the point of occurrance; and then you propigate it (rethrow it) so that the correct handler further up the chain can handle it
2) if you can handle the exception at that point and recover from the error
If you can't do either one, then there is no point in catching it. So don't bother; assume that somewhere up the chain is a handler for it. For out of memory exception, it's likely that the program can't continue anyway.
-
RE: I hope no one can guess the password.
Checkbox security (and ignorance) is a bliss!
-
RE: I hope no one can guess the password.
Obviously they have to setup the passwords before you can get them, that is probably what's taking the time.
-
RE: JavaScript translation - BTW or WTF?
@toth said:
That looks like absolute hell to maintain. "text0001"?
I left the original text in the HTML so it doesn't stand only as a dumb identifier, though it will be overwritten in all cases. That said, I haven't "maintained" this part of the application yet. -
RE: JavaScript translation - BTW or WTF?
@immibis said:
Definitely a WTF, because now you need JavaScript enabled to view the page in any other language. (Did you mean FTW instead of BTW in the title?)
Well, it's a full blown JavaScript application, it doesn't do anything useful without JavaScript enabled anyway. Only problem is that it's kinda hard translating the "You need JavaScript enabled"-message in this manner. (BTW - Better than win - The logical opposite of "Worse than failure") -
JavaScript translation - BTW or WTF?
Years ago I got a job writing a small HTML/JavaScript application, since then it has through added features grown to pretty big HTML/JavaScript application (150 kB in one file). The latest requested feature was translating the program. While I don't recall stuffing the program full of text, it turns out there is actually quite a lot of it, with no translation-friendly organisation. Not wanting to branch the application into different language version, or do any more work than necessary for that matter, I came up with an ingenious solution: Use JavaScript to edit the document when it's loaded in the users browser.
First add some markings to identify plain text for translation:<span class="text0001">Plain text</span>
Then write a script that packs all the text nicely into a JavaScript Object (export by copy pasting from Chromes JavaScript console):
all=document.getElementsByTagName("*")
dispout=""
matchtext=/[0-9]{4}/
strings=[ ]
titles={}
for(a=all.length-1;a;a--){
b=matchtext.exec(all[a].className)
if(b){
index=parseInt(b,10)
strings[index]=all[a].innerHTML
}
if(c=all[a].title){
titles[c]=c
}
if(all[a].type=="button"){
if(c=all[a].value){
titles[c]=c
}
}
}
jsonstring=JSON.stringify({"strings":strings,"titles":titles}).replace(/\n/g,"").replace(/<//g,"<\/").replace(/","/g,"",\n"")Then translate the lot and do the runtime magic:
all=document.getElementsByTagName("*")
dispout=""
matchtext=/[0-9]{4}/
for(a=all.length-1;a;a--){
b=matchtext.exec(all[a].className)
if(b){
index=parseInt(b,10)
all[a].innerHTML=clang.strings[index]
}
if(c=all[a].title){
d=clang.titles[c]
if(d){
all[a].title=d
}
}
if(all[a].type=="button"){
if(c=all[a].value){
d=clang.titles[c]
if(d){
all[a].value=d
}
}
}
}It works beautifully, I just ain't sure if I should be proud of it.
-
RE: What is this "Boolean logic" of which you speak?
It looks suspiciously like a strange way of writing [code]x != y[/code] , now the questions left are, is [code]!x.equalsTo(y)[/code] different from [code]x != y[/code] ? And in what cases will null make the sky fall down?
-
RE: When "read only" mode doesn't actually do anything and the system can be broken with four lines of code...
Cross Site Request Forgery, that has always been my favourite exploit. It's very easy to code against, but complex enough that most people don't get it, and thus continue to serve the holes en masse.