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

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

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static List<Character> englishAlphabet;
    
        public static final Integer ENGLISH_ALPHABET_LENGTH = 26;
    
        static {
            englishAlphabet = new ArrayList<Character>();
            englishAlphabet.add('#');
            for (int i = 0; i < ENGLISH_ALPHABET_LENGTH; i++) {
                englishAlphabet.add((char) ('A' + i));
            }
        }

    Товарищ уже уволился :)

    jekyll, 20 Января 2012

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

    +111

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    while (true)
                    {
                        if (sec > 10)
                        {
                            sec = 0;
                            // Вызор функции
                        }
                        else
                            sec++;
    
                        Thread.Sleep(1000);
                    }

    Боевой код, который допиливаю(

    yorikim, 20 Января 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    if (!isset($pmas_table[0][3])) $pmas_table[0][3]='';
    if (!isset($pmas_table[0][5])) $pmas_table[0][5]='';
    if (!isset($pmas_table[0][6])) $pmas_table[0][6]='';
    if (!isset($pmas_table[0][7])) $pmas_table[0][7]='';

    UserSide v2.48 again. Так как там каждая строчка имеет право быть на этом сайте, выкладываю The best of the best =)

    Neka, 18 Января 2012

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

    +126

    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
    public static bool IsLong(string tmpStr)
    {
    	bool blRetVal = true;
    	for (int i = 0; i < tmpStr.Length; i++)
    	{
    		if (tmpStr[i] != '0' && tmpStr[i] != '1' && tmpStr[i] != '2' &&
    			tmpStr[i] != '3' && tmpStr[i] != '4' && tmpStr[i] != '5' &&
    			tmpStr[i] != '6' && tmpStr[i] != '7' && tmpStr[i] != '8' &&
    			tmpStr[i] != '9')
    			blRetVal = false;
    	}
    	return blRetVal;
    }
    
    static public string ConvertDateTimeForSQL(DateTime tmpDateTime)
    {
    	return (
    		tmpDateTime.Year.ToString() + "-" +
    		(tmpDateTime.Month < 10 ? "0" : "") + tmpDateTime.Month.ToString() + "-" +
    		(tmpDateTime.Day < 10 ? "0" : "") + tmpDateTime.Day.ToString() + " " +
    		(tmpDateTime.Hour < 10 ? "0" : "") + tmpDateTime.Hour.ToString() + ":" +
    		(tmpDateTime.Minute < 10 ? "0" : "") + tmpDateTime.Minute.ToString() + ":" +
    		(tmpDateTime.Second < 10 ? "0" : "") + tmpDateTime.Second.ToString());
    }
    
    static public string ConvertDateTimeShortForSQL(DateTime tmpDateTime)
    {
    	return (tmpDateTime.Year.ToString() + "-" +
    		(tmpDateTime.Month < 10 ? "0" : "") + tmpDateTime.Month.ToString() + "-" +
    		(tmpDateTime.Day < 10 ? "0" : "") + tmpDateTime.Day.ToString());
    }
    
    -----------------------------------
    P.S. Версия .NET 3.5

    yorikim, 17 Января 2012

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

    +65

    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
    for (...) {
      Comparator<Date> date_comparator = new Comparator<Date>() {
        @Override
        public int compare(Date s1, Date s2) {
          long n1 = s1.getTime();
          long n2 = s2.getTime();
          if (n1 < n2)
            return -1;
          else if (n1 > n2)
            return 1;
          else
            return 0;
        }
      };
      Date beforeSaveDate = (Date) beforeSaveParam.getValue();
      beforeSaveDate.setSeconds(0);
      Date toSaveDate = (Date) toSaveParam.getValue();
      comparedValue = date_comparator.compare(beforeSaveDate, toSaveDate);
    }

    Задача была сравнить две даты, игнорируя при этом секунды.

    LexeY4eg, 13 Января 2012

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

    +118

    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
    private Excel._Application _excel;
    ...
    private void RefreshFormulas(FormulaRefreshOption formulaRefreshOption, object objectToRefresh)
    		{
    			//Где-то в дебрях километрового метода бросилось в глаза
                            ...
    			try
    			{
    				Excel.Range intersection = selection, selection2 = selection;
    				while (selection2 != null)
    				{
    					intersection = _excel.Intersect(selection2, selection2.Dependents,
    						Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    						 Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    						  Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    						   Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    
    
    					System.Windows.Forms.Application.DoEvents();
    					excelUtilities.RecalculateRangeInstance(true, intersection/*_excel.Selection as Excel.Range*/);
    					selection2 = intersection;
    				}
    
    			}
    			catch (Exception) { /*ignore the exception because .Dependents will throw an exception if there aren't any dependents*/}
                            ...
    		}

    fade, 04 Января 2012

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

    +144

    1. 1
    $

    TarasGovno, 04 Января 2012

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

    +1001

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void Object::destroy ()
    {
      evas_object_del (o);
      
      // do a suicide as the delete operator isn't public available
      // the reason is that the C design below is a suicide design :-(
      //delete (this); // TODO: why does this make problems sometimes???
    }

    source: trunk/BINDINGS/cxx/elementaryxx/src/Object.cpp @ 65926

    rat4, 04 Января 2012

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    @fwrite($fp, "<?php
    \$config['dbhost'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbhost'])))."\";
    \$config['dbuser'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbuser'])))."\";
    \$config['dbpass'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbpass'])))."\";
    \$config['dbname'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbname'])))."\";
    \$config['dbpref'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbprefix'])))."\";
    ?>");
    ?>

    avecms нах.

    TBoolean, 19 Декабря 2011

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    if(!$this->result = $this->dbo->query($this->sql))
    {
       throw new Exception('Error Query: '. $this->sql);
    }

    Ооо я знаю про исключения...

    Sulik78, 19 Декабря 2011

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