1. JavaScript / Говнокод #16792

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    asdasd
    asd
    asd
    asd
    asf
    2
    F
    if

    embrace, 03 Октября 2014

    Комментарии (2)
  2. Java / Говнокод #16791

    +89

    1. 1
    2. 2
    3. 3
    String os = System.getProperty("os.name");
    if (os.startsWith("Windows 9") || os.equals("Windows Me")) {
    throw new RuntimeException(

    https://searchcode.com/?q=if%28version%2Cstartswith%28%22window s+9%22%29
    Очевидно Windows 10 спасёт ситуацию.

    Говногость, 03 Октября 2014

    Комментарии (54)
  3. bash / Говнокод #16790

    −97

    1. 1
    if [ `ls -al /some/path/ | grep filename | (read a b c d e f g h i j k && echo ${i})` != "" ]; then

    я бы до такого никогда не додумался. авторство утеряно в аналах: то ли немецкое, то ли американское творчество.

    Dummy00001, 02 Октября 2014

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

    −398

    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
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save", nil) style:UIBarButtonItemStylePlain target:self action:@selector(save:)];
        
        // ...
    
        self.navigationItem.rightBarButtonItems = @[saveButton, someOtherButton];
    
        self.saveBarButtonItem = saveButton;
    }
    
    - (void)someMethod
    {
        [self.navigationItem.rightBarButtonItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
            UIBarButtonItem *barItem = (UIBarButtonItem *)obj;
            if ([barItem.title isEqualToString:NSLocalizedString(@"Save", nil)]) {
                barItem.enabled = NO;
            }
        }];
    }

    Задача: включать/выключать кнопку по определенному событию.

    gumbert, 02 Октября 2014

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

    −413

    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
    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        [TMSpinner hide];
        if (self.registrationModel && !self.loggedIn && [[self.webView.request.URL absoluteString] length]) {
            [self autologinTheWebView];
        }
    }
    
    #pragma mark - Black magic
    
    - (void)autologinTheWebView {
        [self.webView stringByEvaluatingJavaScriptFromString:[self javascriptToInject]];
        [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"autologin('%@', '%@');", self.registrationModel.email, self.registrationModel.password]];
        self.loggedIn = YES;
    }
    
    - (NSString *)javascriptToInject {
        return @"autologin = function(email, password) {"
               @"  var emailField = document.getElementById('user_email');"
               @"  var passwordField = document.getElementById('user_password');"
               @"  var submitButton = document.querySelector('input.btn.btn-default.btn-success');"
               @"  emailField.value = email;"
               @"  passwordField.value = password;"
               @"  submitButton.click();"
               @"};";
    }

    js в obj-c. кому то после меня это поддерживать :)

    Drenwtc, 02 Октября 2014

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

    +158

    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
    $(document).ready(function() {
     $('.tab1').click(function () {
      $('.tab-t1').show();
        $('.tab-t2').hide();
        $('.tab-t3').hide();
        $('.tab1 i').addClass('active');
        $('.tab2 i').removeClass('active');
        $('.tab2 i').removeClass('active');
     });
    
     $('.tab2').click(function () {
      $('.tab-t1').hide();
        $('.tab-t2').show();
        $('.tab-t3').hide();
        $('.tab1 i').removeClass('active');
        $('.tab2 i').addClass('active');
        $('.tab3 i').removeClass('active');
     });
     $('.tab3').click(function () {
      $('.tab-t1').hide();
        $('.tab-t2').hide();
        $('.tab-t3').show();
        $('.tab1 i').removeClass('active');
        $('.tab2 i').removeClass('active');
        $('.tab3 i').addClass('active');
     });
    });

    Из тестового задания

    IRIDON, 02 Октября 2014

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    $logics = $elementORM->getLogics();
    					if (count($logics > 0)) {
    						foreach($logics as $kLogic => $logic) { // logic
    							foreach($logic["conditions"] as $kCondition => $condition) { // condition

    limitium, 02 Октября 2014

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    try {
     Transform_Excel::$zohoFilterEbanyKostyl2 = true;
     $importService->import($id);
     Helpers_Response::json([

    limitium, 02 Октября 2014

    Комментарии (13)
  9. ActionScript / Говнокод #16784

    −94

    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
    private function getYouTubeVideoIdFromURL (url:String):String {
    	if (URLUtil.isHttpsURL(url)||URLUtil.isHttpURL(url)) {
    		var startIndex:int = url.indexOf("v=")+2;
    		var endIndex:int = url.indexOf("&");
    		if (endIndex>startIndex) {
    			url = url.slice(startIndex, endIndex); 
    		}
    		else {
    			url = url.slice(startIndex);
    		}
    	}
    	return url;
    }

    Целый отдел над этой функцией работал.

    wvxvw, 01 Октября 2014

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    static public function dateDb2Human($dbDate) {
    
    	$date = strptime(explode('.', $dbDate)[0], '%Y-%m-%d %H:%M:%S');
    	return $date['tm_mday'].'.'.$date['tm_mon'].'.'.(1900+$date['tm_year']).' ('.($date['tm_hour'] < 10 ? '0' : '').$date['tm_hour'].':'.($date['tm_min'] < 10 ? '0' : '').$date['tm_min'].')';
    
    } //static public function dateDb2Human($dbDate)

    Это функция для преобразования даты из формата ГГГГ-ММ-ДД ЧЧ:ММ:CC в ДД.ММ.ГГГГ (ЧЧ:ММ)

    alxkolm, 01 Октября 2014

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