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

    −382

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if (present) {
            // only if not pull down
            _isLoading = !self.refreshControl.isRefreshing;
            
            self.tableView.userInteractionEnabled = NO;
        }
        if (!present) {
            _isLoading = NO;
            
            self.tableView.userInteractionEnabled = YES;
        }

    stanislaw, 12 Ноября 2014

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

    +86

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public interface ArchitectureUnit<T> {
    		
    		public T release(Object... params); 
    		
    	}

    максимальная гибкость

    _a_o_O, 12 Ноября 2014

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

    −101

    1. 1
    self.exclude = list(set(list(self.exclude or []) + ['str1', 'str2']))

    american_idiot, 12 Ноября 2014

    Комментарии (14)
  4. JavaScript / Говнокод #17097

    +160

    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
    $scope.close_menu = function(resize){
            if(window.innerWidth<=1023) var width=280;
            else var width=390;
            var duration=(resize)? 0:300;
            $('.menu').removeClass('active').animate({right:-width+'px'},duration);
            $('.wrapper').animate({right:'0px'},duration);
            $('body').css({'overflow':'auto'});
            $('.menu_btn').animate({marginRight:'0px'},duration,function(){});
            $('.videocontainer').animate({right:'0px'},duration);
            $('.blog_share.active > a,.blog_share.active > ul').animate({right:'0px'},duration);
            $('.backgorund_transparent').hide();
    
            if(typeof isMoving != 'undefined') isMoving=false;
        }

    Просто AngularJs...

    keitoaino, 12 Ноября 2014

    Комментарии (26)
  5. Си / Говнокод #17096

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    static enum rc (*request_functions[])(void) = {
        ko,
        koko,
        kokoko,
        illegal_request
    };
    static inline enum rc illegal_request(void) { return ILLEGAL_REQUEST; }
    
    reply.rc = request_functions[cmd.opcode < NKEYS(request_functions) ? cmd.opcode : ILLEGAL_REQUEST]();

    Вызываем функцию по опкоду с абортом в случае index_out_of_bounds.

    codemonkey, 12 Ноября 2014

    Комментарии (38)
  6. Ruby / Говнокод #17095

    −82

    1. 1
    2. 2
    3. 3
    4. 4
    @old_article_purchase.old_article.warehouse_placement = '102A1'
    if @old_article_purchase.old_article.valid?
       @old_article_purchase.old_article.save   
     end

    andrejlr, 12 Ноября 2014

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

    −396

    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
    @implementation SlideMenuNavigationBar
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
    
        for (UIView *aView in self.subviews) {
            
            // Correcting menu toggle button position
            if ([[aView.class description] isEqualToString:@"UIButton"] && aView.frame.origin.x < self.frame.size.width/2) {
                CGRect frame = aView.frame;
                frame.origin.x = 12; // 8 for correlation
                frame.origin.y = -1; // 1 for correlation
                aView.frame = frame;
            }
            
            if (aView.frame.origin.x > self.frame.size.width/2 && !isIPad && ![[aView.class description] isEqualToString:@"ColoredView"]) {
                CGRect frame = aView.frame;
                frame.origin.x = 260; // 8 for correlation
                frame.origin.y = -1;  // 1 for correlation
                aView.frame = frame;
            }
            
            // Correcting back button and right button positions
            if ([[aView.class description] isEqualToString:@"_UINavigationBarBackIndicatorView"]) {
                CGRect frame = aView.frame;
                frame.origin.y = [self.class navigationBarHeight] - kDefaultNavigationBarHeight + 5; // 5 for correlation
                aView.frame = frame;
            }
            if ([[aView.class description] isEqualToString:@"UINavigationButton"]) {
                CGRect frame = aView.frame;
                frame.origin.y = [self.class navigationBarHeight] - kDefaultNavigationBarHeight + 2; // 2 for correlation
                aView.frame = frame;
            }
            
            if ([aView isKindOfClass:[NavigationBarButton class]]) {
                CGRect frame = aView.frame;
                frame.origin.x = 278; // 8 for correlation
                frame.origin.y = 6;   // 1 for correlation
                aView.frame = frame;
            }
        }
    }
    
    @end

    фиг знает что думали :D

    l0gg3r, 11 Ноября 2014

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

    +50

    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
    #include <iostream>
    using namespace std;
    
    void f(int i)
    {
    	cout << "----" << endl;
    	void *array[] = { &&foo, &&bar, &&baz };
    	goto *array[i];
    	foo:
    	cout << "Foo" << endl;
    	bar:
    	cout << "Bar" << endl;
    	baz:
    	cout << "Baz" << endl;
    }
    
    int main() {
    	// your code goes here
    	f(0);
    	f(1);
    	f(2);
    	return 0;
    }

    http://ideone.com/63tRls
    gcc extension

    DlangGovno, 10 Ноября 2014

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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // Real itemid is "contained" in public itemid in a bit tricky way. The formula is:
    
    public_itemid = itemid * 256 + anum
    
    // Quite easy, isn't it? Except where to get that anum. anum is some number assigned when you create a new post in LJ.
    
    // But in fact, you don't need it. Because it is always less than 256, we can avoid searching for it, and just use simple Math to find itemid.
    
    $anum = $public_itemid - floor($public_itemid / 256) * 256;
    $itemid = ($public_itemid - $anum) / 256;

    Прекрасный подход, то место, где вордпресс и ЖЖ сошлись воедино.

    http://drumrock.skipitnow.org/livejournal-tools/itemid/

    Fike, 10 Ноября 2014

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

    +159

    1. 1
    $image_type = substr($image_data,strpos($image_data, '/')+1,strpos($image_data, ';')-(strpos($image_data, '/')+1));

    Выдирание типа из заголовка base64-закодированного изображения (data:image/jpeg;base64,......................)

    Anxizzz, 10 Ноября 2014

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