1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #23557

    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
    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
    //функция возвращает название списка товара для аналитики
        getItemListName: function(obj) {
            obj = $(obj);
            var list = 'other';
            if (obj.parents('.AddedToCart__box--showcase').length > 0) {
                list = 'paneAddToCart';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Лучшая цена') {
                list = 'paneBestPrice';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Цена недели') {
                list = 'paneWeekPrice';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Акционные товары') {
                list = 'panePromo';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Популярные товары'
                && $('body').hasClass('Page--itemCard')) {
                list = 'panePopDetail';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Популярные товары'
                && document.location.pathname.indexOf('/personal/cart/') >= 0) {
                list = 'panePopCart';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Популярные товары'
                && $('.Rubric--category').length > 0) {
                list = 'panePopRubrics';
            } else if (obj.parents('.slider').length > 0
                && obj.parents('.slider').find('.sliderHeader').html() == 'Популярные товары') {
                list = 'panePopCatalog';
            } else if (obj.parents('.relatedItem').length > 0
                && obj.parents('.relatedItem').find('.relatedItemsHeader').html() == 'Сопутствующий товар') {
                list = 'relatedCart';
            } else if (obj.parents('.analogues').length > 0 
                && document.location.search.indexOf('REMOVE_CODE') >= 0) {
                list = 'replacements';
            } else if (obj.parents('.analogues').length > 0) {
                list = 'analog';
            } else if (obj.parents('.consumables').length > 0) {
                list = 'consumables';
            } else if (document.location.pathname.indexOf('/search/') >= 0) {
                list = 'search';
            } else if (document.location.pathname.indexOf('/promo/actions/') >= 0) {
                list = 'promo';
            } else if (document.location.pathname.indexOf('/personal/favorite/') >= 0) {
                list = 'favorite';
            } else if (document.location.pathname.indexOf('/personal/remind/') >= 0) {
                list = 'remind';
            } else if (document.location.pathname.indexOf('/personal/order/') >= 0) {
                if (document.location.href.indexOf('plist=Y') >= 0) {
                    list = 'allMyOrder';
                } else {
                    list = 'myOrder';
                }
            } else if (document.location.pathname.indexOf('/services/code/') >= 0) {
                list = 'orderByCode';
            } else if (document.location.pathname.indexOf('/catalog/compare/') >= 0) {
                list = 'compare';
            } else if (document.location.pathname.indexOf('/services/cartridges/') >= 0) {
                list = 'cartridge';
            } else if (document.location.pathname.indexOf('/promo/best_price/') >= 0) {
                list = 'bestPrice';
            } else if (document.location.pathname.indexOf('/promo/sale/') >= 0) {
                list = 'sale';
            } else if (document.location.pathname.indexOf('/catalog/novelty/') >= 0) {
                list = 'novelty';
            } else if (document.location.pathname.indexOf('/services/sets/') >= 0) {
                list = 'collections';
            } else if (document.location.pathname.indexOf('/catalog/brands/') >= 0) {
                list = 'brands';
            } else if (obj.parents('.listItemsContainer').length > 0
                && document.location.search.indexOf('REMOVE_CODE') >= 0) {
                list = 'replacements';
            } else if (obj.parents('.listItemsContainer').length > 0) {
                list = 'catalog';
            } else if ($('body').hasClass('Page--itemCard')) {
                list = 'detail';
            }
    
            return list;
        },

    Объект-обертка над Гугл аналитикой
    Написано старшим программистом

    _copy_of, 20 Ноября 2017

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    ВЫБРАТЬ
      SEO.титл КАК Титл,
      SEO.Описание КАК дескриптионс,
      SEO.Кейворд КАК Кейворд,
      SEO.Ссылка КАК сео
    ИЗ
      Справочник.SEO КАК SEO

    импортозамещение...

    OdinAsss, 14 Ноября 2017

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

    −4

    1. 1
    Итого байт: 205812872340

    Результат прошлого кода! А давайте письками померяемся?

    samopisiets, 09 Ноября 2017

    Комментарии (4)
  5. Си / Говнокод #23487

    −7

    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
    #include <stdio.h>
    // Бесконечный дождик на экране! Ахуенчик ёпта
    int main()
    {
    	char c = '\\';
    	while(1)
    	{
    		for(int i=0; i<20; i++)
    		{
    			usleep(1000);
    			for(int sp=0;sp<i;sp++) printf(" "); //печатаем пробелы
    			printf("%c", c);
    		}
    	}
    }

    pawn-master, 04 Ноября 2017

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

    −2

    1. 1
    2. 2
    Возврат;	
    КонецПроцедуры

    Процедуры!!!

    qwertyk, 18 Октября 2017

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

    −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
    public static function GenerateMenu()
        {
            $item = [];
            $section = self::find()->all();
            $count_section = 0;
    
            foreach ($section as $model_section) {
                $item[] = ['label' => $model_section->name, 'url' => '#'];
                $category = \common\models\Category::find()->where(['id_section' => $model_section->id])->all();
                $count_category = 0;
                foreach ($category as $model_category) {
                    $item[$count_section]['items'][$count_category] = ['label' => $model_category->name, 'url' => '#'];
                    $subcategory = \common\models\Subcategory::find()->where(['id_category' => $model_category->id])->all();
                    $count_subcategory = 0;
                    foreach ($subcategory as $model2) {
                        $item[$count_section]['items'][$count_category]['items'][$count_subcategory] = ['label' => $model2->name, 'url' => '#'];
                        $count_subcategory++;
                    }
                    $count_category++;
                }
                $count_section++;
            }
    
            return $item;
        }

    Феерическое решение для вывода tree из трех категорий.

    qstd, 09 Сентября 2017

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

    −19

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    let countries = ``
    
    missingCountries.map((c, i) => {
      countries += ` '${c.country}'`
      if (i !== missingCountries.length - 1) countries += `,`
    })

    map? Ara.

    sigod, 07 Сентября 2017

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

    −15

    1. 1
    github.com/mpak2/mpak.su/tree/master/include/mail

    В mpak завезли composer.json

    d_fomenok, 27 Августа 2017

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

    +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
    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
    var L = {
                'Рђ': 'A',
                'Р°': 'a',
                'Р‘': 'B',
                'Р±': 'b',
                'Р’': 'V',
                'РІ': 'v',
                'Р“': 'G',
                'Рі': 'g',
                'Р”': 'D',
                'Рґ': 'd',
                'Р•': 'E',
                'Рµ': 'e',
                'РЃ': 'Yo',
                'С‘': 'yo',
                'Р–': 'Zh',
                'Р¶': 'zh',
                'Р—': 'Z',
                'Р·': 'z',
                'И': 'I',
                'Рё': 'i',
                'Р™': 'Y',
                'Р№': 'y',
                'Рљ': 'K',
                'Рє': 'k',
                'Р›': 'L',
                'Р»': 'l',
                'Рњ': 'M',
                'Рј': 'm',
                'Рќ': 'N',
                'РЅ': 'n',
                'Рћ': 'O',
                'Рѕ': 'o',
                'Рџ': 'P',
                'Рї': 'p',
                'Р ': 'R',
                'СЂ': 'r',
                'РЎ': 'S',
                'СЃ': 's',
                'Рў': 'T',
                'С‚': 't',
                'РЈ': 'U',
                'Сѓ': 'u',
                'Р¤': 'F',
                'С„': 'f',
                'РҐ': 'Kh',
                'С…': 'kh',
                'Р¦': 'Ts',
                'С†': 'ts',
                'Р§': 'Ch',
                'С‡': 'ch',
                'РЁ': 'Sh',
                'С€': 'sh',
                'Р©': 'Sch',
                'С‰': 'sch',
                'РЄ': '',
                'СЉ': '',
                'Р«': 'Y',
                'С‹': 'y',
                'Р¬': "",
                'СЊ': "",
                'Р­': 'E',
                'СЌ': 'e',
                'Р®': 'Yu',
                'СЋ': 'yu',
                'РЇ': 'Ya',
                'СЏ': 'ya'
            };

    Pavel-Pronskiy, 23 Августа 2017

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

    +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
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    #!/usr/bin/env python
    
    import jinja2
    
    import contextlib
    import os.path
    import shutil
    import subprocess
    import sys
    import tempfile
    
    
    @contextlib.contextmanager
    def rm_dir(d):
        yield d
        shutil.rmtree(d)
    
    
    def main():
        if len(sys.argv) < 2:
            return
    
        if os.path.basename(sys.argv[1]) != "compile":
            subprocess.call(sys.argv[1:])
            return
    
        command = sys.argv[1:]
        preprocessed_files = []
    
        with rm_dir(tempfile.mkdtemp()) as tmpdir:
            print "Temp dir is", tmpdir
    
            while len(command) > 0 and not command[-1].startswith("-") and command[-1].endswith(".go"):
                tmpfile = os.path.join(tmpdir, str(len(command)) + ".go")
    
                with open(command[-1]) as input:
                    with open(tmpfile, "wb") as preprocessed:
                        print "Preprocess", command[-1], "into", tmpfile
                        preprocessed.write(jinja2.Template(input.read()).render())
    
                preprocessed_files.append(tmpfile)
                command.pop()
    
            subprocess.call(command + preprocessed_files)
    
    
    if __name__ == "__main__":
        main()

    Прикручиваем шаблонизатор jinja к го, чтобы копипастить с комфортом. Использовать так:

    go build -toolexec '/path/to/preprocess.py' package_na_go

    123123123, 22 Августа 2017

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