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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private static string GetServerHostFromUrl(string url)
      {
          char[] delimiterChars = { '/', ':' };
          var urlParser = url.Split(delimiterChars);
    
          if (urlParser[0] == "http" || urlParser[0] == "https")
              return urlParser[3];
          else
              return string.Empty;
      }

    Когда ты умеешь решать все поставленные задачи

    partizanes, 05 Ноября 2019

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    private List<string> StrSplit(string str)
    {
        if (!string.IsNullOrEmpty(str))
            return str.Split(new char[] { ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries).ToList();
        return null;
    }

    m_sandman, 25 Октября 2019

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

    0

    1. 1
    2. 2
    3. 3
    string log = pair;
    log += ":";
    log += new string(Convert.ToChar(32), 21 - pair.Length); /*spaces*/

    m_sandman, 25 Октября 2019

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

    0

    1. 1
    let res: boolean = result.lmr_customertype === typeOfSaleValue ? false : true;

    m_sandman, 25 Октября 2019

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

    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
    public class HttpQueryNameValueCollection : NameValueCollection
        {
            private ParallelLoopResult _parallelLoopResult;
    
            public override string ToString()
            {
                List<string> result;
                result = new List<string>();
                _parallelLoopResult = Parallel.ForEach(AllKeys, p =>
                {
                    if (BaseGet(p) != null)
                        result.Add(p + "=" + Get(p));
                });
                return string.Join("&", result);
            }
        }

    Формирование ссылки с query-параметрами недостаточно быстро, поэтому нужно это сделать в параллель :D

    adoconnection, 24 Октября 2019

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

    +1

    1. 1
    public int HowManyHoursWillGoBackForConvertingUkToUtc(DateTime ukTime) => IsAlreadyGoForward(ukTime) ? 1 : 0;

    когда название говорит само за себя

    govnoBet, 17 Октября 2019

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

    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
    55. 55
    56. 56
    57. 57
    58. 58
    internal void OnItemSaved(object sender, EventArgs args)
    {
    Sitecore.Diagnostics.Log.Error("OnItemSaved: Fired", new Exception());     
    var eventArgs = args as Sitecore.Events.SitecoreEventArgs;
    Sitecore.Diagnostics.Assert.IsNotNull(eventArgs, "eventArgs");
    
    if (eventArgs == null) return;
    
    var item = eventArgs.Parameters[0] as Sitecore.Data.Items.Item;
    var currItem = item;
    
    Sitecore.Diagnostics.Log.Error("OnItemSaved: " + item.Name, new Exception());     
    
    TaxonomyBaseItem i = item;
    
    if (currItem != null)
    {
        try
        {
            while (item != null && item.TemplateID.ToString() != TopicSectionFrontPageItem.TemplateId)
            {
                item = item.Parent;
            }
    
            if (item == null) return;
    
            Sitecore.Diagnostics.Log.Error("OnItemSaved: " + item.Name, new Exception());
            
            if (!i.TopicTaxonomy.ListItems.Contains(item))
            {
                Sitecore.Diagnostics.Log.Error("OnItemSaved: Doesn't contain it", new Exception());     
    
                Sitecore.Data.Fields.MultilistField mfield = currItem.Fields["Topic Taxonomy"];
                if (!mfield.Contains(item.ID.ToString()))
                {
                    using (new Sitecore.SecurityModel.SecurityDisabler())
                    {
                        currItem.Editing.BeginEdit();
                        if (currItem.Fields["Topic Taxonomy"].Value == string.Empty)
                        {
                            currItem.Fields["Topic Taxonomy"].Value += item.ID.ToString();
                        }
                        else
                        {
                            currItem.Fields["Topic Taxonomy"].Value += "|" + item.ID.ToString();
                        }
                        Sitecore.Diagnostics.Log.Error("OnItemSaved: " + currItem.Fields["Topic Taxonomy"].Value, new Exception());     
    
                        currItem.Editing.EndEdit();
                    }
                }
            }    
        }
        catch (Exception ex)
        {
            Sitecore.Diagnostics.Log.Error("OnItemSaved: " + ex.Message, new Exception());        
        }        
    }

    Когда ты хочешь чтобы твои логи были заметны: Sitecore.Diagnostics.Log.Error("OnItemSa ved: " + item.Name, new Exception());
    И когда никому не хочешь рассказывать об эксепшенах:
    catch (Exception ex)
    {
    Sitecore.Diagnostics.Log.Error("OnItemSa ved: " + ex.Message, new Exception());
    }

    VolAnder, 25 Сентября 2019

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

    −1

    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
    class Label : System.Windows.Forms.Label {
            public Label ( string s , int x , int y , Form parent ) {
                this.Location = new Point ( x , y ) ;
                this.Text = s ;
                this.AutoSize = true ;
                this.Font = new Font ( SystemFonts.CaptionFont , FontStyle.Bold ) ;
                parent.Controls.Add ( this ) ;
            }
        }
        class Button : System.Windows.Forms.Button {
            public Button ( string s , int x , int y ,  EventHandler f , Form parent ) {
                this.Location = new Point ( x , y ) ;
                this.Text = s ;
                this.Font = new Font ( SystemFonts.CaptionFont , FontStyle.Bold ) ;
                this.Click += f ;
                parent.Controls.Add ( this ) ;
            }
        }
    
        static Form form = new Form() ;
        static Button[,] a = new Button [ 4 , 4 ] ;
        static Random rnd = new Random() ;
        static Timer timer = new Timer() ;
        static Label time = new Label ( "0" , width + cellspacing * 3 , 4 * ( width + cellspacing ) + cellspacing * 2 , form ) ;
        static Label nclicks = new Label ( "0" , 3 * width + cellspacing * 5 , 4 * ( width + cellspacing ) + cellspacing * 2 , form ) ;

    Нашел архив своего старого говна :)

    Pretty_Young_Thing, 03 Сентября 2019

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    public class clsActMarriage
    {
       ...
    }

    Трудности перевода из серии "Ясные печеньки".

    Как вам название сущности? Буквально "Акт женитьбы".
    Оглянулся на 300+ строк вокруг и понял что это на самом деле "Акт брака" в контексте товара.
    Класс занимается созданием и наполнением документа о наличии брака по утвержденной форме.

    Ну кто так называет? Откуда это: лень, глупость или неграмотность? Как это пропустили на ревью?
    Почему не "FlawReport" не "DefectBulletin" или
    на худой конец "DocumentOfUnquality" если по инглишу в школе неуд был.
    Кто-то в прошлом сэкономил 1 минуту, а в настоящем это обернулось потерей 20 минут на раскуривание.
    Плохие имена переменных которые нельзя изменить - боль кровавого энтерпрайза.

    Ух, пичот! (╯°□°)╯︵┻━┻

    Gilbert, 23 Августа 2019

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

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public class class inheritance mein (kampf) {
        int **her_na_polke = cidiez_alloc(sizeof(int) * SIZE);
    
        // suka blyat ebany ci diez
    
        ...
    
        // here is garbage collector, so... nothing do
    }

    _________

    Ksyrx, 29 Июля 2019

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