1. PHP / Говнокод #4228

    +165

    1. 1
    2. 2
    $res = explode(" ", $price);		
    $price = trim(str_replace(".", "", str_replace(",", "", substr(trim($res[0]), 0, strlen(trim($res[0])) - 2))));

    Изначально в переменной $price строка такого вида: 144.07 РУБ.
    Судя по всему автор хотел таким образом получить из нее целое значение

    partizan22, 12 Сентября 2010

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

    +125

    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
    command = new System.Data.SqlClient.SqlCommand();
    command.Connection = connection;
    
    command.CommandText = "select data from filestorage where id=@id;";            
    command.Parameters.AddWithValue("@id", fileId);
    command.CommandType = CommandType.Text;
    byte[] data = (byte[])command.ExecuteScalar();
    
    command.CommandText = "select filename from filestorage where id=@id;";
    string fName = (string)command.ExecuteScalar();
    
    command.CommandText = "select sizebytes from filestorage where id=@id;";
    long lngFileSize = (int)command.ExecuteScalar();
    
    command.CommandText = "select foldername from filestorage where id=@id;";
    string store= command.ExecuteScalar().ToString();

    akai_mirror, 11 Сентября 2010

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

    −155

    1. 1
    2. 2
    3. 3
    4. 4
    @image = (image unless image.nil?) or 
             (Rubygame::Surface.autoload(image_file) unless image_file.nil?) or 
             (Rubygame::Surface.autoload("#{@name}.png") unless @name.nil?) or 
             Rubygame::Surface.new([16, 16])

    (c) http://stackoverflow.com/questions/3690508

    Nakilon, 11 Сентября 2010

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    if( !$this->dirsmodel->isExist(array('alias' => $_POST['alias']))) {
        $this->messages[] = 'Такой алиас уже существует';
        return $this->redirect("admin/dirs/#" . $cat_id);
    }

    Говнокод тонкий особый. Кто найдёт получит пиченьку

    DrFreez, 11 Сентября 2010

    Комментарии (22)
  5. Python / Говнокод #4224

    −305

    1. 1
    if random.randint(1, 9999) is 42:

    Ockonal, 11 Сентября 2010

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

    +165

    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
    72. 72
    73. 73
    74. 74
    75. 75
    case  KEY_F9: {
    			if ( !strcmp( chlist->gettype(), "ethernet" ) ) {
    				/* Редактор канала Ethernet */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "/m.cfg", buf );
    				//
    				tethcfgedit* edit = new tethcfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gprs" ) ) {
    				/* Редактор канала GPRS */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgprscfgedit* edit = new tgprscfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gsm" ) ) {
    				/* Редактор канала GSM */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgsmcfgedit* edit = new tgsmcfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gsppp" ) ) {
    				/* Редактор канала GS (пакетный) */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgspppcfgedit* edit = new tgspppcfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gs" ) ) {
    				/* Редактор канала GS (прямой) */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgscfgedit* edit = new tgscfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "radio" ) ) {
    				/* Редактор канала радиомодема */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tradiocfgedit* edit = new tradiocfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(),"cbs" ) ) {
    				/* Редактор канала Ethernet */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR,"",buf );
    				//
    				tcbscfgedit* edit=new tcbscfgedit( getscr(),buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "ptsn" ) ) {
    				/* Редактор канала GSM */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tptsncfgedit* edit = new tptsncfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			}
    ......

    Кусок case'a, где запускается редактор настроек соотвествующего канала связи. Код из одной встроенной железки.

    vollmond, 11 Сентября 2010

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

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    {if $oUserProfile->getProfileIcq()}
    	<strong>{$aLang.profile_social_contacts}</strong>
    	<ul>
    	{if $oUserProfile->getProfileIcq()}
    		<li class="icq"><a href="http://www.icq.com/people/about_me.php?uin={$oUserProfile->getProfileIcq()|escape:'html'}" target="_blank">{$oUserProfile->getProfileIcq()}</a></li>
    	{/if}					
    	</ul>
    {/if}

    Smarty-шаблон. ActionProfile/sidebar.tpl (17-я строчка в скине "new") из LiveStreet.
    Озадачивают 1-я и 4-я строки. Типа: "А вдруг?!"

    hybroid, 11 Сентября 2010

    Комментарии (12)
  8. ActionScript / Говнокод #4221

    −160

    1. 1
    2. 2
    3. 3
    4. 4
    function midVal(X, Y)
    {
        return (Math.max(X, Y) - Math.min(X, Y)) / 2 + Math.min(X, Y);
    }

    Это среднее арифметическое один один чел так считает.
    Взято отсюда: http://www.gamedev.ru/flame/forum/?id=137879&page=4#m47
    Тема сама по себе весёлая.

    TarasB, 10 Сентября 2010

    Комментарии (87)
  9. Lua / Говнокод #4220

    −79

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ga = {} --gay/pure lua style
    GA = ga --1337 men style
    GlobalAdmin = ga --Java style
    GlObAlAdMiN = ga --xxx asked :D
    globalAdmin = ga --C style
    globaladmin = ga --other plain lua style

    Долго не могли решить как назвать глобальную таблицу в lua... лучшего решения не нашли.

    Alexsey, 10 Сентября 2010

    Комментарии (61)
  10. bash / Говнокод #4219

    −149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    gconftool-2 --unload '/usr/share/imfundo/appearance-switcher/xp-panels.xml'
    gconftool-2 --load '/usr/share/imfundo/appearance-switcher/classic-panels.xml'
    #Шаманство и мистицизм. Иначе глючит, зараза!
    sleep 0.5
    gconftool-2 --unload '/usr/share/imfundo/appearance-switcher/xp-panels.xml'
    gconftool-2 --load '/usr/share/imfundo/appearance-switcher/classic-panels.xml'

    Кусок скрипта, меняющего внешний вид панелей GNOME

    Shnatsel, 10 Сентября 2010

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