1. C# / Говнокод #16734

    +136

    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
    class Program
        {        
            class A
            {
    
                //-----------------------------------------------------------------------
                public static A CurrentRoot;
                public static Dictionary<object, A> RootMap = new Dictionary<object, A>();
                public static object Lock = new object();
                //-----------------------------------------------------------------------
    
                public int Test;
    
                public A()
                {
                    lock (Lock)
                    {
                        CurrentRoot = this; 
                        b = new B();
                    }   
                }   
                internal class B
                {
                    public B() { RootMap.Add(this, CurrentRoot); }
    
                    public A root { get { return RootMap[this]; } }                
    
                    ~B() { RootMap.Remove(this); }                
                }
                public B b;
            }
         
            static void Main(string[] args)
            {
    
                A a1 = new A(); a1.Test = 555;
                A a2 = new A(); a2.Test = 888;
    
                Console.WriteLine(a1.b.root.Test); Console.WriteLine(a1.Test);
                Console.WriteLine(a2.b.root.Test); Console.WriteLine(a2.Test);
    
    
                Console.WriteLine(a1.b.root.b.root.b.root.b.root.b.root.Test);
            }

    Класс создан для того чтобы вложенные структуры имели доступ к структуре родителя. Safe thread support.

    maxillion, 20 Сентября 2014

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

    +135

    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
    private void button1_Click(object sender, EventArgs e)
            {
                if (comboBox1.Text == "Випадково")
                {
                   LoadMatrixRand(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Повна")
                {
                    LoadMatrixFull(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Пуста")
                {
                    LoadMatrixZero(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Діагональна")
                {
                    LoadMatrixDiagonal(masP, dataGridView1);
                }
    
                if (comboBox1.Text == "Антидіагональна")
                {
                    LoadMatrixAntiDiagonal(masP, dataGridView1);
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                if (comboBox2.Text == "Випадково")
                {
                    LoadMatrixRand(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Повна")
                {
                    LoadMatrixFull(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Пуста")
                {
                    LoadMatrixZero(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Діагональна")
                {
                    LoadMatrixDiagonal(masQ, dataGridView2);
                }
    
                if (comboBox2.Text == "Антидіагональна")
                {
                    LoadMatrixAntiDiagonal(masQ, dataGridView2);
                }
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                if (comboBox3.Text == "Випадково")
                {
                    LoadMatrixRand(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Повна")
                {
                    LoadMatrixFull(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Пуста")
                {
                    LoadMatrixZero(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Діагональна")
                {
                    LoadMatrixDiagonal(masR, dataGridView3);
                }
    
                if (comboBox3.Text == "Антидіагональна")
                {
                    LoadMatrixAntiDiagonal(masR, dataGridView3);
                }
            }

    shitty life as my code

    Nutell_a, 19 Сентября 2014

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

    +140

    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
    @foreach (var groupTest in Model.Select(t => t.TestType).Distinct())
    {
        <div class="form-column form-column2">
            <div class="static-height">
                <p class="content-subblock-title left upper-text">
                    <label>
                        @if (@groupTest.GetEnumDescription().Length < 34)
                        {
                            <text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>
                        }
                        @groupTest.GetEnumDescription()
                    </label>
                </p>
                @foreach (var item in Model.Where(t => t.TestType == groupTest).OrderBy(t => t.Order))
                {
                    <div class="donation-row">
                        <label>@item.TestName</label>
                        <span class="@item.TestClass blood-test-value-don">
                            @item.TestValue
                        </span>
                    </div>
                }
    
            </div>
        </div>
    }

    Я пялюсь на этот кусок вот уже полчаса...

    amatenkov, 17 Сентября 2014

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

    +135

    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
    if ((Mathf.Abs(_mouseOverX) > 0.2f || Mathf.Abs(_mouseOverY) > 0.2f))
         {
    
    
            switch (selecetedItemIndex)
         {
                case -1 :
                    var a = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a += angle / 2.0f;
                    if (a < 0) a = a + 360.0f;
    
                    index = (int)(a / angle);
             break;
                case 0:
                    var a0 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a0 += angle / 2.0f;
                    if (a0 < 0) a0 = a0 + 360.0f;
    
                    index = (int)(a0 / angle);
    
                 switch (index)
                 {
                     case 5 :
                         index = 7;
                         break;
                        case 6:
                            index = 7;
                            break;
                        case 4 :
                         index = -1;
                         break;
                        case 3:
                            index = 1;
                            break;
                        case 2:
                            index = 1;
                            break;
                 }
                 break;
                case 1:
                    var a1 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a1 += angle / 2.0f;
                    if (a1 < 0) a1 = a1 + 360.0f;
    
                    index = (int)(a1 / angle);
    
                 switch (index)
                 {
                     case 0 :
                         index = 0;
                         break;
                        case 7:
                            index = 0;
                            break;
                        case 6 :
                         index = -1;
                         break;
                        case 5:
                            index = -1;
                            break;
                        case 4:
                            index = 3;
                            break;
                        case 3:
                            index = 3;
                            break;
                        case 2:
                            index = 2;
                            break;
                 }
                 break;
                case 2:
                    var a2 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a2 += angle / 2.0f;
                    if (a2 < 0) a2 = a2 + 360.0f;
    
                    index = (int)(a2 / angle);
    
                    switch (index)
                    {
                        case 0: index = 1; break;
                        case 7: index = 1; break;
                        case 6: index = -1; break;
                        case 5: index = 3; break;
                        case 4: index = 3; break;
                    }
                    break;
                case 3:
                    var a3 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a3 += angle / 2.0f;
                    if (a3 < 0) a3 = a3 + 360.0f;
    
                    index = (int)(a3 / angle);
    
                    switch (index)

    Radial menu govnokod style

    noshitleft, 17 Сентября 2014

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

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    class Class1
    {
        ...
        public bool checkErrors(){...}
        public void DrawNumber(){...}
        public void PDF_Resize(){...}
        ...
    }

    http://vk.com/feed?z=photo-30666517_340773889%2Fb5a138e78eb1b23380

    dzzpchelka, 17 Сентября 2014

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

    +133

    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
    namespace pck_pkx
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("Выберите файлы для слияния!");
                }
                else
                {
                    FileStream fs = new FileStream(textBox2.Text, FileMode.Open, FileAccess.Read);
                    BinaryReader br = new BinaryReader(fs);
                    BinaryWriter bw = new BinaryWriter(new FileStream(textBox1.Text, FileMode.Open, FileAccess.Write));
                    bw.BaseStream.Seek(0, SeekOrigin.End);
                    bw.Write(br.ReadBytes(Convert.ToInt32(fs.Length)));
                    MessageBox.Show("Успешно!");
                }
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Angelica engine files|*.pck";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    textBox1.Text = ofd.FileName;
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Angelica engine files|*.pkx";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    textBox2.Text = ofd.FileName;
                }
            }
        }
    }

    Сука, до слез.
    http://kn1fe-zone.ru/index.php?threads/pck-pkx.399/

    DesmondHume, 16 Сентября 2014

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

    +138

    1. 1
    p.fANT = Convert.ToUInt16(((devStat & (1 << 13)) != 0 ? "1" : "0") + ((devStat & (1 << 12)) != 0 ? "1" : "0"), 2);

    Вот сижу думаю так задуманно или автор сам не понял что написал

    Smekalisty, 12 Сентября 2014

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

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private void gv3_HiddenEditor(object sender, EventArgs e)
    {
    	if (cloneDt != null)
    	{
    		cloneDt = null;
    	}
    	if (cloneCt != null)
    	{
    		cloneCt = null;
    	}
    }

    Коллега в скайпе поделился говном из одного коммерческого проекта

    Smekalisty, 12 Сентября 2014

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

    +136

    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
    if(GUI.Button(Rect(100,50,50,50),NewTexture[0])) 
    { Change = true; Clicks += 1; GridNumber = 0;   }
    if(GUI.Button(Rect(150,50,50,50),NewTexture[1])) 
    { Change = true; Clicks += 1; GridNumber = 1;   }
    if(GUI.Button(Rect(200,50,50,50),NewTexture[2])) 
    { Change = true; Clicks += 1; GridNumber = 2;   }
    if(GUI.Button(Rect(250,50,50,50),NewTexture[3])) 
    { Change = true; Clicks += 1; GridNumber = 3;   }
    if(GUI.Button(Rect(300,50,50,50),NewTexture[4])) 
    { Change = true; Clicks += 1; GridNumber = 4;   }
    if(GUI.Button(Rect(350,50,50,50),NewTexture[5])) 
    { Change = true; Clicks += 1; GridNumber = 5;   }
    if(GUI.Button(Rect(400,50,50,50),NewTexture[6])) 
    { Change = true; Clicks += 1; GridNumber = 6;   }
    if(GUI.Button(Rect(100,100,50,50),NewTexture[7])) 
    { Change = true; Clicks += 1; GridNumber = 7;   }
    if(GUI.Button(Rect(150,100,50,50),NewTexture[8])) 
    { Change = true; Clicks += 1; GridNumber = 8;   }
    if(GUI.Button(Rect(200,100,50,50),NewTexture[9])) 
    { Change = true; Clicks += 1; GridNumber = 9;   }
    if(GUI.Button(Rect(250,100,50,50),NewTexture[10])) 
    { Change = true; Clicks += 1; GridNumber = 10;  }
    if(GUI.Button(Rect(300,100,50,50),NewTexture[11])) 
    { Change = true; Clicks += 1; GridNumber = 11;  }
    if(GUI.Button(Rect(350,100,50,50),NewTexture[12])) 
    { Change = true; Clicks += 1; GridNumber = 12;  }
    if(GUI.Button(Rect(400,100,50,50),NewTexture[13])) 
    { Change = true; Clicks += 1; GridNumber = 13;  }
    if(GUI.Button(Rect(100,150,50,50),NewTexture[14])) 
    { Change = true; Clicks += 1; GridNumber = 14;  }
    if(GUI.Button(Rect(150,150,50,50),NewTexture[15])) 
    { Change = true; Clicks += 1; GridNumber = 15;  }
    if(GUI.Button(Rect(200,150,50,50),NewTexture[16])) 
    { Change = true; Clicks += 1; GridNumber = 16;  }
    if(GUI.Button(Rect(250,150,50,50),NewTexture[17])) 
    { Change = true; Clicks += 1; GridNumber = 17;  }
    if(GUI.Button(Rect(300,150,50,50),NewTexture[18])) 
    { Change = true; Clicks += 1; GridNumber = 18;  }
    if(GUI.Button(Rect(350,150,50,50),NewTexture[19])) 
    { Change = true; Clicks += 1; GridNumber = 19;  }
    if(GUI.Button(Rect(400,150,50,50),NewTexture[20])) 
    { Change = true; Clicks += 1; GridNumber = 20;  }
    if(GUI.Button(Rect(100,200,50,50),NewTexture[21])) 
    { Change = true; Clicks += 1; GridNumber = 21;  }
    if(GUI.Button(Rect(150,200,50,50),NewTexture[22])) 
    { Change = true; Clicks += 1; GridNumber = 22;  }
    if(GUI.Button(Rect(200,200,50,50),NewTexture[23])) 
    { Change = true; Clicks += 1; GridNumber = 23;  }
    if(GUI.Button(Rect(250,200,50,50),NewTexture[24])) 
    { Change = true; Clicks += 1; GridNumber = 24;  }
    if(GUI.Button(Rect(300,200,50,50),NewTexture[25])) 
    { Change = true; Clicks += 1; GridNumber = 25;  }
    if(GUI.Button(Rect(350,200,50,50),NewTexture[26])) 
    { Change = true; Clicks += 1; GridNumber = 26;  }
    if(GUI.Button(Rect(400,200,50,50),NewTexture[27])) 
    { Change = true; Clicks += 1; GridNumber = 27;  }
    if(GUI.Button(Rect(100,250,50,50),NewTexture[28])) 
    { Change = true; Clicks += 1; GridNumber = 28;  }
    if(GUI.Button(Rect(150,250,50,50),NewTexture[29])) 
    { Change = true; Clicks += 1; GridNumber = 29;  }
    if(GUI.Button(Rect(200,250,50,50),NewTexture[30])) 
    { Change = true; Clicks += 1; GridNumber = 30;  }
    if(GUI.Button(Rect(250,250,50,50),NewTexture[31])) 
    { Change = true; Clicks += 1; GridNumber = 31;  }
    if(GUI.Button(Rect(300,250,50,50),NewTexture[32])) 
    { Change = true; Clicks += 1; GridNumber = 32;  }
    if(GUI.Button(Rect(350,250,50,50),NewTexture[33])) 
    { Change = true; Clicks += 1; GridNumber = 33;  }
    if(GUI.Button(Rect(400,250,50,50),NewTexture[34])) 
    { Change = true; Clicks += 1; GridNumber = 34;  }
    if(GUI.Button(Rect(400,350,50,50),NewTexture[40])) 
    { Change = true; Clicks += 1; GridNumber = 40;  }
    if(GUI.Button(Rect(450,350,50,50),NewTexture[41])) 
    { Change = true; Clicks += 1; GridNumber = 41;  }
    if(GUI.Button(Rect(500,350,50,50),NewTexture[42])) 
    { Change = true; Clicks += 1; GridNumber = 42;  }
    ...
    if(GUI.Button(Rect(100,550,65,65),NewTexture[35])) 
    { Change = true; Clicks += 1; GridNumber = 35; }
    if(GUI.Button(Rect(165,550,65,65),NewTexture[36])) 
    { Change = true; Clicks += 1; GridNumber = 36; }
    if(GUI.Button(Rect(230,550,65,65),NewTexture[37])) 
    { Change = true; Clicks += 1; GridNumber = 37; }
    if(GUI.Button(Rect(295,550,65,65),NewTexture[38])) 
    { Change = true; Clicks += 1; GridNumber = 38; }
    if(GUI.Button(Rect(360,550,65,65),NewTexture[39])) 
    { Change = true; Clicks += 1; GridNumber = 39; }

    http://answers.unity3d.com/questions/691870/gui-button-not-showing-up.html

    dzzpchelka, 12 Сентября 2014

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static string GetString(string inpString, string defValue)
    {
    	if (inpString == null)
    		return defValue;
    	return inpString;
    }

    Этот метод заботливо лижит в файле с всякими вспомогательными функциями, мало ли где может понадобиться

    Smekalisty, 08 Сентября 2014

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