1. Python / Говнокод #16794

    −98

    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
    def down_cast_qobject(tp, obj):
        assert obj
        assert isinstance(tp, type)
        assert issubclass(tp, QObject)
        addresses = shiboken.getCppPointer(obj)
        assert isinstance(addresses, collections.Iterable)
        assert len(addresses)
        ptrs = filter(lambda p: p > 0L, addresses)
        assert ptrs
        ptr = ptrs[0]
        assert isinstance(ptr, long)
        wrapped = shiboken.wrapInstance(ptr, tp)
        assert isinstance(wrapped, tp)
        return wrapped

    Paranoid_mode = True

    QBatman, 03 Октября 2014

    Комментарии (32)
  2. JavaScript / Говнокод #16793

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $("a").easyTooltip();
    		$("a#link").easyTooltip({
    			tooltipId: "easyTooltip2",
    			content: '<img src="new/img/our_work/mosdacha_g.jpg" />'
    		});

    Неуверенный программист.

    Vasiliy, 03 Октября 2014

    Комментарии (6)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. 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)
  10. 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)