1. Python / Говнокод #10015

    −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
    # TODO: fix this hell
    def pretty_print(w, p):
        w = truncate(w)
        p = truncate(p)
        my_matrix = zip(p, w)
        print  "\n".join(["\t\t".join(["\t".join(map(str, r)) for r in t]) for t in my_matrix])        
    
    # TODO: and this
    def truncate(m):
        for i in range(len(m)):
            for j in range(len(m[0])):
                if(len(str(m[i][j])) > 5):
                    m[i][j] = "%.3f" % m[i][j]
        return m

    catcall, 22 Апреля 2012

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

    +92

    1. 1
    "".equalsIgnoreCase(propertiesFile) != true

    индусское достояние

    Desperate, 22 Апреля 2012

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

    +120

    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
    if(isset($_POST['myinfo'])){
    	if(trim($_POST['email'])=="" && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Введите адрес электронной почты.";
    	} elseif(strlen(trim($_POST['email']))>"128" && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Слишком длинный адрес электронной почты.";
    	} elseif(!preg_match("/^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)*$/", trim($_POST['email'])) && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Некорректный адрес электронной почты.";
    	} elseif(mysql_num_rows(mysql_query("SELECT `email` FROM `users` WHERE `email` = '".htmlspecialchars(trim(strtolower($_POST['email'])))."' AND `userid`!='".$_SESSION['userid']."' LIMIT 1"))>0 && !mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$aSuccess=false;
    		$aErrorType="eEMail";
    		$aErrorMsg="Пользователь с таким адресом электронной почты уже зарегистрирован.";
    	} elseif(strlen(trim($_POST['about']))>"12000"){
    		$aSuccess=false;
    		$aErrorType="eAbout";
    		$aErrorMsg="Вы предоставили слишком много информации о себе.";
    	} else {
    		if(!mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `userid`='".$_SESSION['userid']."' AND `vkid`!='';"))){
    		$mail="`email`='".htmlspecialchars(trim(strtolower($_POST['email'])))."', ";
    		} else {
    		$mail="";
    		}
    		mysql_query("UPDATE users SET ".$mail."`about`='".mysql_real_escape_string(trim($_POST['about']))."' WHERE userid='".$_SESSION['userid']."';");
    		$aSuccess=true;
    		header("Location: editme.php?msg=SUCCESSFULLY_UPDATED");
    		exit();
    	}
    }

    Код, используемый в моём самописном движке для изменения пользователем своего профиля на сайте.

    BiggestFox, 22 Апреля 2012

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

    +122

    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
    <?php
    $pictures =new Array(4);
    pictures[0]="1.jpg";
    pictures[1]="2.png";
    pictures[2]="3.jpg";
    pictures[3]="4.jpg";
    global $i=0;
    function Next(){
    if($i==3)
    $i=0;
    else
    $i++;
    document.getElementById('pic').setAttribute("src", picture[i]);
    }
    function Prev(){
    if($i==0)
    $i=3;
    else
    $i--;
    document.getElementById('pic').setAttribute("src", picture[i]);
    }
    ?>

    Отличный салат.

    cthulhu25, 22 Апреля 2012

    Комментарии (14)
  5. Pascal / Говнокод #10011

    +129

    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
    function assemble(var w:word;s:string):boolean;
    .....
     else if length(cmd)=3 then
      begin
       {ТРЕХБУКВЕННЫЕ КОМАНДЫ}
       case cmd[1] of
        'a':case cmd[2] of
             'c':if cmd[3]='i' then
                  begin
                   code:=$ce;
                   typ:=7;
                  end;
             'd':case cmd[3] of
                  'd':begin
                       code:=$80;
                       typ:=4;
                      end;
                  'c':begin
                       code:=$88;
                       typ:=4;
                      end;
                  'i':begin
                       code:=$c6;
                       typ:=7;
                      end;
                 end;
    ..... еще 500 подобных строк ....
    end;

    Прочитал http://govnokod.ru/10002 и вспомнил, как когда-то писал асм\дизасм\эмуль для 8080 на паскале.

    bormand, 22 Апреля 2012

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

    +91

    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
    #include <amxmodx>
    
    new g_MsgSync
    new g_MsgSync2
    
    new isConnected[33 char]
    
    public plugin_init()
    {
       register_plugin("Damager", "1.0", "Prayer")
       
       register_event("Damage", "EVENT_Damage", "b", "2!0", "3=0", "4!0")
       
       g_MsgSync = CreateHudSyncObj()
       g_MsgSync2 = CreateHudSyncObj()
    }
    
    public client_putinserver(id)
    {
       isConnected{id} = true
    }
    
    public client_disconnect(id)
    {
       isConnected{id} = false
    }
    
    public EVENT_Damage(id)
    { 
       if(isConnected{id})
       {
          static damage, pid
          damage = read_data(2)
          
          set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1)
          ShowSyncHudMsg(id, g_MsgSync2, "%d", damage)
       
          pid = get_user_attacker(id)
          
          if((pid > 0) && (pid < 33) && isConnected{pid})
          {
             set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
             ShowSyncHudMsg(pid, g_MsgSync, "%d", damage)
          }
       }
    }

    Это павн переработанный вельвом. Кто писал плагины для CS тот поймёт всю соль.

    Dg_INC, 22 Апреля 2012

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

    +138

    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
    //
    		switch (cwin->cpref->shuffle) {
    			case TRUE:
    				last = g_list_last(cwin->cstate->rand_track_refs);
    				if ((!cwin->cstate->curr_rand_ref) || (last && (cwin->cstate->curr_rand_ref == last->data))){
    					path = get_next_unplayed_random_track(cwin);
    					if (!path)
    						rand_unplayed = TRUE;
    				}
    				else path = get_next_random_ref_track(cwin);
    				break;
    			case FALSE:
    				path = get_next_sequential_track(cwin);
    				if (!path) seq_last = TRUE;
    				break;
    			default:
    				break;
    		}

    буль...

    rat4, 21 Апреля 2012

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

    +105

    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
    public static bool IpCheck(String ip)
            {
                String [] octs = ip.Split(new char[] { '.' });
    
                try
                {
    
                    for (int n = 0; n < 4; n++)
                    {
                        byte b = Convert.ToByte(octs[n]);
                    }
    
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }

    Индуский валидатор IP - адреса

    dens, 21 Апреля 2012

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

    +128

    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
    Unsigned long int getset (void)
    {unsigned long int a; int k; h=0;
    While (‘<не конец файла>==<читать число в k>’);
    {switch k
    {case 1: h = h/0x 0001; break;
    case 2: h = h/0x 0002; break;
    case 3: h = h/0x 4; break;
    case 4: h = h/0x 8; break;
    case 5: h = h/0x 10; break;
    case 6: h = h/0x 20; break;
    case 7: h = h/0x 40; break;
    case 8: h = h/0x 80; break;
    …
    case 30: h = h/0x 2000 0000; break;
    case 31: h = h/0x 4000 0000; (- 1 на 31 месте) break;
    case 32: h = h/0x 8000 0000; (- 1 на 32 месте) break;
    }
    }
    return (h)
    }

    Мне кажется или весь смысл сводиться к h = h/2^(k-1)

    ApeNN, 21 Апреля 2012

    Комментарии (11)
  10. Куча / Говнокод #10002

    +100

    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
    procedure interpretation;
    var
    s,f:string;
    i,m,v:integer;
    
    begin
    s:=#0;
    
    for I:=0 to form9.Memo2.Lines.Count-1 do begin
      s:=form9.Memo2.Lines.Strings[i];//ïðîñìîòð ñòðîê èäåò
      //ñâåðõó âíèç
    
      if s='hex' then hex;
      if s='acsii' then acsii;
    
      if (s[1]='a') and (s[2]='d') and (s[3]='d') then begin
      form9.Edit6.Text:=s[5];
      form9.Edit5.Text:=s[7];
      peredsim;
      end;
    
      if (s[1]='s') and (s[2]='a') and (s[3]='m') then begin
      form9.Edit2.Text:=s[5];
      form9.Edit4.Text:=s[7];
      samsimbyl;
      end;
    
      if (s[1]='d') and (s[2]='e') and (s[3]='l') then begin
      form9.Edit3.Text:=s[5];
      for v:=1 to length(s) do
      deletesimbyl;
      end;
    
      if (s[1]='d') and (s[2]='e') and (s[3]='l') and (s[4]='s') then begin
      form9.Edit3.Text:=s[6];
      dels;
      end;
    
      if (s[1]='i') and (s[2]='n') and (s[3]='f') then begin
      form9.Memo1.Text:=s[5]+form9.Memo1.Text;
      end;
    
      if (s[1]='f') and (s[2]='n') and (s[3]='i') then begin
      form9.Memo1.Text:=form9.Memo1.Text+s[5];
      end;
    
      if (s[1]='p') and (s[2]='h') and (s[3]='e') then RapsrRedel;
    
    
      if (s[1]='n') and (s[2]='a') and (s[3]='b') then PerstNO;
    
    
      if (s[1]='a') and (s[2]='t') and (s[3]='s') then acsiitosim;
      if (s[1]='h') and (s[2]='t') and (s[3]='s') then hextosim;
      if (s[1]='h') and (s[2]='t') and (s[3]='a') then hextoacsii;
      if (s[1]='a') and (s[2]='t') and (s[3]='h') then acsiitohex;
    end;
    end;

    Нужно было быстро накодить интерпретатор, которым никто пользоваться не будет, кроме собственно автора программы, для создания простеньких скриптов (сами понимаете семантический анализатор писать, в данном случае не улыбалось). Потому получился такой МегОАдЪовый говнокод!

    Kerny, 21 Апреля 2012

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