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

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

    +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
    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
    if RadioGroup1.ItemIndex=0   then cpr:=cpr+1;
    if RadioGroup1.ItemIndex=1   then cth:=cth+1;
    if RadioGroup2.ItemIndex=0   then cch:=cch+1;
    if RadioGroup2.ItemIndex=1  then czs:=czs+1;
    if RadioGroup3.ItemIndex=0   then chd:=chd+1;
    if RadioGroup3.ItemIndex=1  then cpr:=cpr+1;
    if RadioGroup4.ItemIndex=0   then  cth:=cth+1;
    if RadioGroup4.ItemIndex=1  then cch:=cch+1;
    if RadioGroup5.ItemIndex=0   then czs:=czs+1;
    if RadioGroup5.ItemIndex=1  then chd:=chd+1;
    if RadioGroup6.ItemIndex=0   then cpr:=cpr+1;
    if RadioGroup6.ItemIndex=1  then cch:=cch+1;
    if RadioGroup7.ItemIndex=0   then chd:=chd+1;
    if RadioGroup7.ItemIndex=1  then cth:=cth+1;
    ....// Это всё в 60 строк
    if (cpr>cth) and (cpr>cch) and (cpr>czs) and (cpr>chd) then cpr1:=+1
    else
    if (cth>cpr) and (cth>cch) and (cth>czs) and (cth>chd) then cth1:=+1
    else
    if (cch>cpr) and (cch>cth) and (cch>czs) and (cch>chd) then cch1:=+1
    else
    if (czs>cpr) and (czs>cch) and (czs>cth) and (czs>chd) then czs1:=+1
    else
    if (chd>cpr) and (chd>cch) and (chd>czs) and (chd>cth) then chd1:=+1;
    
    if cpr>chd or czs or cth or cch     then
    begin
    ShowMessage('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;')   ;
    Datamodule4.ADOTable1.Edit;
    Datamodule4.ADOTable1.FieldValues['test2']:=('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;');
    Datamodule4.ADOTable1.Post;
    end
    else
    if chd>cpr or cth or cch or czs   then   begin
    ShowMessage('человек-техника – все технические профессии;')   ;
    Datamodule4.ADOTable1.Edit;
    Datamodule4.ADOTable1.FieldValues['test2']:=('человек-техника – все технические профессии;');
    Datamodule4.ADOTable1.Post;
    ...... И далее результаты в общем их 5
    отдельная кнопка для вывода остальных 10 вопросов х)
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Radiogroup11.Visible:=true;
    Radiogroup12.Visible:=true;
    Radiogroup13.Visible:=true;
    Radiogroup14.Visible:=true;
    Radiogroup15.Visible:=true;
    Radiogroup16.Visible:=true;
    Radiogroup17.Visible:=true;
    Radiogroup18.Visible:=true;
    Radiogroup19.Visible:=true;
    Radiogroup20.Visible:=true;
    Button2.Visible:=True;
    end;

    Программа тестирования на профориентацию
    хД сколько он radiogroup создал)

    Ryuko, 05 Января 2012

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

    +156

    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
    <?php
    	if(!isset($legal_include)) { header("HTTP/1.0 404 Not Found"); die(); }
    	
    	if(!isset($_POST['login']) OR !isset($_POST['password']) OR !isset($_POST['password_retype'])) {
    		text(gic('tpl/register_form.html'));
    	} else {
    		$_POST = postget();
    		$error = array();
    		if(strlen($_POST['login']) < 4 OR empty($_POST['login'])) {
    			array_push($error, 'len_login');
    		} else {
    			if(preg_match('/^[a-z0-9]+$/', $_POST['login'])) {
    				if(check_avalaibility($_POST['login']) != true) {
    					array_push($error, 'login_used');
    				}
    			} else {
    				array_push($error, 'inc_login');
    			}
    		}
    			
    		if(strlen($_POST['password']) < 4 OR empty($_POST['password'])) {
    			array_push($error, 'len_passwd');
    		} else {
    			if($_POST['password'] != $_POST['password_retype']) {
    				array_push($error, 'inc_passwds');
    			}
    		}
    		
    		if(count($error) > 0) {
    			$fields = array('inc_login' => language($_SESSION['lang'], 'inc_login'), 
    			'len_login' => language($_SESSION['lang'], 'len_login'),
    			'len_passwd' => language($_SESSION['lang'], 'len_passwd'),
    			'login_used' => language($_SESSION['lang'], 'login_used'),
    			'inc_passwds' => language($_SESSION['lang'], 'inc_passwds'));
    			$text = language($_SESSION['lang'], 'have_errs').'<ul>';
    			foreach($error as $value) {
    				$text .= '<li>'.$fields[$value].'</li>';
    			}
    			$text .= '</ul>';
    			error($text, 'text');
    			sendback('?register');
    		} else {
    			$SQL = 'INSERT INTO `'.pr.'users` (`login`, `password`, `levels`) VALUES (\''.$_POST['login'].'\', \''.md5($_POST['password']).'\', 1)';
    			mysql_query($SQL);
    			$_SESSION['logined'] = true;
    			$_SESSION['levels'] = 1;
    			$_SESSION['name'] = $_POST['login'];
    		}
    	}
    	
    	function check_avalaibility($username) {
    		$SQL = 'SELECT `login` FROM `'.pr.'users` WHERE `login` = \''.$username.'\'';
    		$result = mysql_query($SQL);
    		if(mysql_num_rows($result) > 0) {
    			return false;
    		} else {
    			return true;
    		}
    	}
    ?>

    why so serious?

    afr0xED, 18 Декабря 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php /*
    host=localhost
    db_name=db
    user=db_user
    password=db_pass
    charset=utf8
    */ ?>

    Совершенно гениальный и единственно верный способ хранить конфиги в PHP.
    Имя файла тоже, должно быть именно таким - db.ini.php

    Starkua, 16 Декабря 2011

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

    +133

    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
    /// <summary>
            /// Abs function
            /// </summary>
            private static object Abs(List<Expression> p)
            {
                return Math.Abs(p[0]);
            }
    
            /// <summary>
            /// Acos function
            /// </summary>
            private static object Acos(List<Expression> p)
            {
                return Math.Acos(p[0]);
            }
    
            /// <summary>
            /// Asin function
            /// </summary>
            private static object Asin(List<Expression> p)
            {
                return Math.Asin(p[0]);
            }
    
            /// <summary>
            /// Atan function
            /// </summary>
            private static object Atan(List<Expression> p)
            {
                return Math.Atan(p[0]);
            }
    
            /// <summary>
            /// Atan2 function
            /// </summary>
            private static object Atan2(List<Expression> p)
            {
                return Math.Atan2(p[0], p[1]);
            }

    Кусок кода от "Капитана Очевидность"

    govnokoder_, 15 Декабря 2011

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

    +145

    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
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    #define eps 0.001
    
    float Phi1 (float x_pred[1])
    {
          return asin(1.2 + x_pred[1]) - 1;
    }
    
    float Phi2 (float x_pred[0])
    {
          return acos(2 - 2*x_pred[0]);
    }
    
    int main ()
    {
        float x_pred[1],x[1];
        float norma;
        
        x_pred[0] = 0.4;
        x_pred[1] = -0.3;
        
        do
        {
          x[0] = Phi1(x_pred[1]);
          x[1] = Phi2(x_pred[0]);
          printf("%6.2f",x[0]);
          printf("             %6.2f\n",x[1]);
          norma = (fabs(x[0] - x_pred[0])) > fabs((x[1] - x_pred[1])) ? fabs(x[0] - x_pred[0]) : fabs(x[1] - x_pred[0]);
          if (norma >= eps) break;
          else
          {
            x_pred[0] = x[0];
            x_pred[1] = x[1];
          }
        }
        while (1);
        getch();
        return 0;
    }

    govnouser, 13 Декабря 2011

    Комментарии (8)
  7. Ruby / Говнокод #8790

    −102

    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
    <div class="pane">
            <% #Вывод материалов
               if pms.size > 0 %>
                <% for pm in pms do %>
                    <div class="mat">
                      <div><%= pm.name %></div>
                      <p>art. <%= pm.id %></p>
                      <%= image_tag pm.image.url(:small) %>
                      <%= link_to 'Выбрать +', '#' %>
                    </div>
                <% end %>
            <% end %>
          </div>

    ПМС =)

    opak, 10 Декабря 2011

    Комментарии (8)
  8. JavaScript / Говнокод #8783

    +150

    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
    function fixPNG(element)
    {
      if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
        var src;
        src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
    	
        if(src){
          src = src[1];
          element.runtimeStyle.backgroundImage = "none";
        }
    	
        if(src){
          element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src = '" + 
    	    src + "',sizingMethod = 'scale')";
    	}
      }
    }

    shlyapa, 09 Декабря 2011

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

    −84

    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
    -(void)shekinNow:(id)prev
    {
        float YI = rand() / (float)RAND_MAX;
        NSArray *subv = [imageV subviews];
        long index = (long)(rand()/(RAND_MAX/([subv count])));
        SlotUnit *unit = [subv objectAtIndex:index];
        if(unit == prev) {
            [self shekinNow:prev];//рекурисия епт
            return;
        }
        CGFloat gradus = ((YI*70/99)*100);
        CGFloat radian = (gradus * M_PI / 180);
        [unit setTag:0];
        [UIView beginAnimations:@"one" context:unit];
        [UIView setAnimationDidStopSelector:@selector(moveTuda:finished:context:)];
        [UIView setAnimationDuration:anidur];
        [UIView setAnimationDelegate:self];
        [unit sendRotating:radian];
        [UIView commitAnimations];
    }

    Вот так трансректально можно применять рекурсию.

    Psionic, 06 Декабря 2011

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

    +171

    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
    // Записываем просмотр профайла
    MySQL::QueryInsert(
    	'profile_views', 
    	array(
    		'profile_id' => (int)$user['id'], 
    		'visitor' => (int)User::$current['id'], 
    		'date' => (int)$cur_time, 
    		'hidden' => (int)User::$current['hidden']
    		)
    	);
    // Смотрим последнюю запись в просмотрах
    $prev_visit = MySQL::FetchAll(
    	MySQL::Query(
    		'SELECT `visitor`,`date` 
    		   FROM profile_views 
    		  WHERE profile_id='.(int)$user['id'].' AND `date`<'.(int)$cur_time.
              ' AND `hidden`='.(int)User::$current['hidden'].' 
           ORDER BY `date` DESC 
              LIMIT 1'
            )
        );
    // если юзер сам посмотрел свой профиль - удаляем только что вставленную запись
    if ($prev_visit[0]['visitor'] == User::$current['id']) {
        MySQL::Query(
    	    'DELETE FROM profile_views 
    	      WHERE profile_id='.(int)$user['id'].' 
    	        AND `date`='.(int)$prev_visit[0]['date'].
              ' AND `hidden`='.(int)User::$current['hidden'].' 
                AND visitor='.(int)User::$current['id']
        );
    };

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

    Sc0rp10, 28 Ноября 2011

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

    +174

    1. 1
    $users[] = User::$current['id']; //Ok, do etogo ne doidet. Nu i h s nim.

    ghost404, 24 Ноября 2011

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