1. Куча / Говнокод #24653

    −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
    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
    #!/l_l5l2/8IN/l>Y7l-lON3
    
    IMl>Ol27 5Y5
    
    41l>l-l4 = {
            '4': '4',
            '8': '8',
            '(': '(',
            ')': ')',
            '3': '3',
            '#': '#',
            '9': '9',
            'l-l': '1-1',
            '1': '1',
            '_l': '_1',
            'l<': '1<',
            'l>': '1>',
            '&': '&',
            'l2': '12',
            '5': '5',
            '7': '7',
            'l_l': '1_1',
            '\/': '\/',
            '\/\/': '\/\/',
            '><': '><',
            'Y': 'Y',
            '2': '2'
    }
    
    I# 13N(5Y5.4l29\/) > 1:
        # = Ol>3N(5Y5.4l29\/[1])
    3153:
        # = 5Y5.57)IN
    
    8l_l##3l2 = []
    #Ol2 ( IN #.l234)().l_ll>l>3l2():
        8l_l##3l2.4l>l>3N)(41l>l-l4[(] I# ( IN 41l>l-l4 3153 ()
    
    l>l2IN7(''._lOIN(8l_l##3l2))

    vistefan, 24 Августа 2018

    Комментарии (73)
  2. C++ / Говнокод #24652

    +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
    class TaxStorage {
    public:
      using TaxCode = Code<3>; // Code<int N, typename Storage = uint32_t> тип для маленьких строк
      using TaxType = Code<3>;
      using TaxId = std::tuple<TaxCode, TaxType>;
      using TaxMap = std::map<TaxId, int>
    
      using CityId = int;
      using TaxPointMap = std::unordered_map<CityId, TaxMap>;
    
      TaxMap forCityOrOther(const TaxPointMap& map, const CityId cityId) const {
        const auto found = map.find(cityId);
        return found == map.cend() ? map.at(OTHER_CITY) : *found; // должно быть found->second
      }
    }

    Dev: Ok GCC, tell me what is wrong.
    GCC: /home/whatever/project/TaxStorage.h:102: error: incompatible operand types ('const std::unordered_map<int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > > > >::mapped_type' (aka 'const std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >') and 'const std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > >')

    ДОКОЛЕ?!!

    Elvenfighter, 24 Августа 2018

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

    −1

    1. 1
    2. 2
    $query  = "SELECT * FROM archivo_mhora WHERE id_aparato=" . $aparatos_row->id;
    $query .= " && DATE_FORMAT(fecha, '%Y.%m.%d')='" . date('Y.m.d', $cur_fecha) . "' ORDER BY energy";

    Я не знаю, к какой секции следует отнести этот высер:
    1) Автор решил учить испанский. Таблицы имеют имена `aparatos`, `abonandos`, etc
    2) Само собой, SQL injection
    3) Порнография при работе с датой

    kai, 23 Августа 2018

    Комментарии (3)
  4. Куча / Говнокод #24645

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    def $qmark = 1
    def ? = 1
    
    // Error:(2, 6) method ? is defined twice

    Scala-way

    vistefan, 21 Августа 2018

    Комментарии (26)
  5. JavaScript / Говнокод #24641

    0

    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
    <!-- todo: put this in a different file!!! -->
    <script>
    function authenticateUser(username, password) {
      var accounts = apiService.sql(
        "SELECT * FROM users"
      );
    
      for (var i = 0; i < accounts.length; i++) {
        var account = accounts[i];
        if (account.username === username &&
            account.password === password)
        {
          return true;
        }
      }
      if ("true" === "true") {
        return false;
      }
    }
    
    $('#login').click(function() {
      var username = $("#username").val();
      var password = $("#password").val();
    
      var authenticated = authenticateUser(username, password);
    
      if (authenticated === true) {
        $.cookie('loggedin', 'yes', { expires: 1});
      } else if (authenticated === false) {
        $("#error_message").show();
      }
    });
    </script>

    This JavaScript code powers a 1,500 user intranet application

    theraphim, 20 Августа 2018

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

    −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
    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
    private static function preparePostProperty(&$data, $propName = [], $type = 'float'){
            if(!in_array($type, ['float', 'integer', 'string']))
                return;
            if(is_array($data) && !empty($propName)){
                $key = '$data["' . implode('"]["', $propName) . '"]';
    
                @eval("if(isset($key)) $key = ($type)$key;");
            }
        }
    
    
        public static function preparePost($data, $documentsObjects = []){
            if(is_array($data)){
                self::preparePostProperty($data, ['general', 'fromMtender', 'lotDetails', 'lotAmount']);
                self::preparePostProperty($data, ['general', 'additionalData', 'budgetDetails', 'amountBrutto']);
                self::preparePostProperty($data, ['general', 'additionalData', 'budgetDetails', 'amountNetto']);
                self::preparePostProperty($data, ['general', 'additionalData', 'budgetDetails', 'amountPrepayment']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountGuarantee']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountGE']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountWithdraw']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountMaxWithdraw']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'transferDuration']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'nonPaymentMax']);
                self::preparePostProperty($data, ['general', 'additionalData', 'executionShouldStart']);
                self::preparePostProperty($data, ['general', 'additionalData', 'executionDuration']);
    
                foreach ($data['subject'] as $k => $subjects){
                    //data[subject][0][fromMtender][itemQuantity]
                    self::preparePostProperty($data, ['subject', $k, 'fromMtender', 'itemQuantity']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'unitPrice', 'withoutVAT']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'unitPrice', 'withVAT']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'amountPrice', 'withoutVAT']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'amountPrice', 'withVAT']);
    
                    foreach ($subjects['additionalData']['budget'] as $kb => $budgets){
                        self::preparePostProperty($data, ['subject', $k, 'additionalData', 'budget', $kb, 'budgetAmount']);
                    }
                }
    
                self::preparePostProperty($data, ['ca', 'additionalData', 'caPerson', 'caPersonCode']);
    
                self::preparePostProperty($data, ['eo', 'fromMtender', 'eoCode']);
                self::preparePostProperty($data, ['eo', 'additionalData', 'eoLicenses', 'eoValidityDuration']);
                self::preparePostProperty($data, ['eo', 'additionalData', 'eoPerson', 'eoPersonCode']);
    
                self::preparePostProperty($data, ['otherConditions', 'sla', 'deliveryDelayLiability', 'liabilityPercent']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'deliveryDelayLiability', 'liabilityPercentMax']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'paymentDelayLiability', 'liabilityPercent']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'paymentDelayLiability', 'liabilityPercentMax']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'maxPenalty']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'maxDelay']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'warrantyPeriod']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'informOnSigned']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'informOnFM']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'informOnTermination']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'respondOnTermination']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'submitClaimsMax']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'respondClaimsMax']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'deliverOnClaims']);
            }
    
            self::appendPostDocuments($data, $documentsObjects);
    
            return $data;
        }

    ЧТОЕТА?

    dd3d, 20 Августа 2018

    Комментарии (10)
  7. Java / Говнокод #24639

    −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
    public Pattern waitNotEmptyRegex(){
            String read;
            Pattern pattern;
    
            while (true) {
                try {
                    try {
                        read = in.readLine();
                        if (!read.trim().isEmpty()) {
                            pattern = Pattern.compile(read);
                        } else {
                            context.getOut().write(context.localizKey("console.messages.emptyString") + "\n");
                        }
                    } catch (PatternSyntaxException e) {
                        context.getOut().write(context.localizKey("console.messages.invalidPattern") + "\n");
                    }
                }catch (IOException e){
                    throw new IllegalStateException(e);
                }
            }
        }

    Боооольше вложенных блоков

    the-alator, 20 Августа 2018

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

    −1

    1. 1
    Нах c#, если есть Java?

    shite, 19 Августа 2018

    Комментарии (123)
  9. Java / Говнокод #24635

    −3

    1. 1
    System.out.println("The result of " + calc.getFirstNo() + " " + calc.getCharacter() + " " + calc.getSecondNo() + " is " + calc.calculate(calc.getFirstNo(), calc.getCharacter(), calc.getSecondNo()));

    shite, 19 Августа 2018

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

    −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
    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
    /*
    	Программа для генерации и вывода разряженной матрицы
    	Специально для сайта govnokod.ru
    */
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    
    // Объявление переменных
    const int first_index_size=20;
    const int second_index_size=50;
    char matrix_array[first_index_size][second_index_size];
    
    enum border_style{
    	line,single 
    };
    
    void borders(border_style matrix_border)
    {
    	switch(matrix_border)
    	{
    		case 0:
    			for(int i=0; i<(second_index_size+2); i++)
    				std::cout<<"#";
    			std::cout<<"\n";
    			break;
    		case 1:
    			std::cout<<"#";
    	}
    }
    
    void rand_func_init()
    {
    	// Инициализация функции rand()
    	srand(time(0));
    	rand();
    }
    
    void matrix_init_zero()
    {
    	// Инициализация матрицы нулём	
    	for(int i=0; i<first_index_size; i++)
    		for(int t=0; t<second_index_size; t++)
    			matrix_array[i][t]=0;
    }
    
    void matrix_init_rand()
    {
    	// Заполнение матрицы
    	for(int i=0; i<first_index_size; i++)
    	{
    		int init_num=rand()%11;
    		while(init_num)
    		{
    			init_num--;
    			matrix_array[i][rand()%50]=149;
    		}
    	}
    }
    
    void matrix_print()
    {
    	// Вывод матрицы	
    	borders(line);
    	for(int i=0; i<first_index_size; i++)
    	{
    		borders(single);
    		for(int t=0; t<second_index_size; t++)	
    			std::cout<<matrix_array[i][t];
    		borders(single);
    		std::cout<<"\n";
    	}
    	borders(line);
    }
    
    int main()
    {
    	rand_func_init();
    	matrix_init_zero();
    	matrix_init_rand();
    	matrix_print();
    	return 0;
    }

    Разряженная матрица 20x50.
    Количество ненулевых значений от 0 до 10.

    BelCodeMonkey, 18 Августа 2018

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