1. Java / Говнокод #3389

    +68

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    def InvoicedExtra(JobExtra extra) {
       type = extra.type
       clientPrice = extra.price ?: ZERO
       vatPrice = (extra.type.vatBand?.band ?: 0) * extra.price / 100
       grossPrice = vatPrice ?: ZERO + clientPrice ?: ZERO
    }

    Мой код на Groovy. Обратите внимание на строку 5. Это типа хитрый способ суммирования который не бросает NullPointerException. Однако не учтены приоритеты операторов. Оцените красоту выстрела в ногу =)

    tinhol, 03 Июня 2010

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

    +1001

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    struct Dir {
        Dir(const char* name) {
            d = opendir("/var/log");
        }
        ~Dir();
        const char* next();
        bool operator== (DIR* other);
    private:
        DIR* d;
    };
    ...
    Dir var_log("/var/log");

    evlad, 03 Июня 2010

    Комментарии (39)
  3. Си / Говнокод #3387

    +141

    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
    for (int x=0; x < TANK_SIZE; x++)
    
    	{
    
    		for (int y=0; y < TANK_SIZE; y++)
    
    		{
    
    			*((Uint32 *)(((Uint8 *)player_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * player_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * player_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * player_surface[LEFT]->pitch + y * player_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[RIGHT]->pixels) + x * player_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * player_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[UP]->pixels) + y * player_surface[UP]->pitch + x * player_surface[UP]->format->BytesPerPixel));
    
    			*((Uint32 *)(((Uint8 *)enemy_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * enemy_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * enemy_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * enemy_surface[LEFT]->pitch + y * enemy_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[RIGHT]->pixels) + x * enemy_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * enemy_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[UP]->pixels) + y * enemy_surface[UP]->pitch + x * enemy_surface[UP]->format->BytesPerPixel));
    
    			
    
    		}
    
    	}

    dageru, 03 Июня 2010

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

    +132

    1. 1
    2. 2
    3. 3
    if ((strlen == 0) && (key ==BNS_CLR_K || key ==WISE_K_BSPACE))
    				;
    else

    aljosha, 03 Июня 2010

    Комментарии (30)
  5. Си / Говнокод #3385

    +130

    1. 1
    2. 2
    3. 3
    #if defined (CAMCORDER_FEATURE_SUPPORT_VIEW_MODE)
    //		case SETTING_VIEW_MODE:	
    #endif

    aljosha, 03 Июня 2010

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if(TouchRegist && !gIsCleanView && !gChangeZoom &&!gChangeBrightness)
    			if( TouchRegist && gChangeZoom)
    			{
    				...
    			}	
    			break;

    aljosha, 03 Июня 2010

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

    +1005

    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
    void bvnr(char *text)
    {
    for(int f=0; f<=strlen(text); f++)
    {
    switch(text[f])
    {
    case 'Q' : text[f] = 'q' ; break;
    case 'W' : text[f] = 'w' ; break;
    case 'E' : text[f] = 'e' ; break;
    case 'R' : text[f] = 'r' ; break;
    case 'T' : text[f] = 't' ; break;
    case 'Y' : text[f] = 'y' ; break;
    case 'U' : text[f] = 'u' ; break;
    case 'I' : text[f] = 'i' ; break;
    case 'O' : text[f] = 'o' ; break;
    case 'P' : text[f] = 'p' ; break;
    case 'A' : text[f] = 'a' ; break;
    case 'S' : text[f] = 's' ; break;
    case 'D' : text[f] = 'd' ; break;
    case 'F' : text[f] = 'f' ; break;
    case 'G' : text[f] = 'g' ; break;
    case 'H' : text[f] = 'h' ; break;
    case 'J' : text[f] = 'j' ; break;
    case 'K' : text[f] = 'k' ; break;
    case 'L' : text[f] = 'l' ; break;
    case 'Z' : text[f] = 'z' ; break;
    case 'X' : text[f] = 'x' ; break;
    case 'C' : text[f] = 'c' ; break;
    case 'V' : text[f] = 'v' ; break;
    case 'B' : text[f] = 'b' ; break;
    case 'N' : text[f] = 'n' ; break;
    case 'M' : text[f] = 'm' ; break;
    )
    }
    }

    Перевод текста в нижний регистр. Можно пугать детей на ночь))

    hromjo, 03 Июня 2010

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

    +132

    1. 1
    oSqlStr[0, 12] = " '<DIV onclick=\"fShowWindow(''../ReglamSchemesDoc.aspx?code='+Cast(s1.n_pp AS VarChar(50))+''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxemaRed.gif\"></DIV>'+CASE WHEN s1.s_reglament>'' THEN '<DIV onclick=\"fShowFile('''+Replace(Replace(s1.s_reglament,' ',''),';',''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxema.gif\"></DIV><DIV onclick=\"fShowFile(''')+''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxema.gif\"></DIV>' ELSE '' END ";

    Однострочная каша из трёх языков
    Взято отсюда...
    http://www.aspnetmania.com/Forums/ForumMessage/336926.html

    mrbig66, 03 Июня 2010

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

    +112

    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
    static void Main(string[] args)
            {
                IPEndPoint myIP = null;
                TcpListener server = null;
                bool loop = true;
                while (loop)
                {
                    try
                    {
                        Random rnd = new Random(DateTime.Now.Millisecond);
                        new IPEndPoint(new IPAddress(new byte[] { 127, 0, 0, 1 }), rnd.Next(1000, 9999));
                        server = new TcpListener(myIP);
                        loop = false;
                    }
                    catch
                    {
                        loop = true;
                    }
                }
               //...
    }

    Подключаемся к серверу =)

    psina-from-ua, 02 Июня 2010

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    session_start();
    // супер-мега защита от ддоса
    $_SESSION['antiddos']==time() ? exit() : $_SESSION['antiddos']=time();
    //конец супер мега защиты
    ....
    ?>

    Найдено в старом проекте, код не мой.
    Но вы знаете, от толпы школьников с кнопками F5 это реально помогает!

    mr.The, 02 Июня 2010

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