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

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

    +133.8

    1. 1
    2. 2
    3. 3
    4. 4
    var lox == alert('fuck you')
    if(lox == true) {
            alert(lox)
                           };

    ыыыыыыыыыыы

    fuckyounoob, 26 Октября 2009

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

    +133.8

    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
    public static XmlNode FindNodeXPath(XmlNode root, string xPath)
            {
                string[] paths = xPath.Split(new char[] { '/' });
                XmlNode node = root;
                for (int i = 0; i < paths.Length; i++)
                {
                    XmlNode childNode = null;
                    for (int j = 0; j < node.ChildNodes.Count; j++)
                    {
                        if (node.ChildNodes[j].Name == paths[i])
                        {
                            childNode = node.ChildNodes[j];
                            node = childNode;
                            break;
                        }
                    }
                    if (childNode == null)
                    {
                        return null;
                    }
                }
                return node;
            }
    
            public static XmlNode FindNodeXPath(XmlNode root, string nodeName, string xPath)
            {
                XmlNode node = FindNodeXPath(root, xPath);
                if (node != null)
                {
                    for (int i = 0; i < node.ChildNodes.Count; i++)
                    {
                        if (node.ChildNodes[i].Name == nodeName)
                        {
                            node = node.ChildNodes[i];
                        }
                    }
                }
                return node;
            }
    
            public static void UpdateBaseAddress(string url, string fileConfig)
            {
                // Create config file to create 
                XmlDocument xmlDom = new XmlDocument();
                xmlDom.Load(fileConfig);
                XmlNode root = xmlDom.DocumentElement;
                // Get XML node 
                XmlNode xmlNode = FindNodeXPath(root, "endpoint", "system.serviceModel/services/service");
                xmlNode.Attributes["address"].Value = url;
    
                xmlNode = FindNodeXPath(root, "add", "system.serviceModel/services/service/host/baseAddresses");
                xmlNode.Attributes["baseAddress"].Value = url;
    
                xmlDom.Save(fileConfig);
            }

    Виетнамский XPath эквивалент :)

    bugotrep, 15 Августа 2009

    Комментарии (2)
  4. JavaScript / Говнокод #672

    +133.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    iplist += "<ul id='iplist'>";
    jsonData="[";
    for(var i=0;i<selections.length;i++) {
        jsonData += Ext.util.JSON.encode(selections[i])+",";
        iplist += "<li>" + selections[i] + "; </li>";
    }
    jsonData = jsonData.substring(0,jsonData.length-1) + "]";
    iplist += "</ul>";
    win.show();
    Ext.get("list").update(iplist);
    win.hide();
    win.show();

    В ExtJS не хотел обновляться компонент окна.

    guest, 05 Марта 2009

    Комментарии (2)
  5. Си / Говнокод #2166

    +133.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if(no!=s.FrameCounter) 
            s.FramesGarbage++;  //выкидываем кадр
            else { s.FramesOK++; s.NakCount++; }
            curbufdata=packet-data;
            if(no==s.FrameCounter) 
            WriteAdminLog("Не готов принять отриц. квитанцию (не в ожидании подтверждения) ",no,0,TRUE);
            else if(no!=s.FrameCounter) {  
            WriteAdminLog("Получена отриц. квитанция на последний переданный кадр! Часть данных могла потеряться. Корректируется счётчик на:",no,PARAM_LONG,FALSE);
            s.FrameCounter=no;
            }

    Из курсовой работы (своей). Готовлю к сдаче и нахожу такое.
    Видимо, в первоначальном варианте условие имело смысл, а потом я его поменял и оно стало лишним.

    vyalcevanet, 22 Ноября 2009

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

    +133.7

    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
    try
                {
                    var st = ((JsonString)options["tribes"]).Value.Split(',');
                    foreach (var s in st)
                    {
                        if (s != string.Empty)
                        {
                            ShowTribes.Add(s);
                        }
                    }
                }
                catch (KeyNotFoundException)
                { }
                try
                {
                    ShowNotes = ((JsonString)options["show_comments"]).Equals("true") || (url.IndexOf("#note_id=") != -1);
                }
                catch (KeyNotFoundException)
                { }
                try
                {
                    Rating = ((JsonString)options["eye"]).Value;
                }
                catch (KeyNotFoundException)
                { }

    plsc_rover, 21 Октября 2009

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

    +133.7

    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
    public class ImageRotator {
    
        public static BufferedImage rotate(BufferedImage originalImage, int angle) {
            BufferedImage image = null;
            switch (angle) {
                case 90:
                case -270:
                    image = ImageRotator.rotate90Right(originalImage);
                    break;
                case 270:
                case -90:
                    image = ImageRotator.rotate90Left(originalImage);
                    break;
                case 180:
                case -180:
                    image = ImageRotator.rotate180(originalImage);
                    break;
                default:
                    image = originalImage;
                    break;
            }
            return image;
        }
    
        private static BufferedImage rotate90Left(BufferedImage bi) {
            int width = bi.getWidth();
            int height = bi.getHeight();
            BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    biFlip.setRGB(height - 1 - j, width - 1 - i, bi.getRGB(i, j));
                }
            }
            return biFlip;
        }
    
        private static BufferedImage rotate90Right(BufferedImage bi) {
            int width = bi.getWidth();
            int height = bi.getHeight();
            BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    biFlip.setRGB(j, i, bi.getRGB(i, j));
                }
            }
            return biFlip;
        }
    
        private static BufferedImage rotate180(BufferedImage bi) {
            int width = bi.getWidth();
            int height = bi.getHeight();
            BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    biFlip.setRGB(i, j, bi.getRGB(width - 1 - i, height - 1 - j));
                }
            }
            return biFlip;
        }
    }

    Есть в Java для работы с изображениями такой класс как AphineTransform, но в после 3 часов активного взаимодействия с ним добился только того что изображение после болшого кол-ва поворотов привращалось в точку. Поэтому из себя была выдавлена эта заглушка...

    guest, 05 Марта 2009

    Комментарии (1)
  8. Си / Говнокод #2691

    +133.6

    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
    char *errdesc;
    
    [...]
    
                switch errno
                {
                    case EACCES: errdesc="For Unix domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path prefix. (See also path_resolution(2).) " ;break;
                    case EPERM: errdesc="The user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connection request failed because of a local firewall rule. ";break;
                    case EADDRINUSE: errdesc="Local address is already in use. ";break;
                    case EAFNOSUPPORT: errdesc="The passed address didn't have the correct address family in its sa_family field. ";break;
                    case EAGAIN: errdesc="No more free local ports or insufficient entries in the routing cache. For PF_INET see the net.ipv4.ip_local_port_range sysctl in ip(7) on how to increase the number of local ports. ";break;
                    case EALREADY: errdesc="The socket is non-blocking and a previous connection attempt has not yet been completed. ";break;
                    case EBADF: errdesc="The file descriptor is not a valid index in the descriptor table. ";break;
                    case ECONNREFUSED: errdesc="No one listening on the remote address. ";break;
                    case EFAULT: errdesc="The socket structure address is outside the user's address space. ";break;
                    case EINPROGRESS: errdesc="The socket is non-blocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed here, explaining the reason for the failure). ";break;
                    case EINTR: errdesc="The system call was interrupted by a signal that was caught. ";break;
                    case EISCONN: errdesc="The socket is already connected. ";break;
                    case ENETUNREACH: errdesc="Network is unreachable. ";break;
                    case ENOTSOCK: errdesc="The file descriptor is not associated with a socket. ";break;
                    case ETIMEDOUT: errdesc="Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.";break;
                    case EADDRNOTAVAIL: errdesc="EADDRNOTAVAIL";break;
                    case EPROTOTYPE: errdesc="EPROTOTYPE";break;
                    case EINVAL: errdesc="Invalid argument passed.";break;
                    case ENOMEM: errdesc="Could not allocate memory for recvmsg().";break;
                    case ENOTCONN: errdesc="The socket is associated with a connection-oriented protocol and has not been connected (see connect(2) and accept(2)).";break;
                    default: errdesc="Unknown error";break;
                }

    Мдя, просматривать код писанный мной же, когда я ещё только-только начинал писать на Си стыдновато. :)

    xaionaro, 28 Февраля 2010

    Комментарии (17)
  9. Си / Говнокод #761

    +133.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    /* {{{ proto mixed array_reduce(array input, mixed callback [, int initial])
       Iteratively reduce the array to a single value via the callback. */
    ...
    
            if (ZEND_NUM_ARGS() > 2) {
                    ALLOC_ZVAL(result);
                    *result = **initial;
                    zval_copy_ctor(result);
                    convert_to_long(result); // SIC!
                    INIT_PZVAL(result);
            }
    ...

    Исходники PHP, array_reduce.

    Обнаружил http://antilamer.livejournal.com/269560.html

    guest, 23 Марта 2009

    Комментарии (1)
  10. Pascal / Говнокод #1112

    +133.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
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    program Project1;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils,
      Windows;
    
    const
      C: array[0..5] of Cardinal = ($4A9AAA90, $8AA33308, $8AA2AA88, $4C9AAA90, $22200, $822200);
    
    var
      I: Byte;
      B: PByte;
    begin
      for I := 191 downto 0 do
      begin
        B := @C[I div 32];
        Inc(B, (I - (I div 32) * 32) div 8);
        if (B^ and (1 shl (I mod 8))) <> 0 then
          Write('X')
        else
          Write(' ');
        if (I mod 32) = 0 then
          Writeln('');
      end;
      ReadLn;
    end.

    nickkk govnokod

    guest, 31 Мая 2009

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

    +133.5

    1. 1
    #define TRUE __LINE__

    Тонкая версия #define TRUE чего-то-там.
    __LINE__ во многом будет вести себя как нормальный TRUE, выстрелит при применении оператора ==

    guest, 24 Апреля 2009

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