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

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public double Supremum()
    {
    	HazardEstimation intensityEstimation = new IntensityEstimation(Sample, new EpanechnikovKernel(), SmoothingParameterMethod.Asymptotic);
    	var s = new List<double>(Sample.Size);
    	for (int i = 0; i < Sample.Size; i++)
    	s.Add(Math.Abs(intensityEstimation.NonParametricEstimation(Sample[i].Value) - rv.h(Sample[i].Value)));
    	return s.Max();
    }

    Дипломники не ищут легких путей

    zontar, 13 Марта 2013

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

    +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
    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
    <html>
        <head>
        <meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>
        <head>
        <title>test</title>
        <script type="text/javascript">
        // Функция, осуществляющая AJAX запрос
        function loadXMLDoc(method, url) {
          if(window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = processReqChange;
            req.open(method, url, true);
            req.send(null);
          } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            req.onreadystatechange = processReqChange;
            req.open(method, url, true);
            req.send();
          }
        }
        // Функция, выполняемая при изменении статуса
        // запроса, если статус  равен 200, данные получены
        function processReqChange() {
          if(req.readyState == 4) {
         
            if(req.status == 200) {
              getNumber(req.responseText);
         
            } else {
              alert("There was a problem retrieving the XML data:\n" + req.statusText);
            }
          }
        }
        // Функция выполняется при клике по кнопке
        function process() {
         
           var v = document.getElementById("flag");
           var url = "ajax.php?flag=" + v.checked;
           loadXMLDoc( "get", url );
           setTimeout('process()', 1000);
        }
         
        // Функция записывает в элемент content значение, полученное от сервера
        function getNumber(text) {
          //для текстового поля
          var content = document.getElementById( "content" );
         content.value = text;
          //для div
         var content = document.getElementById( "content2" );
         content.innerHTML = text;
         
        }
         
        </script>
        </head>
        <body onload='process()'>
        <input type='checkbox' id='flag'>Флажок
        <input type='text' id='content'>
        <div id='content2'></div>
        </body>
        </html>
        .....................................................................................
         
        //файл ajax.php
        <?php
        if (isset($_GET['flag']))
        {
        if($_GET['flag']==='true') echo 'checked';
        else echo 'not checked';
        }
        ?>

    Как скопировать значение одного поля в другое.
    Очередное оригинальное решение от нашего старого знакомого, который не верит в существование говнокода и быдлокодеров.

    Stallman, 13 Марта 2013

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $_SESSION["db_options"] = array ('host'     => trim($this->IP).":".trim($this->Port),
    										'user'     => trim($this->User),
    										'password' => trim($this->Pass),
    										'database' => trim($this->DB)
    										);

    Наследование? Не, не слышал

    nonamez, 05 Марта 2013

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

    +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
    $code_date = strtotime($sms_action_date);
        $date = date(
            "Y-m-d H:i:s",
            mktime(
                date('H', $code_date),
                date('i', $code_date) + 30,
                date('s', $code_date),
                date("m", $code_date),
                date("d", $code_date),
                date("Y", $code_date)
            )
    );

    Определяем +30 минут грамотно.

    miraage, 05 Марта 2013

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

    +74

    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
    private boolean userInOneRegistrationNode() throws DfException {
    
            String uname = OrganizationStaffStructureHelper.getCurrentUserName();
    
            int i = 0;
            IDfCollection NodesCol = DQLHelper.getCollection(DQL_GET_REGISTRATOR_DIV, new String[]{uname});
            while (NodesCol.next()) {
                if (!(NodesCol == null)) {
                    String group_name = NodesCol.getString(GROUP_NAME);
                    i = i + 1;
                }
            }
    
            if (i == 1) {
                return true;
            }
            return false;
    }

    Заменяется 2мя строками один - select count(*), вторая - полученный результат Integer.ValueOf(...).

    Landing, 04 Марта 2013

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

    −107

    1. 1
    2. 2
    SelectionViewController* controller = [[[SelectionViewController alloc] initWithArray:options selectedIndex:&_selectedIndex] autorelease];
     [self.navigationController pushViewController:controller animated:YES];

    _selectedInded это ivar типа int, который передается по ссылке!! Ад!

    notxcain, 22 Февраля 2013

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

    −98

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
                [NSThread sleepForTimeInterval:0.35];
                [[NSThread mainThread] performBlock:^{
                    [titleLabel setHidden:NO];
                }];
            });

    torip3ng, 20 Февраля 2013

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

    +110

    1. 1
    <img border="0" width="476" height="179" src="file:///C|/Users/jy88h0/AppData/Roaming/Macromedia/Dreamweaver /eCustomer/iq/images/AI289.jpg" alt="Image of a properly addressed mail piece">

    http://faq.usps.com/eCustomer/iq/usps/request.do?create=kb%3AUSPSFAQ&view%28%2 9=c[c_usps0910]

    someone, 13 Февраля 2013

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    void *threadFunc(void *)
    {
    	// ...
    	pthread_exit( (void*)lTaskId );
    	return ( (void*)lTaskId );
    	// ...
    }

    позабавило.

    для непосвященных: return в функции потока аналогичен вызову pthread_exit().

    Dummy00001, 11 Февраля 2013

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

    +135

    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
    namespace CuttingBox
    {
    
        class Program
        {
            static public Tuple<int[], String> getProperty()
            {
                int[] itemDimensionProperty = new int[3];
                String itemColorProperty;
                String[] parseResult = new String[4];
                parseResult = (Console.ReadLine().Split(' '));
                for (int counter = 0; counter < 3; counter++)
                {
                    itemDimensionProperty[counter] = Convert.ToInt32(parseResult[counter]);
                }
                itemColorProperty = parseResult[3];
                Tuple<int[], String> itemProperty = new Tuple<int[], string>(itemDimensionProperty, itemColorProperty);
                return itemProperty;
            }
    
            static void Main(string[] args)
            {
                List<Tuple<int[], String>> itemProperty = new List<Tuple<int[], String>>();
                itemProperty.Add(getProperty());
                int numberOfBoxes = Convert.ToInt32(Console.ReadLine());
                for (int counter=1; counter<=numberOfBoxes; counter++){
                    itemProperty.Add(getProperty());
                }
            }
        }
    }

    Парсим строки правильно...

    javanesovsemgovno, 11 Февраля 2013

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