1. JavaScript / Говнокод #24537

    −1

    1. 1
    Почему "getElementById", а не "getElementByID"?

    KOHTPArEHTTBOEuMAMKu, 24 Июля 2018

    Комментарии (5)
  2. Python / Говнокод #24536

    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
    #-*-coding:utf8;-*-
    
    combinators = {
       'I': lambda x: x if len(x) <= 1 else calc(x[1:]),
       'K': lambda x: x if len(x) <= 2 else calc((x[1],) + x[3:]),
       'W': lambda x: x if len(x) <= 2 else calc(x[1:3] + x[2:]),
       'S': lambda x: x if len(x) <= 3 else calc((x[1], x[3], (x[2], x[3])) + x[4:]),
       'B': lambda x: x if len(x) <= 3 else calc((x[1], (x[2], x[3])) + x[4:]),
       'C': lambda x: x if len(x) <= 3 else calc((x[1], x[3], x[2]) + x[4:]),
       'U': lambda x: x if len(x) <= 2 else calc((x[2], (x[1], x[1], x[2])) + x[3:]),
       'Y': lambda x: x if len(x) <= 1 else calc(('S',('K',('S','I','I')),('S',('S',('K','S'),'K'),('K',('S','I','I')))) + x[2:])
    }
    
    def calc(x):
        def f(x, top = False):
            if type(x) is not tuple or len(x) == 0:
                return x
            if top:
                while type(x[0]) is tuple:
                    x = x[0] + x[1:]
            else:
                if type(x[0]) is tuple:
                    return (calc(x[0]),) + f(x[1:])
            print(termrepr(x))
            input('Press Enter...')
            return combinators.get(x[0], lambda _: (x[0],) + f(x[1:]))(x)
    
        return f(x, True)
    
    def parse(s):
        def f(s, n):
            res = ()
            i = n
            while i < len(s):
                if s[i] == '(':
                    t, j = f(s, i + 1)
                    res += (t,)
                    i = j - 1
                elif s[i] == ')':
                    return (res, i + 1)
                else:
                    res += (s[i],)
                i += 1
            return (res, i)
            
        return f(s, 0)[0]
    
    def termrepr(x):
        if len(x) == 0:
            return ''
        if type(x[0]) is tuple:
            return '(' + termrepr(x[0]) + ')' + termrepr(x[1:])
        else:
            return x[0] + termrepr(x[1:])
    
    print('>> ', end = '')
    while True:
        print(termrepr(calc(parse(input()))))
        print('\n>> ', end = '')

    Я перепесал #24129:

    >> BUGURT
    BUGURT
    Press Enter...
    U(GU)RT
    Press Enter...
    R((GU)(GU)R)T
    Press Enter...
    GU(GU)R
    Press Enter...
    U(GU)R
    Press Enter...
    R((GU)(GU)R)
    Press Enter...
    GU(GU)R
    Press Enter...
    U(GU)R
    Press Enter...

    666_N33D135, 24 Июля 2018

    Комментарии (12)
  3. Lua / Говнокод #24534

    −4

    1. 1
    https://pikabu.ru/story/moy_kuzen_byil_gospitalizirovan_posle_togo_kak_zasunul_sebe_v_anus_28_malenkikh_loshadok_6045256

    Potap, 23 Июля 2018

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

    −2

    1. 1
    2. 2
    А что если конпелятору переносить комментарии в ассемблерный код?
    Это относится к швабодке?

    OlegUP, 23 Июля 2018

    Комментарии (20)
  5. Куча / Говнокод #24530

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Роман, вы там палитесь.
    
    1) Отключаем историю поиска и просмотров в youtube
    2) Смотрим какое-нибудь нехарактерное для себя видео
    3) Видим рекомендации, основанные на этом видео
    4) Проверяем историю просмотров: там этого видео нет
    5) Говорим, что не интересуемся этой рекомендацией, щёлкаем "Tell us why"
    6) Один из вариантов будет "мне не интересны рекомендации на основе..." того видео, которого нет в истории
    7) Это не проблема кэширования, таймингов и синхронизации
    8) Упс

    seo: #багрепорт #роман #корпорация_добра

    CHayT, 22 Июля 2018

    Комментарии (76)
  6. Lua / Говнокод #24525

    −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
    -- пофикшу позже, юникод неработает. Почему? ХЗ. КОИ-8 навсегда. Armat.
    function tmp (...)
    ...
    end
    
    -- я ХЗ на кой тут это надо, но без этой ереси все падает к del . А логи можно и почистить руками. David.
    callerr (...)
    
    WTF = GetScriptPosX(ScriptWay, ObrStroka, FlagZalypyByka)
    -- Да, без флага никак. То есть совсем. И что он делает мы не знаем, возвращает nil. Но без него nil идет уже в основу. И как эта магия вызова сОтоны работает мы тоже ХЗ. Я не нашел даже где он выставляется - то ли в недрах функции, то ли вообще из двигла выдергивается, там, del, МАГИЯ происходит. David.
    ...
    -- Я без понятия почему, но в двигле этих гомоdel значения XYZ мыши инвертированы. Кроме того, граничные значения опять таки инвертируются, так что далее - такой вот трэш. BK4Ever. И да, del v0.15.2 - ну просто полный del, баг на баге.
    WTF4 = WTF4 * -1
    if WTF4 == 128 then
    WTF4 = 127
    elseif WTF4 == -128 then
    WTF4 = -127
    elseif WTF4 > 128 or WTF4 < -128
    callerr(...)
    WTF4 = 0
    end
    SetScriptPos(X, WTF4, dec)
    -- Почему везде DEC? Потому, что на дробных в одних местах надо точку, в других - запятую. В падлу, проще округлить. David.

    Наш старый обработчик скриптового языка на Lua, аргументы частично удалены для сокращения объема*и потому, что стыдно:-) Сейчас пересмотрел и понял, что некоторые фрагменты определенно заслуживают вклада сюда. И ради б-га не спрашивайте, как это работало - сами по прошествии пяти(вроде) лет без понятия.

    david52522, 21 Июля 2018

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

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Object oriented style
    string mysqli::escape_string ( string $escapestr )
    string mysqli::real_escape_string ( string $escapestr )
    
    
    Procedural style
    string mysqli_real_escape_string ( mysqli $link , string $escapestr )
    
    
    http://php.net/manual/en/mysqli.real-escape-string.php

    roskomgovno, 20 Июля 2018

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

    −5

    1. 1
    2. 2
    Кто смотри передачу "ДНК" на "НТВ"?
    Это просто не багор, а багорище )))

    Potap, 20 Июля 2018

    Комментарии (49)
  9. Assembler / Говнокод #24518

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    sub1:
        ; ...
        push sub2.end
    sub2:
        ; ...
        ret
    .end:
        ; ...
        ret

    Это нормально? Или я мудэ?

    666_N33D135, 19 Июля 2018

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

    −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
    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
    // https://github.com/Qqwy/raii_with/blob/74e4c66a821fba6a483d62a8c583b3fab06e3443/raii/raii.h#L60
    
    /**
     * Custom Control Structure Macro to provide Resource Acquisition Is Initialization (and Resource Relinquishment is Destruction).
     *
     * Use this to run a block of code with `var_decl` initialized to `init`, where at the end of the block (or at an earlier `safe_return`),
     * the passed `destr`-function will automatically be called with the given resource.
     *
     * Gotcha's:
     * 1. Do not use `return` from within `raii_with`, but only `safe_return`, because otherwise the destructors will not be run.
     * 2. Do not perform pointer-swaps with `var_decl`; the destructor will still be run on the original structure, because `raii` keeps its own reference to the resource.
     */
    #define raii_with(var_decl, init, destr)                                \
      while(1) /* i.c.m. break on l.4, so we can jump past the user-supplied block */ \
        if(0)                                                               \
        raii_glue(__raii_with_finished, __LINE__):                              \
          break;                                                            \
        else                                                                \
          /* initialize _tmp lifetime list elem so replacement `raii_lifetime_list` can have previous one as tail. */ \
          for(struct raii_lifetime_list_t _tmp = {.elem.resource = init, .elem.destructor = destr, .next = raii_lifetime_list};;) \
            /* initialize user-supplied variable name */                    \
            for(var_decl = _tmp.elem.resource;;)                            \
              if (1) {                                                      \
                /* Fill `_tmp`'s tail before `raii_lifetime_list` is shadowed */ \
                _tmp.next = raii_lifetime_list;                             \
                goto raii_glue(__raii_with_setup, __LINE__);                    \
              } else                                                        \
              raii_glue(__raii_with_setup, __LINE__):                           \
                /* Shadow `raii_lifetime_list` with inner version */        \
                for(struct raii_lifetime_list_t *raii_lifetime_list = &_tmp;;) \
                  if(1){                                                    \
                    goto raii_glue(__raii_with_body, __LINE__);                 \
                  } else                                                    \
                    while (1) /* so break works as expected */              \
                      while (1) /*so continue works as expected */          \
                        if (1){                                             \
                          /*after the else-block (or break or continue), destruct and finish */ \
                          destruct_raii_lifetime(raii_lifetime_list->elem); \
                          goto raii_glue(__raii_with_finished, __LINE__);       \
                        } else                                              \
                        raii_glue(__raii_with_body, __LINE__):
    
    
    #endif // RAII_WITH_H

    raii

    A simple library to provide RAII in standard-compliant C99, using raii_with(resource, initializer, destructor) { ... }-syntax:

    j123123, 19 Июля 2018

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