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

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

    −1

    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
    def da_pizda(update, context):
        global da_counter, pizda_counter
    
        text = update.message.text.split()
        text = [word.lower() for word in text]
    
        if 'дa' in text or 'da' in text or 'dа' in text:
            text.append('да')
        if 'пиздa' in text or 'pizda' in text or 'pizdа' in text or 'Πизда' in text:
            text.append('пизда')
    
        if 'да' in text:
            bot.send_message(chat_id=update.message.chat_id, text='пизда',
                             reply_to_message_id=update.message.message_id)
            pizda_counter += 1
        if 'пизда' in text:
            bot.send_message(chat_id=update.message.chat_id, text='да',
                             reply_to_message_id=update.message.message_id)
            da_counter += 1
    
        da_counter += update.message.text.split().count('да')
        pizda_counter += update.message.text.split().count('пизда')

    Бот, проверяющий наличие слов "да" и "пизда" в чате телеграма, и отвечающий соответственно.

    Umerenkov21, 23 Апреля 2019

    Комментарии (60)
  3. JavaScript / Говнокод #25339

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    checkTableFilters () {
        if (this._activeTableFilter && this._filter.filter._filters.get(this._activeTableFilter)) {
          this._filter.filter._filters.get(this._activeTableFilter).Update();
        }
      }

    "Так вышло" - хороший ответ.
    1. this._filter.filter._filters (фильтры фильтра фильтра?..)
    2. Зачем имитировать приватность полей класса соглашением о наименовании, если её игнорируют как могут?..
    3. ... дополните сами

    webviewer, 30 Января 2019

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

    +2302

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    http://govnokod.ru/20924
    
    Запрашиваемая страница не найдена!
    
    Возможно, её и не было никогда

    http://dump.bitcheese.net/files/pimarut/%D0%93%D0%BE%D0%B2%D0%BD%D0%BE%D0%BA%D0%BE%D0%B4_%2320924_%E2%80%94_C___%E2%80%94_%D0%93%D0%BE%D0%B2%D0%BD%D0%BE%D0%BA%D0%BE%D0%B4.%D1%80%D1%83.html
    но бекап я сделал, так что хуй вам. Я требую продолжения банкета.

    j123123, 24 Августа 2016

    Комментарии (60)
  5. PHP / Говнокод #20428

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    function is_assoc( $array ) {
    
    	return is_array($array) && substr( json_encode($array), 0, 1 ) == '{';
    }

    bot, 26 Июля 2016

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

    +5

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    class Db {
    
        private $where;
        private $select = '*';
        private $limit;
        private $order_by;
        private $query;
        private $set;
    
        private function query_string($table){
            $query = ($this->query) ? $this->query : "SELECT $this->select FROM $table WHERE $this->where $this->order_by $this->limit";
            return $query;
        }
        function query($text){
            $this->query = $text;
            return $this;
        }
        function where_text($text){
            $operator = 'AND';
            if (!$this->where){
                $this->where = $text;
            } else {
                $this->where .= $operator." ".$text;
            }
            return $this;
        }
        function order_by_text($text){
            if (!$this->order_by){
                $this->order_by = ' ORDER BY '.$text;
            } else {
                $this->order_by .= ', '.$text;
            }
        }
        function connect($host,$login_mysql,$password_mysql,$baza_name) {
            $db = @mysql_connect("$host", "$login_mysql", "$password_mysql");
            mysql_set_charset('utf8',$db);
            if (!$db) exit("<p>Sorry, not available MySQL server</p>");
            if (!@mysql_select_db($baza_name,$db)) exit("<p>Unfortunately, the database is not available</p>");
        }
        function select($column){
            $this->select = $column;
            return $this;
        }
        function limit($start,$count){
            $this->limit = ' LIMIT '.$start.','.$count;
            return $this;
        }
        function order_by($key){
            if (is_array($key)){
                foreach ($key as $column => $value){
                    if (!$this->order_by){
                        $this->order_by = ' ORDER BY '.$column.' '.$value;
                    } else {
                        $this->order_by .= ', '.$column.' '.$value;
                    }
                }
            } else {
                if (!$this->order_by){
                    $this->order_by = ' ORDER BY '.$key;
                } else {
                    $this->order_by .= ', '.$key;
                }
            }
            return $this;
        }
        function where($key,$compare = '='){
            $operator = 'AND';
            if (is_array($key)){
                foreach ($key as $column=>$value){
                    if (!$this->where){
                        $this->where = $column.$compare."'".$value."' ";
                    } else {
                        $this->where .= $operator." ".$column.$compare."'".$value."' ";
                    }
                }
            } else {
                $key = explode(',',$key);
                if (!$this->where){
                    $this->where = $key[0].$compare."'".$key[1]."' ";
                } else {
                    $this->where .= $operator." ".$key[0].$compare."'".$key[1]."' ";
                }
            }
            return $this;
        }
        function search($column,$search){
            $operator = 'AND';
            $search = strtr($search,array(" "=>" +"));
            $search = '+'.$search;
            $w = 'MATCH('.$column.") AGAINST('".$search."' IN BOOLEAN MODE)";
            if (!$this->where){
                $this->where = $w;
            } else {
                $this->where .= $operator." ".$w;
            }
            return $this;
        }
        function lines($table,$ext = true){
            $msql_query = mysql_query($this->query_string($table));
            $line = mysql_fetch_assoc($msql_query);

    "Удобный php класс для работы с MySQL"
    https://habrahabr.ru/post/277095

    Lure Of Chaos, 12 Февраля 2016

    Комментарии (60)
  7. PHP / Говнокод #18262

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function json2array($json_data)
    {
        $json_array = false;
        $json = substr($json, 1, -1);
        $json = str_replace(array(":", "{", "[", "}", "]"), array("=>", "array(", "array(", ")", ")"), $json_data);
        @eval("\$json_array = array({$json});");
        return $json_array;
    }

    Парсим json

    acer_paser, 01 Июня 2015

    Комментарии (60)
  8. Haskell / Говнокод #17746

    −99

    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
    --Поиск минимальной выпуклой оболочки
    import Data.List; import Data.Ord
    --общие функции и типы
    data Point = P{x::Float,y::Float}
    	deriving (Show,Eq) 
    	
    getRotate a b c = baX * cbY - baY * cbX
    	where baX = x b - x a; baY = y b - y a;
    		  cbX = x c - x b; cbY = y c - y b;
    		 
    sortFunc a b c 
    	|k < 0  = LT
    	|k == 0 = compare (long a c) (long a b) 
    	|k > 0  = GT
    		where k = getRotate a b c
    
    long a b = (x b - x a)*(x b - x a) + (y b - y a)*(y b - y a)
    		
    getLeftPoint = minimumBy (comparing x)
    --Джарвис
    getMBOJarvis l = mboJ fp l fp
    	where fp = getLeftPoint l		
    		
    mboJ current list fp 
    	|getRotate current next fp > 0   = []
    	|True                            = current : mboJ next listWOC fp
    		where listWOC = filter ((/=)current) list;
    			  next    = minimumBy (sortFunc current) listWOC;
    --Грехем			
    getMBOGragam = tail.throwGraham.sortGraham 
    
    sortGraham list = fp:sortBy (sortFunc fp) list
    	where  fp = getLeftPoint list
    		   
    throwGraham (f:s:t) = mboG (s:f:[]) t
    		   
    mboG fs@(f:s:st) sn@(h:t)
    	|sortFunc s f h == GT = mboG (s:st) sn
    	|True                 = mboG(h:fs) t
    	
    mboG fs@(f:st) sn@(h:t)   = mboG(h:fs) t
    	
    mboG l [] = l
    --тесты		     
    testList1 = [P 0 (-1), P (-1) 0, P 0 1,P 1 0,P (-0.5) (-0.5),P 0.5 (-0.5),P (-0.5) 0.5,P 0.5 0.5,P 0 0]
    		  
    testList2 = [P 0 0, P 1 0, P 0 1,P 2 0,P 1 1,P 0 2,P 2 1,P 1 2,P 2 2]
    	
    	
    testJ1  = mapM_ print $ getMBOJarvis testList1		
    		
    testG1  = mapM_ print $ getMBOGragam testList1
    
    testJ2  = mapM_ print $ getMBOJarvis testList2		
    		
    testG2  = mapM_ print $ getMBOGragam testList2

    Haskell
    [сарказм]
    Как я могу идти против моды - не заливать этих французских лаб и не выпивать чаю?

    Выкладываю, что бы порадовать своего кота Барсика. Барсик, покойся с миром.

    А спонсор этого говна - компания "Потролль препода". "Потролль препода" - пиши лабы на хаскелле
    [/сарказм]

    kegdan, 07 Марта 2015

    Комментарии (60)
  9. C++ / Говнокод #16699

    +52

    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
    double cCompositeBlock::determinant4x4(double *d){ // WARNING It's not logically connected with class.
        return  d[3]*d[6]*d[9]*d[12]  -d[2]*d[7]*d[9]*d[12]-
                d[3]*d[5]*d[10]*d[12] +d[1]*d[7]*d[10]*d[12]+
                d[2]*d[5]*d[11]*d[12] -d[1]*d[6]*d[11]*d[12]-
                d[3]*d[6]*d[8]*d[13]  +d[2]*d[7]*d[8]*d[13]+
                d[3]*d[4]*d[10]*d[13] -d[0]*d[7]*d[10]*d[13]-
                d[2]*d[4]*d[11]*d[13] +d[0]*d[6]*d[11]*d[13]+
                d[3]*d[5]*d[8]*d[14]  -d[1]*d[7]*d[8]*d[14]-
                d[3]*d[4]*d[9]*d[14]  +d[0]*d[7]*d[9]*d[14]+
                d[1]*d[4]*d[11]*d[14] -d[0]*d[5]*d[11]*d[14]-
                d[2]*d[5]*d[8]*d[15]  +d[1]*d[6]*d[8]*d[15]+
                d[2]*d[4]*d[9]*d[15]  -d[0]*d[6]*d[9]*d[15]-
                d[1]*d[4]*d[10]*d[15] +d[0]*d[5]*d[10]*d[15];
    }

    Abbath, 16 Сентября 2014

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

    +3

    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
    #include <iostream>
    
    using namespace std;
    
    class Base {
    public:
           Base() {
                  cout << "Base construct\n";
           }
           virtual  ~Base() {
                  cout << "Base destruct\n";
           }
    };
    
    class Child: public Base {
    public:
           Child() {
                  cout << "Child construct\n";
           }
           ~Child() {
                  cout << "Child destruct\n";
           }
    };
    
    int main() {
           Base *base = new Child();
           delete base;
    }

    Hy нe oчeвиднo жe! Для тoгo, чтoб вызывaлиcь вce дecтpyктopы, нyжнo oбъявить eгo виpтyaльным. B тo вpeмя кaк кoнcтpyктop бeз мoдификaтopa virtual paбoтaeт тaк жe, кaк виpтyaльный дecтpyктop.
    И зaчeм вoбщe ocтaвлять вoзмoжнocть нe виpтyaльнoгo дecтpyктopa - нe мoгy пpeдcтaвить ceбe cлyчaя, кoгдa пpи yдaлeнии oбъeктa нyжeн вызoв дecтpyктopa тoлькo бaзoвoгo клacca.

    Pythoner, 18 Марта 2014

    Комментарии (60)
  11. C++ / Говнокод #14415

    +4

    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
    #include <iostream>
    using namespace std;
    
        void enable_misalignment_access_check(){
          cout<<"begin "<<__FUNCTION__<<endl;
          __asm__(
            "pushf\n"
            "orl $(1<<18),(%esp)\n"
            "popf\n"
          );
          cout<<"end "<<__FUNCTION__<<endl;
        }
    
    void alignedAccess(volatile unsigned char foo[])
    {
      cout<<"begin "<<__FUNCTION__<<endl;
      volatile int t = *(int *)(foo);
      cout<<"end "<<__FUNCTION__<<endl;
    }
    
    void unalignedAccess(volatile unsigned char foo[])
    {
      cout<<"begin "<<__FUNCTION__<<endl;
      volatile int t = *(int *)(foo+1);
      cout<<"end "<<__FUNCTION__<<endl;
    }
    
    unsigned char foo[] = { 1, 2, 3, 4, 5, 6 };
    
    int main(void)
    {
        alignedAccess(foo);
        unalignedAccess(foo);
        enable_misalignment_access_check();
        alignedAccess(foo);
        unalignedAccess(foo);
        return 0;
    }

    http://codepad.org/D6b5asES

    begin alignedAccess end alignedAccess 
    begin unalignedAccess end unalignedAccess
    begin enable_misalignment_access_check end enable_misalignment_access_check
    begin alignedAccess end alignedAccess
    begin unalignedAccess
    Bus error

    LispGovno, 26 Января 2014

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