1. PHP / Говнокод #11317

    +58

    1. 1
    2. 2
    3. 3
    $attr_id = json_decode($_GET['attr_id']);
    $obj_id = json_decode($_GET['obj_id']);
    $a_href = $_GET['file_id'];

    Разгребаю что осталось от недавно уволенного джуниора.
    2 json_decoda толкают в уныние. При том что джсон туда вообще не приходит =\

    Жаль вот уже, не сохранился код, в к-м он пришедший на _клиент в браузер_ json парсил руками(JSON.parse() - для слабых)

    vitaly, 29 Июня 2012

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

    −92

    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
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    	
        self.view.frame=CGRectMake(10,10, 300, 200);
        
    	return 3;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    	
    	static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
        
        // Configure the cell...
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        switch (indexPath.row) {
            case 0:
                //ToDo: Add UserInfo's view into TableView
                [cell.contentView addSubview:upperView];
                break;
            case 1:{
                //Remove preous view/tableview
                for (id vw in cell.contentView.subviews) {
                    if ([vw isKindOfClass:[UITableView class]]) {
                        [vw removeFromSuperview];
                    }
                }
                //
                
                //Add View which contain tableview
                 EditListViewController *editlistvw=[[EditListViewController alloc] initWithNibName:@"EditListViewController" bundle:nil]  ;
                
                editlistvw.view.frame=CGRectMake(10, 10, 300, 20);
                
                [cell.contentView addSubview:editlistvw.tableView];
                //
                break;
            }
            case 2:
                //Remove previous view/tableview
                for (id vw in cell.contentView.subviews) {
                    if ([vw isKindOfClass:[UITableView class]]) {
                        [vw removeFromSuperview];
                    }
                }
                break;
            default:
                break;
        }
        return cell;
    }

    Творение индийского джуниора, совместно с которым приходится делать проект

    GLvRzZZ, 29 Июня 2012

    Комментарии (19)
  3. Assembler / Говнокод #11315

    +184

    1. 1
    CD20

    первая программа на асм

    nefedoff-96, 29 Июня 2012

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

    −16

    1. 1
    2. 2
    3. 3
    void setOn(const bool &on) {
        // ...
    }

    А вот чего только не встретишь в коде...

    glook, 29 Июня 2012

    Комментарии (18)
  5. Assembler / Говнокод #11313

    +199

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    sum proc ; ax=ax+bx
            push dx
    m1:     mov dx, ax
            xor ax, bx
            and bx, dx
            shl bx, 01h
            cmp bx, 00h
            jnz m1
            pop dx
            ret
    sum endp

    Навеяно http://govnokod.ru/11311

    movaxbx, 28 Июня 2012

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

    +65

    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
    $quGroup = mysql_query($x = "
            SELECT
                a.latitude, a.longitude, a.catid, a.id, a.title, a.arttype, a.userid, b.firstname, b.lastname, b.usertype,
                a.latitude2, a.longitude2, a.latitude3, a.longitude3, a.latitude4, a.longitude4, a.latitude5, a.longitude5,
                a.latitude6, a.longitude6, a.latitude7, a.longitude7, a.latitude8, a.longitude8, a.latitude9, a.longitude9,
                a.latitude10, a.longitude10, a.latitude11, a.longitude11
            from materials a, users b
            where a.status='1' and a.userid=b.id and add_date > $day)
            $sql_cond");
        while ($flGroup = mysql_fetch_row($quGroup)) {
            $j++;
            $a1 = $a2 = array ();
            $l1 = $flGroup[0];
            $l2 = $flGroup[1];
            if ($l1 && $l2) {
                $a1[] = $l1;
                $a2[] = $l2;
            }
    
            $latitude2 = $flGroup[10];
            $longitude2 = $flGroup[11];
            if ($latitude2 && $longitude2) {
                $a1[] = $latitude2;
                $a2[] = $longitude2;
            }
    
            $latitude3 = $flGroup[12];
            $longitude3 = $flGroup[13];
            if ($latitude3 && $longitude3) {
                $a1[] = $latitude3;
                $a2[] = $longitude3;
            }
    
            $latitude4 = $flGroup[14];
            $longitude4 = $flGroup[15];
            if ($latitude4 && $longitude4) {
                $a1[] = $latitude4;
                $a2[] = $longitude4;
            }
    
            $latitude5 = $flGroup[16];
            $longitude5 = $flGroup[17];
            if ($latitude5 && $longitude5) {
                $a1[] = $latitude5;
                $a2[] = $longitude5;
            }
    
            $latitude6 = $flGroup[18];
            $longitude6 = $flGroup[19];
            if ($latitude6 && $longitude6) {
                $a1[] = $latitude6;
                $a2[] = $longitude6;
            }
    
            $latitude7 = $flGroup[20];
            $longitude7 = $flGroup[21];
            if ($latitude7 && $longitude7) {
                $a1[] = $latitude7;
                $a2[] = $longitude7;
            }
    
            $latitude8 = $flGroup[22];
            $longitude8 = $flGroup[23];
            if ($latitude8 && $longitude8) {
                $a1[] = $latitude8;
                $a2[] = $longitude8;
            }
    
            $latitude9 = $flGroup[24];
            $longitude9 = $flGroup[25];
            if ($latitude9 && $longitude9) {
                $a1[] = $latitude9;
                $a2[] = $longitude9;
            }
    
            $latitude10 = $flGroup[26];
            $longitude10 = $flGroup[27];
            if ($latitude10 && $longitude10) {
                $a1[] = $latitude10;
                $a2[] = $longitude10;
            }
    
            $latitude11 = $flGroup[28];
            $longitude11 = $flGroup[29];
            if ($latitude11 && $longitude11) {
                $a1[] = $latitude11;
                $a2[] = $longitude11;
            }
    
            if (!$l1 && !$l2 && !$latitude2 && !$longitude2 && !$latitude3 && !$longitude3 && !$latitude4 && !$longitude4 && !$latitude5 && !$longitude5 && !$latitude6 && !$longitude6 && !$latitude7 && !$longitude7 && !$latitude8 && !$longitude8 && !$latitude9 && !$longitude9 && !$latitude10 && !$longitude10 && !$latitude11 && !$longitude11)
                continue;
    
    ...
    }

    как изящно

    shmaltorhbooks, 28 Июня 2012

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

    −2

    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
    //сравниваем два числа, функция не использует операторы < и > в целях переносимости на платформы, где они не поддерживаются
    auto intcmp( int a, int b ) -> int {
    	while( a && b ) {
    		a--;
    		b--;
    	}
    	if ( a == 0 && b == 0 ) // числа равны
    		return 0;
    	if ( a == 0 ) // a - меньше 
    		return -1;
    	if ( b == 0 ) // a - больше
    		return 1;
    	assert( true ); // да нам подсунули какие-то неправильные числа
    }

    К слову "auto foo( ... ) -> type" добавили в C++11.

    Fai, 27 Июня 2012

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

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if ($_GET['where'] != '') {
    	if ($_GET['where'] != '') {
    		die ("<meta http-equiv='refresh' content='0; url=".$page."?where=".$_GET['where']."'>");
    	} else {
    		die ("<meta http-equiv='refresh' content='0; url=".$page."?pid=".$_GET['pid']."'>");
    	}
    } else {
    	die ("<meta http-equiv='refresh' content='0; url=".$page."?pid=".$_GET['pid']."'>");
    }

    Интересно, в каком случае выполнится второй die()?

    domaster, 27 Июня 2012

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

    +71

    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
    # Разбор time()
    function GetTime( $time ) {
    	
    	# Получение массива из элементов даты
    	$time = getdate( $time );
    	
    	# Все элементы с ведущими нулями
    	$d = ( $time['mday'] > 9 ) ? $time['mday'] : '0' . $time['mday'];
    	$w = ( $time['mon'] > 9 ) ? $time['mon'] : '0' . $time['mon'];
    	$y = $time['year'];
    	$h = ( $time['hours'] > 9 ) ? $time['hours'] : '0' . $time['hours'];
    	$m = ( $time['minutes'] > 9 ) ? $time['minutes'] : '0' . $time['minutes'];
    	$s = ( $time['seconds'] > 9 ) ? $time['seconds'] : '0' . $time['seconds'];
    	
    	# Сборка и возврат результата
    	return $d . '/' . $w . '/' . $y . '&nbsp;' . $h . ':' . $m . ':' . $s;
    }

    Про date() явно не в курсе...

    nethak, 27 Июня 2012

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

    −29

    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
    calculateSomething(int n){
    	float* x = new float[n];
    	/*do smth*/
    	
           if ( /*validation*/ ) {
    		delete[] x;
    		return;
    	}
    	
    	float* y = new float[n];
    	/*do smth*/
    	
    	if ( /*validation*/ ) {
    		delete[] x;
    		delete[] y;
    		return;
    	}
    	
    	float* z = new float[n];
    	/*next step*/
    	
    	if ( /*smth goes wrong*/ ) {
    		delete[] x;
    		delete[] y;
    		delete[] z;
    		return;
    	}
    
            /*more calculations with validation*/
    
           delete[] x;
           delete[] y;
           ...
           /*more delete[]*/
           
           return;
    }

    Принципиальная схема говногода, найденного на просторах сети.

    interested, 26 Июня 2012

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