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

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // Делаем из префикса количество хостов (без .0 и броадкаста)
    numips = pow(2.0, (double)(32 - slashnet)) - 2;
    
    // Делаем префикс из маски сети
    slashnet = 32 - ((int)log2((double)(0xFFFFFFFF - vnetconfig->nm)) + 1);

    Всё те же, всё оттуда же...

    raorn, 12 Мая 2010

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

    +67

    1. 1
    2. 2
    3. 3
    public boolean isActive() {
            return !isKilling() && !isKilled() && !isKillPending();
        }

    Made in Estonia (part 2)

    bot225, 28 Апреля 2010

    Комментарии (9)
  4. PHP / Говнокод #3119

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    //выяснение адреса сайта
     define( "SITE_URL", "http://" . str_replace( "-", "-", preg_replace('#^(.*)/[^/]*#', '\\1', $_SERVER['HTTP_HOST']).'/admin/' ) );
     define( "SITE_EDIT_URL", str_replace( "-", "-", preg_replace('#^(.*)/[^/]*#', '\\1', $_SERVER['HTTP_HOST']) ) ); //.$_SERVER['REQUEST_URI'])."/" ) );
     define( "SITE_EDIT_URL_HTTP", "http://" . str_replace( "-", "-", preg_replace('#^(.*)/[^/]*#', '\\1', $_SERVER['HTTP_HOST'])."/" ) ); //.$_SERVER['REQUEST_URI'])."/" ) );

    xynta, 27 Апреля 2010

    Комментарии (9)
  5. Куча / Говнокод #3113

    +143

    1. 1
    !<>

    Просто очень короткий говнокод:
    Читается как не больше и не меньше.
    Конечно, выдумано, но тем не менее :)

    wvxvw, 26 Апреля 2010

    Комментарии (9)
  6. VisualBasic / Говнокод #3108

    −86

    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    using System;
    using System.Web;
    using MaxPro;
    
    namespace HandlerFile
    {
    	public class FileHttpHandler : IHttpHandler
    	{
    		// Переопределяем метод ProcessRequest.
    		public void ProcessRequest(HttpContext context)
    		{
    			//var
    			Byte[] oImg;
    			Int32 iId=0;
    			Int32 iRemInt=0;
    			//var Zap
    			Int32 iNum=0;
    			Exception oErr;
    			Object[,] oZap=new Object[0,0];
    			//end var
    			if(All.IsInteger(context.Request.QueryString["iId"]))
    			{
    				iId=Convert.ToInt32(context.Request.QueryString["iId"]);
    				iNum=Ow.iZap1i("OneWindow.Procedure173","@iId",iId,out oZap,out oErr);
    			}
    			else if(All.IsInteger(context.Request.QueryString["iRemInt"]))
    			{
    				iId=Convert.ToInt32(context.Request.QueryString["iRemInt"]);
    				iNum=Ow.iZap1i("OneWindow.Procedure174","@iRemInt",iRemInt,out oZap,out oErr);
    			}
    			if(iNum>0)
    			{
    				oImg=(Byte[])oZap[0,0];
    				//генерация бинарного потока
    				/* Возможно пригодится, хотя ясности нет зачем,
    				 * но когда ie сбоит и не открывает файл, то это помогает, особенно ClearHeaders
    				 * Response.ClearContent()
    				 * Response.ClearHeaders()
    				 *///
    				context.Response.ContentEncoding=System.Text.Encoding.GetEncoding("UTF-8");
    				context.Response.Charset="UTF-8";
    				context.Request.ContentEncoding=System.Text.Encoding.UTF8;
    				switch (Convert.ToString(oZap[2,0]))
    				{
    					case "gif":
    						context.Response.ContentType="image/GIF";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "jpg":
    						context.Response.ContentType="image/JPEG";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "jpeg":
    						context.Response.ContentType="image/JPEG";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "bmp":
    						context.Response.ContentType="image/BMP";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "png":
    						context.Response.ContentType="image/PNG";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "txt":
    						context.Response.ContentType="text/plain";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "htm":
    						context.Response.ContentType="text/HTML";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "html":
    						context.Response.ContentType="text/HTML";
    						context.Response.AddHeader("Content-Disposition","filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "xls":
    						context.Response.ContentType="application/vnd.ms-excel";
    						context.Response.AddHeader("Content-Disposition","attachment; filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "doc":
    						context.Response.ContentType="application/msword";
    						context.Response.AddHeader("Content-Disposition","attachment; filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "dot":
    						context.Response.ContentType="application/msword";
    						context.Response.AddHeader("Content-Disposition","attachment; filename="+Convert.ToString(oZap[1,0]));
    						break;
    					case "ppt":
    						context.Response.ContentType="application/vnd.ms-powerpoint";
    						context.Response.AddHeader("Content-Disposition","attachment; filename="+Convert.ToString(oZap[1,0]));
    						break;
    					default:
    						context.Response.AddHeader("Content-Disposition","attachment; filename="+Convert.ToString(oZap[1,0]));
    						break;
    				}
    				context.Response.OutputStream.Write(oImg,0,oImg.Length);
    			}
    		}

    а вам слабо? всё те же мос окна

    ursus, 26 Апреля 2010

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

    +118.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
    private ArrayList SortListings(ArrayList _listings)
            {
                ArrayList result = new ArrayList();
                ArrayList company_names = new ArrayList();
                Hashtable entities = new Hashtable();
    
                foreach (ListOfListings l in _listings)
                {
                    try
                    {
                        entities.Add(l.ListingName, l);
                        company_names.Add(l.ListingName);
                    }
                    catch
                    {
                    }
                }
    
                company_names.Sort();
                for (int i = 0; i < company_names.Count; i++)
                {
                    result.Add(entities[company_names[i]]);
                }
                return result;
            }

    Сортировка :)

    bugotrep, 18 Апреля 2010

    Комментарии (9)
  8. PHP / Говнокод #3026

    +150.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $tttr = rand( 1, 2 );
    if ( $tttr == 1 )
    {
        $bonusik = "&dd=10|";
    }
    if ( $tttr == 2 )
    {
        $bonusik = "&dd=5|dd=5|";
    }

    Random and naming fails.

    Bobby, 16 Апреля 2010

    Комментарии (9)
  9. PHP / Говнокод #3010

    +166.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
    <?
    $mese[0]="-";
    $mese[1]="01";
    $mese[2]="02";
    $mese[3]="03";
    $mese[4]="04";
    $mese[5]="05";
    $mese[6]="06";
    $mese[7]="07";
    $mese[8]="08";
    $mese[9]="09";
    $mese[10]="10";
    $mese[11]="11";
    $mese[12]="12";
    
    $gisett=(int)date("w");
    $mesnum=(int)date("m");
    
    echo date("d")."/".$mese[$mesnum]."/".date("Y") ;?>

    Нашёл на форуме. Код 2004 года, но это не умаляет его достоинств.

    Int, 15 Апреля 2010

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

    +971.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    oi.Status = o.Active && o.ByCondition!=Condition.None && o.Time==DateTime.MinValue 
       ? OrderStatusType.Condition :
        o.Active
         ? OrderStatusType.Active
         : o.Cancelled
          ? OrderStatusType.Cancelled
          : o.Matched ? OrderStatusType.Matched : OrderStatusType.Unknown;

    Суровый такой, очень суровый код. Спартанец-неформал.

    terR0Q, 13 Апреля 2010

    Комментарии (9)
  11. VisualBasic / Говнокод #2990

    −125.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
    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
    Sub Макрос2()
        Dim pos0, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9, digitPos As Integer
    
        For Counter = 2 To 999999
            digitPos = 1000
        
            Set curCell = Worksheets("Лист1").Cells(Counter, 5)
            Set primCell = Worksheets("Лист1").Cells(Counter, 6)
        
            pos0 = InStr(1, primCell.Value, "0")
            pos1 = InStr(1, primCell.Value, "1")
            pos2 = InStr(1, primCell.Value, "2")
            pos3 = InStr(1, primCell.Value, "3")
            pos4 = InStr(1, primCell.Value, "4")
            pos5 = InStr(1, primCell.Value, "5")
            pos6 = InStr(1, primCell.Value, "6")
            pos7 = InStr(1, primCell.Value, "7")
            pos8 = InStr(1, primCell.Value, "8")
            pos9 = InStr(1, primCell.Value, "9")
            
            If pos0 > 0 And pos0 < digitPos Then
                digitPos = pos0
            End If
            
            If pos1 > 0 And pos1 < digitPos Then
                digitPos = pos1
            End If
            
            If pos2 > 0 And pos2 < digitPos Then
                digitPos = pos2
            End If
            
            If pos3 > 0 And pos3 < digitPos Then
                digitPos = pos3
            End If
            
            If pos4 > 0 And pos4 < digitPos Then
                digitPos = pos4
            End If
            
            If pos5 > 0 And pos5 < digitPos Then
                digitPos = pos5
            End If
            
            If pos6 > 0 And pos6 < digitPos Then
                digitPos = pos6
            End If
            
            If pos7 > 0 And pos7 < digitPos Then
                digitPos = pos7
            End If
            
            If pos8 > 0 And pos8 < digitPos Then
                digitPos = pos8
            End If
            
            If pos9 > 0 And pos9 < digitPos Then
                digitPos = pos9
            End If
            
            'MsgBox Left(primCell.Value, digitPos - 1)
            
            curCell.Value = Trim(Left(primCell.Value, digitPos - 1))
        Next Counter
    End Sub

    Я идиот и не умею программировать в excel!!
    Мне надо было отрезать текст до первой цифры в одной ячейке и засунуть его в другую.
    Наверное, надо было почитать про массивы в VB

    striker, 12 Апреля 2010

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