Click here to Skip to main content
15,887,214 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: How to convert minutes into milliseconds... Pin
OriginalGriff19-Mar-10 5:55
mveOriginalGriff19-Mar-10 5:55 
GeneralRe: How to convert minutes into milliseconds... Pin
supercat919-Mar-10 6:01
supercat919-Mar-10 6:01 
GeneralRe: How to convert minutes into milliseconds... Pin
Andrew Rissing19-Mar-10 7:08
Andrew Rissing19-Mar-10 7:08 
GeneralRe: How to convert minutes into milliseconds... Pin
PIEBALDconsult19-Mar-10 9:54
mvePIEBALDconsult19-Mar-10 9:54 
GeneralRe: How to convert minutes into milliseconds... Pin
Andrew Rissing19-Mar-10 10:38
Andrew Rissing19-Mar-10 10:38 
GeneralRe: How to convert minutes into milliseconds... Pin
Luc Pattyn19-Mar-10 11:09
sitebuilderLuc Pattyn19-Mar-10 11:09 
GeneralRe: How to convert minutes into milliseconds... Pin
Andrew Rissing19-Mar-10 11:40
Andrew Rissing19-Mar-10 11:40 
GeneralBrowser Support Check Pin
ghaberek9-Mar-10 10:21
ghaberek9-Mar-10 10:21 
One of our users was sent to a client's site to upload some work files for review. She got a message that said something like:
This website requires an HTML 4.0 compliant web browser with Javascript enabled. You are using a browser version that does not meet these requirements. It is recommended that you use either Internet Explorer versions 5.5/6.x/7.x, or Netscape version 7.x. Refer to your browser's online help for specific instructions to enable Javascript.

Yet we are using IE 7 with JavaScript enabled. So I went digging through their page to see what triggered that message and found this little gem:
function browserSupported()
{
    var agt=navigator.userAgent.toLowerCase();
    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var is_nav62up = (is_nav && (is_major >= 5) && (is_minor >=5) && (agt.indexOf("gecko")!=-1) );
    var is_ie   = (agt.indexOf("msie") != -1);
    var is_ie3  = (is_ie && (is_major < 4));
    var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
    var is_ie4up  = (is_ie  && (is_major >= 4));
    var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
    var is_ie55  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5")!=-1) );
    var is_ie55up  = (is_ie  && ((!is_ie3 && !is_ie4 && !is_ie5) || is_ie55));
    var is_ie6  = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.0")!=-1) );
    var is_ie6up  = (is_ie  && ((!is_ie3 && !is_ie4 && !is_ie5 && !is_ie55) || is_ie6));
    var is_opera = (agt.indexOf("opera") != -1);
    if (is_nav62up || is_ie55up || is_opera || is_ie6up || is_ie6)
    {
        return true;
    }
    return false;
}

Note the complete and utter lack of a check for "msie 7.0", let alone the horrible combination of and's and not's to set all those is_<browser> flags. D'Oh! | :doh:
-Greg

JokeRe: Browser Support Check Pin
chevu9-Mar-10 18:12
chevu9-Mar-10 18:12 
GeneralRe: Browser Support Check Pin
Chris Meech10-Mar-10 6:10
Chris Meech10-Mar-10 6:10 
GeneralHow to split a string the hard way (VB6) Pin
AaronM_NZ7-Mar-10 12:58
AaronM_NZ7-Mar-10 12:58 
GeneralRe: How to split a string the hard way (VB6) Pin
GibbleCH8-Mar-10 6:14
GibbleCH8-Mar-10 6:14 
GeneralRe: How to split a string the hard way (VB6) Pin
peterchen9-Mar-10 8:57
peterchen9-Mar-10 8:57 
GeneralRe: How to split a string the hard way (VB6) Pin
OriginalGriff9-Mar-10 9:25
mveOriginalGriff9-Mar-10 9:25 
GeneralRe: How to split a string the hard way (VB6) Pin
Stanciu Vlad9-Mar-10 10:30
Stanciu Vlad9-Mar-10 10:30 
GeneralRe: How to split a string the hard way (VB6) Pin
Paulo Zemek9-Mar-10 10:35
mvaPaulo Zemek9-Mar-10 10:35 
GeneralEver heard of casting? Pin
ArchimaX3-Mar-10 0:49
ArchimaX3-Mar-10 0:49 
GeneralRe: Ever heard of casting? [modified] Pin
OriginalGriff3-Mar-10 1:11
mveOriginalGriff3-Mar-10 1:11 
AnswerMessage Removed Pin
3-Mar-10 1:24
chevu3-Mar-10 1:24 
GeneralRe: Ever heard of casting? Pin
johannesnestler3-Mar-10 3:52
johannesnestler3-Mar-10 3:52 
GeneralRe: Ever heard of casting? [modified] Pin
chevu3-Mar-10 16:25
chevu3-Mar-10 16:25 
GeneralRe: Ever heard of casting? Pin
Luc Pattyn3-Mar-10 16:41
sitebuilderLuc Pattyn3-Mar-10 16:41 
GeneralRe: Ever heard of casting? Pin
johannesnestler4-Mar-10 22:54
johannesnestler4-Mar-10 22:54 
GeneralRe: Ever heard of casting? Pin
Luc Pattyn3-Mar-10 4:39
sitebuilderLuc Pattyn3-Mar-10 4:39 
GeneralRe: Ever heard of casting? Pin
harold aptroot3-Mar-10 7:11
harold aptroot3-Mar-10 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.