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

    +142

    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
    using (new MPI.Environment(ref args))
                {
                    //Эта программа для MPI. Внешний алгоритм
                    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                    stopwatch.Start();
                    Intracommunicator world = Communicator.world;
                    if (world.Rank == 0)
                    {
                        RightRectangleSubDomain(horror, world);
                        LeftRingSubdomain(dolor, world);
                        world.Barrier();
                        SendArthas(dolor, world);
                        RecvKelthuzad(kelthuzad, world);
                    }
                    if (world.Rank == 1)
                    {
                       LeftRectangleSubDomain(pavor, world);
                       RightRingSubdomain(tristicia, world);
                       world.Barrier();
                       SendKelthuzad(tristicia, world);
                       RecvArthas(arthas, world);
                    }
                    stopwatch.Stop();
                    Console.WriteLine("Elapsed time: {0}", stopwatch.ElapsedMilliseconds);
    
                }

    Очень сильно напугала лабораторная, что отразилось на названиях переменных. Да и сам файл был назван MPITenebris.

    Stubborn, 29 Мая 2015

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

    +142

    1. 1
    2. 2
    3. 3
    return optionsBackButtonCommand ?? ((Func<RelayCommand>)(() =>
                                                         optionsBackButtonCommand = new RelayCommand(param =>
                                                         RandomMethod() )))();

    Сам придумал. "Изящно" обошел использование if.

    mee2xuh, 28 Мая 2015

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

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    string q = DateTime.Now.ToString().Substring(3, 3);
    string w = DateTime.Now.ToString().Substring(0, 2);
    string e = DateTime.Now.ToString().Substring(5, DateTime.Now.ToString().Length - 5);
    string dsasd = q + w + e;
    
    CrmDateTimeProperty _new_date_fitst_update_rstatus = new CrmDateTimeProperty();
    _new_date_fitst_update_rstatus.Name = "new_date_first_update_rstatus";
    _new_date_fitst_update_rstatus.Value = new CrmDateTime();
    _new_date_fitst_update_rstatus.Value.Value = dsasd;
    dynamicEntity.Properties.Add(_new_date_fitst_update_rstatus);

    Попался проект на фрилансе. Попросили исправить ошибки. Начал исправлять и вот такое.

    Shturman, 19 Мая 2015

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

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // ...
    
    Action updatingLoadedItemsList = null;
    
    foreach (Item loadedItem in loadedItems)
        if (loadedItem.Id == currentItem.Id)
            updatingLoadedItemsList = () => loadedItems.RemoveAt(loadedItems.IndexOf(loadedItem));
    
    if(updatingLoadedItemsList != null)
        updatingLoadedItemsList.Invoke();
    	
    // ...

    pushistayapodmyshka, 19 Мая 2015

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

    +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
    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 List<string> urls = new List<string>();
    
            private int urls_index = -1;
    
            private ProgressBar pb = new ProgressBar()
            {
                Width = 291,
                Height = 26,
                Maximum = 100,
                Minimum = 0,
                Location = new Point(12, 41)
            };
    
            public Object SyncIndex = new Object();
    
    public void DownLoad(object index)
            {
                int indexwhile = (int) index;
                while (work)
                {
                    int localIndex;
    
                    lock (SyncIndex)
                    {
                        urls_index++;
                        localIndex = urls_index;
                    }
    
                    WebClient webClient = new WebClient();
                    try
                    {
                        webClient.DownloadFile(new Uri(urls[localIndex]), "img/" + localIndex + ".jpg");
                        webClient.DownloadProgressChanged += (s, a) => Invoke(new Action(() => {progressBars[indexwhile].Value = a.ProgressPercentage;})); 
                    }
                    catch (Exception exception)
                    {
                        Invoke(new Action(() =>
                        {
                            listBox2.Items.Add("Ошибка" + listBox1.Items[localIndex]);
                        }));
    
                        DownLoad(index);
                    }
    
                    Invoke(new Action(() =>
                    {
                        listBox1.Items[localIndex] =  "Загружен" + listBox1.Items[localIndex];
                        label1.Text = urls.Count.ToString();
                        richTextBox1.Text += localIndex + @".jpg Загружен" + Environment.NewLine;
                    }));
    
                    Thread.Sleep(500);
    
                }
            }
    
    
    private void button2_Click(object sender, EventArgs e)
            {
                work = true;
    
                Thread[] threads = new Thread[30];
    
                
    
                for (int i = 0; i < 20; i++)
                {
                    int mnoj = i + 1;
                    progressBars[i] = new ProgressBar()
                    {
                        Width = 291,
                        Height = 26,
                        Maximum = 100,
                        Minimum = 0,
                        Location = new Point(12, 41)
                    };
                    progressBars[i].Location = new Point(12, 41 * mnoj);
                    Controls.Add(progressBars[i]);
                    threads[i] = new Thread(DownLoad);
                    threads[i].IsBackground = true;
                    threads[i].Start(i);
                }
            }

    И все в одной форме..

    igorkrets, 14 Мая 2015

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

    +143

    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
    public enum WebViewImageType {
    	Back = 0,
    	Close = 1,
    	Menu = 2
    }		
    
    WebViewImageType GetImageType(int jsType){ 
    	switch (jsType) {
    		case 0:
    			return WebViewImageType.Back;
    		case 1:
    			return WebViewImageType.Close;
    		case 2:
    			return WebViewImageType.Menu;
    		default:
    			return WebViewImageType.Back;
    	}
    }

    kjuby8709gsome, 12 Мая 2015

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    catch (Exception ex)
                {
                    status = ex.Message;
                    throw ex;
                }

    zhilinskyegor, 07 Мая 2015

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

    +147

    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
    public static object get_pack_print(int packid)
                {
                    OracleConnection conn = connect();
                    conn.Open();
                    string json = "";
                    string sql1 = "select id, num, k01.fio||' '||k01.fnam||' '||k01.fot fio, k02.fio||' '||k02.fnam||' '||k02.fot fior, s01.s_name_s sno, s02.s_name_s snor " +
                                  "from ertd_card ec, HCM_K01@DBLKIPR k01, HCM_K01@DBLKIPR k02, HCM_S01@DBLKIPR s01, HCM_S01@DBLKIPR s02 " +
                                  "where " +
                                  "EC.PACKID=" + packid +
                                  " and k01.tnr = ec.tnr " +
                                  "and k02.tnr = ec.tnrr " +
                                  "and s01.s_no = ec.sno " +
                                  "and s02.s_no = ec.snor " +
                                  "and ec.del= 0";
                    try
                    {
    
                        OracleCommand cmd = new OracleCommand(sql1, conn);
                        cmd.CommandType = CommandType.Text;
                        OracleDataReader dr = cmd.ExecuteReader();
                        dr.Read();
                       
                        do
                        {
                            if (string.IsNullOrEmpty(json))
                            {
                               
    
                                json += "{\"data\":[{\"id\":\"" + dr["id"].ToString() + "\",\"num\":\"" + dr["num"].ToString() + "\",\"sno\":\"" + dr["sno"].ToString() + "\",\"snor\":\"" + dr["snor"].ToString() +
                                    "\",\"fio\":\"" + dr["fio"].ToString() +
                                    "\",\"fior\":\"" + dr["fior"].ToString() + "\"}";
    
                            }
                            else
                            {
                                json += ",{\"id\":\"" + dr["id"].ToString() + "\",\"num\":\"" + dr["num"].ToString() + "\",\"sno\":\"" + dr["sno"].ToString() + "\",\"snor\":\"" + dr["snor"].ToString() +
                                    "\",\"fio\":\"" + dr["fio"].ToString() +
                                    "\",\"fior\":\"" + dr["fior"].ToString() + "\"}";
                            }
                        }
                        while (dr.Read());
                      
                        json += "]}";
    
                        conn.Close();
                        return new System.Web.Script.Serialization.JavaScriptSerializer().DeserializeObject(json);
                      
                    }
                    catch (Exception ex)
                    {
                        conn.Close();
                        return null;
                    }
                }

    да просто стиль у него такой. Суровый.
    += "}"

    LIBERTE, 06 Мая 2015

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

    +942

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static class IntExtension
        {
            public static int NotMoreThan(this int i, int thanWhat){
                return i < thanWhat ? thanWhat : i;
            }
        }

    непонятно что

    tjmaster, 06 Мая 2015

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

    +144

    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
    public string[] razborstroki(string str)
            {
                string[] array = new string[100];
                int j = 0;
                for (int i = 0; i < str.Length; i++)
                {
                    if (str[i] != ';')
                        array[j] += str[i];
                    else
                        j++;
                }
                return array;
            }

    Обнаружил недавно в одном из переданных нам проектов. Правильно, у нас будет свой split с маджонгом и гейшами!!!!

    flea3m, 05 Мая 2015

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