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

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

    −104

    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
    function BU(BTN:MovieClip, URL_to){
    BTN.buttonMode = true;
    function STRT_CLOS(BTN:MovieClip, K_P){
     BTN.removeEventListener(Event.ENTER_FRAME,  POS_CLOS)
     BTN.addEventListener(Event.ENTER_FRAME,  POS_CLOS)
    }
    function STRT_OP(BTN:MovieClip, K_P){
     BTN.removeEventListener(Event.ENTER_FRAME,  OPen)
     BTN.addEventListener(Event.ENTER_FRAME,  OPen)
    ...
    
    
    p.p.gotoAndStop ("prav_sr"
    p.p.b.nadp.stop ();
    p.p.f.nadp.stop ();
    p.p.k.nadp.stop ();
    p.p.konf.nadp.stop ();
    p.p.prav.nadp.stop ();
    p.p.raz.stop ();
    raskr (p.p.b);
    raskr (p.p.f);
    raskr (p.p.k);
    raskr (p.p.konf);
    raskr (p.p.prav);
    raskr (p.p.raz);
    p.p.b.t=false;
    p.p.f.t=false;
    p.p.k.t = false;
    
    ....
    
    var SS:MovieClip = this.parent.parent as MovieClip
    var SSSS = this.parent.parent.parent as MovieClip
    var OOOO:MovieClip = SSSS.BAZ_LOER.getChildByName("ZaGl")
    
    ....
    
    BTN.otkr="otkr";
    BTN.kloc="klos";
    if (BTN.otkr!="otkr") return;

    Код на кадрах, в проекте не одна к строк подобного содержания.

    kyzi007, 03 Мая 2011

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

    +192

    1. 1
    class AutocompleteAddressZaplatka2 extends AutocompleteAddressZaplatka

    Фундаментальные объектно-ориентированные костыли ...

    _tL, 29 Апреля 2011

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

    +107

    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
    procedure TFCar.Button3Click(Sender: TObject);
     begin
     gUpload.Visible:= True;
     Button3.Enabled:= False;
     bClear.Enabled:= False;
     bAdd.Enabled:= False;
     bCreateOrder.Enabled:= False;
     bCloce.Enabled:= False;
     mysleep(100);
     sleep(10000);
     ShowMessage('sleep off');
     end;
     ----------------
     procedure mysleep(i:Integer);
     var
     z:Integer;
     begin
     for z:=0 to i do
     begin
     Sleep(5);
     Application.ProcessMessages;
     end ;
     end;
     ---------------
     это немного помогло решить проблему... кнопки становятся неактивными до выполнения sleep(10000);

    Немного классического торможения двигателем...

    bugmenot, 21 Апреля 2011

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

    −174

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    import hashlib
    a='letsstart'
    def h(inp):
        return hashlib.md5(inp).hexdigest()
    while h(a) != a:
        a=h(a)
    print 'I FIND IT!!! ITS ',a

    Давно хочу найти эту строку.

    ichi, 19 Апреля 2011

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

    +118

    1. 1
    2. 2
    object res = DataConnection.ExecuteScalar(sql);
    int count = (int)(long)res;

    Чтокуда?

    Vadimyan, 14 Апреля 2011

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

    +161

    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
    //main.cpp
    #include "head.h"
    int main()
    {
    //fcii.cpp
    #include "head.h"
    void odin (vector<Zapis> &mas)
    {
    Zapis buf;
    cout<<"Введите номер УДК: ";
    cin>>buf.id;
    cout<<"Введите фамилию и инициалы автора: ";
    cin>>buf.fio;
    cout<<"Введите название книги: ";
    cin>>buf.nazv;
    cout<<"Введите год издания: ";
    cin>>buf.god;
    cout<<"Введите количество экземпляров: ";
    cin>>buf.kol;
    mas.resize(mas.size()+1,buf);
    vivod (mas);
    }
    void dva (vector<Zapis> &mas)
    {
    char udk[4];
    cout<<"Введите УДК книги, которую необходимо удалить: ";
    cin>>udk;
    int flag=1;
    int k=0;
    for (vector<Zapis>::iterator i=mas.begin();i!=mas.end();i++)
    {
    flag=1;
    if (strlen(udk)==strlen(mas[k].id))
    for (int j=0;udk[j]!=0;j++)
    if (udk[j]!=mas[k].id[j])
    flag=0;
    if (flag==1)
    {
    mas.erase(i);
    flag=-1;
    break;
    }
    k++;
    }
    
    if (flag!=-1)
    {
    cout<<endl<<"Книги с данным УДК не существует"<<endl;
    }
    else vivod(mas);
    }
    void tri(vector<Zapis> &mas)
    {
    vector<int> mas_buf(mas.size());
    for (int i=0;i<mas.size();i++)
    mas_buf[i]=mas[i].god;
    sort(mas_buf.begin(),mas_buf.end()) ;
    for (int i=0;i<mas.size();i++)
    mas[i].god=mas_buf[i];
    vivod(mas);
    }
    int zapros (vector<Zapis> &mas)
    {
    int otvet;
    cout<<endl<<"Если вы хотите добавить данные о книгах - нажмите 1;"<<endl;
    cout<<"Если вы хотите удалить данные о списываемых книгах - нажмите 2;"<<endl;
    cout<<"Если вы хотите упорядочить книги по годам издания - нажмите 3;"<<endl;
    cout<<"Если вы хотите завершить работу программы - нажмите 0."<<endl;
    cin>>otvet;
    
    switch (otvet)
    {
    case 0: {return 0;}
    case 1: {
    odin(mas);
    zapros(mas);break;
    }

    Взято отсюда: http://programmersforum.ru/forumdisplay.php?f=14

    elenbert, 14 Апреля 2011

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    $dateFrom_array = explode('-', $_REQUEST['intervalFrom']);
    $dateUnix = mktime(0, 0, 0, $dateFrom_array[1], $dateFrom_array[2], $dateFrom_array[0]);
    $dateUnix -= 60 * 60 * 24 * 30 * 2; // - 2 месяца
    $dateFrom = date("Y-m-d", $dateUnix);

    goliath, 11 Апреля 2011

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

    +162

    1. 1
    2. 2
    foreach(split(',', '101,102,150,1351,2135,22153,351,15321,5351,235') as $key => $val)
    	$tmparray[] = $val;

    разбиваем строку в массив )))

    pes, 05 Апреля 2011

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

    +117

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Caeser_method
    {
        class Program
        {
            static void Main(string[] args)
            {
                int n = 3;
                Console.Write("Input string to encoding: ");
                string input = Console.ReadLine();
                Csr enc = new Csr(n,input);
               // Csr dec;
                enc.encrypt();
                Console.WriteLine(enc);
               // dec = new Csr(n, input);
                enc.decrypt();
                
                Console.WriteLine(enc);
                Console.ReadLine();
            }
        }
    }
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Caeser_method
    {
        class Csr
        {
            public int n;
            public string phraze,outputphr;
            public Csr(int n, string phraze) 
            {
                this.n = n;
                this.phraze = phraze;
                this.outputphr = "";
            }
    
            
            public void encrypt() 
            {
                foreach (char c in this.phraze)
                    if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
                    {
                        if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
                                                                          (c + this.n > 'Z' ? ('A' + ((c -'Z'  + (this.n - 1)))) : (c + this.n)) :
                                                                          (c + this.n > 'z' ? ('a' + ((c - 'z' + (this.n - 1)))) : (c + this.n)));
                        else this.outputphr += c;
                    }
                    else
                    {
                        if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
                                                                          (c + this.n > 'Я' ? ('А' + ((c - 'Я' + (this.n - 1)))) : (c + this.n)) :
                                                                          (c + this.n > 'я' ? ('а' + ((c - 'я' + (this.n - 1)))) : (c + this.n)));
                        else this.outputphr += c;
                    }
            }
    
    
            public void decrypt()
            {
                this.phraze = this.outputphr;
                this.outputphr = "";
                foreach (char c in this.phraze)
                    if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
                    {
                        if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
                                                                          (c - this.n < 'A' ? ('Z' - (('A' - c + (this.n - 1)))) : (c - this.n)) :
                                                                          (c - this.n < 'a' ? ('z' - (('a' - c + (this.n - 1)))) : (c - this.n)));
                        else this.outputphr += c;
                    }
                    else
                    {
                        if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
                                                                          (c - this.n < 'А' ? ('Я' - (('А' - c + (this.n - 1)))) : (c - this.n)) :
                                                                          (c - this.n < 'а' ? ('я' - (('а' - c + (this.n - 1)))) : (c - this.n)));
                        else this.outputphr += c;
                    }
            }
    
            public override string ToString()
            {
                return string.Format("Encoded string: {0}",this.outputphr);
            }
    
        }
    }

    Реализация шифрования методом Цезаря

    rybaki, 27 Марта 2011

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

    +158

    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
    class Query {
      protected $baseTable;
      protected $baseTableAlias;
      protected $whereGroup;
    
      protected $joins = array();
      protected $fields = array();
    
      protected $executed = FALSE;
      protected $resource = NULL;
    
    
      function __construct($base_table = 'node', $alias = 'n') {
        $this->whereGroup = new QueryWhereGroup();
        $this->baseTable = $base_table;
        $this->baseTableAlias = empty($alias) ? $base_table : $alias;
      }
    
      function select($fields) {
        settype($fields, 'array');
        foreach ($fields as $alias => $field) {
          if (is_numeric($alias)) {
            $this->fields[] = $field;
          }
          else {
            $this->fields[$alias] = "$field as $alias";
          }
        }
    
        return $this;
      }
    
      /**
       * @param QueryWhereGroup $whereGroup
       * @return Query
       */
      function where($whereGroup) {
        call_user_func_array(array($this->whereGroup, 'cond'), func_get_args());
        return $this;
      }
    
      function createWhereGroup() {
        return new QueryWhereGroup();
      }
    
      function join($table, $alias = NULL, $condition, $join_type = 'INNER') {
        if (!$alias) {
          $alias = $table;
        }
    
        if (is_array($condition)) {
          $condition = 'USING ('. join(', ', $condition) .')';
        }
        if (!preg_match('/^ON|USING/i', $condition)) {
          $condition = 'ON '. $condition;
        }
    
        $this->joins[$alias] = "$join_type JOIN $table $alias $condition";
        return $this;
      }
    
      function compile() {
        $select_fields = join(', ', array_unique($this->fields));
        $joins_list = join("\n", $this->joins);
        $where_conditions = $this->whereGroup->compile();
    
        if (!empty($where_conditions)) {
          $where_conditions = 'WHERE '. $where_conditions;
        }
    
        return "SELECT $select_fields FROM {{$this->baseTable}} {$this->baseTableAlias} \n $joins_list $where_conditions";
      }
    
      function args() {
        return $this->whereGroup->args;
      }
    
      function execute() {
        return db_query($this->compile(), $this->args());
      }
    
      function fetchAll() {
        $res = $this->execute();
        while($row = db_fetch_object($res)) {
          $rows[] = $row;
        }
        return $rows;
      }
    }

    построитель запросов (drupal 6)
    wheregroup здесь http://govnokod.ru/6076

    vectoroc, 23 Марта 2011

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