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

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $code_date = strtotime($sms_action_date);
        $date = date(
            "Y-m-d H:i:s",
            mktime(
                date('H', $code_date),
                date('i', $code_date) + 30,
                date('s', $code_date),
                date("m", $code_date),
                date("d", $code_date),
                date("Y", $code_date)
            )
    );

    Определяем +30 минут грамотно.

    miraage, 05 Марта 2013

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

    +74

    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
    private boolean userInOneRegistrationNode() throws DfException {
    
            String uname = OrganizationStaffStructureHelper.getCurrentUserName();
    
            int i = 0;
            IDfCollection NodesCol = DQLHelper.getCollection(DQL_GET_REGISTRATOR_DIV, new String[]{uname});
            while (NodesCol.next()) {
                if (!(NodesCol == null)) {
                    String group_name = NodesCol.getString(GROUP_NAME);
                    i = i + 1;
                }
            }
    
            if (i == 1) {
                return true;
            }
            return false;
    }

    Заменяется 2мя строками один - select count(*), вторая - полученный результат Integer.ValueOf(...).

    Landing, 04 Марта 2013

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

    −107

    1. 1
    2. 2
    SelectionViewController* controller = [[[SelectionViewController alloc] initWithArray:options selectedIndex:&_selectedIndex] autorelease];
     [self.navigationController pushViewController:controller animated:YES];

    _selectedInded это ivar типа int, который передается по ссылке!! Ад!

    notxcain, 22 Февраля 2013

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

    −98

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
                [NSThread sleepForTimeInterval:0.35];
                [[NSThread mainThread] performBlock:^{
                    [titleLabel setHidden:NO];
                }];
            });

    torip3ng, 20 Февраля 2013

    Комментарии (3)
  6. Куча / Говнокод #12580

    +110

    1. 1
    <img border="0" width="476" height="179" src="file:///C|/Users/jy88h0/AppData/Roaming/Macromedia/Dreamweaver /eCustomer/iq/images/AI289.jpg" alt="Image of a properly addressed mail piece">

    http://faq.usps.com/eCustomer/iq/usps/request.do?create=kb%3AUSPSFAQ&view%28%2 9=c[c_usps0910]

    someone, 13 Февраля 2013

    Комментарии (3)
  7. Си / Говнокод #12574

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    void *threadFunc(void *)
    {
    	// ...
    	pthread_exit( (void*)lTaskId );
    	return ( (void*)lTaskId );
    	// ...
    }

    позабавило.

    для непосвященных: return в функции потока аналогичен вызову pthread_exit().

    Dummy00001, 11 Февраля 2013

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

    +135

    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
    namespace CuttingBox
    {
    
        class Program
        {
            static public Tuple<int[], String> getProperty()
            {
                int[] itemDimensionProperty = new int[3];
                String itemColorProperty;
                String[] parseResult = new String[4];
                parseResult = (Console.ReadLine().Split(' '));
                for (int counter = 0; counter < 3; counter++)
                {
                    itemDimensionProperty[counter] = Convert.ToInt32(parseResult[counter]);
                }
                itemColorProperty = parseResult[3];
                Tuple<int[], String> itemProperty = new Tuple<int[], string>(itemDimensionProperty, itemColorProperty);
                return itemProperty;
            }
    
            static void Main(string[] args)
            {
                List<Tuple<int[], String>> itemProperty = new List<Tuple<int[], String>>();
                itemProperty.Add(getProperty());
                int numberOfBoxes = Convert.ToInt32(Console.ReadLine());
                for (int counter=1; counter<=numberOfBoxes; counter++){
                    itemProperty.Add(getProperty());
                }
            }
        }
    }

    Парсим строки правильно...

    javanesovsemgovno, 11 Февраля 2013

    Комментарии (3)
  9. Pascal / Говнокод #12544

    +106

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    for j := Low(Matrix) to High(Matrix) do begin
        Caption := 'Processing ' + IntToStr(j) + ' of ' + IntToStr(High(Matrix));
        for i := Low(Matrix[j]) to High(Matrix[j]) do begin
            SendMessage(PictureWindow, WM_MOUSEMOVE, 0, MakeLPARAM(i,j));
            S := GetCaption(TemperatureWindow);
            Matrix[j,i].V := StrToFloat(S);
        end;
    end;

    Я не смог раскрыть формат нужной программы, поэтому я извлекаю данные, бегая по окну с картинкой и считывая число из окна с температурой, лол.
    Скорость считывания удручает, но пока альтернатив нет.

    TarasB, 06 Февраля 2013

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

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    SqlConnection connection = new SqlConnection(connectionString);
                SqlCommand command = connection.CreateCommand();
                using (connection = new SqlConnection(connectionString))
                {
                    command.CommandText = storedProcedure;
                }
    
                command.Connection.Open();

    Открывает соединение с сервером.

    kore_sar, 05 Февраля 2013

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

    +48

    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
    class A { 
    
        public $timeline = array();  
    
        function  __construct(){ 
            for ( $i=3; $i-->0;){ 
                array_push($this->timeline, new B); 
            } 
        } 
    } 
    
     
    
    class B { 
        public $moments = array(); 
    
        function  __construct(){ 
            for ( $i=3; $i-->0;){ 
                array_push($this->moments, new C); 
            } 
        } 
    } 
    
     
    
    class C { 
    
        public $minutes = array(); 
    
        function  __construct(){ 
            for ( $i=3; $i-->0;){ 
                array_push($this->minutes, new D); 
            } 
        } 
    } 
    
     
    
    class D { 
        public $time = 0; 
    } 
    
    echo json_encode(new A);

    Вопрос от автора: Добрый день, столкнулся с такой задачей, нужно составить массив в php что бы перегоняя в json он был вида (туткусокжасона) ...бла-бла-бла... Нашел что-то типо этого, расскажите пожалуйста толком как правильно это реализовать
    Пруфлинк: http://forum.php.su/topic.php?forum=72&topic=1873

    Razban_Guestov, 01 Февраля 2013

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