1. Список говнокодов пользователя Nemerle

    Всего: 11

  2. 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)
  3. C++ / Говнокод #2592

    +53.4

    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
    void __fastcall TUsers::DBG2DrawColumnCell(TObject *Sender,
          const TRect &Rect, int DataCol, TColumn *Column,
          TGridDrawState State)
    {
    
        const int iIsChecked[2] = {DFCS_BUTTONCHECK | DFCS_FLAT, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT};
        int DrawState;
        TRect DrawRect;
        if (State.Contains(gdFocused) == true)
        {
            if (Column->Field->FieldName == dbchkApplyDoc2->DataField)
            {
                ShowMessage("Зацикливает :( ");
                ShowMessage("Эта надпись будет повторяться бесконечно - почему ???");
            }
        }
        else
        {
            if (Column->Field->FieldName == dbchkApplyDoc2->DataField)
            {
                DrawRect = Rect;
                InflateRect(&DrawRect, -2, -2); // Matters ?
                DrawState = iIsChecked[Column->Field->AsBoolean];
                DBG2->Canvas->FillRect(Rect);
                DrawFrameControl(DBG2->Canvas->Handle, &DrawRect, DFC_BUTTON, DrawState);
            }
        }
    }

    Почему

    Nemerle, 11 Февраля 2010

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

    +142.6

    1. 1
    myDataSet.Tables[0].DataSet.GetXml();

    need XML Data Source from XML for making dynamic ASP:Menu
    This code makes DataSource as a Parent element and elements from sql as a Children
    I need Parent Elements only from my sql. To make it like a Horizontal TabSet . . .

    Nemerle, 10 Февраля 2010

    Комментарии (17)
  5. JavaScript / Говнокод #2572

    +144

    1. 1
    2. 2
    if (document.all && document.getElementById && !window.opera) this.initIEengine();
    	if (!document.all && document.getElementById && !window.opera) this.initFFengine();

    А в чём суть ?
    p.s. а я вот не понимаю почему в опере не работает :(
    Взято отсюда : http://www.dotnetcurry.com/ShowArticle.aspx?ID=255&AspxAutoDetectCo okieSupport=1

    Nemerle, 08 Февраля 2010

    Комментарии (12)
  6. JavaScript / Говнокод #2568

    +161.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    this.each(function(){
    	if (jQuery.browser.msie)
                alert( ' Change your browser please ' );
            else
                ...

    IE is being me to mean again...

    Nemerle, 08 Февраля 2010

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

    +142.6

    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 Nemerle.Collections;
    using Nemerle.Text;
    using Nemerle.Utility;
    using System.Runtime.InteropServices;
    
    namespace nCdy
    {
    
      /// <summary>
      /// Description of Win32API.
      /// </summary>
      
    public static class Win32API
      {
      
      
    [ Flags ]
    public enum AllocationType
    {
        | Commit = 0x1000
    }
    
    [ Flags ]
    public enum ProcessAccess : int
    {
        | VMOperation = 0x8
        | VMRead      = 0x10
        | VMWrite     = 0x20
    }
    
    [ Flags ]
    public enum MemoryProtection
    {
        | ReadWrite = 0x04
    }
      
      
      
    //[StructLayout(LayoutKind.Sequential)]
    public struct LUID {
    internal LowPart : uint;
    internal HighPart : uint;
    }
    
    //[StructLayout(LayoutKind.Sequential)]
    public struct TOKEN_PRIVILEGES
    {
        public PrivilegeCount : UInt32;
        public Luid : LUID;
        public Attributes : UInt32;
    }
    
    public struct MOUSEINPUT
    {
    dx : int;
    dy : int;
    mouseData : int;
    dwFlags : int;
    time : int;
    dwExtraInfo : IntPtr;
    }
    
    public struct KEYBDINPUT
    {
    public mutable wVk : char ;
    public wScan : short ;
    public dwFlags : int ;
    public time : int ;
    public dwExtraInfo : IntPtr ;
    }
    
    public struct HARDWAREINPUT
    {
    uMsg : int ;
    wParamL : short ;
    wParamH : short ;
    }
    
    [StructLayout(LayoutKind.Explicit)]
    public struct INPUT
    {
    [FieldOffset(0)]
    public mutable typefield : int ; 
    [FieldOffset(4)]
    mi : MOUSEINPUT;
    [FieldOffset(4)]
    public mutable ki : KEYBDINPUT;
    [FieldOffset(4)]
    hi : HARDWAREINPUT;
    }
    
            [DllImport("user32.dll")]
            public static extern keybd_event(
            bVk : byte,
            bScan : byte,
            dwFlags : uint,
            dwExtraInfo : UIntPtr) : void ;
            
            [DllImport("user32.dll")]

    ООП

    Nemerle, 05 Февраля 2010

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

    +130.9

    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
    def TryToFix() : void 
    {
    def  RozoviySlon()  : bool
    {
       System.Diagnostics.Process.Start("http://rsdn.ru/Users/73.aspx");
       if("solution"=="Весёлый слоник не поднимает настроение ?")
              false
      else
             true
    }
    
    unless (  (if ( RozoviySlon() ) "Розовый слон"
    else "Всё хорошо :D") == "Всё хорошо :D" )
         while( RozoviySlon() )
         MessageBox.Show("ААААААААААААААААААА !!!");
    }
    
    try
    {
      Application.Run(nCdy.nForm());
    }
    catch
    {
      | e is Exception => TryToFix();
    }

    Весёлый слоник не поднимает настроение ?

    Nemerle, 05 Февраля 2010

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

    +138.4

    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
    private button1_Click (sender : object,  e : System.EventArgs) : void
        {
            PatchOptions.noerror = if (this.textBox1.Text=="")
            {
                MessageBox.Show("Wind header caption could not be empty");
                false
            }
            else
            if (this.textBox2.Text=="")
            {
                MessageBox.Show("BaseAddress could not be empty");
                false
            }
            else
            if (this.textBox3.Text=="")
            {
                MessageBox.Show("NewValue could not be empty");
                false
            }
            else
            {
                try
                {
                    PatchOptions.WinHeader=this.textBox1.Text.ToString();
                    PatchOptions.BaseAddress=Int32.Parse( this.textBox2.Text.ToString() );
                    PatchOptions.NewValue=BitConverter.GetBytes(Int32.Parse(this.textBox3.Text.ToString()));
                    this.Close();
                    true
                }
                catch
                {
                    e is Exception => MessageBox.Show("You entered incorrect values.");
                    false
                } 
            }
        }

    nc

    Nemerle, 04 Февраля 2010

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

    +101.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
    if (imageContent != null)
                   context.Response.OutputStream.Write(imageContent, 0, imageContent.Length);
               else
               {
                   byte[] x = {0xff, 0xd8, 0xff, 0xe0, 0x0, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x0, 0x1, 0x2, 0x0, 0x0, 0x64, 
    0x0, 0x64, 0x0, 0x0, 0xff, 0xec, 0x0, 0x11, 0x44, 0x75, 0x63, 0x6b, 0x79, 0x0, 0x1, 0x0, 
    0x4, 0x0, 0x0, 0x0, 0x1b, 0x0, 0x0, 0xff, 0xee, 0x0, 0xe, 0x41, 0x64, 0x6f, 0x62, 0x65, 
    0x0, 0x64, 0xc0, 0x0, 0x0, 0x0, 0x1, 0xff, 0xdb, 0x0, 0x84, 0x0, 0x11, 0xc, 0xc, 0xc, 
    0xd, 0xc, 0x11, 0xd, 0xd, 0x11, 0x19, 0x10, 0xe, 0x10, 0x19, 0x1d, 0x16, 0x11, 0x11, 0x16, 
    0x1d, 0x22, 0x17, 0x17, 0x17, 0x17, 0x17, 0x22, 0x21, 0x1a, 0x1d, 0x1c, 0x1c, 0x1d, 0x1a, 0x21, 
    0x21, 0x26, 0x28, 0x2b, 0x28, 0x26, 0x21, 0x34, 0x34, 0x38, 0x38, 0x34, 0x34, 0x41, 0x41, 0x41, 
    0xff, 0xc4, 0x0, 0x75, 0x0, 0x1, 0x0, 0x3, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x5, 0x6, 0x4, 0x2, 0x1, 0x1, 0x1, 0x0, 0x0, 
    0x0, 0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0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xff, 0xd9};

    'Канал форума программистов VIngrad
    p.s. пришлось убрать большую часть байтов.

    Nemerle, 03 Февраля 2010

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

    +124.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
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    Functions called:
     fflush (4 times)
     delete (11 times)
     fclose (1 times)
     free (11 times)
     fread (3 times)
     fopen (1 times)
     vsnprintf (4 times)
     new (11 times)
     SysReallocMem (652 times)
     SysFreeMem (13185 times)
     SysGetMem (13188 times)
     lstrlenA (1 times)
     lstrcpynA (4 times)
     calloc (1 times)
     strlen (98 times)
     realloc (1 times)
     strdup (1 times)
     malloc (8 times)
     memcpy (4 times)
    Resource types used:
     object (11 allocs, 11 max)
     memory block (13199 allocs, 4007 max)
     file stream (1 allocs, 1 max)
     file handle (1 allocs, 1 max)

    Nemerle, 29 Декабря 2009

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