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

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

    −114

    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
    select 
    
    row_number() over (order by count(*) desc) r, 
    
    case when t719.f7171 is null and t719.f7201 is null then 'За поданням
    голови ОВК, капітана судна, керівн. полярної станції України' 
    
                when t719.f7171 is not null  then t717.name1 
    
                when t719.f7201 is not null  then t720.f7202||'
    '||t720.f7203||' '||t720.f7204
    
           end t021f02, 
    
            count(*) count1
    
    from  t719,
    
          t066,
    
          t714,
    
          v1_t717 t717,
    
          t720
    
    where t719.t001f01=PT001F01 and
    
          t719.t001f01=t066.t001f01 and
    
          t719.f7331=t066.f7331 and
    
          t719.f7141=t066.f7141 and
    
          t719.f7191=t066.f7191 and
    
          t066.T066F02 is not null and
    
          t066.T066F03 is null and
    
          t719.t001f01=t714.t001f01 and
    
          t719.f7331=t714.f7331 and
    
          t719.f7141=t714.f7141 and
    
          t714.f71480 is null and
    
          t719.f7171=t717.f7171(+) and
    
          t719.t001f01=t717.t001f01(+) and
    
          t719.f7201=t720.f7201(+) and
    
          t719.t001f01=t720.t001f01(+)
    
    group by case when t719.f7171 is null and t719.f7201 is null then 'За
    поданням голови ОВК, капітана судна, керівн. полярної станції України' 
    
                  when t719.f7171 is not null  then t717.name1 
    
                  when t719.f7201 is not null  then t720.f7202||'
    '||t720.f7203||' '||t720.f7204
    
             end
    
    order by count(*) desc, 1;

    Оттуда же.

    Ну и как такое можно сапортить?

    DBdev, 24 Мая 2014

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

    +123

    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
    namespace Рунге_Кутты_1._4
    {
        public partial class Form1 : Form
        {
            double x0 = 1, y0 = 2, z0 = 4, t0 = 0, T = 1, h = 0.001, Eps = 0.000001, fx, fy, fz, xx, yy, zz, Ex, Ey, Ez, Eps1;
            double[] x = new double[4]; double[] y = new double[4]; double[] z = new double[4];
            double[] Kx = new double[4]; double[] Ky = new double[4]; double[] Kz = new double[4];
            bool a;
            public void Calculates()
            {
                System.IO.File.Delete(@"C:\Results\results.dat");
                x[0] = x0; y[0] = y0; z[0] = z0;
                while (t0 <= T)
                {
                    for (int i = 0; i <= 3; i++)
                    {
                        fx = -y[i] - z[i];
                        fy = x[i] + 0.2 * y[i];
                        fz = 0.2 + (x[i] - 5.7) * z[i];
                        Kx[i] = h * fx;
                        Ky[i] = h * fy;
                        Kz[i] = h * fz;
                        x[1] = x[0] + 0.5 * Kx[0];
                        x[2] = x[0] + 0.5 * Kx[1];
                        x[3] = x[0] + Kx[2];
                        y[1] = y[0] + 0.5 * Ky[0];
                        y[2] = y[0] + 0.5 * Ky[1];
                        y[3] = y[0] + Ky[2];
                        z[1] = z[0] + 0.5 * Kz[0];
                        z[2] = z[0] + 0.5 * Kz[1];
                        z[3] = z[0] + Kz[2];
                    }
                    Ex = Math.Abs(2 * (Kx[0] - Kx[1] - Kx[2] + Kx[3]) / 3);
                    Ey = Math.Abs(2 * (Ky[0] - Ky[1] - Ky[2] + Ky[3]) / 3);
                    Ez = Math.Abs(2 * (Kz[0] - Kz[1] - Kz[2] + Kz[3]) / 3);
                    Eps1 = Eps / 8;
                    a = Check();
                    if (a == false)
                    {
                        xx = x[0] + (Kx[0] + 2 * Kx[1] + 2 * Kx[2] + Kx[3]) / 6;
                        yy = y[0] + (Ky[0] + 2 * Ky[1] + 2 * Ky[2] + Ky[3]) / 6;
                        zz = z[0] + (Kz[0] + 2 * Kz[1] + 2 * Kz[2] + Kz[3]) / 6;
                        x[0] = xx;
                        y[0] = yy;
                        z[0] = zz;
                        t0 += h;
                        string f1 = Convert.ToString(xx);
                        string f2 = Convert.ToString(yy);
                        string f3 = Convert.ToString(zz);
                        string[] f = new string[] { f1, f2, f3 };
                        string path = @"C:\Results\results.dat";
                        string appendtext = xx + " " + yy + " " + zz + Environment.NewLine;
                        System.IO.File.AppendAllText(path, appendtext);
                    }
                }
            }
            public bool Check()
            {
                bool a;
                if (Ex > Eps | Ey > Eps | Ez > Eps)
                {
                    a = true;
                    h /= 2;
                    Calculates();
                }
                else a = false;
                return a;
            }
            public Form1()
            {
                InitializeComponent();
                Calculates();
                DrawGraph();
            }
            public void DrawGraph()
            {
                    GraphPane pane = zedGraph.GraphPane;
                    pane.CurveList.Clear();
                    PointPairList list = new PointPairList();
                    for (t0 = 0; t0 <= T; t0 += h)
                    {
                        list.Add(t0, x[0]);
                    }
                    LineItem MyCurve = pane.AddCurve("x(t)", list, Color.Blue, SymbolType.None);
                    zedGraph.AxisChange();
                    zedGraph.Invalidate();
            }
        }
    }

    пытаюсь вывести решения в виде графика. выводится только последнее решение из цикла

    mr07th, 16 Мая 2014

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function c(){
      //Внимание! Далее идёт индусский код! Слабонервных попрошу уда(л|в)иться...
      require ('config.php');
     $included = get_included_files();
      if(!in_array('config.php',$included)){
       Error(404);
       return;
      }
     ...
     ...
    }

    Стиль и коммент оставил оригинальные, видимо ЭТО кому-то из наших уже попадало до меня.
    Далее код - в натуре полный "хадж".

    virtual_cia, 15 Мая 2014

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

    +13

    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
    #include <iostream>
    
    using namespace std;
    
    class Foo
    {
    public:
    	void foo()
    	{
    		cout << "Destruct" << endl;
    	}
    };
    
    int main() 
    {
    	void (Foo::*func)() = &Foo::foo;
    	void *adress = (void*&)func;
    	void (*new_func)(Foo*) = (void (*)(Foo*))adress;
    	Foo obj;
    	new_func(&obj);
    }

    Юный падаван постигает силу void-указателей.

    west_coast_coders, 13 Мая 2014

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

    +132

    1. 1
    <!--php session_start(); include('blocks/sessions.php'); -->

    Комментарии в php? Не, не слышали

    Webius, 09 Мая 2014

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

    +117

    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
    DataSection
      Data.f 0.0025,0.0026,0.00235
    EndDataSection
    
    Global SCREENWIDTH,SCREENHEIGHT
    
    Define .f:bitplanes.b=32
    
    SCREENWIDTH=GetSystemMetrics_(#SM_CXSCREEN)
    SCREENHEIGHT=GetSystemMetrics_(#SM_CYSCREEN)
    
    If InitSprite()=0 Or InitSprite3D()=0 Or InitKeyboard()=0
      MessageRequester("Error","Can't access DirectX",0)
      End
    EndIf
    
    desktop.l = CreateImage(0,DesktopWidth(0),DesktopHeight(0))
    hdc.l = StartDrawing(ImageOutput(0))
    SelectObject_(hdc,desktop)
    BitBlt_(hdc,0,0,DesktopWidth(0),DesktopHeight(0),GetDC_(GetDesktopWindow_()),0,0,#SRCCOPY)
    StopDrawing()
    DeleteDC_(hdc)
    
    While OpenScreen(SCREENWIDTH,SCREENHEIGHT,bitplanes.b,"FullScreen")=0
      If bitplanes.b>16
        bitplanes.b-8
      ElseIf SCREENHEIGHT>600
        SCREENWIDTH=800
        SCREENHEIGHT=600
      ElseIf SCREENHEIGHT>480
        SCREENWIDTH=640
        SCREENHEIGHT=480
      ElseIf SCREENHEIGHT>400
        SCREENWIDTH=640
        SCREENHEIGHT=400
      ElseIf SCREENHEIGHT>240
        SCREENWIDTH=320
        SCREENHEIGHT=240
      ElseIf SCREENHEIGHT>200
        SCREENWIDTH=320
        SCREENHEIGHT=200
      Else
        MessageRequester("Listen:","Can't open Screen!",0)
        End
      EndIf
    Wend
    w=DesktopWidth(0)
    h=DesktopHeight(0)
    z=1000/Sqr(3)
    perspw=w
    PerspectiveAngle.d=#PI/16
    CreateSprite(0,w,h,#PB_Sprite_Texture)
    StartDrawing(SpriteOutput(0))
    DrawImage(ImageID(0),0,0)
    StopDrawing()
    DisplaySprite(0,0,0)
    FlipBuffers()
    DisplaySprite(0,0,0)
    CreateSprite3D(0,0)
    x3=w-1
    x4=0
    y3=h
    y4=h
    z3=z
    z4=z
    For t.b=1 To 3
      omega=-omega
      Read alfa
      Repeat
        ExamineKeyboard()
        ClearScreen(0)
        Incrz=h*Sin(Angle)
        x1=Incrz*Tan(PerspectiveAngle)
        x2=x3-x1
        y1=h-h*Cos(Angle)
        y2=y1
        z1=z+Incrz/4.75
        z2=z1:Start3D()
        TransformSprite3D(0,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4)
        DisplaySprite3D(0,0,0,255)
        Stop3D()
        omega+alfa
        If omega<0
          Angle-Pow(omega,2)
        Else
          Angle+Pow(omega,2)
        EndIf
        If Angle<0 Or Angle>4/5*#PI
          Break
        EndIf
        FlipBuffers()
        Delay(10)
      Until KeyboardPushed(#PB_Key_Escape)
    Next
    DisplaySprite(0,0,0)
    FlipBuffers()
    Delay(10)
    DisplaySprite(0,0,0)

    Очень интересный эффект - экран "отшатывается" от юзера :)
    Для компиляции понадобится PureBasic не ниже 4.50

    brutushafens, 01 Мая 2014

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

    +141

    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
    ...
    else if ( (!BG_InSpecialJump( legsAnim )//not in a special jump anim 
    						||BG_InReboundJump( legsAnim )//we're already in a rebound
    						||BG_InBackFlip( legsAnim ) )//a backflip (needed so you can jump off a wall behind you)
    					//&& pm->ps->velocity[2] <= 0 
    					&& pm->ps->velocity[2] > -1200 //not falling down very fast
    					&& !(pm->ps->pm_flags&PMF_JUMP_HELD)//have to have released jump since last press
    					&& (pm->cmd.forwardmove||pm->cmd.rightmove)//pushing in a direction
    					//&& pm->ps->forceRageRecoveryTime < pm->cmd.serverTime	//not in a force Rage recovery period
    					&& pm->ps->fd.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_2//level 3 jump or better
    					//&& WP_ForcePowerAvailable( pm->gent, FP_LEVITATION, 10 )//have enough force power to do another one
    					&& BG_CanUseFPNow(pm->gametype, pm->ps, pm->cmd.serverTime, FP_LEVITATION)
    					&& (pm->ps->origin[2]-pm->ps->fd.forceJumpZStart) < (forceJumpHeightMax[FORCE_LEVEL_3]-(BG_ForceWallJumpStrength()/2.0f)) //can fit at least one more wall jump in (yes, using "magic numbers"... for now)
    					//&& (pm->ps->legsAnim == BOTH_JUMP1 || pm->ps->legsAnim == BOTH_INAIR1 ) )//not in a flip or spin or anything
    					)
    			{//see if we're pushing at a wall and jump off it if so
    				if ( allowWallGrabs )
    				{
    					//FIXME: make sure we have enough force power
    					//FIXME: check  to see if we can go any higher
    					//FIXME: limit to a certain number of these in a row?
    					//FIXME: maybe don't require a ucmd direction, just check all 4?
    					//FIXME: should stick to the wall for a second, then push off...
    ...

    Больше условий богу условий!
    Jedi Academy source, 2003

    gost, 21 Апреля 2014

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

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    private int[] pageBreaks = new int[] { 25, 48, 71, 94, 117, 140, 163, 186,
    			209, 232, 255, 278, 301, 324, 347, 370, 393, 416, 439, 462, 485,
    			508, 531, 554, 577, 600, 623, 646, 669, 692, 715, 738, 761, 784,
    			807, 830, 853, 876, 899, 922, 945, 968, 991, 1014, 1037 };

    evg_ever, 17 Апреля 2014

    Комментарии (7)
  10. PHP / Говнокод #15766

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    $fp = fopen('log.php', 'a');
    fwrite($fp, $_GET['Message']." \n");
    fclose($fp);
    ?>
    
    file log.php
    <?PHP header("Content-Type: text/html; charset=CP1251");?>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    Пишем логи на сервере.

    any0ne2567, 17 Апреля 2014

    Комментарии (7)
  11. PHP / Говнокод #15666

    +160

    1. 1
    $result = (string)(int)false;

    drull, 04 Апреля 2014

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