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

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

    +135.9

    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
    StiReport report = // создание отчета  StimulSoft Reporter          
     // . . . . .
     
    // . . . . . 
                string tempfilename = System.Guid.NewGuid().ToString() + ".tmp";
                report.ExportDocument(StiExportFormat.Word2007, tempfilename);    //позволяет конвертировать отчет только в поток 
    
                FileStream stream = new FileStream(tempfilename, FileMode.Open);
                byte[] reportFile = new byte[stream.Length];
                stream.Read(reportFile, 0, (int)stream.Length);
                stream.Close();
                File.Delete(tempfilename);
    
                if (reportFile.Length > 0)
                    if (MessageBox.Show("Зберегти друковану форму?", "Запит", MessageBoxButtons.OKCancel) == DialogResult.OK)
                         WriteToDB(reportFile, "Документ.docx");

    sven47, 31 Октября 2009

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

    +144.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
    curEl.change(function (e) {
                switch(current_c){
                    case '1': l = 0.001;  break;
                    case '2': l = 0.001;  break;
                    case '3': l = 1 ;     break;
                }
    
                switch(curEl.val()){
                    case '1': l2 = 0.001;  break;
                    case '2': l2 = 0.001;  break;
                    case '3': l2 = 1 ;     break;
                }
    
                convfrom = parseFloat((curr[current_c]/curr[curEl.val()]) *from.val() * (l/l2));
                convto   = parseFloat((curr[current_c]/curr[curEl.val()])*to.val()*(l/l2));
    
                if(from.val()!='')	from.val(convfrom);
                if(to.val()!='')    to.val(convto);
                from.focus();
            });

    kovel, 28 Октября 2009

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

    +156.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
    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
    final class HelperCurrency {
      
      	public function format($number, $currency = '', $value = '', $format = TRUE) {
    		/*** .... some code .... ***/
        	if ($value) {
          		$value = $value;
        	} else {
          		$value = $this->currencies[$currency]['value'];
        	}
    
        	if ($value) {
          		$value = $number * $value;
        	} else {
          		$value = $number;
        	}
    
    		/*** .... some code .... ***/
    		
    		if ($format) {
    			$decimal_point = $this->language->get('decimal_point');
    		} else {
    			$decimal_point = '.';
    		}
    		
    		if ($format) {
    			$thousand_point = $this->language->get('thousand_point');
    		} else {
    			$thousand_point = '';
    		}
    
    		/*** .... some code .... ***/
      	}
    }

    класика от OpenCart v. 1.3.2

    Under, 27 Октября 2009

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

    +77.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // Год и месяц редактируются как Double, а хранятся в  базе как два инта
                    if (aValue == null) {
                        current.setStartMonth(0);
                        current.setStartMonth(0);
                    } else {
                        current.setStartMonth(Integer.parseInt(aValue.toString().split(".")[0]));
                        current.setStartMonth(Integer.parseInt(aValue.toString().split(".")[1]));
                    }

    Программисты клиента и базы стоят один другого

    Jk, 27 Октября 2009

    Комментарии (2)
  6. VisualBasic / Говнокод #2026

    −129.8

    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
    For intAtts As Integer = 5 To strParams.Length - 1
                Select Case (intAtts + 1) Mod 3
                    Case 0
                        '--- Set where to find the attachments
                        Select Case strParams(intAtts).ToUpper
                            Case "TASKVIEW"
                                strAttach = CType(Me.Parent, ctlTaskViewTemplate).ctlDocNavigator.ContainerID.ToString & ","
                            Case "WORKITEM"
                                strAttach = WorkItem.WorkItemContainer.ToString & ","
                            Case "CASE"
                                strAttach = BFECase.CaseContainerID.ToString & ","
                        End Select
                    Case 1
                        '--- Set the relative path of where to find the attachments
                        strAttach = strAttach & strParams(intAtts) & ","
                    Case 2
                        '--- Set the type of document used to find the attachments
                        strAttach = strAttach & strParams(intAtts)
                        arrAttachments.Add(strAttach)
                        strAttach = ""
                End Select
            Next intAtts

    вот и попробуй пойми что в этих массивах по какому принципу лежит

    6istik, 22 Октября 2009

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

    +77.5

    1. 1
    2. 2
    3. 3
    4. 4
    //devPin и pin - массивы байт, а сравниваем мы их так :
    
    if (Utils.bytesToHex(devPin).equals(Utils.bytesToHex(pin))) {
    ....

    :)))

    tuba.linux, 21 Октября 2009

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

    +151.9

    1. 1
    if ($startTime == $endTime || $endTime < $startTime) {

    Написал, ужаснулся и тут же переписал

    striker, 30 Сентября 2009

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

    +151.2

    1. 1
    <?=trim(base64decode(trim($_GET['zzz'])))?>

    Ну как-то вот так

    McLeod, 25 Сентября 2009

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

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (s.length() < 2)
                return false;
    if (s.charAt(1) == ':') {
                return true;
    }
    return false;

    lian, 23 Сентября 2009

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

    +156.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    array_walk($additional_constraints_arr, create_function('&$field_value, $field_dest', '$field_value = (substr($field_dest, -1) == "!" ? "' .
        $table . '.' . ($prepend_table_name ? make_singular($table) . '_' : '') . '" . 
        substr($field_dest, 0, -1) . " != " . "\"" . $field_value . "\"" : (substr($field_dest, -1) == "%" ? "LOWER(" . "' .
        $table . '.' . ($prepend_table_name ? make_singular($table) . '_' : '') . '" . 
        substr($field_dest, 0, -1) . ") LIKE " . "LOWER(\"%" . $field_value . "%\")" : (substr($field_dest, -1) == "~" ? "' .
        $table . '.' . ($prepend_table_name ? make_singular($table) . '_' : '') . '" . 
        substr($field_dest, 0, -1) . " = " . $field_value : "' . 
        $table . '.' . ($prepend_table_name ? make_singular($table) . '_' : '') . '" . ' .
        '$field_dest . " = " . "\"" . $field_value . "\"")));'));

    ... just a simple 'WHERE' clause expanded to Godzilla-size ...

    core-ix, 10 Сентября 2009

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