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

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

    +1

    1. 1
    chunksLst.erase(++it1);

    laMer007, 16 Июня 2014

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

    +142

    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
    List<EntryChange> changes = new List<EntryChange>();
    
    for (int index = 0;
                index < partsContainer.transform.childCount;
                        ++index)
    {
    
        if (partsContainer
                    .transform
                        .GetChild(index)
                                .GetComponent<castle_parts_container>()
                                    .inSave()
                        ==
                        true)
        {
    
            // id of current part on scene
            int partId =
                    partsContainer.transform
                        .GetChild(index).gameObject
                                .GetComponent<castle_parts_container>()
                                                        .partIdentificator;
    
            int partColor =
                    partsContainer.transform
                        .GetChild(index).gameObject
                                .GetComponent<castle_parts_container>()
                                                            .savedColor();
            int partNumber =
                    partsContainer.transform
                        .GetChild(index).gameObject
                                .GetComponent<castle_parts_container>()
                                                            .savedNumber();
    
            EntryChange change = new EntryChange();
    
            change.original =
                    partsContainer.transform
                                    .GetChild(index).gameObject;
            change.target =
                    partPrefabs.Where(
                        x => x.GetComponent<castle_parts_container>().partIdentificator
                                ==
                                partId
                                    &&
                                x.GetComponent<castle_parts_container>().partColor
                                    ==
                                    partColor
                                        &&
                                    x.GetComponent<castle_parts_container>().partNumber
                                        ==
                                        partNumber
                    ).First();
    
            changes.Add(change);

    Избыточный код с форматированием в стиле Маяковского

    arazect, 08 Апреля 2014

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

    +81

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    procedure tmythread.execute;
      procedure fillmemo;
      begin
        form1.memo1.lines.add('Some string');
      end;
    begin
      synchronize(fillmemo); //[Error] Unit1.pas(54): There is no overloaded version of 'Synchronize' that can be called with these arguments
    end;

    Почему нельзя сделать вещи, сделанные "через анус", еще более "через анус"?

    Stertor, 29 Января 2014

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

    +168

    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
    // ==UserScript==
    // @name        no horses
    // @match       *://govnokod.ru/*
    // @grant       none
    // @run-at      document-start
    // ==/UserScript==
    var CONFIG = {
        horses: [ 
            "Horse2", 
            "PragramistOtBoga", 
            "anonimb84a2f6fd141",
        ],
        autoDownVote: true,
    };
    var observer = new MutationObserver(observeCallback);
    var config = {
        childList: true,
        subtree: true,
    };
    observer.observe(document, config);
    function observeCallback(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.addedNodes) {
                Array.prototype.forEach.call(mutation.addedNodes, function(node) {
                    try {
                        if (node.nodeType === 1 && /^comments_\d+$/.test(node.id)) {
                            handleComments(node);
                        }
                    } catch (e) {
                        console && console.warn && console.warn(e);
                    }
                });
            }
        });
    }
    function downVote(node, type) {
        var sel;
        switch (type) {
        case "post": sel = ".vote-against"; break;
        case "comment": sel = ".comment-vote-against"; break;
        default: throw 42; break;
        }
        var el = node.querySelector(sel);
        if (el) {
            var evt = document.createEvent("MouseEvents");
            evt.initMouseEvent("click", true, true, unsafeWindow, 
                0, 0, 0, 0, 0, false, false, false, false, 0, null); 
            el.dispatchEvent(evt);
        }
    }
    function handleComments(node) {
        var comments = node.querySelectorAll(".entry-comment-wrapper");
        Array.prototype.forEach.call(comments, function(comment) {
            try {
                handleComment(comment);
            } catch (e) {
                console && console.warn && console.warn(e);
            }
        });
    }
    function handleComment(node) {
        var author = node.querySelector(".entry-author").textContent.trim();
        if (CONFIG.horses.indexOf(author) != -1) {
            node.style.opacity = 0.3;
            node.style.maxHeight = "4em";
            node.style.overflow = "scroll";
    
            if (CONFIG.autoDownVote) {
                downVote(node, "comment");
            }
        }
    }
    function handlePosts(node) {
        var posts = node.querySelectorAll(".hentry");
        var i;
        for (i = 0; i < posts.length; i++) {
            try {
                handlePost(posts[i]);
            } catch (e) {
                console && console.warn && console.warn(e);
            }
        }
    }
    function handlePost(node) {
        var author = node.querySelector(".author a:nth-child(2)").textContent.trim();
        if (CONFIG.horses.indexOf(author) != -1) {
            if (!/^\/\d+$/.test(document.location.pathname)) {
                node.style.opacity = 0.3;
                node.style.maxHeight = "4em";
                node.style.overflow = "scroll";
            }
            if (CONFIG.autoDownVote) {
                downVote(node, "post");
            }
        }
    }
    document.addEventListener("DOMContentLoaded", function() {
        handleComments(document.body);
        handlePosts(document.body);
    });

    Я так и не смог заставить MutationObserver срабатывать на новые элементы, появляющиеся во время загрузки страницы. Отсюда и костыль в последних строчках.

    WGH, 22 Октября 2013

    Комментарии (121)
  6. Java / Говнокод #13661

    +64

    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
    import java.util.ArrayList;
    
    public class Chapter19 {
    	/* find repeat chars in text (in all words of text)
    	 * print repeat chars
    	 * 
    	 */
    	private String stringArray[] = { "Allocates ae neaw Setringa tehat",
    			"represeants tahe same saequence " };
    			
    	final private String alfabetArray = "abcdefghijklmnopqrstuvwxyz"; 
    	private ArrayList <Character> repeatChars; 
    
    	public void run() {
    		
    		printStringArray();			
    		
    		repeatChars = new ArrayList<Character>();
    		extractRepeatChars();
    		
    		if (!repeatChars.isEmpty()) {
    			printRepeatChars();
    		} else {
    			System.out.println("not repeat ");
    		}
    	}
    	
    	private void printRepeatChars(){
    		System.out.println("");
    		for (char c : repeatChars) {
    			System.out.println(c);
    		}	
    	}
    	
    	private void printStringArray(){
    		System.out.println(" ");
    		for (String s : stringArray) {
    			System.out.println(s);
    		}	
    	}
    	
    	
    	public String [][] parseStringArray() {
    		String wordsArray[][] = new String[stringArray.length][]; 
    		for (int i = 0; i < wordsArray.length; i++) {
    			wordsArray[i] = stringArray[i].split("\n|\t| "); 
    		}
    		
    		return wordsArray;
    	}
    
    	
    	public int findRepeatCharInWordsArray(String [][]wordsArray, char c) {		 													
    		for (int i = 0; i < wordsArray.length; i++) { 										
    			for (int j = 0; j < wordsArray[i].length; j++) { 			
    				if (wordsArray[i][j].indexOf(c) < 0) { 
    					return 0; // zodyje c nerastas
    				}
    			}	
    		}
    
    		return 1;
    	}
    
    
    	public void extractRepeatChars() {
    		String wordsArray[][] = parseStringArray();	
    		for (char c : alfabetArray.toCharArray()) {
    			if (findRepeatCharInWordsArray(wordsArray, c) > 0) {
    				repeatChars.add(c);
    			}
    		}
    	}
    
    } // end

    chapter 19

    spivti, 24 Августа 2013

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

    +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
    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
    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
    void swap (char *x, char *y)
    {
        char temp;
        temp = *x;
        *x = *y;
        *y = temp;
    }
     
    void permute(char *a, int i, int n)
    {
        int j;
        if (i == n)
        printf("%s\n", a);
        else
        {
            for (j = i; j <= n; j++)
            {
                swap((a+i), (a+j));
                permute(a, i+1, n);
                swap((a+i), (a+j));
            }
        }
    }
     
     
    int main()
    {
        char str[80] ;
        int len=0,i;
        puts("Enter a string:\n\n");
        gets(str);
        for (i=0; str[i] != '\0'; i++)
        {
            len++;
        }
        permute(str, 0, len);
        getchar();
        return 0;
    }

    Источник:
    http://www.c-program-example.com/2012/04/c-program-to-find-all-permutations-of.html

    про strlen видимо никто не слышал

    denis90, 13 Июля 2013

    Комментарии (121)
  8. Куча / Говнокод #26437

    0

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

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

    Fike, 13 Февраля 2020

    Комментарии (120)
  9. 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)
  10. Куча / Говнокод #25768

    0

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

    Skarn, 17 Августа 2019

    Комментарии (120)
  11. 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)