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

    В номинации:
    За время:
  2. Куча / Говнокод #26437

    0

    1. 1
    https://mangalib.me/fisheye-placebo/v1/c1?page=3

    именно поэтому я за «‎SSH-соединение»

    Fike, 13 Февраля 2020

    Комментарии (120)
  3. C++ / Говнокод #26318

    −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
    #include <boost/hana.hpp>
    #include <boost/hana/ext/std/tuple.hpp>
    #include <cstdint>
    
    namespace hana = boost::hana;
    using namespace hana::literals;
    using hana::transform, hana::decltype_, hana::to_set, hana::type_c;
    
    auto copy = [](uint8_t * in, uint8_t * out, auto n, auto s) {
      
      n.times.with_index([&](auto x) {
        
        if constexpr(x == s) {
          ++in;
        } else {
          *(uint16_t *)out = *(uint16_t *)in;
          out +=2; in += 2;
        }
        
      });
      
      return in;
    };
    
    auto f(uint8_t * in, uint8_t * out) {
        return copy(in, out, 33_c, 15_c);
    }

    https://habr.com/ru/post/482834/#comment_21094618
    > Простая задача, самый базовый вариант https://godbolt.org/z/5F5mt9 — повторите.

    Очередные набросы крестоговна на хабр от царя.

    Найдите UB.

    j123123, 06 Января 2020

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

    0

    1. 1
    2. 2
    Узнали? Согласны?
    https://www.youtube.com/watch?v=0GIcP6xvW5Q

    Skarn, 17 Августа 2019

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

    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
    std::string makeFormContent(const std::string & album,
                                const std::wstring & filename,
                                const std::string & boundary)
    {
        static const std::string DELIM = "\r\n";
        std::ostringstream ss;
        std::ifstream file(filename, std::ios::binary);
    
    
        ss << boundary << DELIM;
        ss << "Content-Disposition: form-data; name=\"album\"" << DELIM << DELIM;
        ss << album << DELIM;
    
        ss << boundary << DELIM;
        ss << "Content-Disposition: form-data; name=\"image\"; filename=\"image\"" << DELIM << DELIM;
        ss << file.rdbuf() << DELIM;
    
        ss << boundary << DELIM << "--";
    
        return ss.str();
    }

    Заебали. Куча HTTP-либ под кресты, а банально сделать POST-запрос с multipart/form-data без кучи ебли нельзя. Приходится самому составлять, лол.

    Именно поэтому я за «requests.post(url, data=data, files=files)».

    gost, 02 Июля 2019

    Комментарии (120)
  6. Си / Говнокод #25314

    −3

    1. 1
    2. 2
    3. 3
    4. 4
    void print_line(char *s){
        for(int i = 0; i < strlen(s); i++) putchar(s[i]);
        putchar('\n');
    }

    Почему C работает медленнее чем JavaScript ?

    o8603054, 17 Января 2019

    Комментарии (120)
  7. JavaScript / Говнокод #20136

    +5

    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
    function insertComment(comment) {
        // todo: optimize this shit
        for (var j = 0; j < $scope.comments.length; ++j) {
            if ($scope.comments[j].thread_id == comment.thread_id) {
                $scope.comments[j] = comment;
                return;
            }
            if ($scope.comments[j].comment_id < comment.comment_id) {
                $scope.comments.splice(j, 0, comment);
                return;
            }
        }
        $scope.comments.push(comment);
    }
    
    for (var i = 0; i < data.length; ++i) {
        comment = data[i];
        comment.text = $sce.trustAsHtml(comment.text);
        comment.postedFuzzy = fuzzyDate(new Date(comment.posted), new Date());
        insertComment(comment);
    }

    Оптимальное набивание комментов в сток за O(n^2).

    http://146.185.130.46/ngk/

    bormand, 06 Июня 2016

    Комментарии (120)
  8. Java / Говнокод #18475

    +70

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    List<Integer> positionList = new ArrayList<Integer>(positions.keySet());
    Collections.sort(positionList, new Comparator<Integer>() {
        @Override
        public int compare(Integer lhs, Integer rhs) {
            if (lhs > rhs) {
                return 1;
            } else if (lhs < rhs) {
                return -1;
            }
            return 0;
        }
    });

    Видать разработчику за кол-во написанных строк платили...

    tony777, 13 Июля 2015

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

    −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
    import java.util.Scanner;
    
    public class JavaApplication5 {
    
        public static void main(String[] args) {
            Scanner sw = new Scanner(System.in);
            System.out.print("Введите число: ");
            int week = sw.nextInt();
            System.out.println("The day is "+day);
        
    }
    
    class Month{
        
            String day;
            switch (int week) {
                case 1:
                    day = "Monday";
                    break;
                case 2:
                    day = "Tuesday";
                    break;
                case 3:
                    day = "Wednesday";
                    break;
                // match the value of week
                case 4:
                    day = "Thursday";
                    break;
                case 5:
                    day = "Friday";
                    break;
                case 6:
                    day = "Saturday";
                    break;
                case 7:
                    day = "Sunday";
                    break;
                default:
                    day = "---";
                    break;
            }
            
        }
    }

    Нужно чтобы от пользователя запрашивался номер дня недели, а получалось название. Не пойму, что не так. Помогите, пожалуйста, Добрые Люди

    123AAAANNNAAA, 08 Января 2022

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

    +5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
    
    // The Curiously Recurring Template Pattern (CRTP)
    template<class T>
    class Base
    {
        // methods within Base can use template to access members of Derived
    };
    class Derived : public Base<Derived>
    {
        // ...
    };

    > The Microsoft Implementation of CRTP in Active Template Library (ATL) was independently discovered, also in 1995 by Jan Falkin who accidentally derived a base class from a derived class. Christian Beaumont, first saw Jan's code and initially thought it couldn't possibly compile in the Microsoft compiler available at the time. Following this revelation that it did indeed work, Christian based the entire ATL and Windows Template Library (WTL) design on this mistake.

    А какая ошибка по-вашему положена в основу всего дизайна языка C++?

    j123123, 06 Февраля 2019

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

    +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
    // https://github.com/telegramdesktop/tdesktop/blob/5f5770dd46491133b135a71fc2d4f92d13107ade/Telegram/SourceFiles/history.cpp#L1455
    
    int History::countUnread(MsgId upTo) {
    	int result = 0;
    	for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) {
    		--i;
    		for (auto j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) {
    			--j;
    			if ((*j)->id > 0 && (*j)->id <= upTo) {
    				break;
    			} else if (!(*j)->out() && (*j)->unread() && (*j)->id > upTo) {
    				++result;
    			}
    		}
    	}
    	return result;
    }
    
    void History::updateShowFrom() {
    	if (showFrom) return;
    
    	for (auto i = blocks.cend(); i != blocks.cbegin();) {
    		--i;
    		for (auto j = (*i)->items.cend(); j != (*i)->items.cbegin();) {
    			--j;
    			if ((*j)->id > 0 && (!(*j)->out() || !showFrom)) {
    				if ((*j)->id >= inboxReadBefore) {
    					showFrom = *j;
    				} else {
    					return;
    				}
    			}
    		}
    	}
    }

    очередная порция говнеца из телесрамного клиента

    j123123, 07 Ноября 2017

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