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

    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
    class Animal {
        move(distanceInMeters = 0) {
            print(`Animal moved ${distanceInMeters}m.`);
        }
    }
    
    function main() {
        const dog = new Animal();
        dog.move(10);
    
        const dog2 = Animal();
        dog2.move(11);
    }

    Загадка дня... кто знает что первый вызов конструктора отличается от второго?

    ASD_77, 07 Июля 2021

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

    +3

    1. 1
    IT Оффтоп #99

    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
    #82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
    #83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
    #84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
    #85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
    #86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
    #87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
    #90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
    #91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
    #92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
    #93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
    #94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
    #95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
    #96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
    #97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
    #98: https://govnokod.ru/27495 https://govnokod.xyz/_27495

    nepeKamHblu_nemyx, 07 Июля 2021

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

    +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
    25. 25
    26. 26
    class C {
        _length: number;
    
        constructor() {
            this._length = 10;
        }
    
        get length() {
            return this._length;
        }
        set length(value: number) {
            this._length = value;
        }
    }
    
    function main() {
        const c = new C();
    
        print(c.length);
        c.length = 20;
        print(c.length);
    
        delete c;
    
        print("done.");
    }

    пока вы тут балаболили я тут наговнокодил "property" или "accessors"

    ASD_77, 07 Июля 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    public function isBooted()
    {
        return true === $this->booted;
    }

    Дичь

    deenmluzsxbpg, 07 Июля 2021

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

    0

    1. 1
    Пиздец-оффтоп #24

    #1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
    #2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
    #3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
    #4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
    #5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
    #5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
    #6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
    #7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
    #8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
    #9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
    #10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
    #11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
    #12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
    #13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
    #14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
    #15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
    #16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
    #17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
    #18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
    #19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
    #20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
    #21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
    #22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
    #23: https://govnokod.ru/27493 https://govnokod.xyz/_27493

    nepeKamHblu_nemyx, 07 Июля 2021

    Комментарии (7072)
  6. Куча / Говнокод #27500

    0

    1. 1
    Просто оффтоп #19

    #1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
    #2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
    #3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
    #4: (vanished) https://govnokod.xyz/_25472
    #5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
    #6: (vanished) https://govnokod.xyz/_26649
    #7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
    #8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
    #9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
    #10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
    #11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
    #12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
    #13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
    #14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
    #15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
    #16: https://govnokod.ru/27282 https://govnokod.xyz/_27282
    #17: https://govnokod.ru/27319 https://govnokod.xyz/_27319
    #18: https://govnokod.ru/27380 https://govnokod.xyz/_27380

    nepeKamHblu_nemyx, 07 Июля 2021

    Комментарии (2054)
  7. Python / Говнокод #27499

    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
    import logging
    import requests
    from .. import loader, utils
    
    logger = logging.getLogger(__name__)
    
    def register(cb):
        cb(TagallMod())
    
    def chunks(lst, n):
        for i in range(0, len(lst), n):
            yield lst[i:i + n]
    
    class TagallMod(loader.Module):
    
        strings = {"name": "Tagall"}
    
        def __init__(self):
            self.config = loader.ModuleConfig("DEFAULT_MENTION_MESSAGE", "Привет", "Default message of mentions")
            self.name = self.strings["name"]
    
        async def client_ready(self, client, db):
            self.client = client
    
        async def tagallcmd(self, message):
            arg = utils.get_args_raw(message)
    
            logger.error(message)
            notifies = []
            async for user in self.client.iter_participants(message.to_id):
                notifies.append("<a href=\"tg://user?id="+ str(user.id) +"\">\u206c\u206f</a>")
            chunkss = list(chunks(notifies, 10))
            logger.error(chunkss)
            await message.delete()
            for chunk in chunkss:
                await self.client.send_message(message.to_id, (self.config["DEFAULT_MENTION_MESSAGE"] if not arg else arg) + '\u206c\u206f'.join(chunk))

    tars777, 06 Июля 2021

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

    +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
    class c1 {
        pin: number;
    
        hello() {
    	this.#hello();
        }
    
        #hello() {
            print("Hello World", this.pin);
    	this.pin = 20;
        }
    }
    
    function main() {
        const c = new c1();
        c.pin = 10;
        c.hello();
        print("Hello World", c.pin);
        delete c;
    
        print("done.");
    }

    Хорошие говно-новости по говно-помпилятору. Начал имплементировать классы. (когда меня это зае...т я еще не знаю, но чую что скоро)

    ASD_77, 05 Июля 2021

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

    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
    Короче, размышлял я как-то на тему того, как надо делать правильный
    теорем прувер, а не питушню всякую заедушную. Вот взять тот же Metamath -
    там какие-то непонятные distinct правила для хуиты, что надо какие-то там
    disjoint переменные, вот тут https://groups.google.com/g/metamath/c/M2dUfFATxD8
    про это подробнее сказано.
    
    Есть вот еще Metamath zero https://github.com/digama0/mm0 и это вот кажется ближе
    к тому, что мне нравится.
    Например вот https://github.com/digama0/mm0/blob/master/examples/assembler.mm1
    тут есть какая-то теорема про ELF хедер. Это вот определение ELF идентификатора
    
    local def ELF_IDENT_s: string =
    $ ,0x7f ': ,"E" ': ,"L" ': ,"F" ':
      _x02 ': _x01 ': _x01 ': _x00 ': _x00x8 $;
      
    и там еще какой-то такой хуйней описывается то, где там точка входа записана в заголовке,
    еще separation logic есть какая-то.
    Но вот если почитать спецификацию для этого mm0 языка
    https://github.com/digama0/mm0/blob/master/mm0.md :
    
    pure means that this sort does not have any term formers. It is an uninterpreted domain which may have
      variables but has no constant symbols, binary operators, or anything else targeting this sort. If a sort has
      this modifier, it is illegal to declare a term with this sort as the target.
    
    strict is the "opposite" of pure: it says that the sort does not have any variable binding operators. It is illegal
      to have a bound variable or dummy variable of this sort, and it cannot appear as a dependency in another
      variable. For example, if x: set and ph: wff x then set must not be declared strict. (pure and strict are not
      mutually exclusive, although a sort with both properties is not very useful.)
    
    provable means that the sort is a thing that can be "proven". All formulas appearing in axioms and theorems
     (between $) must have a provable sort.
     free means that definitions and theorems are not allowed to use dummy variables with this sort.
    
    то кажется мне, что слишком это сложно. Надо проще это всё сделать, по принципу какой-нибудь
    хрени типа SKI кобенационного исчисления. Т.е. допустим аксиома для модус поненса
    
    AXIOM
    %A
    P P $IMP %A %B
    _
    %B
    
    т.е. если мы матчим некую хуйню "%A" и некую хуйню "P P $IMP %A %B" где %A и %B это некая
    срань, которая может быть "что-то" "P чтото чтото" или там "P чтото P чтото чтото" и т.д.
    ну короче P означает что там две какие-то хуйни, вот как в той хрени https://govnokod.ru/27420
    то можем дополнительно синтезировать высказывание "%B"
    
    А теоремы это negj композиции из аксиом и других теорем. Типы можно прикручивать через какую-то хуйню
    типа если арифметику Пеано описывать, тип можно так что-то нахуевертить аксиому, ну типа
    
    Определение что ZERO это натуральное число.
    AXIOM
    _
    P NAT ZERO
    
    Что если инкрементнуть натуральное, будет тоже натуральное (S это функция следования)
    AXIOM
    P S %A
    P NAT %A
    _
    P NAT P S %A
    
    В общем надо бы подумать, как там запилить максимально простой и эффективно расширяемый язык для
    доказывания всякой хуйни.
    
    Смотрел Coq - какая-то ебаная перепитушня со всякими там типами-хуипами и какими-то
    блядь рекурсиями. Хер поймешь, как эта вся дрнсня работает. Меня ваши типы не ебут
    совершенно, я хочу сам свои типы конструировать, а не полагаться на какую-то невнятную
    ебанину.

    j123123, 05 Июля 2021

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

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stdbool.h>
    #include <math.h>
    
    #define width 65
    #define height 25
    
    char mas[height][width+1];
    
    typedef struct {
      int x, y, w;
    } TRocket;
    
    TRocket racket;
    
    typedef struct {  float x, y;  int ix, iy;  float alfa;  float speed;} TBall;
    
    TBall ball;
    
    int hitCnt = 0;int maxHitCnt = 0;
    
    void init(int level)
    {  for(int w=0; w<width; w++)   mas[0][w] = '#';  strncpy(mas[1], mas[0], width)  for(int w=1; w < width-1; w++)   mas[1][w] = ' ';  for(int h=2; h < height; h++)    strncpy(mas[h], mas[1], width);
      if(level == 1)
      {
        for(int w=10; w < width-10; w++)
          mas[5][w] = '#';
      }
    }
    
    void show()
    {
      for(int x=0; x<height; x++)
      {
        printf("%s", mas[x]);   if(x == 3)
          printf("   hit: %d", hitCnt);
        if(x == 4)     printf("   max: %d", maxHitCnt);
        printf("\n");
      }
    }
    
    void initRocket()
    {
      racket.w = 7;
      racket.x = (width - racket.w) / 2;
      racket.y = height - 1;
    }
    
    void initBall()
    {
      moveBall(2.0, 2.0);
      ball.alfa = -1;
      ball.speed = 0.5;
    }
    
    void putBall()
    {
      mas[ball.iy][ball.ix] = '*';
    }
    
    void moveBall(float x, float y)
    {
      ball.x = x;
      ball.y = y;
      ball.ix = (int)ball.x;
      ball.iy = (int)ball.y;
    }
    
    void autoMoveBall()
    {
      if(ball.alfa < 0) ball.alfa += M_PI*2;
      if(ball.alfa > M_PI*2) ball.alfa -= M_PI*2;
      TBall bl = ball;
      moveBall(ball.x + cos(ball.alfa) * ball.speed,
               ball.y + sin(ball.alfa) * ball.speed);
      if(mas[ball.iy][ball.ix] == '#' || mas[ball.iy][ball.ix] == '@')
      {
        if(mas[ball.iy][ball.ix] == '@')

    ебаный рот!

    rom4ik, 03 Июля 2021

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