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

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    case WM_SIZE:
    			for(i=0;i<6;i++)
    			{
    				if(RegNotifyChangeKeyValue(hTopKeys[i],TRUE,REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_ATTRIBUTES|
    					REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_CHANGE_SECURITY,NULL,FALSE)==ERROR_SUCCESS)
    				{
    					MessageBox(NULL,"1","1",MB_OK);
    				}
    			}

    http://forum.shelek.ru/index.php/topic,14613.0.html

    Обратите внимание, товарищи, что у лица, создавшего сей шедевр, статус - "Опытный". Вот так и живем.

    Stertor, 30 Июля 2013

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

    +79

    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
    #include <iostream>
    #include <Windows.h>
    #include <iomanip>
    #include <string>
    #include <cctype>
    #include <sstream>
     
    using namespace std;
     
    void main()
    {
    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);
     stringstream ss;
     int counter = 0, vvod = 0;
     char str[9];
     cout << "Введите число - ";
     cin >> vvod;
     ss << vvod;
     ss >> str;
     for(int i = 0; i < strlen(str); i++)
     {
         counter++;
     }
     cout << counter << " разрядов." << endl;
     
    cout << "\n";
    system("PAUSE");
    }

    psina-from-ua, 28 Июля 2013

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

    +69

    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
    static {
    	Unsafe u = null;
    	Exception ex = null;
    	try {
    		Class objectStreamClass = Class.forName("sun.misc.Unsafe");
    		Field unsafeField = objectStreamClass.getDeclaredField("theUnsafe");
    		unsafeField.setAccessible(true);
    		u = (Unsafe) unsafeField.get(null);
    	} catch (ClassNotFoundException e) {
    		ex = e;
    	} catch (SecurityException e) {
    		ex = e;
    	} catch (NoSuchFieldException e) {
    		ex = e;
    	} catch (IllegalArgumentException e) {
    		ex = e;
    	} catch (IllegalAccessException e) {
    		ex = e;
    	}
    	exception = ex;
    	unsafe = u;
    }

    xstream-1.2.2 - древнота, но попахивает...

    kostoprav, 01 Июля 2013

    Комментарии (23)
  5. Pascal / Говнокод #13258

    +142

    1. 1
    Язык Богов

    Stertor, 29 Июня 2013

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    public function parse_url($url)
    {
            return parse_url($url);
    }

    Модель из моего диплома... Всё по фен-шуй!

    nonamez, 28 Июня 2013

    Комментарии (23)
  7. JavaScript / Говнокод #13186

    +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
    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
    function Order(obj) {
      var frm = $(obj);
      var first_name = frm.find("input[name='first_name']").val();
      var last_name = frm.find("input[name='last_name']").val();
      var email = frm.find("input[name='email']").val();
      var phone = frm.find("input[name='phone']").val();
      var text = frm.find(".coment-form-textarea").val();
      var captcha = frm.find("input[name='captcha']").val();
    
      var valid = true;
      MsgErrorDestroy(frm, '#order-first_name', 'input[name="first_name"]');
      MsgErrorDestroy(frm, '#order-last_name', 'input[name="last_name"]');
      MsgErrorDestroy(frm, '#order-email', 'input[name="email"]');
      MsgErrorDestroy(frm, '#order-phone', 'input[name="phone"]');
      MsgErrorDestroy(frm, '#order-text', '.coment-form-textarea');
    
      if (first_name == '') {
        MsgError(frm, 'Введите ваше имя.', '#order-first_name', 'input[name="first_name"]');
        valid = false;
      }
      if (last_name == '') {
        MsgError(frm, 'Введите вашу фамилию.', '#order-last_name', 'input[name="last_name"]');
        valid = false;
      }
      if (!emailValid(email)) {
        MsgError(frm, 'Введите ваш email.', '#order-email', 'input[name="email"]');
        valid = false;
      }
      if (phone == '') {
        MsgError(frm, 'Введите ваш номер телефона.', '#order-phone', 'input[name="phone"]');
        valid = false;
      }
      if (text == '') {
        MsgError(frm, 'Введите ваше сообщение.', '#order-text', '.coment-form-textarea');
        valid = false;
      }
      if (captcha == '') {
        MsgError(frm, 'Введите капчу.', '#comment-capcha', 'input[name="captcha"]');
        valid = false;
      }
      if (valid == false) {
        return false;
      }
    }
    
    function MsgError(frm, msg, select_msg, select_input) {
      if (select_msg != 0) {frm.find(select_msg).html(msg);}
      if (select_input != 0) {frm.find(select_input).addClass('input-error');}
      if (select_msg != 0) {frm.find(select_msg).removeClass('hide');}
      //frm.find('#'+'profile-'+key).addClass('show');
    }
    function MsgErrorDestroy(frm, select_msg, select_input) {
      if (select_msg != 0) {frm.find(select_msg).html('');}
      if (select_input != 0) {frm.find(select_input).removeClass('input-error');}
      if (select_msg != 0) {frm.find(select_msg).removeClass('show');}
      //$('#'+'profile-'+key).addClass('hide');
    }

    Валидация какого-то там заказа. Автор вероятно не слышал про массивы и объекты.

    baldrs, 17 Июня 2013

    Комментарии (23)
  8. SQL / Говнокод #13032

    −165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    delete
        from liaison
    where
        type = 'UsersGroup' and
        `group` = 'static_' || (select id from usergroup where name = :grp)

    Час назад вынес этим запросом все связи между группами и юзерами в боевой базе ;)

    P.S. Почему в mysql все дерьмо, работающее совсем не так, как оно работает почти во всех остальных СУБД, включено по умолчанию?

    bormand, 22 Мая 2013

    Комментарии (23)
  9. PHP / Говнокод #12841

    +160

    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
    $query = "INSERT INTO analiz SET
        obegin = $duss,
        vbegin = $leas,
        lbegin = $duls,
        opodk  = $dusc,
        vpodk  = $leac,
        lpodk  = $dulc,
        oend   = $duse,
        vend   = $leae,
        lend   = $dule,
        ozatr  = $dusZ,
        vzatr  = $leaZ,
        lzatr  = $dulZ,
        ooplat = $dusU,
        voplat = $leaU,
        loplat = $dulU,
        opay   = $dusN,
        vpay   = $leaN,
        lpay   = $dulN,
        date   = '$dnow'";

    cOde = $pzDc

    rsvasilyev, 02 Апреля 2013

    Комментарии (23)
  10. Java / Говнокод #12810

    +86

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @Override
    public boolean equals(Object obj)
    {
       return obj != null && obj.equals(this);
    }

    SSSandman, 26 Марта 2013

    Комментарии (23)
  11. C# / Говнокод #12684

    +140

    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
    [WebMethod]
            public void runCompareService(string mAuthToken, int documentId, int origVerNum, int revisedVerNum)
            {
                //string result = null;
                DirectoryInfo tmpDirInfo = getTempDirectoryPath(documentId);
                try
                {
                    //authToken = authClient.AuthenticateUser(username, password);
                    authToken = mAuthToken;
                    otAuth.AuthenticationToken = authToken;
    
                    try
                    {
                        string origFilePath = String.Format(tmpFilePath, tmpDirInfo.ToString(), origVerNum);
                        string revisedFilePath = String.Format(tmpFilePath, tmpDirInfo.ToString(), revisedVerNum);
                        string resultFilePath = String.Format(tmpResFilePath, tmpDirInfo.ToString(), origVerNum, revisedVerNum);
    
                        string origContextId = getDocContextId(documentId, origVerNum);
                        string revisedContextId = getDocContextId(documentId, revisedVerNum);
    
                        try
                        {
                            downlodFileByContextId(origContextId, origFilePath);
                            downlodFileByContextId(revisedContextId, revisedFilePath);
                            try
                            {
                                doCompare(origFilePath, revisedFilePath, resultFilePath);
                                try
                                {
                                    DownloadToBrowser(resultFilePath);
                                    
                                    //uploadResultToCS(targetId, resultFilePath);
                                }
                                catch (Exception e)
                                {
                                    throw new Exception(String.Format("Failed to Download To Browser. Error: {0}", e.ToString()));
                                }
                            }
                            catch (Exception e)
                            {
                                throw new Exception(String.Format("Failed to do compare method . Error: {0}", e.ToString()));
                            }
                        }
                        catch (Exception e)
                        {
                            throw new Exception(String.Format("Failed to create and download file. Error: {0}", e.ToString()));
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Failed to get Context ID for version Exeption details: " + e.ToString());
                    }
    
                }
                catch (Exception e)
                {
                    throw new Exception("Failed to auth user. Exeption details: " + e.ToString());
                }
                finally
                {
                    docManClient.Close();
                    contentServiceClient.Close();
                    if (Directory.Exists(tmpDirInfo.ToString()))
                    {
                        tmpDirInfo.Delete(true);
                    }
                }
                
            }

    Landing, 04 Марта 2013

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