1. Objective C / Говнокод #10400

    −83

    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
    + (void) playMovieWithResourceFile: (NSString *) file
    {
        const char *source = [ file cStringUsingEncoding: [NSString defaultCStringEncoding] ];
        size_t length = strlen( source );
        
        char *str = malloc( sizeof( char) * (length + 1)  );
        memcpy( str, source, sizeof (char) * (length + 1) );
        
        char *type = strstr( str, "."); 
        *type = 0;
        type++; //< now we have extension in type, and name in str cStrings
        
        NSAutoreleasePool *pool = [NSAutoreleasePool new];
        NSString *sName, *sType;
    	
        sName = [ NSString stringWithUTF8String: str ];
        sType = [ NSString stringWithUTF8String: type];
        [self playMovieWithName: sName Type: sType];
        
        // free str, but do not free type - it is a part of str
        free( str );
        
        [pool release];    
    }

    Вроде бы серьезный проект cocos2d-extensions https://github.com/cocos2d/cocos2d-iphone-extensions
    Отрезаем расширение у файла :)

    Или я что-то не понимаю…

    pilot34, 29 Мая 2012

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

    +75

    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
    if (ereg("^/products/([0-9]+)/$",$dn,$m)){
        $block_id = $m[1];
        $dn_page = "/products/";
    }
    
    if (ereg("^/products/([-a-z0-9_\.]+)/$",$dn,$m)){
        $block_alias = $m[1];
        $dn_page = "/products/";
    }
    
    if (ereg("^/articles/([0-9]+)/$",$dn,$m)){
        $block_id = $m[1];
        $dn_page = "/articles/";
    }
    
    if (ereg("^/news/([0-9]+)/$",$dn,$m)){
        $block_id = $m[1];
        $dn_page = "/news/";
    }
    
    if (ereg("^/products/([0-9]+)/([0-9]+)/$",$dn,$m)){
        $block_id = $m[1];
        $product_id = $m[2];
        $dn_page = "/products_detail/";
    }
    
    if (ereg("^/products/([-a-z0-9_\.]+)/([-a-z0-9_\.]+)/$",$dn,$m)){
        $block_alias = $m[1];
        $product_alias = $m[2];
        $dn_page = "/products_detail/";
    }
    // дальше начинается ад, не для слабонервных

    Я не буду показывать остальной код и рассказывать, что html в php пихать не красиво, ведь все мы индивидуальны и пишем как хотим. =)
    Кроме всего прочего, человек видимо очень стар и использует давно устаревшую функцию ereg, которая в версии 5.3.0 не имеет силы.
    На эту тему можно пофилософствовать и развести холивар, но мы же разумные люди и те кто пишет комментарии высшие программисты,
    ибо их слово это закон. По крайней мере вы так думаете)

    oooZinka, 29 Мая 2012

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

    −40

    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
    /*
    	 * This GtkIMHtml has the maximum number of smileys allowed, so don't
    	 * add any more.  We do this for performance reasons, because smileys
    	 * are apparently pretty inefficient.  Hopefully we can remove this
    	 * restriction when we're using a better HTML widget.
    	 */
    	unescaped = purple_unescape_html(smiley);
    	numsmileys_thismsg = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg"));
    	if (numsmileys_thismsg >= 30) {
    		gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1);
    		g_free(unescaped);
    		return;
    	}
    	numsmileys_total = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total"));
    	if (numsmileys_total >= 300) {
    		gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1);
    		g_free(unescaped);
    		return;
    	}

    Вот такой прикол от Pidgin. Больше 30 смайлов в сообщении и 300 в диалоге - низя. Захардкодили, ибо стыдно, что тормозит. А оно действительно тормозит.

    g0rky, 29 Мая 2012

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

    +102

    1. 1
    return (m.Id == Id) ? (true) : (false);

    походу платят за символы

    MegaZver, 29 Мая 2012

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

    +72

    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
    public AllianceEntity getByMember(BigInteger dcgId) {
            for (AllianceEntity alliance : getAll()) {
                if (String.valueOf(alliance.getAdminDcgId()).equals(String.valueOf(dcgId))) {
                    return alliance;
                }
                for (BigInteger memberDcgId : alliance.getMembersAsList()) {
                    if (String.valueOf(memberDcgId).equals(String.valueOf(dcgId))) {
                        return alliance;
                    }
                }
                for (BigInteger officerDcgId : alliance.getOfficersAsList()) {
                    if (String.valueOf(officerDcgId).equals(String.valueOf(dcgId))) {
                        return alliance;
                    }
                }
            }
            return null;
        }

    все айдишники BigInteger..

    iliakot, 29 Мая 2012

    Комментарии (0)
  6. Java / Говнокод #10395

    +123

    1. 1
    createCanvas(); // create canvas!

    Комментарии от Кэпа.

    someone, 29 Мая 2012

    Комментарии (16)
  7. Java / Говнокод #10394

    +119

    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
    /**
     * crane looks like this: ("----" - fork, "ssss" - stand, "xxx" - crane rail)
     * 
     * ----- .pos2 __/0/ ----- | sssss | sssss | xxx | ----- distance between stands .pos1 __|/distance/ ----- sssss
     * sssss xxx xxx xxx xxx xxx xxx
     * 
     * so if pos2 defined - it will be the second fork; BUT! if the flag "draw second stand" defined - that will draw or
     * not draw the stand for pos1...
     * 
     * if there is just one fork but two TUs to handle is possible:
     * 
     * xxx ________ .pos1 .pos2 ________ sssss sssss xxx xxx xxx
     */

    someone, 29 Мая 2012

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

    +62

    1. 1
    2. 2
    <<<<<<<<<<<<<<<<<===============================>>>>>>>>>>>>>>>>>
                                                      АДМИН - ПИДОР!!!

    uiopqwertyasd, 29 Мая 2012

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

    −119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Запрос.Текст = "ВЫБРАТЬ РАЗЛИЧНЫЕ
    .....
    ГДЕ
    .....
    И ОсновныеНачисления.Авторасчет = Истина
    И ОсновныеНачисления.Авторасчет = Ложь"

    Выбрать обязательно различные! :)

    mrbus, 29 Мая 2012

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

    −30

    1. 1
    2. 2
    TempAnalogTable[ArrayData->GetNomerElement( j )].Data = 
                Chanel.TempPlace[in] + ( Chanel.TempPlace[in + 1] << 8 );

    Скажите, это нормально?

    cyrax, 29 Мая 2012

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