1. PHP / Говнокод #12496

    +49

    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
    /**
        * Used to show configurable product attributes in case when all elements are out-of-stock
        * 
        * "$_product->isSaleable() &&" should be commented out at line #100 (where "container2" block is outputted) in catalog/product/view.phtml
        * to make this work
        * 
        * @see Mage_Catalog_Model_Product::isSalable
        * @param object $observer
        */
        public function onCatalogProductIsSalableAfter($observer)
        {
            if (Mage::getStoreConfig('amstockstatus/general/outofstock'))
            {
                $salable = $observer->getSalable();
                $stack = debug_backtrace();
                foreach ($stack as $object)
                {
                    if (isset($object['file']))
                    {
                        if ($object['file'])
                        {
                            if ( isset($object['file']) && false !== strpos($object['file'], 'options' . DIRECTORY_SEPARATOR . 'configurable'))
                            {
                                $salable->setData('is_salable', true);
                            }
                        }
                    }
                }
            }
        }

    Вот такой вот веселый модуль для Magento, одна из возможностей которого - отобразить опции для всех out-of-stock вариантов конфигурируемого товара.

    vo1, 29 Января 2013

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

    +73

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    //QC 1487 - Modifying the order of creation of the SFC Teams.
    //DO NOT CHANGE THE ORDER, THIS WILL DISTURB THE ORDER OF DISPLAY IN THE UI.
    //The Order is 1) Credit Team 2) Comp Team 3) Servicing Team
    createCreditTeam(contract);     // Creating an Empty Credit Team.
    createCompTeam(contract);       // Creating an Empty Comp Team.
    createServicingTeam(contract);  // Creating an Empty Servicing Team.

    askell, 29 Января 2013

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

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public class ClientSourceTranslator implements ITranslator
    {
      public Object map(Object input)
      {
        return String.valueOf(12);
      }
    }

    askell, 29 Января 2013

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

    +53

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /**
    	 * Магический геттер
    	 * 
    	 * @param string $name
    	 * @return mixed 
    	 */
    	public function __get($name)
    	{
    		if ($name == $this->fileName)
    			return $this->fileName;
    	}

    Magic is here

    travka, 29 Января 2013

    Комментарии (15)
  5. Java / Говнокод #12492

    +71

    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
    private String getSecondsToTimeFormat(long startTime, long finishTime) {
    
            int secs = Math.round((finishTime - startTime) / 1000);
    
            int hours = secs / 3600,
                    remainder = secs % 3600,
                    minutes = remainder / 60,
                    seconds = remainder % 60;
    
            StringBuilder result = new StringBuilder();
    
            if (hours > 0) {
                result.append((hours < 10 ? "0" : "") + hours).append(":");
            }
    
            if (minutes > 0 || hours > 0) {
                result.append((minutes < 10 ? "0" : "") + minutes).append(":");
            }
    
            if (seconds > 0 || hours > 0 || minutes > 0) {
                result.append((seconds < 10 ? "0" : "") + seconds);
            }
    
            if (hours == 0 && minutes == 0) {
                if (seconds == 1) {
                    result.append(" second");
                } else {
                    result.append(" seconds");
                }
            }
    
            return result.toString();
        }

    Задача - перевести из секунд в человеческий формат

    nafania217518, 29 Января 2013

    Комментарии (8)
  6. JavaScript / Говнокод #12491

    +149

    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
    Wreqr.Commands = (function(Wreqr){
      "use strict";
    
      return Wreqr.Handlers.extend({
        execute: function(){
          var name = arguments[0];
          var args = Array.prototype.slice.call(arguments, 1);
    
          this.getHandler(name).apply(this, args);
        }
      });
    
    })(Wreqr);

    из библиотеки которая претендует на популярность, шаблонность (в модном нынче смысле слова) и стэйт-оф-зэ-артность
    вопрос - НАХ8Я СТРОКА 6???????

    dimalev, 29 Января 2013

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

    +38

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    isset($params) && array_push(
                $urlPart,
                implode('/',
                    array_map(
                        function ($key, $value) {
                            return $key . '/' . $value;
                        },
                        array_keys($params),
                        array_values($params)
                    )
                )
            );

    __proto__, 29 Января 2013

    Комментарии (2)
  8. Куча / Говнокод #12489

    +133

    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
    .wrapper#container {
        background-color: #ffffff;
        border-style: hidden;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        margin: 0 auto 0;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        padding: 15px 20px 20px 30px;
    }

    Из сорса страницы Evernote, вообще там порядка 8к строк для 4 дивов....

    nonamez, 28 Января 2013

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

    +19

    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
    struct Base { };
    
    struct Class : Base
    {
        int mem{ 0 };  // init non-static data member
    
        Class(int i)
        : Base{}   // init base class
        , mem{i}   // init member
        {
          int j{i};   // init local var
    
          int k = int{0};  // init temporary
    
          f( { 1 } );  // init function arg
    
          int* p = new int{1};  // new init
    
          // int k(int());  // most vexing parse, declares function
          int k{ int{} };   // ok, declares variable
    
          int i[4]{ 1,2,3,4 };   // init array
        }
    
        Class f(int i)
        {
          return { i };   // init return value
        }
    };
    
    Class c{1};   // init global var

    LispGovno, 28 Января 2013

    Комментарии (41)
  10. JavaScript / Говнокод #12487

    +155

    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
    /**
     * Checks if a setting is enabled
     *
     * @api public
     */
    
    Manager.prototype.enabled = function (key) {
      return !!this.settings[key];
    };
    
    /**
     * Checks if a setting is disabled
     *
     * @api public
     */
    
    Manager.prototype.disabled = function (key) {
      return !this.settings[key];
    };

    https://github.com/LearnBoost/socket.io/blob/develop/lib/manager.js

    makc3d, 28 Января 2013

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