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

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

    +177

    1. 1
    2. 2
    3. 3
    4. 4
    if (!($user_info['room'] == 900002) || $user_info['room'] != 900002) { 
          header("Location: main.php");  
          die(); 
      }

    Разгребаю чужой код и нарыл.
    Чтобы условие выглядело посолидней ... или я чего-нить не понимаю.

    AndryG, 28 Октября 2010

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

    +144

    1. 1
    2. 2
    3. 3
    <?php
    $valueOne = (5 > 1) ? true : false;
    ?>

    http://en.wikipedia.org/wiki/%3F:#PHP

    metalalisa, 26 Октября 2010

    Комментарии (8)
  4. Си / Говнокод #4447

    +141

    1. 1
    sprintf(name," %s", trim("рубль",0));

    Функция trim(char*, int), где вторым параметром указывается с какой стороны удалять пробелы(0 - с обеих сторон)

    wolf, 26 Октября 2010

    Комментарии (8)
  5. Java / Говнокод #4442

    +86

    1. 1
    new Date(System.currentTimeMillis());

    Просто и со вкусом

    galak, 25 Октября 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function LeapYear(intYear) {
    	if (intYear % 100 == 0) {
    		if (intYear % 400 == 0) { return true; }
    	}else{
    		if ((intYear % 4) == 0) { return true; }
    	}
    	return false;
    }

    Пистец %)
    надыбал скриптец в проекте при чистке. Так индусы считали високостный год %))
    походу сразу %4 не работает %) или тут зарыт какой-то мэйджик смысл? %) ы

    Pepper-X, 19 Октября 2010

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

    +170

    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
    var a1 = Math.floor(Math.random()*15 + 1);
    var a2 = Math.floor(Math.random()*15 + 1);
    mismatch(2);
    var a3 = Math.floor(Math.random()*15 + 1);
    mismatch(3);
    var a4 = Math.floor(Math.random()*15 + 1);
    mismatch(4);
    var a5 = Math.floor(Math.random()*15 + 1);
    mismatch(5);
    var a6 = Math.floor(Math.random()*15 + 1);
    mismatch(6);
    var a7 = Math.floor(Math.random()*15 + 1);
    mismatch(7);
    var a8 = Math.floor(Math.random()*15 + 1);
    mismatch(8);
    var a9 = Math.floor(Math.random()*15 + 1);
    mismatch(9);
    var a10 = Math.floor(Math.random()*15 + 1);
    mismatch(10);
    var a11 = Math.floor(Math.random()*15 + 1);
    mismatch(11);
    var a12 = Math.floor(Math.random()*15 + 1);
    mismatch(12);
    var a13 = Math.floor(Math.random()*15 + 1);
    mismatch(13);
    var a14 = Math.floor(Math.random()*15 + 1);
    mismatch(14);
    var a15 = Math.floor(Math.random()*15 + 1);
    mismatch(15);

    Это и многое другое на http://ru.wikiversity.org/wiki/15_puzzle

    eval, 18 Октября 2010

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

    +162

    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
    /*
        Макрос генерирует внутренности функции-заглушки OpenGL.
    */
    #define BWT_DECLARE_OPENGL_PROC_IMPL(PROC, PROC_TYPE, ...)                                  \
        static PROC_TYPE _##PROC = 0;                                                           \
                                                                                                \
        if (_##PROC)                                                                            \
            return _##PROC(__VA_ARGS__);                                                        \
        else                                                                                    \
        {                                                                                       \
            _##PROC = TryToGetProcAddress<PROC_TYPE>(#PROC);    return _##PROC(__VA_ARGS__);    \
        }
    
    /*
        Функция получает адрес функции, или возбуждает исключение, если адрес получить не удалось.
    */
    template<typename proc_type>
    proc_type TryToGetProcAddress(const char *proc_name) throw(error_type<VIDEO>)
    {
        proc_type address = reinterpret_cast<proc_type>(::SDL_GL_GetProcAddress(proc_name));
    
        if (!address)
            BWT_THROW_VIDEO_ERROR(UNDEFINED_ERROR, "OpenGL version does not supported");
    
        return address;
    }
    
    GLAPI void APIENTRY glCullFace (GLenum mode)
    {
        BWT_DECLARE_OPENGL_PROC_IMPL(glCullFace, PFNGLCULLFACEPROC, mode);
    }
    
    ...

    ZltCity, 15 Октября 2010

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

    +144

    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
    void addSlash( const char* command, char* sdo )
    {
    	int command_length;
    	char *command_line = command;
    	command_length = strlen(command);
    	
    	while(command_length>0){
    		switch(*command_line){
    		   case '"':
    		           strcpy(sdo+strlen(sdo),"\\");
    		   default:
    		           strcpy(sdo+strlen(sdo), command_line);
    		}
    		command_line++;
    		command_length--;
    	}
    }

    Должно быть добавление слешей перед двойными кавычками.

    absolut, 11 Октября 2010

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

    +169

    1. 1
    2. 2
    3. 3
    4. 4
    /* создать задачу */
    function add_problem($value) {
    ...
    }

    prof3d, 11 Октября 2010

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

    +1001

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    string GetStringHash(string S)
            {
                MD5 md = MD5.Create();
                byte[] B = md.ComputeHash(Encoding.UTF8.GetBytes(S));
    
                return string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}",
                    B[0x00], B[0x01], B[0x02], B[0x03], B[0x04], B[0x05], B[0x06], B[0x07],
                    B[0x08], B[0x09], B[0x0A], B[0x0B], B[0x0C], B[0x0D], B[0x0E], B[0x0F]);
            }

    Запостил: 4eburashka, прямо перед выпилом ресурса.

    3.14159265, 11 Октября 2010

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