Comment On RePLaCeD

Varg's colleague had an awfully difficult problem challenge to solve: remove the language parameter ("lang") from a query string. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: RePLaCeD

2010-07-07 09:01 • by Karel (unregistered)
Or other languages for that matter

Re: RePLaCeD

2010-07-07 09:04 • by SR (unregistered)
MyComment = Replace(MyComment, "FRIST", "")

frist

Re: RePLaCeD

2010-07-07 09:04 • by akatherder
313832 in reply to 313830
Karel:
Or other languages for that matter


The spec only asked to strip the Greek and English languages. lang=FR is fine, as is LANG=fR.

It really seems like there should be a regular way to express this without hardcoding all the different possibilities. Oh well.

Re: RePLaCeD

2010-07-07 09:04 • by no it isn't (unregistered)
lAng=frist

this is still funny right?

Re: RePLaCeD

2010-07-07 09:07 • by Someone You Know
Better hope you never get a URL where the lang parameter is the first of several parameters.

Re: RePLaCeD

2010-07-07 09:08 • by Ymgve (unregistered)
I love how the second section of replaces will break any query string by removing the vital "?" mark.

Re: RePLaCeD

2010-07-07 09:14 • by SoaperGEM (unregistered)
313836 in reply to 313833
no it isn't:
lAng=frist

this is still funny right?


No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Re: RePLaCeD

2010-07-07 09:15 • by Me (unregistered)
I sense some EN-Gr in his co-worker...

Re: RePLaCeD

2010-07-07 09:18 • by Markp
Varg aurait dû être inquiets que la solution ne fonctionne pas ... Que? Je ne peux pas parler Anglais. Quelle domage!

Re: RePLaCeD

2010-07-07 09:20 • by Philip Newton (unregistered)
313839 in reply to 313832
akatherder:
The spec only asked to strip the Greek and English languages.

Then it didn't do a very good job, since Greek is "el". ("gr" isn't registered as a language tag at all, at least not with IANA: http://www.iana.org/assignments/language-subtag-registry )

Also, it should have replaced the "?lang=xx" forms with "?" if a "&" followed, otherwise "bla.php?lang=en&img=true" would turn into "bla.php&img=true" which wouldn't du what it was supposed to.

Re: RePLaCeD

2010-07-07 09:22 • by getofmymetriclawn (unregistered)
313840 in reply to 313836
SoaperGEM:

No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Yes, but by also using the "reusing the WTF-pattern in the article with some meta-reference to the comment" meme, he is beating one dead horse with another dead horse, which could, in theory, still be funny.

Re: RePLaCeD

2010-07-07 09:24 • by Anonymous (unregistered)
Brute force string replace - now that's a classic WTF. A bit boring, but classic nonetheless.

Re: RePLaCeD

2010-07-07 09:27 • by Anonymous (unregistered)
313842 in reply to 313840
getofmymetriclawn:
SoaperGEM:

No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Yes, but by also using the "reusing the WTF-pattern in the article with some meta-reference to the comment" meme, he is beating one dead horse with another dead horse, which could, in theory, still be funny.

Eh, maybe. If he was beating a dead horse with a dead horse whilst riding a dead horse over a pile of dead horses, that would be funny.

Re: VB.NET

2010-07-07 09:30 • by Ralph (unregistered)
That looks like some perfectly normal VB to me. Yes it would be atrocious in other languages, but again, perfectly fine VB!

Re: RePLaCeD

2010-07-07 09:32 • by Yo dawg (unregistered)
313844 in reply to 313842
Anonymous:
If he was beating a dead horse with a dead horse whilst riding a dead horse over a pile of dead horses, that would be funny.
So he can beat a dead horse while he beats a dead horse?

Re: RePLaCeD

2010-07-07 09:32 • by Stacy (unregistered)
313845 in reply to 313842
Anonymous:
getofmymetriclawn:
SoaperGEM:

No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Yes, but by also using the "reusing the WTF-pattern in the article with some meta-reference to the comment" meme, he is beating one dead horse with another dead horse, which could, in theory, still be funny.

Eh, maybe. If he was beating a dead horse with a dead horse whilst riding a dead horse over a pile of dead horses, that would be funny.


I dunno... I think once you have more than 3 dead horses it becomes less funny and more sad.

