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

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

    0

    1. 1
    2. 2
    3. 3
    let startMonth = Number(moment(payDate).startOf("month").format("DD"));
    let endOfMonth = Number(moment(startMonth).endOf("month").format("DD"));
    let dayOffMonth = (endOfMonth-startMonth +1)

    Это так оказывается можно посчитать число дней в месяце

    kinazarov, 09 Декабря 2020

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    handleShowScheduler() {
                    console.log(this.$parent.$parent.$parent.showScheduler, 'sch')
                    if (this.$parent.$parent.$parent.showScheduler) {
                        this.$parent.$parent.$parent.showScheduler = false;
                        setTimeout(() => {
                            this.$parent.$parent.$parent.showScheduler = true;
                        }, 200)
                    } else {
                        this.$parent.$parent.$parent.showScheduler = true;
                    }
                },

    diman_suvor, 09 Октября 2020

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

    +1

    1. 1
    https://core.telegram.org/constructor/passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow

    Какой багор )))

    rotoeb, 02 Октября 2020

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

    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
    Процедура ОбработкаПолученияПредставления(Данные, Представление, СтандартнаяОбработка)
    	СтандартнаяОбработка=Ложь;
    	Представление="";
    	Для Каждого Стр Из Данные.Ссылка.Состав Цикл
    		Представление=Представление+?(Представление="","",", ")+Стр.Автомобиль;
    		Если СтрДлина(Представление)>50 Тогда 
    			Представление=Представление+"...";
    			Прервать
    		КонецЕсли;
    	КонецЦикла;
    	//Представление=""+Данные.Ссылка.Клиент+" ("+Представление+")";
    КонецПроцедуры

    А чё это списки у нас вдруг тормозить стали?

    NioGoth, 01 Октября 2020

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

    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
    #include <stdio.h>
    #include <csptr/smart_ptr.h>
    #include <csptr/array.h>
    
    void print_int(void *ptr, void *meta) {
        (void) meta;
        // ptr points to the current element
        // meta points to the array metadata (global to the array), if any.
        printf("%d\n", *(int*) ptr);
    }
    
    int main(void) {
        // Destructors for array types are run on every element of the
        // array before destruction.
        smart int *ints = unique_ptr(int[5], {5, 4, 3, 2, 1}, print_int);
        // ints == {5, 4, 3, 2, 1}
    
        // Smart arrays are length-aware
        for (size_t i = 0; i < array_length(ints); ++i) {
            ints[i] = i + 1;
        }
        // ints == {1, 2, 3, 4, 5}
    
        return 0;
    }

    Allocating a smart array and printing its contents before destruction.

    C Smart Pointers

    What this is
    This project is an attempt to bring smart pointer constructs to the (GNU) C programming language.

    Features: unique_ptr, shared_ptr macros, and smart type attribute

    https://github.com/Snaipe/libcsptr

    3.14159265, 15 Сентября 2020

    Комментарии (1)
  7. JavaScript / Говнокод #26878

    −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
    updateTimer() {
                requestAnimationFrame(() => {
                    this.timeLeft = this.resendTimeDuration - (Date.now() * 0.001 - this.lastTimeLeft);
    
                    if (this.timeLeft <= 0) {
                        this.resetTimer();
                        return;
                    } else {
                        this.lastTimeLeft = this.timeLeft;
                        this.updateTimer();
                    }
                });
    }

    А как сделать таймер обратного отсчета?

    somebodyoncetoldme, 18 Августа 2020

    Комментарии (1)
  8. Python / Говнокод #26719

    +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
    enchufar Chamuyo
    
    un Árbol de a es
       bien Hoja a
       bien Nodo a (Árbol de a) (Árbol de a)
    
    el máximo
       dados n m
          si n > m da n
          si no    da m
    
    la altura de Árbol de a en Numerito
      dado (Hoja _)     da 1
      dado (Nodo _ a b) da 1 + máximo (altura a)
                                      (altura b)
    
    el programa es escupir . mostrar . altura $
       Nodo 'a'
            (Nodo 'b'
                  (Hoja 'c')
                  (Hoja 'd'))
            (Nodo 'e'
                  (Hoja 'f')
                  (Hoja 'g'))

    Отсюда:
    https://qriollo.github.io/

    TEH3OPHblu_nemyx, 01 Июня 2020

    Комментарии (1)
  9. Lua / Говнокод #26683

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if number >= 0 and number <= 9 then
        string.format('00%d', number)
    end
    if number >= 10 and number <= 99 then
        string.format('0%d', number)
    end
    if number >= 100 and number <= 999 then
        string.format('%d', number)
    end

    imring, 22 Мая 2020

    Комментарии (1)
  10. Python / Говнокод #26665

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    post_content = post_node.xpath('div[@class="entry-content"]')[0]
    post_code_nodes = post_content.xpath('.//code')
    if len(post_code_nodes) > 0:
        post.code = post_code_nodes[0].text
    else:
        post.code = inner_html_ru(post_content)

    Багор.

    gost, 19 Мая 2020

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private IDictionary<string, Value> valueIndex;
    ...
    
    var result = this.valueIndex
              .Where(v => v.Key == prefix + hashCode.ToString())
             .Select(v => new
             {
                    path = v.Value.Path,
                    field = v.Value.Field
              })
              .FirstOrDefault();

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

    adoconnection, 05 Мая 2020

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