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

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

    −105

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if [ `which which` ]; then
      ...
    else
      ...
    fi

    gongled, 14 Сентября 2012

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

    +29

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    string input;
    string output;
     
    input = "C:\\bla.txt\\";          //"Bla.txt" is the file to copy
    output = "C:\\test\\";            //"Test" is the folder to copy to
     
    system("copy input.c_str() output.c_str()")

    http://cboard.cprogramming.com/cplusplus-programming/109047-help-copy-files-cplusplus.html

    an0nym, 10 Сентября 2012

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

    +134

    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    public void Open()
            {
                _session.OpenSession();
    
                _log = new LogOperations(_session.CurrentSession);
                if (!_session.DBIsExists)
                {
                    var dictList = new List<string> 
                    {
                    #region Добавление всех текстовых ресурсов в список для записи в словарь базы
                        Resources.AllChannelsSelected,
                        Resources.ArchiveClearDone,
                        Resources.ARMShotdown,
                        Resources.BWConnected,
                        Resources.BWConnecting,
                        Resources.BWSelected,
                        Resources.BWServerName,
                        Resources.Cannot_create_0fly,
                        Resources.Cannot_create_1fly,
                        Resources.Cannot_delete_0fly,
                        Resources.Cannot_delete_1fly,
                        Resources.CannotDeleteImage,
                        Resources.CannotDeleteVideo,
                        Resources.CannotSaveImage,
                        Resources.ColorConnected,
                        Resources.ColorConnecting,
                        Resources.ColorSelected,
                        Resources.ColorServerName,
                        Resources.CoolingBreak,
                        Resources.CreateClientError,
                        Resources.FreeSpace20,
                        Resources.FreeSpace5,
                        Resources.ImageSend,
                        Resources.ImageSendASTK,
                        Resources.MainForm_OPUConnect,
                        Resources.MainForm_RecordStart,
                        Resources.MainForm_RecordStop,
                        Resources.OPUAngle,
                        Resources.OPUConnected,
                        Resources.OPUDisconnected,
                        Resources.OPUSavePoint,
                        Resources.OPUScanning,
                        Resources.OPUScanningNotChangedSet,
                        Resources.OPUWatching,
                        Resources.PanoNotExists,
                        Resources.Panorama_Processing,
                        Resources.Panorama_StreamError,
                        Resources.Panorama_Success,
                        Resources.PresetPointRewrite,
                        Resources.PresetPointSaved,
                        Resources.ReadDataError,
                        Resources.Restart,
                        Resources.RestartFailed,
                        Resources.SaveImage,
                        Resources.ScanSetRewrite,
                        Resources.ScanSetSave,
                        Resources.StartRecord,
                        Resources.StopRecord,
                        Resources.ThermalConnected,
                        Resources.ThermalConnecting,
                        Resources.ThermalCoolingTime,
                        Resources.ThermalOFF,
                        Resources.ThermalON,
                        Resources.ThermalReady,
                        Resources.ThermalSelected,
                        Resources.ThermalServerName,
                        Resources.ThermalWork,
                        Resources.UnknowError,
                        Resources.UnknowError2,
                        Resources.UserTypeCommander,
                        Resources.UserTypeDefault,
                        Resources.UserTypeOperator,
                        Resources.UserTypeSystemPreferences,
                        Resources.VideoArchivePlayText,
                        Resources.VideoSend,
                        Resources.VideoSendASTK
                    #endregion
                    };
                    _log.CreateDictionary(dictList);
                }
            }

    Метод, создающий словарь бд из ресурсов проекта

    Flyperformances, 06 Сентября 2012

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

    −99

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // WTF is 8.5? Oo I will never, ever hardcode some random values.
    	linkStatusImage.frame = CGRectMake (5, height / 2 - 8.5, 17, 17);
    	descriptionLabel.frame = CGRectMake (27, 5, width - 32 - rightMargin, 20);
    	authorLabel.frame = CGRectMake (27, 30, width - 32 - rightMargin, 20);
    	addressLabel.frame = CGRectMake (27, 55, width - 32 - rightMargin, height - 60);
    	separatorImage.frame = CGRectMake (0, height - 2, separatorImage.image.size.width, 2);
    	favButton.frame = CGRectMake (width - 22, height / 2 - 8.5, 17, 16);

    byss, 23 Августа 2012

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

    +56

    1. 1
    2. 2
    3. 3
    4. 4
    $data = $this->db->qp($q=(($type == 1 && $this->auth->demo == 0) ? '(SELECT Favorite_Name as s, CONCAT(oname,\'|\',House,\'|\',Enter) as s2, Id as id, \'1\' as t, null as m, IF(LEFT(LOWER(TRIM(Favorite_Name)), '.$c.')=\''.$sword.'\', 0, IF(LEFT(LOWER(TRIM(oname)), '.$c.')=\''.$sword.'\', 1, 2)) as od, \'1\' as t2 FROM :Cabinet_Favorite_Objects: WHERE Client_Phone=\'7'.$this->auth->phone.'\' && (lower(Favorite_Name) LIKE \'%'.$sword.'%\' || lower(oname) LIKE \'%'.$sword.'%\') ORDER BY od ASC, Favorite_Name'.$lim.')
    		UNION ALL
    		(SELECT addr as s, \'1\' as s2, id as id, \'2\' as t, null as m, IF(LEFT(LOWER(TRIM(addr)), '.$c.')=\''.$sword.'\', 0, 1) as od, \'2\' as t2 FROM :cabinet_history_objects: WHERE cid=\''.$this->auth->adata['IDClient'].'\' && lower(addr) LIKE \'%'.$sword.'%\' ORDER BY od ASC, num, addr DESC'.$lim.')
    		' : '').(($type == 1 && $this->auth->demo == 0 && $c > 0) ? ' UNION ALL ' : '').(($c > 0) ? '(SELECT objectName as s, objectMetaType as s2, objectID as id, \'3\' as t, objectAddress as m, IF(LEFT(LOWER(TRIM(SearchField)), '.$c.')=\''.$sword.'\', 0, 1) as od, IF(objectMetaType=\'0\', 3, IF(objectMetaType=\'100\', 4, 5)) as t2 FROM :Cabinet_Objects: WHERE lower(SearchField) LIKE \'%'.$sword.'%\' ORDER BY od ASC, objectMetaType ASC, s ASC'.$lim.')' : ''), '', 'select');

    Получение списка доступных адресов для заказа такси.

    blessed, 21 Августа 2012

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

    +23

    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
    %:include <iostream>
     
    int main(int argc, char *argv<::>) 
    <%
        if (argc > 1 and argv<:1:> not_eq '\0') <%
            std::cout << "Hello " << argv<:1:> << '\n';
        %>
        std::cout<<"ko"<<std::endl;
    %>
     
     
    
    ??=include <iostream>
     
    int main(int argc, char *argv??(??)) 
    ??<
        if (argc > 1 and argv??(1??) not_eq '\0') ??<
            std::cout << "Hello " << argv??(1??) << '\n';
        ??>
        std::cout<<"ko"<<std::endl;
    ??>

    http://liveworkspace.org/code/150ad59b81b309bbffed963829f4fc9e
    http://liveworkspace.org/code/c64104e4272af4d89f2f74c35c5c2ee3
    Просто оставлю это здесь.

    HaskellGovno, 20 Августа 2012

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

    +52

    1. 1
    2. 2
    // Очищаем переменные
            unset($_SESSION['captcha'], $_SESSION['not_a_bot'], $_SESSION['pass'], $_SESSION['mail'], $_SESSION['name'], $_SESSION['agree'], $_SESSION['country'],  $_SESSION['city']);

    session_destroy() уже не в моде?

    duxabilii, 15 Августа 2012

    Комментарии (6)
  9. Си / Говнокод #11581

    +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
    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
    if ( ... )
      {
        if ( ... )
          {
            if ( ... )
              {
                usleep(250000);
              }
            else
              {
                sleep( 1 );
              }
          }
        else
          {
            if ( ... )
              {
                if ( ... )
                  {
                    usleep( 250000 );
                  }
                else
                  {
                    sleep( ... );
                  }
              }
            else
              {
                sleep( ... );
              }
          }
      }
    else
      {
        usleep( 250000 );
      }

    из главного цикла одного "рил-тайм" приложения. (комментарии, етц были удалены.)

    каждый раз тестеры/кастомеры жалуются что приложение работает слишком медленно или слишком быстро - появляется либо новый if со слипом, либо новый else со слипом. за два года существования, вот до этого "полного" дерева доросло. и все равно не работает как надо. :)

    Dummy00001, 13 Августа 2012

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

    +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
    23. 23
    24. 24
    bool ASN1Parser::ConvertOID(const ASN1Block &blk, char *oid, unsigned int bufSize) {
        int a = 0;
        bool first = true;
        char tmp[32];
        oid[0] = 0;
        for (unsigned int i=0;i<blk.size;i++) {
            unsigned char c = data[blk.offset+i];
            if (c & 0x80) {
                a = (a << 7) | (c & 0x7F);
            } else {
                a = (a << 7) | (c & 0x7F);
                if (!first) {
                    sprintf(tmp,".%d",a);
                } else {
                    sprintf(tmp,"%d.%d",a/40,a%40);
                }
                a=0;
                first = false;
                if (strlen(tmp) >= bufSize) return false;
                strcat(oid, tmp);
            }
        }
        return true;
    }

    И еще один говнокодец на тему ASN.1 - распаковка OID'а.
    Кто найдет ошибку - получит пирожок с полочки ;)

    bormand, 12 Августа 2012

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

    +56

    1. 1
    $where = str_replace("post_status = 'publish'","post_status = 'publish' OR post_status = 'future' OR post_status = 'draft' OR post_status = 'inherit'", $where);

    Wordpress. Govnocode is poetry

    telnet, 10 Августа 2012

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