1. C# / Говнокод #9172

    +106

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public void CheckMemoStyle(bool isChecked)
    {
        if (isChecked)
        {
            memoStyleLayoutCntrl.Selected = true;
        }
        else
        {
            memoStyleLayoutCntrl.Selected = false;
        }
    }

    memoStyleLayoutCntrl.Selected = isChecked; уже не модно?

    alpha2050, 19 Января 2012

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

    +146

    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
    class BbCod{
    		
    		function BbCod(){
    				
    		} 
    		
    	 	static function BbB($text){
    			
    			if (is_array($text)) {
    				$text = '<b>'.$text[1].'</b>';
    			}
    			
    			return preg_replace_callback("~\[b]((?:[^[]|\[(?!/?b])|(?R))+)\[/b]~is", "BbCod::BbB" , $text); 
    		}
    		
    		
    		static function BbI($text){
    			
    			if (is_array($text)) {
    				$text = '<i>'.$text[1].'</i>';
    			}
    			
    			return preg_replace_callback("~\[i]((?:[^[]|\[(?!/?i])|(?R))+)\[/i]~is", "BbCod::BbI" , $text); 
    		}
    		
    		
    
    
    // ...
    
    		function Bb($text, $param = array()){
    			if(!isset($param['b']) || $param['b'] !== false) $text = $this->BbB($text);				
    			if(!isset($param['i']) || $param['i'] !== false) $text = $this->BbI($text);	
    			if(!isset($param['u']) || $param['u'] !== false) $text = $this->BbU($text);
    			if(!isset($param['ol']) || $param['ol'] !== false) $text = $this->BbOl($text);
    			if(!isset($param['ul']) || $param['ul'] !== false) $text = $this->BbUl($text);
    			if(!isset($param['li']) || $param['li'] !== false) $text = $this->BbLi($text);
    			if(!isset($param['quote']) || $param['quote'] !== false) $text = $this->BbQuote($text);
    			if(!isset($param['left']) || $param['left'] !== false) $text = $this->BbLeft($text);
    			if(!isset($param['right']) || $param['right'] !== false) $text = $this->BbRight($text);
    			if(!isset($param['center']) || $param['center'] !== false) $text = $this->BbCenter($text);
    			if(!isset($param['justify']) || $param['justify'] !== false) $text = $this->BbJustify($text);
    			if(!isset($param['size']) || $param['size'] !== false) $text = $this->BbSize($text);
    			if(!isset($param['color']) || $param['color'] !== false) $text = $this->BbColor($text);
    			if(!isset($param['fright']) || $param['fright'] !== false) $text = $this->BbFRight($text);
    			if(!isset($param['fleft']) || $param['fleft'] !== false) $text = $this->BbFLeft($text);
    			if(!isset($param['table']) || $param['table'] !== false) $text = $this->BbTable($text);
    			if(!isset($param['td']) || $param['td'] !== false) $text = $this->BbTd($text);
    			if(!isset($param['th']) || $param['th'] !== false) $text = $this->BbTh($text);
    			if(!isset($param['tr']) || $param['tr'] !== false) $text = $this->BbTr($text);
    			if(!isset($param['br']) || $param['br'] !== false) $text = $this->BbBr($text);
    			if(!isset($param['hr']) || $param['hr'] !== false) $text = $this->BbHr($text);
    			if(!isset($param['youtube']) || $param['youtube'] !== false) $text = $this->BbYoutube($text);
    			if(!isset($param['img']) || $param['img'] !== false) $text = $this->BbIms($text);
    			if(!isset($param['src']) || $param['src'] !== false) $text = $this->BbSrc($text);
    			if(!isset($param['mail']) || $param['mail'] !== false) $text = $this->BbMail($text);
    			
    			return $text;	
    		}
    		
    }
    		// end class

    Писал в само начале осваивания ООП в php. И причем такое ощущения что бухой писал)

    vir-mir, 19 Января 2012

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

    +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
    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
    <?php
    function variation($name, $cache = true)
    {
        $hach = md5($name);
        //Проверяем кэш, если его нет - делаем запрос к API(JSON).
        if (!file_exists('cache/variation/' . $hach . '.cache')) {
            $c = file_get_contents('http://export.yandex.ru/inflect.xml?name=' . urlencode($name) . '&format=json');
            //Записываем кэш
            if ($cache === true) {
                file_put_contents('cache/variation/' . $hach . '.cache', $c);
            }
        }
        //Если кэш есть - берем оттуда.
        else {
            $c = file_get_contents('cache/variation/' . $hach . '.cache');
        }
        //Возвращаем массив(Функция работает только с UTF-8)
        return json_decode($c, true);
    }
    $arr = variation('Москва');
    /*
    //Переводим в cp1251(JSON).
    $arr = variation('Москва');
    //Для всего массива
    function _iconv($val)
    {
    return iconv('utf-8', 'cp1251', $val);
    }
    $arr = array_map('_iconv', $arr);
    //Или для отдельного элемента
    $arr[1] = iconv('utf-8', 'cp1251', $arr[1]);
    */
    echo 'Оригинал: ', $arr['original'], '<br/>';
    echo 'Именительный: ', $arr[1], '<br/>';
    echo 'Родительный: ', $arr[2], '<br/>';
    echo 'Дательный: ', $arr[3], '<br/>';
    echo 'Винительный: ', $arr[4], '<br/>';
    echo 'Творительный: ', $arr[5], '<br/>';
    echo 'Предложный: ', $arr[6], '<br/>';

    http://moicoding.ru/php-poleznosti/8-Yandeks-sklonyator

    Unknown, 19 Января 2012

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

    +114

    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
    public void Dispose()
            {
                Dispose(true);  
                GC.SuppressFinalize(this);
            }
    
            protected virtual void Dispose(bool disposing)
            {
                _channelRedrawManager.StopProcessing();
            }
    
            ~ChannelControlViewModel()
            {
                Dispose(false);
            }

    Деструкти правильно..

    Lifter, 19 Января 2012

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

    +142

    1. 1
    ../../../../archive/03_Production/03_Programming/cdn/res/map_1_bg.png

    Мы не ищем простых путей

    kyzi007, 19 Января 2012

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

    +130

    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
    public static string Handle(System.Exception exception)
            {
                try
                {
                    throw exception;
                }
                catch (System.Net.WebException ex)
                {
                    ...
                }
                catch (System.Web.Services.Protocols.SoapHeaderException ex)
                {
                    ...
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    ...
                }
                catch (ArgumentNullException ex)
                {
                    ...
                }
                catch (NullReferenceException ex)
                {
                    ...
                }
                catch (Exception ex)
                {
                    ...
                }
            }

    кусок кода в чужом проекте, который сейчас допиливаю :(

    shtaff, 19 Января 2012

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

    +74

    1. 1
    String.format("USR-БГПУ", new Object[] { new SimpleDateFormat("dd MMMM yyyy", new Locale("ru", "RU")) })

    Нашёл в самолично написанной утильке (из серии блиц-[говно]кодинга). Думал.

    0rt, 19 Января 2012

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

    +1001

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    bool IsDigit(char cKey, const char *cKeys) {
    	for (int i = 0; i < strlen(cKeys); i++)
    		if (cKeys[i] == cKey)
    			return true;
    	return false;
    }

    FalseCoder, 18 Января 2012

    Комментарии (89)
  9. Python / Говнокод #9164

    −102

    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
    def to_sk_pzd(text):
        result = ''
        for char in text:
            for bit in str(bin(ord(char))):
                if bit == '0':
                    result += 'сука'
                elif bit == '1':
                    result += 'пиздец'
        return result
    
    print to_sk_pzd('чо нада?')
    
    # Output:
    # сукапиздецпиздецпиздецпиздецсукапиздецпиздецпиздецсукапиздецпиздецпиздецсукапиздецпиздецпиздецсукасукапиздецсукасукасукасукасукасукапиздецпиздецпиздецсукапиздецпиздецсукапиздецсукапиздецпиздецпиздецсукасукасукасукасукасукапиздецпиздецпиздецсукасукапиздецсукасукасукапиздецпиздецпиздецсукасукасукасукасукасукапиздецпиздецпиздецпиздецпиздецпиздец

    гопник-байт-encoding

    Nyashka, 18 Января 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    $obj = json_decode("http://export.yandex.ru/inflect.xml?name="."Максим"."+"."Крикун"."&format=json");
    $rp = $obj->1;
    echo ($rp);
    ?>

    Друг в скайпе киданул

    valera5505, 18 Января 2012

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