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

    −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
    static void Main(string[] args){
                int i = int.Parse(Console.ReadLine());
                int j = i;
                i = j * Programa(1,2,3,4,5,6,7);
                i = i * Recursia(1);
                int x = i / i;
                Console.WriteLine(x);
            }
            private static int Programa(int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
                int i = i1 * i2 * i3 * i4 * i5 * i6 * i7;
                int j = i / (i7*i4);
                return (j * (i7 * i4)) /i;
            }
            private static int Recursia(int i) {
                if (i * 0 == 0 && i<50000)
                    Recursia(i*2);
                return Suma(i,15);
            }
            private static int Suma(int A, int B){
                if (0 == A) return B;
                if (0 == B) return A;
                return Suma(A - 1, B - 1);
            }

    Вывод 1 используя $еву тучу д(г)ействий

    MkSavin, 03 Ноября 2015

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

    +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
    //~200 строк сбора статистики
    ...
                    detail.AppendLine("     Обработано кодом \"1\" (Готово - полная идентификация)  " + kolvostrok.ToString() + " (" + getProc + "%)" + "");
                    detail.AppendLine("");
                    proc = (((kolvostrok_1 + kolvostro1) / kolvostrok) * 100).ToString();
                    getProc = proc.Substring(0, proc.IndexOf(",") + 3);
                    detail.Append("Обработано данных с кодом \"-1\" и \"1\" , Всего  " + (kolvostrok_1 + kolvostrok).ToString() + " (" + getProc + "%)");
    
                    msgBody += str.ToString();
                    msgBody += detail.ToString();
                    msgBody = msgBody.Normalize();
                }
                catch (Exception e)
                {
                    
                }
                finally
                {
                    ocon.Close();
                    SendEmail.SendEmail.SendMessage(msgSubject, msgBody, msgFrom, msgTo, msgCopy);
                }
            }

    потрясающе

    Lokich, 02 Ноября 2015

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

    +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
    public int RowSpan {
                get {
                    int p = HtmlText.IndexOf("rowspan");
                    if (p > -1) {
                        int index = HtmlText.IndexOf(" ", p + 8);
                        int index1 = HtmlText.IndexOf(">", p + 8);
                        int index2 = HtmlText.IndexOf("/", p + 8);
                        if ((index > index1) && (index1 != -1))
                            index = index1;
                        if ((index > index2) && (index2 != -1))
                            index = index2;
                        string s = HtmlText.Substring(p + 8, index - p - 8);
                        return Convert.ToInt16(s);
                    } else
                        return -1;
                }
                set {
                    if (value == 0) {
                        HtmlText = HtmlText.Replace("rowspan", string.Empty);
                    }
                }
            }
            public int ColSpan {
                get {
                    int p = HtmlText.IndexOf("colspan");
                    if (p > -1) {
                        int index = HtmlText.IndexOf(" ", p + 8);
                        int index1 = HtmlText.IndexOf(">", p + 8);
                        int index2 = HtmlText.IndexOf("/", p + 8);
                        if ((index > index1) && (index1 != -1))
                            index = index1;
                        if ((index > index2) && (index2 != -1))
                            index = index2;
                        string s = HtmlText.Substring(p + 8, index - p - 8);
                        return Convert.ToInt16(s);
                    } else
                        return -1;
                }
            }

    а тут регулярки он не осилил

    Lokich, 02 Ноября 2015

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

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public TD GetColumn(int i) {
                try {
                    return this.Columns[i];
                } catch {
                    return this.Columns[i - 1];
                }
            }

    в продолжение парсера

    Lokich, 29 Октября 2015

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

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    if (args.Length < 2 || args.Length == 3 || args.Length > 5 || args.Length > 2 && args[2] != "-n" && args[2] != "-t" || args.Length == 5 && args[4] != "-f" && args[4] != "-d" && args[4] != "-a")
    {
    	FindPrivateKey.PrintHelp();
    }

    Из майкрософтовского sample для поиска файлов приватных ключей.

    yamamoto, 29 Октября 2015

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    tempPages.Add(page, tempValue);
    rempPages = tempPages;
    if (totalPages != 0)
    {
    	rotalPages = totalPages;
    }
    currentCountItem += tempLength;

    Шашлык-рашлык.

    yamamoto, 23 Октября 2015

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

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public bool IsInRange(string ip, string cidrMask)
    {
                string[] parts = cidrMask.Split('/');
                int iIp = IPAddress.Parse(parts[0].Trim()).GetHashCode();
                int iCidr = IPAddress.Parse(ip.Trim()).GetHashCode();
                int iCidrMask = IPAddress.HostToNetworkOrder(-1 << (32 - int.Parse(parts[1].Trim())));
                return ((iIp & iCidrMask) == (iCidr & iCidrMask));
    }

    Финт ушами - превращение IPv4 в Int32 через вызов GetHashCode

    leon_mz, 14 Октября 2015

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

    +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
    ....
            SetFormPopup("/" & pageName & ".htm")
            pageName = pageName.Replace("(", "-")
            pageName = pageName.Replace(")", "-")
            pageName = pageName.Replace("&", "-")
            pageName = pageName.Replace(",", "-")
            pageName = pageName.Replace("""", "-")
            pageName = pageName.Replace("'", "-")
            pageName = pageName.Replace("_", "-")
            pageName = pageName.Replace("?", "-")
            pageName = pageName.Replace(".-", "-")
            pageName = pageName.Replace("-------", "-")
            pageName = pageName.Replace("------", "-")
            pageName = pageName.Replace("-----", "-")
            pageName = pageName.Replace("----", "-")
            pageName = pageName.Replace("---", "-")
            pageName = pageName.Replace("--", "-")
            pageName = pageName.Trim("-")
            ....

    skydev, 06 Октября 2015

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

    +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
    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
    using DocsTaskInfo = System.Collections.Generic.KeyValuePair<int, bool>;
    using DocAndContentType = System.Collections.Generic.KeyValuePair<int, string>;
    using DocAndContentTypeToCount = System.Collections.Generic.Dictionary<System.Collections.Generic.KeyValuePair<int, string>, System.Collections.Generic.KeyValuePair<int, bool>>;
    //...
    private void DocsCountInternal(RefNetDbContainerDirect db, int docType, string contentType,  int status, int count, bool Checked = true){/*...*/}
    //...
    private DocAndContentTypeToCount[] _docCheckTasks;
    private RefNetDbContainerDirect _dbForCheck;
    private void ClearAllDocCounts(RefNetDbContainerDirect dbForCheck)
            {
                _dbForCheck = dbForCheck;
                _docCheckTasks = Enumerable.Repeat(new DocAndContentTypeToCount(), 2).ToArray();
                    //new DocAndContentTypeToCount[2] { new DocAndContentTypeToCount(), new DocAndContentTypeToCount() };
            }
    private void DocsCount(RefNetDbContainerDirect db, int docType, string contentType, int status, int count, bool Checked = true)
            {
                var taskHistory = _docCheckTasks[status];
                var taskKey = new DocAndContentType(docType, contentType);
                var taskInfo = new DocsTaskInfo(count, Checked);
                if(taskHistory.ContainsKey(taskKey))
                    _exceptions.Add(new Exception(string.Format(
                                     "CheckDocsTask with (_.idDocType == {0}) && (_.contentType == \"{1}\") && (_.status == {2}) ) already contained",
                                     docType, contentType, status)));
                taskHistory.Add(taskKey, taskInfo);
            }
    private void CheckAllDocCounts()
            {
                if (AllDocumentsMadeByServer)
                {
                    //1
                    var taskKeys = _docCheckTasks.SelectMany(_ => _.Keys)/*.Distinct()*/.ToArray();
                    foreach (var taskKey in taskKeys)
                    {
                        DocAndContentType key = taskKey;
                        foreach (var statusedTask in _docCheckTasks.Where(statusedTask => !statusedTask.ContainsKey(key)))
                            statusedTask.Add(taskKey, new DocsTaskInfo(0, true));
                    }
                    taskKeys.Select(_ => new
                    {
                        docAndContentType = _,
                        count = _docCheckTasks[0][_].Key + _docCheckTasks[1][_].Key,
                        Checked = _docCheckTasks[0][_].Value && _docCheckTasks[1][_].Value
                    }).ForEach(_ => DocsCountInternal(_dbForCheck, _.docAndContentType.Key, _.docAndContentType.Value, 1, _.count, _.Checked));
            }
                else
                    //0 и 1
                    foreach(var statusedTask in _docCheckTasks.Select((tasks, status) => new {tasks, status}))
                        foreach (var task in statusedTask.tasks)
                            DocsCountInternal(_dbForCheck, task.Key.Key, task.Key.Value, statusedTask.status, task.Value.Key, task.Value.Value);
                _docCheckTasks = null;
                _dbForCheck = null;
            }

    Автору я бы посоветовал утопиться, но как посоветуете отрефакторить?
    Планировалось, что чувак вызывает ClearAllDocCounts, затем много раз метод DocsCount, а потом CheckAllDocCounts.

    USB, 02 Октября 2015

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

    +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
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    public class UnionDocumentJournalController : BaseDocumentJournalController
    <UnionDocumentJournalFilterViewModel, UnionDocumentJournalEntityViewModel, UnionDocumentJournalDataViewModel,
     UnionDocumentDataProvider, UnionDocumentDataManager, UnionLegalEntityDocumentsJournalViewModelMapper>
     {  }
    
    public class UnionDocumentJournalFilterViewModel : BaseJournalFilterViewModel<UnionDocumentJournalEntityViewModel>
    {
    ...
    }
    
    public class UnionDocumentJournalEntityViewModel : LegalEntityDocumentJournalEntityViewModel
    {
    ...
    }
    
    public class UnionDocumentJournalDataViewModel : BaseJournalDataViewModel<UnionDocumentJournalEntityViewModel>
     {  }
    
    public class UnionDocumentDataManager :
     DocumentDataManager
     <UnionDocumentDataProvider, UnionDocumentJournalFilterViewModel, UnionDocumentJournalEntityViewModel>
     {
    ...
    }
    
    public class UnionLegalEntityDocumentsJournalViewModelMapper :
     LegalEntityDocumentsJournalViewModelMapper<UnionDocumentJournalEntityViewModel, UnionDocumentJournalDataViewModel>
     {
    ...
    }

    Горе от ума

    banderror, 30 Сентября 2015

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