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

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

    +106

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    bool tos = true;
                   susid:
                       while (tos)
                        {
                              goto susid;
                    }

    Энто был я=(

    BlincAttack, 24 Мая 2010

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

    +106

    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
    // Вот так вот говнокодеры встречают конeц света:
    
    Function GetYear(StringYear : String) : Integer;
    Begin
     If StringYear = '2000' then result:=2000;
     If StringYear = '2001' then result:=2001;
     If StringYear = '2002' then result:=2002;
     If StringYear = '2003' then result:=2003;
     If StringYear = '2004' then result:=2004;
     If StringYear = '2005' then result:=2005;
     If StringYear = '2006' then result:=2006;
     If StringYear = '2007' then result:=2007;
     If StringYear = '2008' then result:=2008;
     If StringYear = '2009' then result:=2009;
     If StringYear = '2010' then result:=2010;
     If StringYear = '2011' then result:=2011;
     If StringYear = 'EndOfTheWorld' then result:=2012;
    End;

    Ну, как говорится, no comment :))))))))))

    ZLOvar, 22 Апреля 2010

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

    +105.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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    //одногрупнику надо было проверить, является ли "obj" - "А"
    //наблюдал за процессом, и плакал
    //----------------------------------------------------------------------------------
    //1 версия
    static bool IsA(object obj) {
    if (obj.GetType().Name.Equals("A", StringComparison.InvariantCultureIgnoreCase))
        return true;
        else return false;
    }
    //----------------------------------------------------------------------------------
    //2 версия
    static bool IsA(object obj) {
        A a = new A();
        if (obj.GetType().Equals(a.GetType()))
            return true;
        else return false;
    }
    //----------------------------------------------------------------------------------
    //3 версия
    static bool IsA(object obj) {
        if (obj.GetType().Equals(typeof(A)))
            return true;
        else return false;
    }
    //----------------------------------------------------------------------------------
    //потом он вспомнил, что от "A" могут наследоваться другие классы
    static bool IsA(object obj) {
        Type typeObj = obj.GetType();
        do {
            if (typeObj.Equals(typeof(object)))
                return false;
            else if (typeObj.Equals(typeof(A)))
                return true;
            else typeObj = typeObj.BaseType;
        } while (true);
    }
    
    //плачу, смеюсь и плачу, а с виду одногрупник вроде не Индус...
    //...и весь этот говнокод был написан, вместо простого:
    static bool IsA(object obj) { return obj is A; }

    via xeonix

    striker, 12 Октября 2009

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

    +105.4

    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
    using System;
    using System.Data;
    using System.Configuration;
    using System.IO;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    using NPOI.HSSF.UserModel;
    using NPOI.HPSF;
    using NPOI.POIFS.FileSystem;
    
    public class GridViewExportUtil
    {
        static HSSFWorkbook hssfworkbook;
    
        static MemoryStream WriteToStream()
        {
            //Write the stream data of workbook to the root directory
            MemoryStream file = new MemoryStream();
            hssfworkbook.Write(file);
            return file;
        }
    
        static void InitializeWorkbook()
        {
            hssfworkbook = new HSSFWorkbook();
    
            ////create a entry of DocumentSummaryInformation
            DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
            dsi.Company = "";
            hssfworkbook.DocumentSummaryInformation = dsi;
    
            ////create a entry of SummaryInformation
            SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
            si.Subject = "";
            hssfworkbook.SummaryInformation = si;
        }
        /// <param name="fileName"></param>
        /// <param name="gv"></param>
        public static void Export(string fileName, GridView gv)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.Charset = System.Text.Encoding.Unicode.EncodingName;
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode;
            HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
            HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; // NPOI
            HttpContext.Current.Response.AddHeader(
                 "content-disposition", string.Format(
                    "attachment; filename=Report.xls"));//, fileName)); // Need .XLS file
            HttpContext.Current.Response.Clear();
    
            InitializeWorkbook();
    
            HSSFSheet sheet1 = hssfworkbook.CreateSheet("Таблица");
            //sheet1.CreateRow(0).CreateCell(0).SetCellValue("Таблица");
    
            using (StringWriter sw = new StringWriter())
            {
                    //  Create a form to contain the grid
                    Table table = new Table();
                    //  add the header row to the table
                    if (gv.HeaderRow != null)
                    {
                        GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
                        table.Rows.Add(gv.HeaderRow);
                    }
                    //  add each of the data rows to the table
                    foreach (GridViewRow row in gv.Rows)
                    {
                        GridViewExportUtil.PrepareControlForExport(row);
                        table.Rows.Add(row);
                    }
                    //  add the footer row to the table
                    if (gv.FooterRow != null)
                    {
                        GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
                        table.Rows.Add(gv.FooterRow);
                    }
    
                    sheet1.DisplayGridlines = true;
    
                    HSSFCellStyle style1 = hssfworkbook.CreateCellStyle();
                    style1.Alignment = HSSFCellStyle.ALIGN_CENTER;
    
                    sheet1.SetColumnWidth(0, 10000);
                    sheet1.SetColumnWidth(1, 5000);
                    sheet1.VerticallyCenter = true;
    
                    for (int j = 2; j < table.Rows[0].Cells.Count; j++)
                    {
                        sheet1.SetColumnWidth(j, 4000);
                        sheet1.SetDefaultColumnStyle(short.Parse(j.ToString()), style1);
                    }
    
                    double Temp=0;

    Nemerle, 16 Марта 2010

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

    +105.3

    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
    public class ImportService : System.Web.Services.WebService
       {
           private const string KEY = "*******";
           [WebMethod]
           public void AddFileInQueue(string aKey, ..., out String error)
           {
                     ...
                   if (KEY == aKey)
                     ...
                   else
                   {
                       error = "Invalid key";
                   }
            }
        }

    Мне предложили использовать эту же авторизацию для нового веб-сервиса в том же проекте со словами "there is normal login implemented somewhere"

    Yagg, 28 Октября 2009

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

    +105.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
    public static bool EqualHash(string x, string y)
            {
                if ((x == null || y == null) && x != y)
                    return false;
    
                if (x == null && x == y)
                    return true;
                
                if (x.Length != y.Length)
                    return false;
                
                for (int i=0; i<x.Length; i++)
                {
                    if (x[i] == y[i])
                        return false;
                }
    
                return true;
            }
    
    //чуть ниже в том же классе
    
            public static bool SimpleEqualHash(string x, string y)
            {
                return (x == y);
            }

    sven47, 04 Января 2010

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

    +105

    1. 1
    x = x + exp(ln(2)*i);

    Встретил в коде опроса датчика, не сразу понял, что это делает.
    Когда понял, понял что лучше бы не понимал.

    Vindicar, 20 Апреля 2015

    Комментарии (43)
  9. C# / Говнокод #14509

    +105

    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
    //Невероятные приключения Microsoft'а в Индии:
    
            private string ExtractHttpVerb(XmlDocument configDOM)
            {
                string httpVerb;
    
                string hv = IfExistsExtract(configDOM, "/Config/method", "2");
    
                switch (hv)
                {
                    case "0":
                        httpVerb = HttpVerbs[0];
                        break;
    
                    case "1":
                        httpVerb = HttpVerbs[1];
                        break;
    
                    case "2":
                        httpVerb = HttpVerbs[2];
                        break;
    
                    default:
                        httpVerb = HttpVerbs[2];
                        break;
                }
    
                return httpVerb;
            }

    HellMaster_HaiL, 05 Февраля 2014

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

    +105

    1. 1
    <div class="стиль38" style="position:relative; background:#333333; height:10px;"></div>

    Работа фрилансЁра. И потом удивляются, что я их не люблю.

    Vasiliy, 08 Октября 2013

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

    +105

    1. 1
    2. 2
    3. 3
    4. 4
    if (row["Enable"].ToString().ToLower() == "true" || row["Enable"].ToString() == "1")
             chState.Checked = true;
     else if (row["Enable"].ToString().ToLower() == "false" || row["Enable"].ToString() == "0")
             chState.Checked = false;

    В начале метода такая вот проверка.
    Дальше да же читать не стал.

    pipjaka, 03 Октября 2013

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