1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #14268

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    var a, vr, curq;
    function bgbuild(num1){document.write("<head><title>Річне тематичне оцінювання з астрономії</title><meta http-equiv=\"Content-Type\" content=\"text/html\" charset=unicode\"></head><body bgcolor=#8080ff><img src='library/bgrnd.jpg' height=100% width=100% style='z-index:",num1,";position:absolute;top:0;left:0;right:0;bottom:0'>")};
    function fio(){document.write("<form><input type=\"text\" name=\"pib\" style='z-index:4;position:relative;top:0;left:0;font:normal 15px Lucida Console;'>")};
    function capt(qustn){document.write("<div style='z-index:3;text-align:justify;position:absolute;top:30;left:30;font:normal 30px System;color:black'>",qustn,"</div>")};
    function fld(){document.write("<textarea name=answ rows=30 cols=90 style='z-index:4;position:absolute;top:160;left:30;font:normal 15px Lucida Console;'></textarea>")};
    function kg(qst){document.write("<input style=\"z-index:6;position:absolute;top:0;right:0\" type=\"button\" value=\"Наступне питання\" onclick=\"return q",qst,"()\">")};
    function registr(){document.write("<input type=\"button\" onclick=\"return crfol()\" value=\"Реєстрація\"></form>")};
    function cnctscr(){document.write("<script lang=\"Javascript\" src=\"library/cobuild.js\"></script>");};
    function svr(vr){var fs, b;
    fs = new ActiveXObject("Scripting.FileSystemObject");
    b = fs.OpenTextFile("C:\\variant.tmp", 2, true, true);
    b.write(vr);
    b.close();
    };
    function gvr(){var fs, b;
    fs = new ActiveXObject("Scripting.FileSystemObject");
    b = fs.OpenTextFile("C:\\variant.tmp", 1, true, true);
    vr = b.readall();
    b.close();
    };
    function start(){
    bgbuild(0);
    document.write("<div style='z-index:1;position:absolute;top:30;left:30;right:30;font:normal 25px System;color:black;text-align:justify'>Ви маєте можливість пройти річне тематичне оцінювання з астрономії. Буде запропоновано 6 варіантів по 15 питань різної складності кожний. Ваші відповіді перевіряє вчитель, але приблизно оцінити себе Ви можете самі, ознайомившись після проходження опитування із правильною відповіддю і оцінивши вірність своєї відповіді. Не намагайтесь втрутитись у хід опитування і підкорегувати свої відповіді, адже це може скінчитися порушенням ходу програми, яке призведе до її неповного проходження, а в результаті - нижчої оцінки. Файл із Вашою відповіддю збережеться у спеціальному місці.<br>Для початку введіть своє прізвище та ім'я (не використовуйте ніяких спецсимволів!):<br>");
    fio();
    registr();
    document.write("<br>Оберіть варіант:<br><table><tr><td><form><input type='button' value='1' onclick='svr(1);return q1()'></td><td><input type='button' onclick='svr(2);return q1()' value='2'></td><td><input type='button' onclick='svr(3);return q1()' value='3'></td><td><input type='button' onclick='svr(4);return q1()' value='4'></td><td><input type='button' onclick='svr(5);return q1()' value='5'></td><td><input type='button' onclick='svr(6);return q1()' value='6'></td></form></div>");};
    function crfol(){var fs, n, b;
    fs = new ActiveXObject("Scripting.FileSystemObject");
    n = document.all.pib.value;
    if(n==""){er()};
    nm = "answ/"+n+".dat";
    a = fs.OpenTextFile(nm, 2, true, true);
    a.writeline("Це не підробка, це справжній файл із відповідями!\rУчень: "+n+"\rВаріант: ");
    a.close();
    b = fs.OpenTextFile("C:\\username.tmp", 2, true, true);
    b.write(n);
    b.close();
    }
    function crf(dt){var fs, n, b, nm;
    fs = new ActiveXObject("Scripting.FileSystemObject");
    b = fs.OpenTextFile("C:\\username.tmp", 1, true, true);
    n = b.readall();
    b.close();
    nm = "answ/"+n+".dat";
    a = fs.OpenTextFile(nm, 8, true, true);
    a.writeline(dt);
    a.close();
    }
    function er(){alert("Ану не балуйся! Думаєш, ти розумніше за комп'ютер?!");window.close();}
    function q1(){
    try{
    gvr();
    crf(vr);
    bgbuild(0);
    cnctscr();
    };catch(e){er()};
    if (vr=="1"){curq = "1.1.1. Що вивчає астрономія?"};
    if (vr=="2"){curq = "1.1.2. Що означає слово \"астрономія\"?"};
    if (vr=="3"){curq = "1.1.9. Що таке астрологія?"};
    if (vr=="4"){curq = "1.1.12. Назвіть прізвища відомих вам астрономів минулих часів."};
    if (vr=="5"){curq = "1.1.13. Назвіть небесні тіла, що утворюють Сонячну систему."};
    if (vr=="6"){curq = "2.1.1. Що означає слово \"космос\"?"};
    capt(curq);
    crf(curq);
    fld();
    
    kg(2);
    }
    
    start();

    Короче, первый мой более-менее крупный высер на JS. Писал HTA-приложение для школы (тестирование по астрономии). Интернета у меня тогда ещё не было, компилятор чего-либо нормального взять, соответственно, было негде, поэтому писал на чём можно. JS (точнее, JScript) изучал по справке MSE7 (недо-IDE, которая поставляется с M$Office). Результат немного предсказуем, многие части кода - модифицированные примеры тамошние. Вбрасываю основную либу (там ещё дополнительная, с вхардкоженными вопросами и несколькими функциями, и HTA-оболочка). Остальное будет по просьбам:3

    //Я в этот код даже не заглядываю, боюсь суицидальных приступов от осознания того, что я это написал *HEADBANG*

    MiniRoboDancer, 24 Декабря 2013

    Комментарии (12)
  3. PHP / Говнокод #14240

    +119

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Well, there were other factors in play there. htmlspecialchars was a
    very early function. Back when PHP had less than 100 functions and the
    function hashing mechanism was strlen(). In order to get a nice hash
    distribution of function names across the various function name lengths
    names were picked specifically to make them fit into a specific length
    bucket. This was circa late 1994 when PHP was a tool just for my own
    personal use and I wasn't too worried about not being able to remember
    the few function names.
    
    -Rasmus

    http://news.php.net/php.internals/70691

    someone, 17 Декабря 2013

    Комментарии (12)
  4. Java / Говнокод #14208

    +78

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    private int compareDates(java.sql.Date date1, java.sql.Date date2) {
    
    if (date1.getYear() < date2.getYear())
    return 1;
    
    if (date1.getYear() > date2.getYear())
    return -1;
     
    if (date1.getMonth() < date2.getMonth())
    return 1;
    
    if (date1.getMonth() > date2.getMonth())
    return -1;
     
    if (date1.getDate() < date2.getDate())
    return 1;
    
    if (date1.getDate() > date2.getDate())
    return -1;
     
    return 0;
    }

    Сравнение двух дат

    iboken, 10 Декабря 2013

    Комментарии (12)
  5. PHP / Говнокод #14185

    +159

    1. 1
    $safedatasry = str_replace ('', '', $safedatasry);

    psycho-coder, 06 Декабря 2013

    Комментарии (12)
  6. Куча / Говнокод #14181

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video {
        margin:0;
        padding:0;
        border:0;
        font-size:1em;
        font-family:'Helvetica','Arial',sans-serif;
        vertical-align:baseline
    }

    invision70, 05 Декабря 2013

    Комментарии (12)
  7. Куча / Говнокод #13979

    +64

    1. 1
    2. 2
    Я МОГ БЫ НАКАЛДАВАТЬ СИБЕ ЛАЙКАВ НО МНЕ ЗАПРИЩИНО ИСПОЛЬЗЫВАТЬ МАГИЮ ВНЕ ХОГВАРЦА
    НО ВАЛШЕБНАЯ ПАЛАЧКА У МИНЯ ЕСТЬ МОЖЫШЬ У СВАЕЙ МАМКИ СПРАСИТЬ ЕСЛЕ НЕ ВЕРИЖ АЗАЗАЗАЗЗАЗЗЗЗААА)))00))00)0000

    ЭКСПЕРТУС ТРАЛИУС АЗАЗА))0)0

    PragramistOtBoga, 20 Октября 2013

    Комментарии (12)
  8. Си / Говнокод #13960

    +139

    1. 1
    out[0] = str[0] > str[1] && str[0] > str[2] ? (out[1] = str[1] > str[2] ? (out[2] = str[2],str[1]) : (out[2] = str[1],str[2]) ,str[0]) : (str[1] > str[2] ? (out[1] = str[0] > str[2] ? (out[2] = str[2],str[0]): (out[2] = str[0],str[2]),str[1]) :(out[1] = str[0] > str[1] ? (out[2] = str[1],str[0]): (out[2] = str[0],str[1]),str[2]) );

    Сортируем 3 символа.

    Abbath, 16 Октября 2013

    Комментарии (12)
  9. C# / Говнокод #13701

    +128

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if (null != this.messageTemplateResourceName && null != this.messageTemplateResourceType)
    {
        return ResourceStringLoader.LoadString(this.messageTemplateResourceType.FullName,
            this.messageTemplateResourceName,
            this.messageTemplateResourceType.Assembly);
    }
    if (null != this.messageTemplateResourceName || null != this.messageTemplateResourceType)
    {
        throw new InvalidOperationException(Resources.ExceptionPartiallyDefinedResourceForMessageTemplate);
    }

    Microsoft EnterpriseLibrary
    else? нет, не слышал

    NeoN, 29 Августа 2013

    Комментарии (12)
  10. JavaScript / Говнокод #13667

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    /* mootools javascript */
    function animateCd() {
        $$('.countdown').each(function(el) {
            var inp = $(el).getElement('.ts');
            var time = +$(inp).get('text')-1;
            $(inp).set('text', time);
     
            var _time = Math.abs(time);
            var h = Math.floor(_time/3600);
            var _h = (h < 10 ? '0' : '') + h;
     
            var m = Math.floor(_time/60)-h*60;
            var _m = (m < 10 ? '0' : '') + m;
     
            var s = _time-(h*3600+m*60);
            var _s = (s < 10 ? '0' : '') + s;
     
            var timeStr = _h+' : '+_m+' : '+_s;
            if ( time < 0 ) {
                timeStr = '- '+timeStr;
            }
     
            $(el).getElement('.timer_cd').set('text', timeStr);
        });
        setTimeout(animateCd, 1000);
    }
    animateCd();
    
    <!-- html -->
    <div class="countdown">
        <div class="timer_cd"></div>
        <div style="display: none" class="ts">7200</div>
    </div>

    "Для создания таймера будем отталкиваться от стартового времени указанного в секундах, в примере 7200 (2 часа). Сначала из скрытого блока <div style="display: none" class="ts">7200</div> вытягиваем текущее значение счетчика в секундах, декрементируем его и возвращаем туда новое значение. Потом разбиваем значение счетчика на часы, минуты и секунды, при этом формируя значения в двухзначном формате. Собираем все в кучу и вставляем полученную строку в блок <div class="timer_cd"></div>. Данную операцию повторяем раз в секунду setTimeout(animateCd, 1000);."
    http://webbystep.ru/all-posts/16-js-clock/

    psycho-coder, 26 Августа 2013

    Комментарии (12)
  11. Pascal / Говнокод #13650

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      MText ,temp: string;
      memorystream:tmemorystream;
      link:string;
      i:integer;
      startpos,endpos:integer;
      stag,etag:string;
      c:integer;
    begin
      stop:=false;
      try
      memorystream:=tmemorystream.create;
      stag:='target="_blank" href="#url?to=';
    
        memorystream.clear;
        try
          idhttp1.Get('http://otvet.mail.ru/93516',memorystream);
        except
        end;
        if idhttp1.connected=true then
        idhttp1.Disconnect;
        mtext:=memo1.text;//memorystreamtostring(memorystream);
        memo1.lines.add(mtext);
    
    // Выдает access violation
    
        StartPos := 0;
        endpos:=0;
        while (true) do
        begin
          startPos := Posex(stag, MText,startpos+1);
          endPos := PosEx(etag, MText, startPos);
          if startpos>0 then
          begin
            temp := Copy(MText, startPos, endPos - startPos);
            Memo2.lines.add(temp);
          end
          else
          break;
        end;
    finally
      end;
    end;

    Вонь стоит жуткая. Тому, кто первым найдет ошибку, поставлю пятерку)

    Ы.з. Это мой сотый код, так что теперь я на все 100% с Вами) обнимаю вас всех.

    Stertor, 23 Августа 2013

    Комментарии (12)