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

    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
    class XFoo {
        pin: number;
        buf: number[];
    
        constructor(k: number, l: number) {
            this.pin = k - l;
        }
    
        setPin(p: number) {
            this.pin = p;
        }
    
        getPin() {
            return this.pin;
        }
    
        init() {
            this.buf = [1, 2];
        }
    
        toString() {
            return `Foo${this.getPin()}`;
        }
    }
    
    function main() {
        let f = new XFoo(44, 2);
        let s = "" + f;
        print(s);
    }

    я вам тут хрень принес.. новая фича :)

    ASD_77, 19 Июля 2021

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

    +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
    abstract class Department {
        constructor(public name: string) {}
    
        printName(): void {
            print("Department name: " + this.name);
        }
    
        abstract printMeeting(): void; // must be implemented in derived classes
    }
    
    class AccountingDepartment extends Department {
        constructor() {
            super("Accounting and Auditing"); // constructors in derived classes must call super()
        }
    
        printMeeting(): void {
            print("The Accounting Department meets each Monday at 10am.");
        }
    
        generateReports(): void {
            print("Generating accounting reports...");
        }
    }
    
    function main() {
        let department: Department; // ok to create a reference to an abstract type
        department = new AccountingDepartment(); // ok to create and assign a non-abstract subclass
        department.printName();
        department.printMeeting();
        //department.generateReports(); // error: department is not of type AccountingDepartment, cannot access generateReports
        print("done.");
    }

    Алилуя - я вам абстракты принес :)

    ASD_77, 16 Июля 2021

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    /* В отдельном файле */
    function Skif_Email(auth,em) {
    	em = em.substring(3,em.length-3);
    	auth = auth.substring(4,auth.length-4);
    	document.write('<a href="mailto:',em,'" title="Защищён от спам-роботов">',auth,'</a>');
    }
    
    /* На странице */
    
    <script type="text/javascript">Skif_Email('[email protected]', '[email protected]');</script>

    Какая защита )))

    HEu3BECTHblu_nemyx, 16 Июля 2021

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    class Point {
      x = 0;
      y = 0;
    }
    
    function main() {
      const pt = new Point();
      // Prints 0, 0
      print(`${pt.x}, ${pt.y}`);
    }

    вот пока вы тут языки чесали - я наваял новую фичу. а кто догадается что особенного в этом классе? в чем фича?

    ASD_77, 12 Июля 2021

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

    +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
    class Animal {
        name: string;
    
        constructor(name: string) {
            this.name = name;
        }
    
        speak() {
            print(`${this.name} makes a noise.`);
        }
    }
    
    class Dog extends Animal {
        constructor(name: string) {
            super(name); // call the super class constructor and pass in the name parameter
        }
    
        speak() {
            print(`${this.name} barks.`);
        }
    }
    
    function main() {
        let d = new Dog("Mitzie");
        d.speak(); // Mitzie barks.
        print(d.name);
    }

    Я вам принес нового говнокода для нового говнокомпилятора.... дамп в следующем посту

    ASD_77, 12 Июля 2021

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

    +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
    async Create(id, subscribe_yyyymmdd) {
      const query = "INSERT INTO users(id,subscribe_yyyymmdd) VALUES ($1,$2) RETURNING *";
      const values = [id, subscribe_yyyymmdd];
      try {
        const result = await this.db.query(query, values);
        return result.rows[0].id;
      } catch (error) {
        this.logger.error(error);
      }
    },
    
    async Update() {
      const query = "UPDATE users SET subscribe_yyyymmdd = $1 where id=$2 RETURNING *";
      const values = [id, subscribe_yyyymmdd];
      try {
        const result = await this.db.query(query, values);
        return result.rows[0].id;
      } catch (error) {
        this.logger.error(error);
      }
    },

    Из https://vk.com/wall521764930_6553 .

    PolinaAksenova, 11 Июля 2021

    Комментарии (1024)
  7. 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)
  8. 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)
  9. 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)
  10. JavaScript / Говнокод #27489

    +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
    namespace fooX.bar.baz {
        export class A {
            foo() {
                glb1++
            }
        }
        export function b() {
            glb1++
            glb1++
        }
    }
    
    import bz = fooX.bar.baz
    import AA = fooX.bar.baz.A
    function testImports() {
        glb1 = 0
        bz.b()
        let x = new AA()
        x.foo()
        assert(glb1 == 3, "imports")
    }
    
    function main()
    {
      testImports()
    }

    Даже и не знаю, что вам тут еще наговнокодить... вот работаю над неймспейсами ..

    ASD_77, 29 Июня 2021

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