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

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

    +174

    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
    /*Caused by: java.lang.StackOverflowError
        at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters(SimpleResultTreeImpl.java)
        at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.copy(SimpleResultTreeImpl.java:438)
        at com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.copy(BasisLibrary.java:1317)
        at GregorSamsa.replace()
        at GregorSamsa.replace()
        at GregorSamsa.replace()
        at GregorSamsa.replace()
        at GregorSamsa.replace()
      начали разбираться
    */
        /** 
         * As Gregor Samsa awoke one morning from uneasy dreams he found himself
         * transformed in his bed into a gigantic insect. He was lying on his hard,
         * as it were armour plated, back, and if he lifted his head a little he
         * could see his big, brown belly divided into stiff, arched segments, on
         * top of which the bed quilt could hardly keep in position and was about
         * to slide off completely. His numerous legs, which were pitifully thin
         * compared to the rest of his bulk, waved helplessly before his eyes.
         * "What has happened to me?", he thought. It was no dream....
         */
        protected final static String DEFAULT_TRANSLET_NAME = "GregorSamsa";

    http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
    transofm, factory, bug - какие начитанные разработчки, а.

    3.14159265, 12 Июня 2014

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

    +150

    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
    <?php
    $subjects = array (
      0 => 
        array (
          'title' => 'ОС Unix',
          'teacher' => 'Вася',
          'mark' => '3'),
      1 => 
        array (
          'title' => 'Компьютерные сети',
          'teacher' => 'Петя',
          'mark' =>'4'),
      2 => 
        array (
          'title' =>  'Алгоритмы',
          'teacher' =>  'Коля',
          'mark' => '4'),
    );?>
    <table>
    <?  foreach ($subjects as $key=>$subject) : 
    $number = $key+1;
    ?>
                <tr>
                    <td><?echo $number;?></td>
    				<td><?echo $subject['title'];?></td>
                    <td><?echo $subject['teacher'];?></td>
                    <td><?echo $subject['mark'];?></td>
                </tr>
    <? endforeach; ?>
    </table>
    <? var_dump($subject)?>

    wiedzal, 31 Мая 2014

    Комментарии (3)
  4. C++ / Говнокод #16077

    +3

    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
    #define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
    template <class T>\
    struct TRAITS_PREFIX##_bool\
    {\
       template<bool Add>\
       struct two_or_three {one _[2 + Add];};\
       template <class U> static one test(...);\
       template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
       static const std::size_t value = sizeof(test<T>(0));\
    };\
    \
    template <class T>\
    struct TRAITS_PREFIX##_bool_is_true\
    {\
       static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(one)*2;\
    };\
    //

    Ну тут как бы все просто и понятно. Но зачем заканчивают макрос кодом

    \
    //
    ?

    laMer007, 29 Мая 2014

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    panel1.Visible = checkBoxCCF.Checked;
    panel2.Visible = checkBoxReliabilty.Checked;
    panel3.Visible = checkBoxRisk.Checked;
    panel4.Visible = checkBoxSaftey.Checked;
    panel5.Visible = checkBoxSensitivity.Checked;
    panel6.Visible = checkBoxThroughput.Checked;
    panel7.Visible = checkBoxUncertainity.Checked;

    Почему половина переменных нормальные, половина нет? Логика некоторых погромистов зашкаливает...

    kostoprav, 28 Мая 2014

    Комментарии (3)
  6. Lua / Говнокод #16047

    −85

    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
    c1 = true
    c2 = true
    c3 = true
    c4 = true
    c5 = true
    c6 = true
    c7 = true
    c8 = true
    c9 = true
    c10 = true
    c11 = true
    c12 = true
    c13 = true
    next = true
    
    function goForward()
      c1 = c2
      c2 = c3
      c3 = c4
      c4 = c5
      c5 = c6
      c6 = c7
      c7 = c8
      c8 = c9
      c9 = c10
      c10 = c11
      c11 = c12
      c12 = c13
      c13 = next
    end

    Немножко Lua-кода от геймдизайнера.

    kostoprav, 23 Мая 2014

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

    +68

    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
    class CircuitBreaker
    {
        boolean broken = false;
        CircuitBreaker() {}
        private void breakCircuit()
        {
            this.broken = true;
        }
        private boolean isBroken()
        {
            return this.broken;
        }
    }
    
    private boolean writeAssetsToDisk()
    {
        CircuitBreaker breaker = new CircuitBreaker();
        writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
        writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
        writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
        writeBase64EncodedAssetToDisk(breaker, "...", getPath(...));
        return !breaker.isBroken();
    }
    
    private void writeBase64EncodedAssetToDisk(CircuitBreaker breaker, String base64String, String filename)
    {
        if (breaker.isBroken()) {
            return;
        }
        ...
        try
        {
            ...
        }
        catch (IOException e)
        {
            breaker.breakCircuit(); return;
        }
        ...
    }

    Используй исключения, Люк. Фрагмент из Amazon Mobile Ads SDK.

    chaoswithin, 23 Мая 2014

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

    +154

    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
    function box_navigation($gc, $num, $id, $function, $act){
    	global $tpl, $page;
    	$gcount = $gc;
    	$cnt = $num;
    	$items_count = $cnt;
    	$items_per_page = $gcount;
    	$page_refers_per_page = 5;
    	$pages = '';		
    	$pages_count = ( ( $items_count % $items_per_page != 0 ) ) ? floor( $items_count / $items_per_page ) + 1 : floor( $items_count / $items_per_page );
    	$start_page = ( $page - $page_refers_per_page <= 0  ) ? 1 : $page - $page_refers_per_page + 1;
    	$page_refers_per_page_count = ( ( $page - $page_refers_per_page < 0 ) ? $page : $page_refers_per_page ) + ( ( $page + $page_refers_per_page > $pages_count ) ? ( $pages_count - $page )  :  $page_refers_per_page - 1 );
    	
    	if(!$act)
    		$act = "''";
    	else
    		$act = "'{$act}'";
    			
    	if($page > 1)
    		$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($page-1).', '.$act.'); return false">«</a>';
    	else
    		$pages .= '';
    				
    	if ( $start_page > 1 ) {
    		$pages .= '<a href="" onClick="'.$function.'('.$id.', 1, '.$act.'); return false">1</a>';
    		$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page-1).', '.$act.'); return false">...</a>';
    			
    	}
    					
    	for ( $index = -1; ++$index <= $page_refers_per_page_count-1; ) {
    		if ( $index + $start_page == $page )
    			$pages .= '<span>' . ( $start_page + $index ) . '</span>';
    		else 
    			$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page+$index).', '.$act.'); return false">'.($start_page+$index).'</a>';
    	} 
    			
    	if ( $page + $page_refers_per_page <= $pages_count ) { 
    		$pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page + $page_refers_per_page_count).', '.$act.'); return false">...</a>';
    		$pages .= '<a href="" onClick="'.$function.'('.$id.', '.$pages_count.', '.$act.'); return false">'.$pages_count.'</a>';	
    	} 
    				
    	$resif = $cnt/$gcount;
    	if(ceil($resif) == $page)
    		$pages .= '';
    	else
    		$pages .= '<a href="/" onClick="'.$function.'('.$id.', '.($page+1).', '.$act.'); return false">»</a>';
    
    	if ( $pages_count <= 1 )
    		$pages = '';
    
    	$tpl_2 = new mozg_template();
    	$tpl_2->dir = TEMPLATE_DIR;
    	$tpl_2->load_template('nav.tpl');
    	$tpl_2->set('{pages}', $pages);
    	$tpl_2->compile('content');
    	$tpl_2->clear();
    	$tpl->result['content'] .= $tpl_2->result['content'];
    }

    дали проект чтобы разобрался)

    progsmile, 21 Мая 2014

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

    +11

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    int FCEUI_SetCheat(....)
    {
      ...
      if((t=(char *)realloc(next->name,strlen(name+1))))
      ...
    }

    А пасиму оно на 2 байта меньше выделяет, насяльника?

    http://www.viva64.com/ru/examples/V518/

    gost, 19 Мая 2014

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    class Matrix {
        ArrayList<ArrayList<Double>> arrayList = new ArrayList<ArrayList<Double>>();
        ...
    }

    Вот такая у нас реализация sparsed-матриц.

    kostoprav, 19 Мая 2014

    Комментарии (3)
  11. JavaScript / Говнокод #15979

    +158

    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
    $(document).ready(function() {
    	$('#about').click(function(about){    
    		$('#outside, #outside2, #outside3, #outside4, #outside5, #outside6, #outside7, #outside8, #outside9, #outside10, #outside11').fadeToggle('slow');
    	});
    
    	$('#whyus').click(function(whyus){    
    		$('#outsidewhy, #outsidewhy2, #outsidewhy3, #outsidewhy4, #outsidewhy5, #outsidewhy6, #outsidewhy7, #outsidewhy8, #outsidewhy9, #outsidewhy10, #outsidewhy11').fadeToggle('slow');
    	});
    
    	$('#portfolio').click(function(port){    
    		$('#outsideport, #outsideport2, #outsideport3, #outsideport4, #outsideport5, #outsideport6, #outsideport7, #outsideport8, #outsideport9, #outsideport10, #outsideport11').fadeToggle('slow');
    	});
    
    	$('#contact').click(function(con){    
    		$('#outsidecon, #outsidecon2, #outsidecon3, #outsidecon4, #outsidecon5, #outsidecon6, #outsidecon7, #outsidecon8, #outsidecon9, #outsidecon10, #outsidecon11').fadeToggle('slow');
    	});
    });

    В этом коде все хорошо и солнечно

    kostoprav, 14 Мая 2014

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