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

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

    +155

    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
    <script type="text/php">
    
    $color_op = Style::munge_colour( "#565656" );
    
    $font_op = Font_Metrics::get_font("arial", "normal");
    $font_op2 = Font_Metrics::get_font("arial", "bold");
    
    {literal}
    #	$pdf->text($left_op, $top_op, $text00, $font_op, 16, $color_op);
    #	$pdf->text($left_op, $top_op + 20, $text22, $font_op, 16, $color_op);
    #	$pdf->text($left_op, $top_op + 40, $text33, $font_op, 16, $color_op);	
    
    	$pdf->text($left_op, $top_op, $text00, $font_op2, 16, $color_op);
    	$pdf->text($left_op+87, $top_op, $text01, $font_op2, 16, $color_op2);
    	$pdf->text($left_op+87+15, $top_op, $text02, font_op, 16, $color_op);
    	
    {/literal}
    </script>

    Кусок из шаблона Smarty.

    _tL, 09 Июня 2011

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

    +128

    1. 1
    return Mouse.GetState().LeftButton == ButtonState.Pressed ? _manager.Creatures.Where(el => el.Rectangle.Intersects(new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 2, 2))).FirstOrDefault() : null;

    dotnetdeveloper, 08 Июня 2011

    Комментарии (6)
  4. Python / Говнокод #6899

    −83

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    # In Django model
    def processed_description(self):
        text = self.description. \
               replace('<table', '<div class="table">'
                                 '<div class="bgtop"></div>'
                                 '<div class="overflow"><table'). \
               replace('</table>', '</table></div>'
                                   '<div class="bgbottom"></div>'
                                   '</div>'). \
               replace('<th', '<th width="50%" align="left"')
        return text

    Пользователь хочет редактировать контент в WYSIWYG-редакторе. Дизайнер хочет, чтобы таблицы выглядели красиво. Верстальщику для красоты нужны дополнительные div-ы. Что делает программист? Говнокодит!

    zag, 08 Июня 2011

    Комментарии (6)
  5. Java / Говнокод #6889

    +75

    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
    1.3 @@ -89,9 +89,6 @@
         1.4     public void openFile(File f) {
         1.5        try {
         1.6           Desktop.getDesktop().open(f);
         1.7 -//         String s = "cmd /c \"" + f.getAbsolutePath() + "\" ";
         1.8 -//         System.out.println(s);
         1.9 -//         java.lang.Process p = Runtime.getRuntime().exec(s);
        1.10        }
        1.11        catch (Exception e) {
        1.12           JOptionPane.showMessageDialog(null, "Ошибка при открытии файла", "Ошибка", JOptionPane.ERROR_MESSAGE);
        1.13 @@ -112,21 +109,6 @@
        1.14           temp.mkdir();
        1.15        }
        1.16        String fName = entry.getName();
        1.17 -      fName = fName.replaceAll("\\&", "_");
        1.18 -      fName = fName.replaceAll("\\(", "_");
        1.19 -      fName = fName.replaceAll("\\)", "_");
        1.20 -      fName = fName.replaceAll("\\[", "_");
        1.21 -      fName = fName.replaceAll("\\]", "_");
        1.22 -      fName = fName.replaceAll("\\{", "_");
        1.23 -      fName = fName.replaceAll("\\}", "_");
        1.24 -      fName = fName.replaceAll("\\^", "_");
        1.25 -      fName = fName.replaceAll("\\=", "_");
        1.26 -      fName = fName.replaceAll("\\!", "_");
        1.27 -      fName = fName.replaceAll("\\`", "_");
        1.28 -      fName = fName.replaceAll("\\+", "_");
        1.29 -      fName = fName.replaceAll("\\~", "_");
        1.30 -      fName = fName.replaceAll(" ", "_");
        1.31 -      fName = fName.replaceAll(("№"), "_");
        1.32        String dnFileName = temp.getName() + File.separator + fName;
        1.33  
        1.34        File dlFname = new File(dnFileName);

    Так как открытие файла происходило весьма оригинальным образом через cmd.exe - вполне логично было написано фильтрование символов, неперевариваемых этой cmd.exe.
    Как видно - задача решалась одной строкой - " Desktop.getDesktop().open(f);".

    maxt, 08 Июня 2011

    Комментарии (6)
  6. SQL / Говнокод #6883

    −121

    1. 1
    2. 2
    3. 3
    4. 4
    update RPout
    set ReserveCalculated = round((Base * ElementNorm) /100.0 + 1e-9, 2) * 
    sign(convert(money, floor(Base * ElementNorm) / 100.0)) * sign( 1 + 
    sign(convert(money, floor(Base * ElementNorm) / 100.0)))

    Отрицательные значения изменить на ноль плюс феерическая работа с типами данных.

    Blackened, 07 Июня 2011

    Комментарии (6)
  7. PHP / Говнокод #6798

    +172

    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
    <?php
    
    //...
    
    if(version_compare(phpversion(), '5.0') < 0) {
            insert_charset_header();
            require_once('phpversionfail.php');
            die();
    }
    
    require_once('include/utils/utils.php');
    
    if (version_compare(phpversion(), '5.0') < 0) {
        eval('
        function clone($object) {
          return $object;
        }
        ');
      }
    
    //....
    
    ?>

    Код из vTiger CRM. Индусы как обычно.

    mr.The, 31 Мая 2011

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

    +88

    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
    public synchronized static void reload() 
    	{
            synchronized (properties) 
    		{
                synchronized (questRewardRates)
    			{
                    synchronized (questDropRates)
    				{
                        properties = new ConcurrentHashMap<String, String>();
                        questRewardRates = new ConcurrentHashMap<Integer, Float>();
                        questDropRates = new ConcurrentHashMap<Integer, Float>();
                        load();
                    }
                }
            }
        }

    Я просто оставлю это здесь (c)

    VirtualVoid, 30 Мая 2011

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

    +121

    1. 1
    Change mysql_query to @mysql_query and so on for the other references to suppress the error messages returned from the function calls.

    Ответ на одном форуме, относится к куску кода на PHP. Решил накласть в кучу.

    Yurik, 28 Мая 2011

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

    +147

    1. 1
    2. 2
    3. 3
    <?php
    ///*********************************** PAYMENT MODULE START**************************//////
    ?>

    из шаблона CMS oscommerce. открываем режим php чтобы написать комментарий

    gorky, 26 Мая 2011

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

    +170

    1. 1
    2. 2
    var table = 'table';
    var width = $($(table)[3]).width();

    ой вей

    Sc0rp10, 24 Мая 2011

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