Re: VB.NET

2010-07-07 09:34 • by Drew (unregistered)
313846 in reply to 313843
Ralph:
That looks like some perfectly normal VB to me. Yes it would be atrocious in other languages, but again, perfectly fine VB!


Boooo...

Re: RePLaCeD

2010-07-07 09:34 • by Knux2 (unregistered)
I would love to see how he would handle "Replace any 6 digit numbers with their hexadecimal equivalents."

MyPage = Replace(MyPage, "000000", "00000")
MyPage = Replace(MyPage, "000001", "00001")
MyPage = Replace(MyPage, "000002", "00002")
MyPage = Replace(MyPage, "000003", "00003")
MyPage = Replace(MyPage, "000004", "00004")

...

MyPage = Replace(MyPage, "999999", "F423F")

Re: RePLaCeD

2010-07-07 09:44 • by DonaldK (unregistered)
313849 in reply to 313847
Knux2:

MyPage = Replace(MyPage, "000003", "00003")
MyPage = Replace(MyPage, "000004", "00004")
...

MyPage = Replace(MyPage, "999999", "F423F")


Avoid the common caveat of not uppercasing the strings ... because if "999999" translates to "F423F", then surely uppercase("999999") should also translate to "F423F". And just for good measure do a lowercase("999999") as well...

Unless you're supposed to return "f423f" ... or "f423F" ...

Hmmmm

Re: RePLaCeD

2010-07-07 09:46 • by frits
You have to love how VB.Net has its own special namespace with slightly different implementations of already available string methods.

Re: RePLaCeD

2010-07-07 09:52 • by A Tester (unregistered)
Acarily I actually came quite close to writing this today, seeing as I can't be bothered to learn .NET regexes.

My solution is as follows, where I want to replace the value of the parameter:

string urlTemplate;
string quantParam = "quantity=" + quantity;
int quantIndex = url.IndexOf(quantParam, StringComparison.OrdinalIgnoreCase);
if (quantIndex == -1)
{
urlTemplate = url + "&Quantity={0}";
}
else
{
string actualQuantParam = url.Substring(quantIndex, quantParam.Length);
urlTemplate = url.Replace(actualQuantParam, "Quantity={0}");
}

Re: RePLaCeD

2010-07-07 09:54 • by JamesQMurphy
It's a shame they weren't using TDD. It might be fun to keep adding an additional failing case once a day, assuming Varg's colleague had to keep fixing it. (And who knows, after a few months, the colleague might actually fix it correctly.)

Re: RePLaCeD

2010-07-07 09:54 • by Bobbo (unregistered)
313853 in reply to 313847
Knux2:

I would love to see how he would handle "Replace any 6 digit numbers with their hexadecimal equivalents."


I get asked to do this literally ALL the time.

Re: RePLaCeD

2010-07-07 09:56 • by anonymous coward (unregistered)
313854 in reply to 313853
Bobbo:
Knux2:

I would love to see how he would handle "Replace any 6 digit numbers with their hexadecimal equivalents."


I get asked to do this literally ALL the time.


Why? Didn't you do it right the first time?

Re: RePLaCeD

2010-07-07 10:00 • by akatherder
313855 in reply to 313839
Philip Newton:
akatherder:
The spec only asked to strip the Greek and English languages.

Then it didn't do a very good job, since Greek is "el". ("gr" isn't registered as a language tag at all, at least not with IANA: http://www.iana.org/assignments/language-subtag-registry )

Also, it should have replaced the "?lang=xx" forms with "?" if a "&" followed, otherwise "bla.php?lang=en&img=true" would turn into "bla.php&img=true" which wouldn't du what it was supposed to.


No, GR is greek and SP is Spanish! You might think that because they suck at regular expressions, they are resourceful enough to get the correct language abbreviations. It seems the incompetence is uniform throughout all facets though.

Re: RePLaCeD

2010-07-07 10:02 • by Buddy (unregistered)
313856 in reply to 313840
getofmymetriclawn:
SoaperGEM:

No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Yes, but by also using the "reusing the WTF-pattern in the article with some meta-reference to the comment" meme, he is beating one dead horse with another dead horse, which could, in theory, still be funny.

Kind of grotesque image, that - beating a dead horse with another dead horse.

