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

    +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
    while (s != null)
                {
                    s = fs.ReadLine();
    
                    //arr  line example <rect x="0" y="0" rgba(92,41,235,0.9921568627451 
    
                    String[] arr = s.Split('(');
                    arr = arr[1].Split(',');
    
                    int fourPart = (int)(float.Parse(arr[3].Replace('.',',')) * 0xFF);
                    var binaryFour =  Convert.ToString(fourPart, 2);
    
                    while(binaryFour.Length < 8)
                    {
                        binaryFour = "0" + binaryFour;
                    }
    
                    int threePart = int.Parse(arr[2]);
                    var binaryThree = Convert.ToString(threePart, 2);
    
                    while (binaryThree.Length < 8)
                    {
                        binaryThree = "0" + binaryThree;
                    }
    
                    int twoPart = int.Parse(arr[1]);
                    var binaryTwo = Convert.ToString(twoPart, 2);
    
                    while (binaryTwo.Length < 8)
                    {
                        binaryTwo = "0" + binaryTwo;
                    }
    
                    int firstPart = int.Parse(arr[0]);
                    var binaryfirst = Convert.ToString(firstPart, 2);
    
                    number = Convert.ToInt32((binaryfirst + binaryTwo + binaryThree + binaryFour),2);
    
                    Write("number", number.ToString());
                }

    Хз как такое вообще появляется в голове

    partizanes, 31 Мая 2016

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

    +5

    1. 1
    https://github.com/KvanTTT/Cool-Compiler/blob/master/CoolCompiler/CoolCompiler.cs

    Учитесь, сопляки, как исключения перехватывать!

    dm_fomenok, 26 Мая 2016

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

    +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
    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    namespace Lens.Stdlib
    {
    	/// <summary>
    	/// Standard library randomizer methods.
    	/// </summary>
    	public static class Randomizer
    	{
    		#region Fields
    
    		/// <summary>
    		/// Random seed.
    		/// </summary>
    		public static readonly Random m_Random = new Random();
    
    		#endregion
    
    		#region Methods
    
    		/// <summary>
    		/// Gets a random floating point value between 0.0 and 1.0.
    		/// </summary>
    		/// <returns></returns>
    		public static double Random()
    		{
    			return m_Random.NextDouble();
    		}
    
    		/// <summary>
    		/// Gets a random integer value between 0 and MAX.
    		/// </summary>
    		public static int Random(int max)
    		{
    			return m_Random.Next(max);
    		}
    
    		/// <summary>
    		/// Gets a random integer value between MIN and MAX.
    		/// </summary>
    		public static int Random(int min, int max)
    		{
    			return m_Random.Next(min, max);
    		}
    
    		/// <summary>
    		/// Gets a random element from the list.
    		/// </summary>
    		public static T Random<T>(IList<T> src)
    		{
    			var max = src.Count - 1;
    			return src[Random(max)];
    		}
    
    		/// <summary>
    		/// Gets a random element from the list using a weighter function.
    		/// </summary>
    		public static T Random<T>(IList<T> src, Func<T, double> weighter)
    		{
    			var rnd = m_Random.NextDouble();
    			var weight = src.Sum(weighter);
    			if (weight < 0.000001)
    				throw new ArgumentException("src");
    
    			var delta = 1.0/weight;
    			var prob = 0.0;
    			foreach (var curr in src)
    			{
    				prob += weighter(curr) * delta;
    				if (rnd <= prob)
    					return curr;
    			}
    
    			throw new ArgumentException("src");
    		}
    
    		#endregion
    	}
    }

    Ну что сказать, 3,4-Метилендиоксиамфетамин

    dm_fomenok, 26 Мая 2016

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

    +6

    1. 1
    https://github.com/pascalabcnet/pascalabcnet

    ШОК! Говном компилируется говно. Это рекорд

    dm_fomenok, 25 Мая 2016

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

    +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
    public class tcMoveDirection
    		{
    			public enum tcDirection { R, L, N };
    			static public tcDirection fromstring(string expression)
    			{
    				switch (expression)
    				{
    					case "R":
    						return tcDirection.R;
    
    					case "L":
    						return tcDirection.L;
    
    					case "N":
    						return tcDirection.N;
    
    					default: throw new InvalidCastException();
    				}
    
    			}
    
    		}

    dm_fomenok, 23 Мая 2016

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

    +6

    1. 1
    2. 2
    3. 3
    if (selectedGroup == null)
        return null;
    return selectedGroup;

    зачем if то?

    kontora, 23 Мая 2016

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

    0

    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
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    
    namespace ConsoleApplication2
    {
      [StandardModule]
      internal sealed class Module1
      {
        [STAThread]
        public static void Main()
        {
    label_0:
          int num1;
          int num2;
          try
          {
            ProjectData.ClearProjectError();
            num1 = 1;
    label_1:
            int num3 = 2;
            Test.TTT();
            goto label_8;
    label_3:
            num2 = num3;
            switch (num1)
            {
              case 1:
                int num4 = num2 + 1;
                num2 = 0;
                switch (num4)
                {
                  case 1:
                    goto label_0;
                  case 2:
                    goto label_1;
                  case 3:
                  case 4:
                    goto label_8;
                }
            }
          }
          catch (Exception ex) when (ex is Exception & (uint) num1 > 0U & num2 == 0)
          {
            ProjectData.SetProjectError(ex);
            goto label_3;
          }
          throw ProjectData.CreateProjectError(-2146828237);
    label_8:
          if (num2 == 0)
            return;
          ProjectData.ClearProjectError();
        }
      }
    }

    Вот какая жуть получилась при декомпиляции старого доброго On Error Resume Next из VB.
    Исходный код:
    Sub Main()
    On Error Resume Next
    TTT() 'определен в модуле Test
    Exit Sub
    End Sub

    yamamoto, 23 Мая 2016

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var languageCodes = locales
                    .GroupBy(l => l.Key.Substring(0, 2))
                    .Select(group => group.First())
                    .Select(l => new KeyValuePair<string, string>(l.Key.Substring(0, 2), l.Value))
                    .OrderBy(l => l.Value);

    Прислала боевая подруга из Канады. Да, это продакшен. Но на этот раз код не падавана, а её собственный.

    kerman, 19 Мая 2016

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private void sendCommand(Hi1Command command)
            {
                var aCommand = command as Hi1Command;
                ...
            }

    На случай если Microsoft откажется от строгой типизации С#

    RdlSheetCoder, 18 Мая 2016

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

    +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
    private long m_IsExecuting;
    
    // ...
    
    public virtual void Execute(object parameter)
    {
    	try
    	{
    		if (Interlocked.Read(ref m_IsExecuting) != 0)
    			return;
    		Interlocked.Increment(ref m_IsExecuting);
    		m_Execute(parameter);
    	}
    	finally
    	{
    		Interlocked.Decrement(ref m_IsExecuting);
    	}
    }

    А за то, что ты меня не пустил, я пущу следующего.

    yamamoto, 18 Мая 2016

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