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

    +128

    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
    public string GetUserCurrentStage(int stage)
     {
                string stageName = "";
                if (stage == 1)
                    stageName += "Initial Certification";
                else if (stage == 2)
                {
                    stageName += "Maintenance *";
                }
                else if (stage == 3)
                    stageName += "Recertification";
                else
                    return string.Empty;
                return stageName;
     }

    Когда платят за строчки кода...

    musuk, 17 Июня 2011

    Комментарии (6)
  2. PHP / Говнокод #6987

    +159

    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
    $this->addException(Mage::helper('dataflow')->__('Found %d rows.', $this->_countRows));
    $this->addException(Mage::helper('dataflow')->__('Starting %s :: %s', $adapterName, $adapterMethod));
    
    $batchModel->setParams($this->getVars())
        ->setAdapter($adapterName)
        ->save();
    
    // $adapter->$adapterMethod();
    
    return $this;
    
    $dom = new DOMDocument();
    // $dom->loadXML($this->getData());
    if (Mage::app()->getRequest()->getParam('files')) {
        $path = Mage::app()->getConfig()->getTempVarDir().'/import/';
        $file = $path.urldecode(Mage::app()->getRequest()->getParam('files'));
        if (file_exists($file)) {
            $dom->load($file);
        }
    } else {
    
        $this->validateDataString();
        $dom->loadXML($this->getData());
    }

    Magento 1.5 stable. после return'a идёт около 70 строк... Насладиться можно тут http://svn.magentocommerce.com/source/branches/1.5/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php

    message, 17 Июня 2011

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

    +158

    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
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <?php echo $this->getChildHtml('form_before') ?>
    <form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
    <fieldset>
    <table id="shopping-cart-table" class="data-table cart-table">
        <col width="1" />
        <col />
        <col width="1" />
    <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
        <col width="1" />
    <?php endif ?>
    <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
    <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
        <col width="1" />
    <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
    <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
        <col width="1" />
    
    <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>

    Ну так, для уверенности, можно и 4 раза. Искал в этом смысл - смысла не найдено. Copyright (c) 2011 Magento Inc.

    message, 17 Июня 2011

    Комментарии (8)
  4. PHP / Говнокод #6985

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private function exportPTCsvFile(array $transactions, array $refunds, $fileName)
    	{
    		$csv[] = array('Date', 'Time Zone', 'Name',  'Type',  ' Status',  'Currency',  'Gross', 'Fee', 'Net', 'From Email Address', 'Transaction ID', ' Item Title', 'Deal ID', 'Deal City', 'Merchant ID', 'User ID', 'Purchase Date', 'CMS Transaction ID', 'CMS Quantity', 'CMS Amount', 'Kash Used', 'CC Digits', 'Coupon Link', 'Paymentech Response');
    
    		// headers...
    		
    		foreach ($csv as $titles) {
    		    print utf8_encode(implode(',', $titles))."\n";
    		}
                   // Rest of code...
    }

    kovel, 17 Июня 2011

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

    +123

    1. 1
    this.Border1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(111)))), ((int)(((byte)(111)))), ((int)(((byte)(111)))));

    Встретилось такое внутри сгенеренной системой InitializeComponent()

    absolut, 17 Июня 2011

    Комментарии (7)
  6. Java / Говнокод #6983

    +83

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public void fillFilialNames(ArrayList<String> filialNames) {
    		for (String filialDTO : filialNames) {
    			if (!filialNames.isEmpty())
    			filialNames.add(filialDTO);
    		}
    	}

    Бесконечный цикл :)

    stepanPlus7, 17 Июня 2011

    Комментарии (10)
  7. PHP / Говнокод #6981

    +159

    1. 1
    2. 2
    3. 3
    function doXmlEscape($val) {
      return str_replace(array('&', '<', '>', '"', "'"), array('&', '<', '>', '"', '''), $val);
    }

    http://vkontakte.ru/developers.php?o=-1&p=%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80 +%D0%BE%D0%B1%D1%80%D0%B0%D0%B1%D0%BE%D1 %82%D1%87%D0%B8%D0%BA%D0%B0+%D1%83%D0%B2 %D0%B5%D0%B4%D0%BE%D0%BC%D0%BB%D0%B5%D0% BD%D0%B8%D0%B9+%D0%BD%D0%B0+%D1%8F%D0%B7 %D1%8B%D0%BA%D0%B5+PHP

    Ох и разработчики... T_T

    inf, 17 Июня 2011

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

    −111

    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
    96. 96
    97. 97
    98. 98
    NetworkStatus internet = [internetReachable currentReachabilityStatus];
    
    switch (internet)
    {
        case NotReachable:		{ internetStatus = NO;  break; }
        case ReachableViaWiFi:	{ internetStatus = YES; break; }
        case ReachableViaWWAN:	{ internetStatus = YES; break; }
        default: break;
    }
    
    NetworkStatus host = [hostReachable currentReachabilityStatus];
    switch (host)
    {
        case NotReachable:		{ hostStatus = NO;  break; }
        case ReachableViaWiFi:	{ hostStatus = YES; break; }
        case ReachableViaWWAN:	{ hostStatus = YES; break; }
        default: break;
    }
    
    //-------------------------------------------------------------
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    	return false; 
    }
    
    //-------------------------------------------------------------
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
    	if (logicRotate == 1)
    	{
    		if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) // если ЛандскейпРайт
    		{
    			FlowCover.transform = CGAffineTransformIdentity;
    			indexLandscape = 1;
    		}
    		if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) // если ЛандскейпЛефт
    		{
    			FlowCover.transform = CGAffineTransformMakeRotation(M_PI);
    			indexLandscape = 0;
    		}
    	}
    	else
    	{
    		if (indexLandscape == 1)
    		{
    			FlowCover.transform = CGAffineTransformIdentity;
    		}
    		else
    		{
    			FlowCover.transform = CGAffineTransformMakeRotation(M_PI);
    		}
    		logicRotate = 1;
    	}
    	return false;
    }
    
    //-------------------------------------------------------------
    
    pagetextLabel.hidden = (pageFullScreen.realPageNo) ? NO : YES;
    
    //-------------------------------------------------------------
    
    [(FastImageView*)page showImage:[listOfImages objectAtIndex:pageIndex]]; //картинка
    
    //-------------------------------------------------------------
    
    if (firstPages>2) {
        ...
        if (theAudio) {
            [theAudio play];	//звук
        }
        firstPages++;
    }
    else
    {
        firstPages++;
    }
    
    //-------------------------------------------------------------
    
    LabPercent.text = [NSString stringWithFormat:@"%d%@", percent * 100, @"%"];
    
    //-------------------------------------------------------------
    
    if ([DELEGATE isIPad]) {
        mTempSize = [tempstr sizeWithFont:[UIFont fontWithName:@"Helvetica" size:17.0f] constrainedToSize:maxSize lineBreakMode:UILineBreakModeTailTruncation];
    }
    else {
        mTempSize = [tempstr sizeWithFont:[UIFont fontWithName:@"Helvetica" size:12.0f] constrainedToSize:maxSize lineBreakMode:UILineBreakModeTailTruncation];
    }
    h = mTempSize.height;
    if ([DELEGATE isIPad]) {
        lab.font = [UIFont fontWithName:@"Helvetica" size:17.0f];
    }
    else {
        lab.font = [UIFont fontWithName:@"Helvetica" size:12.0f];
    }

    От того же автора http://govnokod.ru/6964. Тут избранные куски, хотя можно постить весь проект

    GLvRzZZ, 17 Июня 2011

    Комментарии (4)
  9. PHP / Говнокод #6979

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    $value = $this->model->getById(DataUtil::fromGET("id"));
    foreach($this->model->get(PaginationUtil::getStart(),PaginationUtil::$countOnPage) as $value){
       return NewsUtils::createNewsLayout_ND($value);
    }

    В проект был взят стажер, и начал появляться такой вот индусский код.

    Kos, 17 Июня 2011

    Комментарии (12)
  10. Си / Говнокод #6978

    +139

    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
    #include <cstdio>
    #include <malloc.h>
    
    int number;
        printf("Int to c_str convertation whith separator: ");
        do {
            printf("Enter a number (int): ");
        }
        while (!scanf ("%d",&number));
        bool negative = number<0;
        number=abs(number);
        char* reversed = (char*)(malloc(sizeof(char)));
        *reversed = 0;
        int divider=1;
        unsigned char i=3;
        int buf;
        int val = 0;
        int size=1;
       forever{
            buf=number%(divider*10);
            i--;
            size++;
            reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
            *(reversed+size*sizeof(*reversed)-1) = (buf-val)/divider+48;
            divider*=10;
            val=buf;
            if (!i){
                size++;
                reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
                *(reversed+size*sizeof(*reversed)-1)=32;
                i=3;
            }
            if (buf==number) {break;}
        }
        if (negative){
            size++;
            reversed = (char*)(realloc(reversed,size*sizeof(*reversed)));
            *(reversed+size*sizeof(*reversed)-1)='-';
        }
        char* output = (char*)(malloc(size*sizeof(*reversed)));
        for (i=0;i<size*sizeof(*reversed);i++){
            *(output+i) = *(reversed+size*sizeof(*reversed)-((1+i)*sizeof(*reversed)));
        }
         printf("Number as char* is: %s",output);

    Выводит число в строку, вставляя пробел после каждых 3-х цифр.

    Sacha_D, 17 Июня 2011

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