I guess one dead horse would have to be very small so it could be wielded as an instrument to beat the other dead horse. Like one of those miniature horses, which is still classified as a horse and not a pony. It would have to be quite fresh too, and not too decomposed, otherwise it would fall apart early during the beating process. The other horse can be any size and level of decomposition, so there's a bit of leeway there.

Even then, typically in the IT industry one doesn't find that many dead horses lying around. In my career, the closest I could have ever gotten to this is beating a dead pigeon with a dead fish, or vice versa.

Re: RePLaCeD

2010-07-07 10:03 • by savar
This is an instantly fire-able offense.

Re: RePLaCeD

2010-07-07 10:04 • by Helix
TRWTF is being called Varg and no varg jokes yet

Re: RePLaCeD

2010-07-07 10:06 • by SR (unregistered)
313860 in reply to 313854
anonymous coward:
Bobbo:
Knux2:

I would love to see how he would handle "Replace any 6 digit numbers with their hexadecimal equivalents."


I get asked to do this literally ALL the time.


Why? Didn't you do it right the first time?


Using the brute force method he could still be doing it for the first time. I hope your boss is relaxed about deadlines, Bobbo1

Re: RePLaCeD

2010-07-07 10:08 • by dave (unregistered)
313861 in reply to 313851
A Tester:
Acarily I actually came quite close to writing this today, seeing as I can't be bothered to learn .NET regexes.


The source of many a good WTF. Looking forwards to seeing yours!

Re: RePLaCeD

2010-07-07 10:12 • by Also Anonymous (unregistered)
313862 in reply to 313841
Anonymous:
Brute force string replace - now that's a clbuttic WTF. A bit boring, but clbuttic nonetheless.


FTFY

Re: RePLaCeD

2010-07-07 10:14 • by m a t t
313863 in reply to 313857
savar:
This is an instantly fire-able offense.

What? Beating dead animals with other dead animals?

Re: RePLaCeD

2010-07-07 10:16 • by GalacticCowboy
313864 in reply to 313832
akatherder:

It really seems like there should be a regular way to express this without hardcoding all the different possibilities. Oh well.


QFTFY

Re: RePLaCeD

2010-07-07 10:16 • by DOA
"We've just added 3 more languages to our webpage and we need you to tidy up a bit the code your predecessor left. Huh, what's a front controller? Why would we do that, we just copy-paste the code to every page, it's simple. Anyway, get started, this shouldn't take you more than an hour"

Re: RePLaCeD

2010-07-07 10:20 • by Anonymous (unregistered)
A bonus meta-WTF:
We are currently narrating this post.

Can't wait to hear that...

"My page equals replace open bracket my page comma double quote and lang equals E N double quote comma double quote double quote close bracket"

"My page equals replace open bracket my page comma double quote and lang equals G R double quote comma double quote double quote close bracket"

...

Re: RePLaCeD

2010-07-07 10:30 • by Arantor (unregistered)
FFS.

This is the 21st Century. We're even a decade in.

Are there really any sensible languages that DON'T have regular expression support?



Oh wait. You said VB, right? :P

Re: RePLaCeD

2010-07-07 10:35 • by THG (unregistered)
313870 in reply to 313856
Buddy:
getofmymetriclawn:
SoaperGEM:

No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Yes, but by also using the "reusing the WTF-pattern in the article with some meta-reference to the comment" meme, he is beating one dead horse with another dead horse, which could, in theory, still be funny.

Kind of grotesque image, that - beating a dead horse with another dead horse. [ ... snip ... ] . In my career, the closest I could have ever gotten to this is beating a dead pigeon with a dead fish, or vice versa.


on an embedded system with no file-system, only Irish Girl can mix metaphors with memes

Re: RePLaCeD

2010-07-07 10:38 • by Izhido (unregistered)
Hmm... I see your point in here, people. Correct me if I'm wrong here, but TRWTF here is that, instead of manually generating all possible cases for the replaces... he should have used a CASE tool to generate all that code, that automatically considers all poosible cases for him... right?

Re: RePLaCeD

2010-07-07 10:48 • by Mcoder
313872 in reply to 313861
dave:
A Tester:
Acarily I actually came quite close to writing this today, seeing as I can't be bothered to learn .NET regexes.


The source of many a good WTF. Looking forwards to seeing yours!


