1. VisualBasic / Говнокод #9566

    −108

    1. 1
    Replace(Replace(Replace(Replace(Replace(sht1.Cells(i, 4).Value, "(кратность 4 шт)", ""), "O.F.", ""), "D1ECO", ""), "DECO", ""), "SK", "")

    Удаляем из ячейки Excel одно из возможно встречающихся в ней слов.

    Говнокод или вполне нормальный трюк?

    valemak, 28 Февраля 2012

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

    +123

    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
    public static void DecToHex(int din) //Перевод из десятичной системы в шестнадцатеричную
            {
                
                string hout="", buk="";
                int q,r;
    
    
                while (din>0)
                {
                    q = din % 16;
                   
                    din = din / 16;
                    if (q >= 0 && q < 10)
                    
                        buk = q.ToString();
                    
                    else
                    if (q == 10)
                        buk = "A";
                    else if (q == 11)
                        buk = "B";
                    else if (q == 12)
                        buk = "C";
                    else if (q == 13)
                        buk = "D";
                    else if (q == 14)
                        buk = "E";
                    else if (q == 15)
                        buk = "F";
                   
                    hout =hout + buk;
    
                }
                Console.WriteLine(MyReverseString(hout));
    
                
    
            }

    Метод переводит из десятичной системы в шестнадцатеричную. Метод MyReverseString собственный метод переворота строки.

    Hank, 28 Февраля 2012

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

    +1000

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    enum IsHaveItem{
    //...
    switch(Havelo)
        {
            case IsHaveItem::Have: have();
            case IsHaveItem::Havent: haveOrNotHave();break;
            default:assert(false&&"Признай, что ты идиот и это не лечится!");
        }

    Нашёл в проекте. Нет, ни тогда, когда сработал ассерт.

    Говногость, 28 Февраля 2012

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    enum IsHaveItem
    //...
    switch(Havelo)
        {
            case IsHaveItem::Have: have();
            case IsHaveItem::Havent: haveOrNotHave();break;
            default:assert(false&&"Признай, что ты идиот и это не лечится!");
        }

    Говногость, 28 Февраля 2012

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

    +134

    1. 1
    0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /path-to-script

    Замечательный конфиг крона)

    imsamurai, 28 Февраля 2012

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

    +153

    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
    function date_control($date_first,$date_last,$date_logs){
    		$date_elems = explode(" ",$date_first);
    		$date=explode("-", $date_elems[0]);
    		$date_first_result=mktime(00,00,00, $date[1],$date[0], $date[2]);	
    		
    		$date_elems_2 = explode(" ",$date_last);
    		$date_2=explode("-", $date_elems_2[0]);
    		$date_last_result=mktime(00,00,00, $date_2[1],$date_2[0], $date_2[2]);	
    		$date_elems_3 = explode(" ",$date_logs);
    		$date_3=explode("-", $date_elems_3[0]);
    		$date_logs_result=mktime(00,00,00, $date_3[1],$date_3[2], $date_3[0]);	
    		
    		if($date_logs_result<=$date_last_result&$date_logs_result>=$date_first_result){
    			return 'true';
    		}else{
    			return 'false';
    		}
    	}

    Вот, как нужно работать с датой! Вот какие должны быть условия! Вот наш ответ Булю!

    imsamurai, 28 Февраля 2012

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

    +158

    1. 1
    'rule' => '/^[АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯяa-z0-9 ]{1,}$/i'

    Вот такая вот регулярочка...

    imsamurai, 28 Февраля 2012

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

    +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
    $login = trim($user_f[2]);
      $email = trim($user_f[3]);
      $passw = trim($user_f[4]);
      $reg_date = trim($user_f[5]);
      $last_visit = trim($user_f[6]);
      $name = trim($user_f[7]);
      $site = trim($user_f[8]);
      $icq = trim($user_f[9]);
      $pol = trim($user_f[10]);
      $otkuda = trim($user_f[11]);
      $modelphone = trim($user_f[12]);
      $operator = trim($user_f[13]);
      $show_mail = trim($user_f[14]);
      $reputacia = trim($user_f[15]);
      $status = trim($user_f[16]);
      $data_rozhd = trim($user_f[17]);
      $bantime = trim($user_f[18]);
      $bantxt = trim($user_f[19]);
      $banwho = trim($user_f[20]);
      $mes_guest = trim($user_f[21]);
      $mes_forum = trim($user_f[22]);
      $mes_komm = trim($user_f[23]);
      $new_ls = trim($user_f[24]);
      $activ_account = trim($user_f[25]);
      $izm_repu = trim($user_f[26]);
      $plusov = trim($user_f[27]);
      $minusov = trim($user_f[28]);
      $o_sebe = trim($user_f[29]);
      $rating = trim($user_f[30]);
      $time_in_site = trim($user_f[31]);
      $vhodov = trim($user_f[32]);
      $all_temes = trim($user_f[33]);
      $statey = trim($user_f[34]);
      $mes_chat = trim($user_f[35]);
      $status_name = trim($user_f[36]);
      $nick_name = trim($user_f[37]);

    Еще теплое...

    TBoolean, 28 Февраля 2012

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

    +119

    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
    ApiException(final ResourceException cause, final Representation repr,
    			final Class<? extends ErrorResponse> responseClass) {
    		super(cause);
    		this.cause = cause;
    		
    		ErrorResponse response = null;
    		
    		try {
    			response = new ObjectMapper().readValue(repr.getText(), responseClass);
    		} catch (final Exception e) {
    			log.error("Error attempting to parse the error response", e);
    		} finally {
    			this.response = response;
    		}
    	}

    Возникла ошибка при возникновении ошибки...

    someone, 28 Февраля 2012

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

    +106

    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
    public static boolean isNumeric(string word)
    {
    	char[] charArray = word.toCharArray();
    	
    	foreach (char letter in charArray)
    	{
    		if (!(letter == '0' || letter == '1' || letter == '2' || letter == '3' || letter == '4' || letter == '5' || letter == '6' || letter == '7' || letter == '8' || letter == '9'))
    		{
    			return false;
    		}
    		return true;
    	}
    }

    За одно и подскажите правильный, оптимальный вариант этой функции

    vistefan, 28 Февраля 2012

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