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

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

    −99

    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
    - (void)initPlayerViewController
    {
    	BOOL isSuccess = NO;
    	do {
    		NSString *linkString = nil;
    		unsigned long long objectID = [_videoID intValue];
    		
    		int index = GetElementIndex(objectID, _WidevineTestStubs, WIDEVINE_TEST_COUNT);
    		if (index >= 0) {
    			//linkString = GetLink(_WidevineTestServers[index], _WidevineTestFiles[index]);
    			linkString = _WidevineTestLinks[index];
    		}
    		else {
    			linkString = GetString([_videoLink objectForKey:@"src"]);
    		}
    		if(linkString == nil)
    			goto _end;
    
    		self.linkType = GetLinkType(linkString);
    		switch (_linkType) {
    			case LINK_TYPE_HLS:
    				break;
    			case LINK_TYPE_WV_ADAPTIVE:
    			case LINK_TYPE_WV_MULTI:
    				linkString = WidevinePlay(linkString);
    				if ([linkString length] <= 0) {
    					goto _end;
    				}
    				break;
    			default:
    				goto _end;
    		}
    		
    		NSURL *link = [NSURL URLWithString:linkString];
    		if(link == nil)
    			break;
    
    		self.playerViewController = [[[MPMoviePlayerViewController alloc] initWithContentURL:link] autorelease];
    		_playerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
    		_playerViewController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    
    		NSInteger startPosition = GetInteger([_videoLink objectForKey:@"play_start_time"]);
    		if(startPosition > 0) {
    			_playerViewController.moviePlayer.initialPlaybackTime = (NSTimeInterval)startPosition;
    		}
    		
    		[self addControlsView];
    		NSArray *audioTracks = [_videoLink objectForKey:@"audio_list"];
    		if ([audioTracks count] < 2) {
    			UIButton *audioButton = (UIButton *)[_controlsView viewWithTag:TAG_BUTTON_CHANGE_AUDIO];
    			audioButton.enabled = FALSE;
    		}
    		
    		isSuccess = YES;
    	} while(0);
    _end:
    	if(isSuccess) {
    		[_delegate onPlayerCreated:self];
            [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    	}
    	else {
    		[_delegate onLinkError:self];
    	}
    }

    Тут есть все, и do while(0), и проваливающиеся case'ы, и TRUE/FALSE, и глобальные inline методы, и даже goto.

    ArtFeel, 13 Июня 2013

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

    +132

    1. 1
    private static string TestExistFiles(ref int maxd, ref Hashtable executedgroups)

    taburetka, 10 Июня 2013

    Комментарии (15)
  4. PHP / Говнокод #13060

    +147

    1. 1
    trim($_GET['password'])

    nc

    sleeper, 28 Мая 2013

    Комментарии (15)
  5. PHP / Говнокод #13004

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    try {
                die(@date("d.m.Y H:i:s") . "\t" . $this->x($id, true) . "\r\n");
    } catch (Exception $e) {
                die(@date("d.m.Y H:i:s") . "\tERROR: " . $e->getMessage() . "\r\n");
    }

    остаться в живых

    Lure Of Chaos, 15 Мая 2013

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

    +101

    1. 1
    2. 2
    3. 3
    4. 4
    if(searchParams == null)
    {
    	throw new NullReferenceException("параметры поиска = null" + searchParams.ToString());
    }

    Эдакий InnerException, чтоб верняково

    NeoN, 01 Мая 2013

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

    −102

    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
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    @interface CORERatingImages : NSObject
    {
        UIImage *imageForOne;
        UIImage *imageForTwo;
        UIImage *imageForThree;
        UIImage *imageForFour;
        UIImage *imageForFive;
    }
    +(CORERatingImages *) ratingImages;
    -(UIImage *) getRatingImage:(int) ratings;
    @property (nonatomic, retain) UIImage *imageForOne;
    @property (nonatomic, retain) UIImage *imageForTwo;
    @property (nonatomic, retain) UIImage *imageForThree;
    @property (nonatomic, retain) UIImage *imageForFour;
    @property (nonatomic, retain) UIImage *imageForFive;
    -(void) releaseResources;
    @end
    
    static CORERatingImages *ratingImages = nil;
    
    @implementation CORERatingImages
    @synthesize imageForOne;
    @synthesize imageForTwo;
    @synthesize imageForThree;
    @synthesize imageForFour;
    @synthesize imageForFive;
    
    +(CORERatingImages *) ratingImages
    {
        @synchronized(self)
        {
            if (ratingImages == nil)
            {
                ratingImages = [[self alloc] init];
            }
        }
        return ratingImages;
    }
    -(id) init
    {
        if (self = [super init])
        {
            self.imageForOne = [UIImage imageNamed:@"1.png"];
            self.imageForTwo = [UIImage imageNamed:@"2.png"];
            self.imageForThree = [UIImage imageNamed:@"3.png"];
            self.imageForFour = [UIImage imageNamed:@"4.png"];
            self.imageForFive = [UIImage imageNamed:@"5.png"];
        }
        return self;
    }
    -(UIImage *) getRatingImage:(int) ratings
    {
        if (ratings == 1)
        {
            return imageForOne;
        }
        else if (ratings == 2)
        {
            return imageForTwo;
        }
        else if (ratings == 3)
        {
            return imageForThree;
        }
        else if (ratings == 4)
        {
            return imageForFour;
        }
        else if (ratings == 5)
        {
            return imageForFive;
        }
        else
        {
            return [UIImage imageNamed:@"0.png"];
        }
    }
    -(void) dealloc
    {
        NSLog(@"release Images");
        [imageForOne release];
        [imageForTwo release];
        [imageForThree release];
        [imageForFour release];
        [imageForFive release];
        [super dealloc];
    }
    -(void) releaseResources
    {
        [ratingImages release];
        ratingImages = nil;
    }
    
    @end

    Массив или stringWithFormat: @"%d.png"?

    Не, не слышал.

    QuickNick, 11 Апреля 2013

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $.post("include/show_watching.php",
        function(data) {
            $('#content').empty().append(data);
        }
    );

    Вот такой вот POST-запрос.

    Stallman, 26 Марта 2013

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

    +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
    using (var twainManager = new DeviceManager())
    {
        twainManager.Open();
        using (var evn = new ManualResetEvent(false))
        {
            var device = twainManager.Devices[targetDevice.Index];
            device.UserInterfaceClosed += (sender, args) => { evn.Set(); };
            device.Setup();
            evn.WaitOne();
        }
        twainManager.Close();
    }

    Модальное открытие говноформы.

    kovyl2404, 25 Марта 2013

    Комментарии (15)
  10. JavaScript / Говнокод #12774

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function printf(format, value) {
          return format.replace(/%s/, value.toString());
        }
    
        return {
    
          updateProgressBar: function (percentage) {
            console.log("update \"progressBar\" status");
            progressBar.innerHTML = printf("<p>%s %</p>", percentage);
          }
    
        };

    __proto__, 21 Марта 2013

    Комментарии (15)
  11. PHP / Говнокод #12771

    +149

    1. 1
    2. 2
    $ev = '$atHtml[] = template::translateTemplate('.$atArr[0].'::getHTML($atArr[1]));';
    eval($ev);

    Самый простой способ заставить работать статический метод класса из переменной в PHP ниже 5.3.

    Lander, 20 Марта 2013

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