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

    −101

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    - (void)viewDidLoad
    {
        // ...
        
        float os_verson = [[[UIDevice currentDevice] systemVersion] floatValue];
        NSString* dev_ver_str = [[UIDevice currentDevice] systemVersion];
        
        if (os_verson >= 4 || [dev_ver_str hasPrefix:@"3.2"]) {
            [self viewWillAppear:NO];
            [self viewDidAppear:NO];
        }
    }

    Костыли наше всё

    tyler, 21 Января 2013

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    protected override Type GetEntryType()
    {
        return typeof(ReportEntry);
    }

    Код из реального проекта

    UniXoiD, 21 Января 2013

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

    +50

    1. 1
    if(!empty($filter['features']) && !empty($filter['features'])) ...

    Simpla CMS /api/Products.php

    Andretti, 21 Января 2013

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

    −167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    SELECT
    	slave.*,
             -- ...
    	FROM
    		(SELECT * FROM driver WHERE id = '$driverID') as slave
    	LEFT JOIN
             -- ...

    Отыскал в работающем проекте

    et, 21 Января 2013

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

    +21

    1. 1
    angle_in_radians = acos(dot(normalize(o-a), normalize(o-b)));

    Векторы такие сложные, а операции с ними так трудно запомнить, что даже игроделы не могут это сделать.

    TarasB, 20 Января 2013

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

    −90

    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
    95. 95
    - (void)movementScreenUp
    {
        int shift;
        switch (_numberCell) {
            case 3:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 50;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 90;
                    break;
                }
                
            case 4:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 25;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 90;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 90;
                    break;
                }
                
            case 5:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 1;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 40;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 86;
                    break;
                }
                if (clickButtonGameCells.tag == 5 || clickButtonGameCells.tag == 50) {
                    shift = - 86;
                    break;
                }
            
            case 6:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 2;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 52;
                    break;
                }
                if (clickButtonGameCells.tag == 5 || clickButtonGameCells.tag == 50) {
                    shift = - 105;
                    break;
                }
                if (clickButtonGameCells.tag == 6 || clickButtonGameCells.tag == 60) {
                    shift = - 105;
                    break;
                }
                
            default:
                break;
                 
        }
    
        [UIView animateWithDuration:0.25 animations:^{
            CGRect view_frame = self.frame;
            view_frame.origin = CGPointMake(self.frame.origin.x, shift);
            self.frame = view_frame;
        }];
    }

    Магия цифр

    tyler, 20 Января 2013

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

    −109

    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
    - (void)countDown
    {
        NSDate *currentDate = [NSDate date];
        NSTimeInterval timeInterval = ([currentDate timeIntervalSinceDate:startDate]);
        NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"ss"];
        [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
        NSString *timeString=[dateFormatter stringFromDate:timerDate];
        
        if ([timeString isEqualToString:@"02"])
        {
            [logoTimer invalidate];
            logoTimer = nil;
            // some other code
        }
    }
    
    - (void)updateCounter
    {
        startDate = [NSDate dateWithTimeIntervalSinceNow:00];
        logoTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
                                                     target:self
                                                   selector:@selector(countDown)
                                                   userInfo:nil
                                                    repeats:YES];
    }

    Вот так незатейливо можно поставить задержку на 2 секунды

    tyler, 19 Января 2013

    Комментарии (31)
  8. ActionScript / Говнокод #12450

    −120

    1. 1
    2. 2
    3. 3
    4. 4
    private function uncaughtError (e:UncaughtErrorEvent):void {
    			// be a good girl and swallow
    			e.stopImmediatePropagation ();
    		}

    написал какую-то хуету и сижу, радуюсь как маленький. да, я хочу поговорить об этом.

    makc3d, 19 Января 2013

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

    +8

    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
    #include <iostream>
     
    struct Reader_msg;
    template<class T>struct TMsg;
     
    struct IMsg
    {
        virtual ~IMsg(){}
        virtual void SendCast(Reader_msg& obj) = 0;
    };
     
    struct Some{}; 
     
    struct Reader_msg
    {
        template<class T> void ReadMsg(T& msg)
        {
            //Здесь можно приляпать статик_ассерт
            std::cout<<"ERROR UNKNOW TYPE \n";
        }
        void ReadMsg(int msg)   { (void)msg; std::cout<<"TYPE IS INT\n";   }
        void ReadMsg(float msg) { (void)msg; std::cout<<"TYPE IS FLOAT\n"; }
        void ReadMsg(Some msg)  { (void)msg; std::cout<<"TYPE IS SOME\n";  }
     
        template<class T>void TakeMsg(T& msg) { msg.SendCast(*this); }
    };
     
    template<class T>struct TMsg:IMsg
    {
        T data;
        void SendCast(Reader_msg& obj){ obj.ReadMsg(data); }
    };
     
     
    int main()
    {
        Reader_msg reader;
        TMsg<int>    msg1;
        TMsg<float>  msg2;
        IMsg& msg3 = msg1;
        IMsg& msg4 = msg2;
        TMsg<Some>   msg5;
        TMsg<double> msg6;
        
     
        reader.TakeMsg(msg1);
        reader.TakeMsg(msg2);
        reader.TakeMsg(msg3);
        reader.TakeMsg(msg4);
        reader.TakeMsg(msg5);
        reader.TakeMsg(msg6);
    }

    http://liveworkspace.org/code/4FHDTq$6

    LispGovno, 18 Января 2013

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

    +47

    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
    function executeNewsRightRelated(sfWebRequest $request)
      {
        $siteId = $request->getParameter('site')->id;
        $tNewsList = $this->object->News;
    
        $newsList = array();
        foreach ($tNewsList as $news) {
    
          $ids = array();
          foreach ($news->Sites as $idModel) {
            $ids[] = $idModel->id;
          }
    
          if (in_array($siteId, $ids)) {
            $newsList[] = $news;
          }
        }
    
        $this->newsList = $newsList;
      }

    Skiv, 18 Января 2013

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