To be fair, learning regexes is also a source of many good WTFs.

Re: RePLaCeD

2010-07-07 10:50 • by Spoe (unregistered)
313873 in reply to 313855
akatherder:
No, GR is greek and SP is Spanish! You might think that because they suck at regular expressions, they are resourceful enough to get the correct language abbreviations. It seems the incompetence is uniform throughout all facets though.


HTML 4 is speced (and carries over, in essence, to XHTML and HTML5) to use RFC 1766 for languages, however. RFC1766 specifies using ISO 639 two letter codes which, indeed, are "el" for Greek and "es" for Spanish.

http://www.ietf.org/rfc/rfc1766.txt
In the primary language tag:

- All 2-letter tags are interpreted according to ISO standard 639, "Code for the representation of names of languages" [ISO 639].

- The value "i" is reserved for IANA-defined registrations

- The value "x" is reserved for private use. Subtags of "x" will not be registered by the IANA.

- Other values cannot be assigned except by updating this standard.


This is carried over in RFC 3066, which specifies the ISO 639-1 interpretation for two letter codes and ISO 639-2 for three letter codes. This adds "gre" and "ell" for modern Greek (for bibliographic and terminology purposes) and "SPA" for Spanish.

Re: RePLaCeD

2010-07-07 10:53 • by ubersoldat
313874 in reply to 313871
Izhido:
Hmm... I see your point in here, people. Correct me if I'm wrong here, but TRWTF here is that, instead of manually generating all possible cases for the replaces... he should have used a CASE tool to generate all that code, that automatically considers all poosible cases for him... right?


No, TRWTF is that he didn't write a .bat (batch?) file to generate the different cases automatically from an Excel spreadshit.

Re: RePLaCeD

2010-07-07 11:09 • by Mason Wheeler
Bah. I'm not impressed. Lyle could have come up with twice as many Replace permutations, in the same amount of time!

Re: RePLaCeD

2010-07-07 11:10 • by Mike (unregistered)
313876 in reply to 313854
anonymous coward:
Bobbo:
Knux2:

I would love to see how he would handle "Replace any 6 digit numbers with their hexadecimal equivalents."


I get asked to do this literally ALL the time.


Why? Didn't you do it right the first time?


+1 sir

Re: RePLaCeD

2010-07-07 11:13 • by PITA (unregistered)
313877 in reply to 313836
SoaperGEM:
no it isn't:
lAng=frist

this is still funny right?


No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.

Something, something, dead horse.

Re: RePLaCeD

2010-07-07 11:17 • by vovo (unregistered)
313878 in reply to 313863
m a t t:
savar:
This is an instantly fire-able offense.

What? Beating dead animals with other dead animals?


Why are we beating a dead horse with another dead horse? Let's start beating the guy beating the dead horse with another dead horse.

Re: RePLaCeD

2010-07-07 11:21 • by Anonymous (unregistered)
313879 in reply to 313851
Why not just convert the query string to all lower (or upper) case and then just remove the "lang=el" part of it?

Re: VB.NET

2010-07-07 11:26 • by RandomUser423692 (unregistered)
313880 in reply to 313843
Ralph:
That looks like some perfectly normal VB to me. Yes it would be atrocious in other languages, but again, perfectly fine VB!
No, this is pathetic VB, also.

Err...wait. You're a troll, aren't you? Blast!

Re: RePLaCeD

2010-07-07 11:36 • by Ubermensche (unregistered)
313881 in reply to 313833
no it isn't:
lAng=frist

this is still funny right?


Not relaly, lAng=Fritz is funnier.

Only though if you're in Metropolis.

CAPTCHA=enim : Not quite a rap star. Yet.

Re: RePLaCeD

2010-07-07 11:36 • by frits
313882 in reply to 313879
Anonymous:
Why not just convert the query string to all lower (or upper) case and then just remove the "lang=el" part of it?


How would you put it back to its previous capitalization? ;)

Re: RePLaCeD

2010-07-07 11:40 • by re:me (unregistered)
313884 in reply to 313836
SoaperGEM:
no it isn't:
lAng=frist

this is still funny right?


No. "Frist" was never funny to begin with. It's just beating a dead horse. A very, very, very dead horse.


Perhaps you didn't notice the name of the poster?
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment