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

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

    0

    1. 1
    if(!preg_match('/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i', $email)){

    dm_fomenok, 20 Мая 2018

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

    +9

    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
    #define public public: void operator delete(void *pituh) {}; public
         
    class poteklo
    {
    public:
        poteklo() :
            TheAnswer(42)
        {
             ;
        }
         
    private:
         int TheAnswer;
    };
         
    int main(int argc, char *argv[])
    {
        poteklo *uteklo = new poteklo;
        delete uteklo;    // Утекло!
    
        return 0;
    }

    Макро в духе "#define TRUE FALSE", только хардкорнее.
    https://ideone.com/ZdGnuL

    gost, 30 Мая 2016

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

    0

    1. 1
    Тарас с сайта ebanoe.it это не я

    TarasB, 11 Мая 2016

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

    +168

    1. 1
    define("OUTPUT_DIR_CSV", "kokoko/kukarek/files" . DIRECTORY_SEPARATOR);

    Stallman, 19 Февраля 2015

    Комментарии (103)
  6. JavaScript / Говнокод #16141

    +156

    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
    (function(G, D) {
        "use strict";
        var $ = G.jQuery,
            listener;
    
        function addListener(elem, fn) {
            function handler(event) {
                event = event || G.event;
                var dx = event.DeltaX || event.wheelDeltaX || event.detail || 0,
                    dy = event.DeltaY || event.wheelDeltaY || event.detail || 0;
                event.dx = dx === 0 ? 0 : dx / Math.abs(dx);
                event.dy = dy === 0 ? 0 : dy / Math.abs(dy);
                fn(event);
            }
    
            if (elem.addEventListener) {
                if (D.hasOwnProperty('onwheel')) { //Modern browsers
                    listener = "wheel";
                } else if (D.hasOwnProperty('onmousewheel')) { //Old browsers
                    listener = "mousewheel";
                } else { //FF<17
                    listener = "MozMousePixelScroll";
                }
                elem.addEventListener(listener, handler, false);
            } else { //IE<9
                elem.attachEvent("onmousewheel", handler);
                listener = "onmousewheel";
            }
        }
    
        function removeListener(elem) {
            if (elem.removeEventListener) {
                elem.removeEventListener(listener);
            } else {
                elem.detachEvent(listener);
            }
        }
    
        $.fn.mousewheel = function(fn) {
            return this.each(function() {
                addListener(this, fn);
            });
        };
        $.fn.unmousewheel = function(fn) {
            return this.each(function() {
                removeListener(this, fn, false);
            });
        };
    }(this, document));

    Написал плагин для jQuery, который цепляет на элементы обработчик события вращения колесика мыши. Что скажете? Как бы вы написали функцию unmousewheel()?

    dunmaksim, 10 Июня 2014

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

    +135

    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
    private void Button2_Click(object sender, EventArgs e)
        {
          this.Label4.Text = new StreamReader("C:\\Program Files\\Microsoft Visual Studio 10.0\\VB\\VBProjects\\датаметр\\датаметр\\bin\\Release\\Key.txt").ReadLine();
          if (Operators.CompareString(this.Label4.Text, "vrc5rhhgyuuoxr45", false) == 0)
          {
            this.Button1.Visible = true;
            this.TextBox1.Visible = true;
            this.Label1.Visible = true;
            this.Label4.Visible = false;
            this.Button2.Visible = false;
            this.Label3.Visible = true;
            int num = (int) Interaction.MsgBox((object) "Ключ верный.\r\nНе сообщайте его никому !!\r\nИ не потеряйте.", MsgBoxStyle.OkOnly, (object) null);
          }
          else
            this.Label4.Text = "Ключ не верный !!\r\nПоменяйте его в файле \"Key\"";
        }

    Классное расположение файла. Причём в архиве лежит пустой файл Key.txt рядом с программой...
    Как надо было извратиться, чтобы в коде оказался не просто абсолютный путь, но и вот такой-вот с Program Files, ведь по умолчанию VS создаёт проекты в Моих документах

    http://www.cyberforum.ru/vb-net/thread971437.html

    Qwertiy, 08 Октября 2013

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

    +134

    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
    using System;
    using System.Security.Cryptography;
    
    namespace sha1_calc
    {
        class Program
        {
            static void Main(string[] args)
            {
                SHA1 sha = new SHA1CryptoServiceProvider();
                foreach (var fname in args)
                {
                    Console.WriteLine("file: " + fname);
                    try
                    {
                        System.IO.FileStream fs = System.IO.File.Create(fname);
                        byte [] res = sha.ComputeHash(fs);
                        fs.Close();
                        Console.Write("0x");
                        foreach (var i in res)
                        {
                            Console.Write(i.ToString("X"));
                        }
                        Console.WriteLine();
                        Console.WriteLine("---------------------------------");
                    }
                    catch(Exception e)
                    {
                        Console.WriteLine("error: " + e);
                    }
                }
                Console.ReadKey();
            }
        }
    }

    Скачал парочку образов и решил проверить их чексуммы. Протестировал программу на скачанных файлах. Удивился, почему же у них хеши одинаковые?

    Xom94ok, 05 Июля 2013

    Комментарии (103)
  9. Pascal / Говнокод #4805

    +97

    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
    program Project42;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, Math;
    
    const
      Radix = 10;
    
    function čòũʼnť(N: Integer): Integer;
    begin
      Result := 0;
      while N > 0 do
      begin
        N := N div Radix;
        Inc(Result);
      end;
    end;
    
    function count(N: Integer): Integer;
    begin
    //  Result := Ceil(LogN(Radix, N));     { slow! }
      Result := Ceil(Log10(N));
    end;
    
    function rdtsc: Int64;
    asm
            rdtsc
    end;
    
    var
      I: Integer;
      t0: Int64;
    
    const
      N = 100500;
    
    begin
      try
        Assert((count(42) = čòũʼnť(42)) and (count(100500) = čòũʼnť(100500)));
    
        t0 := rdtsc;
        for I := 1 to N do
          čòũʼnť(Random(MaxInt + 1));
        Writeln('naïve: ', rdtsc - t0, ' ticks');
    
        t0 := rdtsc;
        for I := 1 to N do
          count(Random(MaxInt + 1));
        Writeln('prőper: ', rdtsc - t0, ' ticks');
    
        Writeln(StringOfChar('-', 42));
    
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    
      if DebugHook <> 0 then
      begin
        Write('any big key to exit...');
        Readln;
      end;
    
    end.
    
    { http://imgs.xkcd.com/comics/haiku_proof.png :-P }

    матан > метан
    O(1) > O(N)
    логарифм > байтоёбства с делением

    bugmenot, 01 Декабря 2010

    Комментарии (103)
  10. Куча / Говнокод #29132

    0

    1. 1
    IT Оффтоп #216

    #186: https://govnokod.ru/28815 https://govnokod.xyz/_28815
    #187: https://govnokod.ru/28833 https://govnokod.xyz/_28833
    #188: https://govnokod.ru/28837 https://govnokod.xyz/_28837
    #189: https://govnokod.ru/28840 https://govnokod.xyz/_28840
    #190: https://govnokod.ru/28875 https://govnokod.xyz/_28875
    #191: https://govnokod.ru/28878 https://govnokod.xyz/_28878
    #192: https://govnokod.ru/28886 https://govnokod.xyz/_28886
    #193: https://govnokod.ru/28911 https://govnokod.xyz/_28911
    #194: https://govnokod.ru/28914 https://govnokod.xyz/_28914
    #195: https://govnokod.ru/28917 https://govnokod.xyz/_28917
    #196: https://govnokod.ru/28925 https://govnokod.xyz/_28925
    #197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
    #198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
    #199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
    #200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
    #201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
    #202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
    #203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
    #204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
    #205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
    #206: https://govnokod.ru/28991 https://govnokod.xyz/_28991
    #207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
    #208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
    #209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
    #210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
    #211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
    #212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
    #213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
    #214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
    #215: https://govnokod.ru/29125 https://govnokod.xyz/_29125

    nepeKamHblu_nemyx, 11 Мая 2025

    Комментарии (102)
  11. Си / Говнокод #27954

    +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
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      int a[4] = {1, 2, 3, 4};
      int (*a_p1)[4] = (int (*)[4])a;
      int (*a_p2)[4] = &a;
      for(size_t i = 0; i < 4; ++i)
      {
        printf("%p -> %d; %p -> %d\n", &(*a_p1)[i], (*a_p1)[i], &(*a_p1)[i], (*a_p2)[i]);
      }
      return EXIT_SUCCESS;
    }

    Вот такой вывод:
    0x7ffee4ebd950 -> 1; 0x7ffee4ebd950 -> 1
    0x7ffee4ebd954 -> 2; 0x7ffee4ebd954 -> 2
    0x7ffee4ebd958 -> 3; 0x7ffee4ebd958 -> 3
    0x7ffee4ebd95c -> 4; 0x7ffee4ebd95c -> 4

    j123123, 14 Января 2022

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