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

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

    +126

    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
    // Get credit spread rates and tenors
    mDtCreditSpreadTenors = aRDO.GetResultTable(mSelectCreditSpreadRates, mCode, mCreditSpreadCurveDate);
    
    // Check if any credit spread rates are returned
    if (mDtCreditSpreadTenors.Rows.Count == 0)
    {
        // If debugging
        if (System.Diagnostics.Debugger.IsAttached)
            // Get from fixed date
            mDtCreditSpreadTenors = aRDO.GetResultTable(mSelectCreditSpreadRates, mCode, 39396);
        else        
            // Add error
            aMissingData.Add(string.Format("Cannot find credit spread rates for date {0}", mCreditSpreadCurveDate.ToShortDateString()));
    }

    Счастливой отладки, суки!

    xxxcoderxxx, 05 Августа 2011

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

    +126

    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
    <div id="scroller">
      <a href="javascript:scroll(0,0)">Наверх</a>
    </div>
    
    <style type="text/css">
    #scroller {
    position:fixed;
    left:0px;
    top:100%;}
    
    #scroller a {
    position:relative;
    top:-47px;
    padding:5000px 10px 30px 10px;}
    
    #scroller a:hover {background:#d8e3f0;}
    </style>

    Скролл страницы наверх, прикреплённый к левой границе экрана. Надпись "Наверх" -- внизу экрана. Опускаю блок под экран -- "top:100%", а потом поднимаю ссылочку наверх -- "top:-47px".

    opex_jr, 02 Августа 2011

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

    +126

    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
    uses
    crt;
    var
      chasov,
     minutov,
    sekundov :byte;
    tekushchiy_sekund:word;
    begin
    clrscr;
    write('   chasov ');
    read(     chasov);
    if chasov=9
               then
                   begin
                        clrscr;
                        halt;
                   end;
    write('  minutov ');
    read(    minutov);
    write(' sekundov ');
    read(   sekundov);
    clrscr;
    for tekushchiy_sekund:=1
    to sekundov+60*minutov+3600*chasov do
      begin
           if keypressed then
                             if readkey=#27
                                           then halt;
           delay(50000);
      end;
    sound(300);
    readkey;
    nosound;
    end.

    УГАДАЙТЕ

    dos, 11 Июля 2011

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

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public static IEnumerable<TItem> GetNextItemFrom<TItem>(IEnumerable<TItem> Collection)
            {
                foreach (var Item in Collection)
                    yield return Item;
            }

    Говногость, 26 Июня 2011

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

    +126

    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
    public static bool ValidateEmailAddress(string emailAddress)
            {
                try
                {
                    string TextToValidate = emailAddress;
                    // test email address with expression
                    if (emailExpression.IsMatch(TextToValidate))
                    {
                        // is valid email address
                        return true;
                    }
                    else
                    {
                        // is not valid email address
                        return false;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

    public static bool ValidateEmailAddress(string emailAddress)
    {
    if(string.IsNullOrEmpty(emailAddress))
    return false;
    return emailExpression.IsMatch(TextToValidate);
    }

    jenik15, 14 Июня 2011

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

    +126

    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
    FileStream fsSource = new FileStream(fileName, FileMode.Open, FileAccess.Read);
    
    byte[] b = new byte[8192];
    int[] a = new int[4096];
    
    fsSource.Read(b, 0, 8192);
    
    int sum=0;
    int elem;
    for (int i = 0; i < 4096; i++)
    {
    elem = b[i * 2] * 256 + b[i*2+1];
    a[i] = elem; //раз уж нам всё равно надо заполнять этот массив, то мы его заполним
    sum += elem;
    }

    задача: считать 2-х байтные числа с бинарного файла и посчитать его сумму.

    slirx, 12 Июня 2011

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

    +126

    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
    private string ReadFile(string filePath)
    {
        string fileText = string.Empty;
        int openAttempts = 0;
        try
        {
            using (FileStream fs = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
            {
                using (StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(1252)))
                {
                    fileText = sr.ReadToEnd();
                    if (!sr.EndOfStream)
                    {
                        sr.Close();
                        fs.Close();
                        throw new Exception();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //Throw an error if the number of attempts is equal to the number of configured retries
            if (openAttempts == 20)
                throw new Exception(ex.Message);
            else
            {
                openAttempts += 1;
                Thread.Sleep(1000); //Put the thread to sleep for the configured amount of time
                ReadFile(filePath);
            }
        }
    
        return fileText;
    }

    Тут все, и управление исключениями, и бессмысленная рекурсия, и глупые ошибки. Про то, что это можно было заменить на одну строчку я молчу даже.

    Jabberwok, 10 Июня 2011

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

    +126

    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
    g.Graphics.DrawLine( p, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( p, this.pb.Width / 2 - 126, this.pb.Height / 2 + 176, this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 - 126 + 8, this.pb.Height / 2 + 176 + 15 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 - 126 + 8, this.pb.Height / 2 + 176 + 25 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126 - 8, this.pb.Height / 2 + 176 + 15 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126 - 8, this.pb.Height / 2 + 176 + 25 );
                        g.Graphics.FillRectangle( Brushes.White, this.pb.Width / 2 - 25, this.pb.Height / 2 + 176 + 10, 50, 20 );
                        g.Graphics.DrawString( this.textBox1.Text + " mm", new Font( "Arial", 8 ), new SolidBrush( Color.Black ), this.pb.Width / 2 - 21, this.pb.Height / 2 + 176 + 12 );
    
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 - (int)paint_nozh_fill / 2 + 8, this.pb.Height / 2 - 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 - (int)paint_nozh_fill / 2 + 8, this.pb.Height / 2 + 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2 - 8, this.pb.Height / 2 - 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2 - 8, this.pb.Height / 2 + 5 );
                        g.Graphics.FillRectangle( Brushes.White, this.pb.Width / 2 - 25, this.pb.Height / 2 - 10, 50, 20 );
                        g.Graphics.DrawString( this.getNozhFill( ).ToString( ) + " mm", new Font( "Arial", 8 ), new SolidBrush( Color.Black ), this.pb.Width / 2 - 21, this.pb.Height / 2 - 8 );

    Человек похоже перепутал визул студию с фотошопом, но закрывать не стал )) Этот код рисует чертеж - примем со стрелочками, с откосами и даже(!) с отбрасывает тень. Понятия не имею как преписывать

    glilya, 16 Апреля 2011

    Комментарии (20)
  10. Си / Говнокод #6025

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    format MS COFF
    
    public fuckHighLevel as '_fuckHighLevel@4'
    
    fuckHighLevel:
            pop ebx
    
                pop eax
                add eax, 1
    
            jmp ebx

    Вызываем ассемблерную процедуру из Си.
    Вместо retn используем безусловыный переход на адрес возврата.
    Но работает же!

    danilissimus, 19 Марта 2011

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

    +126

    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
    Type window = core.getTypeCreationWindowFromType( this.currentType );
                if (window != null)
                {
                    var cr_window = Activator.CreateInstance( window );
                    if (window == typeof( forms.showWindow ))
                    {
                        ((forms.showWindow)cr_window).setTitle( "Добавить новую позицию" );
                        ((forms.showWindow)cr_window).setType( this.chldrenType );
                        ((forms.showWindow)cr_window).fill( );
                        ((forms.showWindow)cr_window).setSelectionMode( );
                        if (this.isExlusivePositionResolve == true) 
                        {
                            // var new_item = Activator.CreateInstance( this.chldrenType );
                            //new_item = (types.ICovertiablePersist<this.chldrenType>)core.instance().ge
    
                            ((forms.showWindow)cr_window).selectedItem += ( forms.showWindow form ) =>
                            {
                                var new_item = Activator.CreateInstance( this.chldrenType );
                                ///new_item = core.instance().getObject(this, form.selected_id);
    
                                int parent_object_id = -1; // Это номер связанного с 
                                                           //выриьбаемым обектом объекта, 
                                                           //тоесть если окно выбора было 
                                                           //кастомизированна и тип выбираемы 
                                                           //х щзначений другой нежели целевой 
                                                           //то мы ищем звязь между обектом ородите и дитя !!!
                                FieldInfo[] fields = this.chldrenType.GetFields( );
                                
                                int id = ((types.persistent)new_item).id;
                                bool isExists = false;
                                for (int i = 0; i < this.dgv_grid.RowCount; i++) 
                                {
                                    int id_s;
                                    int.TryParse( this.dgv_grid.Rows[i].Cells["id"].Value.ToString( ),out id_s );
                                    if (id_s == id) 
                                    {
                                        int count;
                                        int.TryParse( this.dgv_grid.Rows[i].Cells["count"].Value.ToString( ), out count );
                                        this.dgv_grid.Rows[i].Cells["count"].Value = count++;
                                        isExists = true;
                                    }
                                }
                                if (isExists == false) 
                                {
                                    this.addOnePosition( new_item );
                                }
                            };
                        }
                    }
                    else 
                    {
                        ((Form)cr_window).FormClosed += ( object sender, FormClosedEventArgs e ) => {
                            this.fill( );
                        };                   
                    }
                    ((System.Windows.Forms.Form)cr_window).Show( );
                }
                else
                {
                    MessageBox.Show( "Объекты такого типа создавать запрещено" );
                }

    Нашел его миленкого. Переписываю ))) А коменн то комент

    glilya, 15 Марта 2011

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