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

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

    +130

    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
    #define _WIN32_WINNT 0x0500
    
    #include <windows.h>
    #include <tlhelp32.h>
    #include <stdio.h>
    
    HWND console;
    
    int main(int argc, char *argv[])
    {
        console = GetConsoleWindow();
        ShowWindow(console, SW_HIDE);
        free(console);
    
        THREADENTRY32 te32;
        HANDLE snap = INVALID_HANDLE_VALUE;
    
        while(1) {
            snap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
            if ( snap == INVALID_HANDLE_VALUE ) {
                printf("faile.");
                return 0;
            }
    
            te32.dwSize = sizeof(THREADENTRY32 );
    
            if (!Thread32First(snap, &te32)) {
                printf("faile on exec thread.");
                return 0;
            }
    
            HANDLE td;
            do {
                    td = OpenThread(THREAD_ALL_ACCESS, TRUE, te32.th32ThreadID);
                    SetThreadPriority(td, 0x00010000);
    
            } while ( Thread32Next(snap, &te32 ) );
    
            CloseHandle(snap);
    
            Sleep(10);
        }
    
        return 0;
    }

    говновирус

    danilissimus, 21 Апреля 2010

    Комментарии (8)
  3. SQL / Говнокод #3034

    −856.6

    1. 1
    select to_date(to_char(date_field, 'DD.MM.YYYY'), 'DD.MM.YYYY') from dual

    Смысл операция имеет, но есть способы и попроще :)

    guеst, 18 Апреля 2010

    Комментарии (8)
  4. PHP / Говнокод #2964

    +151.6

    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
    ##	типа база для копипаста. изначально intval отсутствовал, но не суть важно
    	$sqll='select tt.title as titletag, t.id_news as id, DATE_FORMAT(n_d.data, "'.DATE_FORMAT.'") as data, n.title as titlenews, n.subject from  '.T_TAGS.' as tt, '.T_NEWS_TAGS.' as t, '.T_ANALIT_DATA.' as n , '.T_ANALIT.' as n_d where t.id_news=n.news_id and n.news_id=n_d.id and t.id_tags="'.intval($_GET["param2"]).'"  and t.id_tags=tt.id  order by n_d.data desc';
    	$resultt = $DB->Execute($sqll) or DB_Error(__LINE__, $sqll, $DB);
    	$block='main.news';
    	while ($roww = $resultt->FetchRow())	{
    		foreach ($roww as $_key=>$_value)	$xtpl->assign($_key,	stripslashes($_value));
    		$xtpl->assign('titletag',	$roww['titletag']);
    		$xtpl->assign('title_title',	$roww['titletag']);
        $xtpl->parse($block.'.newstags.row');
    	}			
    
    ##	аццкий отжиг
    	$sqll='select tt.descr from  '.T_TAGS.' as tt, '.T_NEWS_TAGS.' as t, '.T_ANALIT_DATA.' as n , '.T_ANALIT.' as n_d where t.id_news=n.news_id and n.news_id=n_d.id and t.id_tags="'.intval($_GET["param2"]).'"  and t.id_tags=tt.id order by n_d.data desc';
    	$resultt = $DB->Execute($sqll) or DB_Error(__LINE__, $sqll, $DB);
    	$roww = $resultt->FetchRow();
    	foreach ($roww as $_key=>$_value)	$xtpl->assign($_key,	stripslashes($_value));
    	if($roww['descr']!='') $xtpl->parse($block.'.newstags.descr');

    копипаст неискореним.

    ufdyjrjlth, 08 Апреля 2010

    Комментарии (8)
  5. C# / Говнокод #2957

    +143.4

    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
    using System;
    
    public unsafe class Starter {
        public static void Main() {
            char* pChar = stackalloc char[26];
            char* _pChar = pChar;
            for (int count = 0; count < 26; ++count) {
                (*_pChar) = (char)(((int)('A')) + count);
                ++_pChar;
            }
            for (int count = 0; count < 26; ++count) {
                Console.Write(pChar[count]);
            }
        }
    }

    Выделяем 26 символов в стеке, цикл присваивает буквы к каждому элементу

    sergylens, 08 Апреля 2010

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

    +123.2

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    uses windos, crt;
    label code1;
    var start: char;
        pr: shortint;
        code: integer;
        z, k, p, c, x: longint;
        h, m, s, hund: word;
        st: string;
        i:comp;
    function time(w : word) : string;
    var s : string;
    begin
     str(w:0, s);
     if length(s) = 1 then s:='0'+s;
     time:=s;
    end;
    procedure rdtsc(var tsc:comp); assembler;
    asm
    db $0f, $31
    les di, tsc
    mov [es:di+0], ax
    db $66, $c1, $e8, $16
    mov [es:di+2], ax
    mov [es:di+4], dx
    db $66, $c1, $ea, $16
    mov [es:di+6], dx
    end;
    begin
    textcolor(white);
    write ('Start?(y/n) '); readln (start);
    if start<>'y' then halt;
    code1:
    z:=14000005; c:=round(z/100); p:=c; pr:=0; k:=0; textcolor(10);
    gettime(h, m, s, hund);
    st:=time(h)+time(m)+time(s)+time(hund);
    val(st, x, code);
            if code<>0 then
            begin
            clrscr;
            textcolor(12);
            writeln ('CODE=', code);
            writeln (h, m, s, hund);
            goto code1;
            end;
    rdtsc(i); i:=i+x*41+x+5;
    
       while z<>k do
       begin
       str(i, st);
       st:=copy(st, 6, 4);
       val(st, i, code);
                    if code<>0 then
                    begin
                    clrscr;
                    textcolor(12);
                    writeln ('CODE=', code);
                    writeln ('ST=', st);
                    goto code1;
                    end;
       i:=i*i+h*104+hund*73+x;
                    if i=0 then
                    begin
                    textcolor(12);
                    writeln ('K=', k);
                    delay(50000);
                    goto code1;
                    end;
       k:=k+1;
              if k=p then
              begin
              p:=p+c;
              pr:=pr+1;
              clrscr;
              writeln ('STATUS: ', pr, '%');
              end;
       end;
    x:=round(i); textcolor(white); writeln ('Result X=', x); textcolor(yellow);
                      while x>=10 do
                      begin
                      str(x, st);
                      z:=length(st);
                      x:=0;
                           for k:=1 to z do
                           begin
                           start:=st[k];
                           val(start, pr, code);
                                      if code<>0 then
                                      begin
                                      clrscr;
                                      textcolor(12);
                                      writeln ('CODE=', code);
                                      write ('START=', start);
                                      goto code1;
                                      end;
                           x:=x+pr;
                           end;
                      end;
    write ('Result=', x); readln
    end.

    Генерация случайного числа от 1 до 9 на Turbo Pascal. Свистоперделки прилагаются. Спешите поблевать! Делал сам. Такое вот задание попалось мне в лаб. работе на 4-м курсе. Хотя паскаль изучал лишь в школе, позиция препода уникальна: "Вы должны уметь всё!", хотя дрочим лишь C#, Java и асм.

    killerman_yar, 29 Марта 2010

    Комментарии (8)
  7. JavaScript / Говнокод #2876

    +156.6

    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
    function getElementsByClass(searchClass,node,tag) {
    	var classElements = new Array();
    	if ( node == null )
    		node = document;
    	if ( tag == null )
    		tag = '*';
    	var els = node.getElementsByTagName(tag);
    	var elsLen = els.length;
    	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    	for (i = 0, j = 0; i < elsLen; i++) {
    		if ( pattern.test(els[i].className) ) {
    			classElements[j] = els[i];
    			j++;
    		}
    	}
    	return classElements;
    }
    
    function show_im_gal (id)
    {
    .............
    	$("#tabs"+id+" img").css({opacity:1});
    	tab = getElementsByClass ('tabNavigation',null,null);
    .............
    }

    Судя по строке 22, автор знает, что проект использует jQuery. Но дальше юзает додревний getElementsByClass, выкопанный на лучших складах говноскриптов 1990-х!

    deraider, 27 Марта 2010

    Комментарии (8)
  8. PHP / Говнокод #2875

    +162.4

    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
    while( $db->next_record() ) {
    				$parent_id = $db->f( "product_parent_id" ) ;
    				if( ($db->f( "product_id" ) != $curr_product) && @$child_id ) {
    					continue ;
    				}
    				// Start row for this child
    				$q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku " ;
    				$q .= "WHERE product_id='" . $db->f( "product_parent_id" ) . "' ORDER BY attribute_list ASC" ;
    				$db_sku->query( $q ) ;
    				$attrib_value = array( ) ;
    				
    				while( $db_sku->next_record() ) {
    					$q = "SELECT attribute_name,attribute_value " ;
    					$q .= "FROM #__{vm}_product_attribute WHERE " ;
    					$q .= "product_id='" . $db->f( "product_id" ) . "' AND " ;
    					$q .= "attribute_name='" . $db_sku->f( "attribute_name" ) . "'" ;
    					$db_item->setQuery( $q ) ;
    					$db_item->query() ;
    					while( $db_item->next_record() ) {
    						if( $ci == 0 ) {
    							$attrib_heading[] = $db_item->f( "attribute_name" ) ;
    							$tpl->set( 'headings', $attrib_heading ) ;
    						}
    						$attrib_value[] = $db_item->f( "attribute_value" ) ;
    					}
    				}

    Не знаю выкладывал ли кто, но захотелось покрыть все матом :(((

    Джумла + вирт. март.
    Выше этого лежит ещё два цикла. С помощью данного участка кода и выше, который я опустил ибо в него долго въезжать, т.к. слишком много букофф - разгоняет нагрузку на бд до 800 запрос ради вывода десяти товаров.

    matrix, 27 Марта 2010

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

    +971.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    string[] dateStringParts = dateString.Split(new [] {DateTimeFormatInfo.CurrentInfo.DateSeparator}, StringSplitOptions.RemoveEmptyEntries);
    
    if (dateStringParts.Count() != 3)
    {
        dateStringParts = DateTime.Now.ToString("dd MMMM yyyy").Split(' ');
    }
    
    string day = dateStringParts[0];
    string month =  dateStringParts[1];
    string year = dateStringParts[2];
    string shortYear = dateStringParts[2].Substring(dateStringParts[2].Length - 2, 2);

    Учитесь парсить дато! :)

    adoconnection, 24 Марта 2010

    Комментарии (8)
  10. PHP / Говнокод #2852

    +175.6

    1. 1
    2. 2
    3. 3
    $header = fopen('base.txt', "r");
    $base = file('base.txt');
    fclose($header);

    Navin, 23 Марта 2010

    Комментарии (8)
  11. PHP / Говнокод #2846

    +160.6

    1. 1
    uniqid(uniqid(uniqid()))

    Получить длинный идентификатор

    mrtaryk, 23 Марта 2010

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