1. PHP / Говнокод #8382

    +155

    1. 1
    2. 2
    3. 3
    $janres = serialize(isset($_POST['janres']) ? SafeEnv($_POST['janres'], 11, int) : array());
    
        if($tree->IdCats[$cat]['janres'] == "0") $janres = serialize(array());

    Бредокод

    Мартин, 01 Ноября 2011

    Комментарии (0)
  2. Си / Говнокод #8381

    +133

    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
    #include <stdio.h>
    #include <stdlib.h>
    
    #define $ /* */
    
    #define ARGV argv
    
    #define if($x) int main(int argc, char *argv[])
    
    #define $start 1  
    
    #if PERL
     sub atoi { $_[0] }
     $ argc=@ARGV;
     $ start=0;
     $ x=1;
    #endif
    
    if($x)
    {
     int $ sum;
     int $ i;
     
     $ sum=0;
    
     for ( $ i = $start; $ i < $ argc ; $ i++) {
       $ sum += atoi ($ ARGV [$ i]);}
    
     printf("%d\n", $ sum);
    
    exit(0);
    }

    Пришла в голову вот такая вот идея, уже пишу серьезный проект, а вам даю на оценку вот такой вот код.
    Думаю вообще связать это все дело еще и с PHP, вот таким вот образом:
    <?php system('./home/Cuberpunk/private/iGuruCodder/SeriousProject/main 15 12 15'); ?>
    Хотел запостить на Хабр, но нету там аккаунта, поэтому пишу сюда ;)
    Оценивайте, комментируйте. Сейчас работаю над крупным проектом на эту тему, ждите.
    Если кому интересно, то вот моя темка на форуме, где все более подробно описано:
    http://forum.antichat.ru/threadedpost2883414.html

    Cyber-punk, 01 Ноября 2011

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

    +154

    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
    function getDirName($artistId)
        {
            $dirName = 1;
            $startNumber = 500;
            $result = false;
    
            while(!$result) {
                if ($artistId <= $startNumber) {
                    $result = true;
                }
                else {
                    $dirName++;
                    $startNumber += 500;
                }
            }
    
            return $dirName;
        }

    Весь прикол такой, что фотки на сервере лежат по 500 штук и зная id артиста можно узнать в какой из директории лежит его фотка. Вместо того чтобы написать, что то типа - $dirName = round($artistId / 500); я выдумал вот такую несуразицу :)

    dev6alexander, 01 Ноября 2011

    Комментарии (20)
  4. Куча / Говнокод #8379

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    data М = М { unМ :: String }
    instance Show М where
        show = map succ . unМ
    
    main = print $ М"ФТИ"

    Синтетический баян...

    kirgo2, 01 Ноября 2011

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

    +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
    int i128 = 0, i256 =0, i384=0, i512=0, i640=0, i786=0, i896=0, i1024=0, i1152=0, i1280=0, i1408=0, i1536=0;
            for (int index: data) {
                if (index>max) max = index;
                if (min>index) min = index;
                if (0<=index & index<128) i128++;
                else if (128<=index & index<256) i256++;
                else if (256<=index & index<384) i384++;
                else if (384<=index & index<512) i512++;
                else if (512<=index & index<640) i640++;
                else if (640<=index & index<786) i786++;
                else if (786<=index & index<896) i896++;
                else if (896<=index & index<1024) i1024++;
                else if (1024<=index & index<1152) i1152++;
                else if (1152<=index & index<1280) i1280++;
                else if (1280<=index & index<1408) i1408++;
                else if (1408<=index & index<1536) i1536++;

    Считаем количество попаданий index в различные диапазоны значений.

    betastat, 01 Ноября 2011

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if (
    	$arItem["DEPTH_LEVEL"]==$previousLevel
    	&&$arItem["IS_PARENT"]
    	&&$arItem["DEPTH_LEVEL"]>3
    	||$arItem["DEPTH_LEVEL"]<$previousLevel
    	&&$arItem["IS_PARENT"]
    	&&$arItem["DEPTH_LEVEL"]==3
    	&&$previousLevel-$arItem["DEPTH_LEVEL"]==1
    ) 
    .....

    Paranoid mode deteсted! Внимание! (Г)Код был в строку, для удобства чтения отформатировал.

    ProfBiss, 01 Ноября 2011

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

    −116

    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
    // было
    
    -(BOOL)textFieldShouldReturn:(UITextField *)textField {
        
        if (textField == firstName) {
            [lastName becomeFirstResponder];
        }
        
        else if (textField == lastName) {
            [zip becomeFirstResponder];
        } 
        
        else if (textField == emailAdr) {
            [confirmEmailAdr becomeFirstResponder];
        }    
        else if (textField == confirmEmailAdr) {
            [zip becomeFirstResponder];
        }
        else if (textField == zip) {
            [street becomeFirstResponder];
        }
        else if (textField == street) {
            [city becomeFirstResponder];
        }
        else if (textField == city) {
            [telephonNumber becomeFirstResponder];
        }
        else if (textField == telephonNumber) {
            [wachtwoord becomeFirstResponder];
        }
      
        else{
            [textField resignFirstResponder];
        }
        
        
        return YES;
    }
    
    // решил заменить на ( при условии что все текстфилды протаганы от 1 до N):
    
    -(BOOL)textFieldShouldReturn:(UITextField *)textField {
    
        int tag = textField.tag;
        
        UITextField* tf = (UITextField*)[self.scrollView viewWithTag:tag+1];
        
        if ( tf ) 
            [tf becomeFirstResponder];
        else 
            [textField resignFirstResponder];
        
        return YES;
    }

    lime, 01 Ноября 2011

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

    +80

    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
    @Deprecated
        private byte getLoByte(int i) {
            byte ret = 0x00;
            String hex = Integer.toHexString(i);
            int length = hex.length();
            if (length == 1) {
                ret = Integer.valueOf(hex.substring(length - 1), 16).byteValue();
            } else if (length >= 2) {
                ret = Integer.valueOf(hex.substring(length - 2), 16).byteValue();
            }
            return ret;
        }
    
        @Deprecated
        private byte getHiByte(int i) {
            String hex = Integer.toHexString(i);
            byte ret = 0x00;
            int length = hex.length();
            if (length > 3) {
                ret = Integer.valueOf(hex.substring(length - 4, length - 2), 16).byteValue();
            } else if (length == 3) {
                ret = Integer.valueOf(hex.substring(length - 3, length - 2), 16).byteValue();
            }
            return ret;
        }

    Вытаскивание старшего и младшего байтов числа из последних одного или двух байтов

    as1an, 01 Ноября 2011

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

    −102

    1. 1
    2. 2
    Сегодня мы отказались от 1С.
    Сегодня, когда день апплодировал стоя.

    А в штанах остались желтые бумажки. В назидание?

    alexoy, 31 Октября 2011

    Комментарии (3)
  10. ActionScript / Говнокод #8373

    −128

    1. 1
    2. 2
    3. 3
    4. 4
    if (players.indexOf(String(Game.uid)) == 0)
    	players.shift();
    else
    	players.pop();

    KirAmp, 31 Октября 2011

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