1. Python / Говнокод #4910

    −179

    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
    class Source:
    		id = ''
    		values = []
    		arrays =[ ( 'bool_array', bool), ( 'float_array', float), ('IDREF_array', str), ('int_array', int), ('Name_array', str), ('SIDREF_array', str), ('token_array', str)]
    		
    		def __init__(self, node):
    			self.id = node.getAttribute('id')
    			
    			accessors = dict([ (accessor.getAttribute('source')[1:], (int(accessor.getAttribute('count')), int(accessor.getAttribute('stride'))) ) for technique in node.getElementsByTagName("technique_common") for accessor in technique.getElementsByTagName("accessor") ])
    			values = [(arrayNode.getAttribute('id'), int(arrayNode.getAttribute('count')), [array[1](v) for v in getText(arrayNode).split()]) for array in Mesh.Source.arrays for arrayNode in node.getElementsByTagName(array[0])]
    			self.values = [ array[2][i*accessors[array[0]][1]:(i+1)*accessors[array[0]][1]] for array in values for i in range(accessors[array[0]][0])]
    			
    
            <source id="Box001-lib-Position">
              <float_array id="Box001-lib-Position-array" count="24">-23.296745 -46.390999 0.000000 23.296745 -46.390999 0.000000 -23.296745 46.390999 0.000000 23.296745 46.390999 0.000000 -23.296745 -46.390999 35.287621 23.296745 -46.390999 35.287621 -23.296745 46.390999 35.287621 23.296745 46.390999 35.287621</float_array>
              <technique_common>
                <accessor source="#Box001-lib-Position-array" count="8" stride="3">
                  <param name="X" type="float"/>
                  <param name="Y" type="float"/>
                  <param name="Z" type="float"/>
                </accessor>
              </technique_common>
            </source>
    
    в результате нужно получить список в виде
    [[-23.296745, -46.390999, 0.0], [23.296745, -46.390999, 0.0], [-23.296745, 46.390999, 0.0], [23.296745, 46.390999, 0.0], [-23.296745, -46.390999, 35.287621], [23.296745, -46.390999, 35.287621], [-23.296745, 46.390999, 35.287621], [23.296745, 46.390999, 35.287621]]

    Неделю назад начал учить питон, и для того чтоб это было совсем полезно, решил попробовать написать на нем парсер Collada файлов.
    Очень сильно проникся идеей инициализации массивов, из-за чего и родился сей говнокод...
    Код выдает правильный результат, но абсолютно не читаемый...

    pushkoff, 13 Декабря 2010

    Комментарии (21)
  2. PHP / Говнокод #4909

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $cif = range(0, 9);
    $mal = range('a', 'z');
    $bol = range('A', 'Z');
    $ob = array_merge($cif, $mal, $bol);
    shuffle($ob);
    $ar = array_slice($ob,0, 5);
    $vivod = implode("", $ar);

    Очередной генератор капчи/пароля.
    Вдруг кому пригодится ;)

    Uchkuma, 12 Декабря 2010

    Комментарии (62)
  3. Java / Говнокод #4908

    +85

    1. 1
    while (r == BigInteger.ONE.subtract(BigInteger.ONE)) {...}

    брутальный 0 и не менее брутальное сравнение объектов...

    dfn, 12 Декабря 2010

    Комментарии (0)
  4. Pascal / Говнокод #4907

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    procedure TForm2.ExitButtonClick(Sender: TObject);
    begin
    Close;
    Form1.Close;
    end;

    Об Application.Terminate даже и не догадываемся...

    PEMOHT, 12 Декабря 2010

    Комментарии (14)
  5. Pascal / Говнокод #4906

    +105

    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
    case nd of
    0..9:days.Caption := '00'+IntToStr(nd);
    10..99:days.Caption := '0'+IntToStr(nd);
    100..999:days.Caption := IntToStr(nd);
    end;
    case nh of
    0..9:hrs.Caption := '0'+IntToStr(nh);
    10..99:hrs.Caption := IntToStr(nh);
    end;
    case nm of
    0..9:mins.Caption := '0'+IntToStr(nm);
    10..99:mins.Caption := IntToStr(nm);
    end;
    case nsec of
    0..9:secs1.Caption := '0'+IntToStr(nsec);
    10..99:secs1.Caption := IntToStr(nsec);
    end;
    case nsec2 of
    0..9:secs2.Caption := '0000000'+IntToStr(nsec2);
    10..99:secs2.Caption := '000000'+IntToStr(nsec2);
    100..999:secs2.Caption := '00000'+IntToStr(nsec2);
    1000..9999:secs2.Caption := '0000'+IntToStr(nsec2);
    10000..99999:secs2.Caption := '000'+IntToStr(nsec2);
    100000..999999:secs2.Caption := '00'+IntToStr(nsec2);
    1000000..9999999:secs2.Caption := '0'+IntToStr(nsec2);
    10000000..99999999:secs2.Caption := IntToStr(nsec2);
    end;

    Таймер для дураков.

    PEMOHT, 12 Декабря 2010

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

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    if (MACaddress == 0)
    		MACaddress = pAdapterInfo->Address [5] + pAdapterInfo->Address [4] * 256 + 
    					pAdapterInfo->Address [3] * 256 * 256 + 
    					pAdapterInfo->Address [2] * 256 * 256 * 256;

    xynta, 12 Декабря 2010

    Комментарии (22)
  7. Python / Говнокод #4904

    −167

    1. 1
    2. 2
    3. 3
    4. 4
    if abs(self.__last_direction%360-direction.angle())==270:
                angle = 360*(self.__last_direction/360+1)+direction.angle()
            else:
                angle = 360*(self.__last_direction/360) + direction.angle()

    крутим крутим спрайт

    nbdarvin, 12 Декабря 2010

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

    +167

    1. 1
    while(!file_exists(getcwd()."/.htroot")){chdir('..');}

    http://www.php.net/manual/en/function.require.php

    if you want always include, require, open files using some 'root' folder based path you may may put file '.htroot' in 'root' folder and use this.

    while(!file_exists(getcwd()."/.htroot")){chdir('..');}

    This code change current dir to dir where '.htroot' file located and everywhere you can use relative to 'root' paths.

    Please avoid absent of '.htroot' file.

    qbasic, 12 Декабря 2010

    Комментарии (13)
  9. Си / Говнокод #4902

    +141

    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
    static int16_t have_upper_dot(cell *c)
    {
     cell *cc;
     int16_t H;
     H=my_bases.ps;
     cc=c->prev;
     if ((cc->flg & c_f_dust) &&
          (c->w>4 && cc->h>=2 && cc->w>=2 &&
    	(abs(cc->h-cc->w)<=H/6 || cc->h<cc->w && cc->w-cc->h<=H/4) &&
    	cc->col+1>=c->col && cc->col+cc->w-5<=c->col+c->w ||
           c->w<=4 && abs(c->col-cc->col+(c->w-cc->w)/2)<=2) &&
          cc->row+cc->h-2<=my_bases.b2)
       return 1;
     cc=c->next;
     if ((cc->flg & c_f_dust) &&
          (c->w>4 && cc->h>=2 && cc->w>=2 &&
    	(abs(cc->h-cc->w)<=H/6 || cc->h<cc->w && cc->w-cc->h<=H/4) &&
    	cc->col+1>=c->col && cc->col+cc->w-5<=c->col+c->w ||
           c->w<=4 && abs(c->col-cc->col+(c->w-cc->w)/2)<=2) &&
          cc->row+cc->h-2<=my_bases.b2)
       return 1;
     return 0;
    }

    Из одной OCR программы.

    f0ma, 12 Декабря 2010

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

    +33

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    <meta http-equiv=Content-Type content="text/html; charset=windows-1251">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel=File-List href="SL_php2weeks_box.files/filelist.xml">
    
    <title>PHP за 2 недели - курс обучения PHP от Школы Программирования</title>
    <style type="text/css">
    <!--
    .style1 {font-family: Georgia, "Times New Roman", Times, serif}
    .style5 {font-family: Georgia, "Times New Roman", Times, serif; font-style: italic; }
    .style6 {font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; }
    .style7 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style8 {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-weight: bold;
    	font-style: italic;
    	color: #009000;
    }
    .style9 {
    	font-family: Georgia, "Times New Roman", Times, serif;
    	font-size: 18px;
    }
    .style10 {
    	font-family: "Courier New", Courier, monospace;
    	font-size: 12px;
    }
    .style11 {
    	font-size: 24px;
    	font-weight: bold;
    }
    .style12 {font-size: 24px; font-weight: bold; font-family: Georgia, "Times New Roman", Times, serif; }
    .style13 {font-size: 24px; font-weight: bold; font-family: Georgia, "Times New Roman", Times, serif; font-style: italic; }
    .style14 {font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; font-style: italic; }
    .style15 {
    	color: #0000FF;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    .style17 {font-family: Georgia, "Times New Roman", Times, serif; font-style: italic; font-size: 16px; }
    .style18 {
    	font-size: 20px
    }
    -->
    </style>
    </head>
    
    
    
    <body lang=RU link=blue vlink=purple>
    
    <!-- SmartResponder.ru PopOver code (begin) -->
    <script language="javascript" type="text/javascript" src="popover.js"></script>
    <span style="margin: 0pt; padding: 0pt; width: 400px; height: 400px; position: absolute; left: 0pt; top: 0pt; right: 0pt; z-index: 1; display: none;" id="SR_PopOver">
    <table cellpadding="0" cellspacing="0" height="246" width="400">
    <tbody>
    <tr>
    <td style="border: 1px solid rgb(0, 0, 0);">
    <table bgcolor="#ffffff" cellpadding="3" cellspacing="0" height="100%" width="100%">
    <tbody>
    <tr bgcolor="#dddddd" valign="middle">
    <td onMouseDown="popover_drag_start(event, this, 'SR_PopOver')" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 255); font-weight: bold;" align="center" width="100%">
    <b>Подарок Вам - <font style="color:#009000;">Курс Web-Старт!</font><br /> 7 Бесплатных Видеоуроков По PHP!</b></td>
    <td align="right">
    <table cellspacing="0">
    <tbody>
    
    <tr>
    <td style="padding: 0pt 3px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: rgb(0, 0, 0); font-weight: bold;" onClick="popover_close(this, 'popover_start_to(\'SR_PopOver\', 21, 0, \'windowWidth\', parseInt(popover_obj.style.top) - popover_base_y)')" onMouseOver="this.style.cursor='pointer'" onMouseOut="this.style.cursor='default'">X</td>
    </tr>
    </tbody>
    </table>

    http://prog-school.ru/php2weeks/

    вот как бывает! исходник страницы смотрите сами :)

    brainstorm, 11 Декабря 2010

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