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

    −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
    69. 69
    70. 70
    71. 71
    let SPAM = {
      "lastWsMessage": null,
      "lastWsLink": null,
      "specialFunctionWS": (urlws) => {
        SPAM.lastWsLink = urlws;
        let ws = new WebSocket(urlws);
        ws.onopen = () => {
          console.log("connected");
          return "connected";
        };
        ws.onclose = () => {
          console.log("disconnected");
          return "disconnected";
        };
        ws.onerror = () => {
          console.log("error");
          return "error";
        };
        ws.onmessage = (event) => {
          console.log("message ${event.data}");
          SPAM.lastWsMessage = event.data;
        };
      },
      "spammer": (text, amount) => {
        for(let a = 0; a < amount; a++) {
          console.log(text);
        };
        return amount;
      },
      "wsConnecting": (url) => {
        let splitter = url.split(":");
        if(splitter[0] == "ws") {
          console.log("WARNING: it is not advised to use the value \"ws\"!");
          SPAM.specialFunctionWS(url);
        };
        if(splitter[0] == "wss") {
          SPAM.specialFunctionWS(url);
        };
        if(splitter[0] == "http" || splitter[0] == "https") {
          console.log("WARNING: don't use the values http/https for socket connecting!\nLink changed: wss://" + url);
          SPAM.specialFunctionWS("wss://" + url);
        };
        if(splitter.length == 1) {
          console.log("WARNING: script is using the value \"wss\"!");
          SPAM.specialFunctionWS("wss://" + url);
        };
      },
      "SendWs": (message) => {
        if(SPAM.lastWsLink != null) {
          let ws = new WebSocket(SPAM.lastWsLink);
        ws.onopen = () => {
          console.log("connected");
          return "connected";
        };
        ws.onclose = () => {
          console.log("disconnected");
          return "disconnected";
        };
        ws.onerror = () => {
          console.log("error");
          return "error";
        };
        ws.onmessage = (event) => {
          console.log("message ${event.data}");
          SPAM.lastWsMessage = event.data;
        };
        } else {
          console.log("ERROR: last connection not found!");
        };
      }
    };

    govnokod!

    govnokoder666, 03 Января 2022

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

    +1

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

    #111: https://govnokod.ru/27644 https://govnokod.xyz/_27644
    #112: https://govnokod.ru/27648 https://govnokod.xyz/_27648
    #113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
    #114: https://govnokod.ru/27659 https://govnokod.xyz/_27659
    #115: https://govnokod.ru/27665 https://govnokod.xyz/_27665
    #116: https://govnokod.ru/27671 https://govnokod.xyz/_27671
    #117: https://govnokod.ru/27675 https://govnokod.xyz/_27675
    #118: https://govnokod.ru/27685 https://govnokod.xyz/_27685
    #119: https://govnokod.ru/27701 https://govnokod.xyz/_27701
    #120: https://govnokod.ru/27703 https://govnokod.xyz/_27703
    #121: https://govnokod.ru/27710 https://govnokod.xyz/_27710
    #122: https://govnokod.ru/27728 https://govnokod.xyz/_27728
    #123: https://govnokod.ru/27729 https://govnokod.xyz/_27729
    #124: https://govnokod.ru/27730 https://govnokod.xyz/_27730
    #125: https://govnokod.ru/27732 https://govnokod.xyz/_27732
    #126: https://govnokod.ru/27733 https://govnokod.xyz/_27733
    #127: https://govnokod.ru/27737 https://govnokod.xyz/_27737
    #128: https://govnokod.ru/27742 https://govnokod.xyz/_27742
    #129: https://govnokod.ru/27747 https://govnokod.xyz/_27747
    #130: https://govnokod.ru/27755 https://govnokod.xyz/_27755
    #131: https://govnokod.ru/27766 https://govnokod.xyz/_27766
    #132: https://govnokod.ru/27790 https://govnokod.xyz/_27790
    #133: https://govnokod.ru/27828 https://govnokod.xyz/_27828
    #134: https://govnokod.ru/27834 https://govnokod.xyz/_27834
    #135: https://govnokod.ru/27839 https://govnokod.xyz/_27839
    #136: https://govnokod.ru/27845 https://govnokod.xyz/_27845
    #137: https://govnokod.ru/27857 https://govnokod.xyz/_27857
    #138: https://govnokod.ru/27867 https://govnokod.xyz/_27867
    #139: https://govnokod.ru/27887 https://govnokod.xyz/_27887
    #140: https://govnokod.ru/27900 https://govnokod.xyz/_27900

    nepeKamHblu_nemyx, 02 Января 2022

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

    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
    function move1(direction: "up" | "down") {
        switch (direction) {
            case "up":
                return 1;
            case "down":
                return -1; 
        }
    
        return 0;
    }
    
    function main() {
    
        print(move1("up"));
        print(move1("down"));
    
        print("done.");
    }

    а ты умеешь так говнокодить на C/C++?

    ASD_77, 02 Января 2022

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

    +1

    1. 1
    description = f"""У тебя , **{ctx.author}** вот столько балов!**{cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]} :polegar_para_cima:**"""

    Насмотревшиеся Хауди Хо ботопейсатели - это, конечно, нечто.
    1. Выполнение SQL-запроса вставлено прямо в шаблонизируемую строку
    2. Сам запрос формируется через форматирование строки (привет, Бобби Тейблз!)
    3. Не проверяется, вернула ли база хоть что-то.

    "Не могу понять в чем проблема?" (с)

    Vindicar, 02 Января 2022

    Комментарии (48)
  5. JavaScript / Говнокод #27911

    +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
    type CreateMutable<Type> = {
      -readonly [Property in keyof Type]: Type[Property];
    };
     
    type LockedAccount = {
      readonly id: string;
      readonly name: string;
    };
    
    type UnlockedAccount = CreateMutable<LockedAccount>;
    
    function main() {
        let a: LockedAccount;
        let b: UnlockedAccount;
    
        print("done.");
    }

    Я вам наговнокодил новую фичу.. называется "mapped type"

    ASD_77, 01 Января 2022

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

    0

    1. 1
    2. 2
    3. 3
    var x1: number;
    x1 = value;
    (x1) = value;

    чем одна строка отличается от другой?

    ASD_77, 01 Января 2022

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

    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
    'use strict'
     
    const {TheCtrl} = require('the-controller-base')
    const {withAuthorized} = require('the-controller-mixins')
     
    async function tryExample () {
      class MyCtrl extends withAuthorized(TheCtrl) {
        /* ... */
      }
    }
     
    tryExample().catch((err) => console.error(err))

    Mixins for the-controller

    Installation
    $ npm install the-controller-mixins --save

    Очень полезный и нужный пакет. Пользуйтесь.
    https://www.npmjs.com/package/the-controller-mixins/v/2.1.0

    3_dar, 31 Декабря 2021

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

    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
    export type Maybe<T> = null | undefined | T;
    
    export interface Path {
        readonly prev: Path | undefined;
        readonly key: string | number;
        readonly typename: string | undefined;
    }
    
    /**
     * Given a Path and a key, return a new Path containing the new key.
     */
    export function addPath(
        prev: Readonly<Path> | undefined,
        key: string | number,
        typename: string | undefined,
    ): Path {
        return { prev, key, typename };
    }
    
    /**
     * Given a Path, return an Array of the path keys.
     */
    export function pathToArray(
        path: Maybe<Readonly<Path>>,
    ): Array<string | number> {
        let curr = path;
        let flattened = [];
        while (curr) {
            flattened.push(curr.key);
            curr = curr.prev;
        }
        //flattened.reverse();
        return flattened;
    }
    
    function main() {
        let pathArray = pathToArray({
            key: "path",
            prev: undefined,
            typename: undefined,
        });
        for (let x of pathArray) {
            print(x);
        }
    }

    последний коммит позволяет скомпилить и выполнить данный код. это невиданный прогресс в компиляторе :)

    и уже традиционный вопрос ... а ты там можешь наговнокодить на С/C++?

    ASD_77, 31 Декабря 2021

    Комментарии (26)
  9. Java / Говнокод #27903

    +2

    1. 1
    2. 2
    - null, null, null, null, null, null, null, null, null, null, null, null, null, null))
    + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null))

    Это реальный коммит с работы
    (не мой, я к jawa не притрагиваюсь)

    3_dar, 30 Декабря 2021

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

    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
    interface Animal {
      live(): void;
    }
    interface Dog extends Animal {
      woof(): void;
    }
     
    type Example1 = Dog extends Animal ? number : string;
     
    type Example2 = RegExp extends Animal ? number : string;
    
    function main() {
    
        let a: Example1;
        a = 10.0;
    
        print(a);
      
        let b: Example2;
        b = "asd";
    
        print(b);
    
        print("done.");
    }

    "Условные типа" подвезли.... ура ... теперь можно всякую х. наговнокодить..

    ASD_77, 28 Декабря 2021

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