Category: Blog

  • pi-stream

    pi-stream

    Raspberry Pi/FastAPI service for streaming HDMI video/audio over the internet using the WebRTC protocol

    Utilizes https://github.com/meetecho/janus-gateway, https://github.com/catid/kvm

    Requirements

    1. Raspberry Pi 4 running 32-bit Raspberry Pi OS (tested with 4 GB RAM)
    2. HDMI-to-USB Capture Card supporting MJPG capture format
    3. (If on corporate network) A STUN/TURN server (see docs/stun.md)

    Setup

    cd /home/pi
    git clone https://github.com/MattWeinberg24/pi-stream.git
    cd pi-stream
    1. edit docker-compose.yml in vim or nano to configure environment variables

    Usage

    1. docker compose up
    2. Navigate to http://<PI IP>:<FASTAPI PORT>/static/index.html in Chrome or Edge (Firefox untested)
    3. Enter STUN/TURN information for frontend
    4. Use the API
      • Test buttons available on the above site
      • Full API documentation available at http://<PI IP>:<FASTAPI PORT>/docs
      • Selected topics detailed in /docs
    • Frontend debug messages can be found in the browser console
    • Backend debug messages can be found through docker’s output

    Ports

    • 8088
      • Janus Gateway WebRTC Server
    • 8000
      • Python FastAPI
      • HTML/Javascript served at /static/index.html on this port
      • Docs served at /docs on this port
    • 5002
      • gstreamer opus RTP audio stream
      • (Used internally)

    Special Thanks

    KVM (Video) Janus plugin by Chris Taylor (https://github.com/catid)

    Janus Gateway server and javascript library by Meetecho (https://github.com/meetecho)

    Mentors and coworkers during my summer internship

    Contact: mattweinberg@wustl.edu

    Visit original content creator repository
    https://github.com/MattWeinberg24/pi-stream

  • dodo-database-service

    Overview

    This repository is intended as a playground to calculate and verify KPIs and metrics defined in the research project DoDo.
    The repository contains a description of the calculated KPIs here.

    The documentation of the fundamental data model for this KPI system can be accessed here.

    Further Repositories

    An additional project is used to visualize the calculated data and can be found here.
    To deploy the complete setup using docker and adding traefik for routing between the containers you can use this repository.

    Installation

    $ npm install

    Running the app

    Start the database by running docker-compose up -d. Per default a web interface displaying the current state of the database is launched on localhost:8081. The credentials are defined in the docker-compose file.

    # development
    $ npm run start
    
    # watch mode
    $ npm run start:dev
    
    # production mode
    $ npm run start:prod

    OpenApi

    The OpenApi description of this API is reachable on the /api endpoint.

    Test

    # unit tests
    $ npm run test
    
    # e2e tests
    $ npm run test:e2e
    
    # test coverage
    $ npm run test:cov

    Run the statistic tests

    $ npm test

    If you run the newest Linux Version (21) you might run into problems, because the mongodb binary is not found. In this case manually set the binary download url as an environment variable (MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-5.0.3.tgz).

    Configuration

    Create local .env.local file in which you store a GitHub access token under the GITHUB_ACCESS_TOKEN key. The GitHub REST API is restricted to 60 requests per hour if you don’t use any access token and this will be exceeded by one of the predefined queries. For more details of the limited rates see the GitHub documentation.

    Database

    Add the URI and user credentials for your database to the .env.local file.

    DB_URI=mongodb://localhost:27017/<shouldReflectYourDatabaseDefinedInDockerCompose>
    DB_USER=<userName as defined in docker-compose>
    DB_USER_PASSWORD=<password as defined in docker-compose>

    The user credentials have to match the ones defined in the docker-compose.yml.

    In order to get a clean setup you have to remove the docker volume! Use docker volume rm visu-code-db-service_mongodb-data for that.

    Windows Only

    Make sure the mongo-init.sh is stored with LF line endings!

    Visit original content creator repository
    https://github.com/fraunhofer-iem/dodo-database-service

  • Seanpm2001_WorldDB_DB_Earth_British-Columbia


    {Project icon} This image failed to load. It may be due to the file not being reached, or a general error. Reload the page to fix a possible general error.

    By:

    Seanpm2001, Et; Al.

    Top

    README.md


    Read this article in a different language

    Sorted by: A-Z

    Sorting options unavailable

    ( af Afrikaans Afrikaans | sq Shqiptare Albanian | am አማርኛ Amharic | ar عربى Arabic | hy հայերեն Armenian | az Azərbaycan dili Azerbaijani | eu Euskara Basque | be Беларуская Belarusian | bn বাংলা Bengali | bs Bosanski Bosnian | bg български Bulgarian | ca Català Catalan | ceb Sugbuanon Cebuano | ny Chichewa Chichewa | zh-CN 简体中文 Chinese (Simplified) | zh-t 中國傳統的) Chinese (Traditional) | co Corsu Corsican | hr Hrvatski Croatian | cs čeština Czech | da dansk Danish | nl Nederlands Dutch | en-us English English | EO Esperanto Esperanto | et Eestlane Estonian | tl Pilipino Filipino | fi Suomalainen Finnish | fr français French | fy Frysk Frisian | gl Galego Galician | ka ქართველი Georgian | de Deutsch German | el Ελληνικά Greek | gu ગુજરાતી Gujarati | ht Kreyòl ayisyen Haitian Creole | ha Hausa Hausa | haw Ōlelo Hawaiʻi Hawaiian | he עִברִית Hebrew | hi हिन्दी Hindi | hmn Hmong Hmong | hu Magyar Hungarian | is Íslenska Icelandic | ig Igbo Igbo | id bahasa Indonesia Icelandic | ga Gaeilge Irish | it Italiana/Italiano | ja 日本語 Japanese | jw Wong jawa Javanese | kn ಕನ್ನಡ Kannada | kk Қазақ Kazakh | km ខ្មែរ Khmer | rw Kinyarwanda Kinyarwanda | ko-south 韓國語 Korean (South) | ko-north 문화어 Korean (North) (NOT YET TRANSLATED) | ku Kurdî Kurdish (Kurmanji) | ky Кыргызча Kyrgyz | lo ລາວ Lao | la Latine Latin | lt Lietuvis Lithuanian | lb Lëtzebuergesch Luxembourgish | mk Македонски Macedonian | mg Malagasy Malagasy | ms Bahasa Melayu Malay | ml മലയാളം Malayalam | mt Malti Maltese | mi Maori Maori | mr मराठी Marathi | mn Монгол Mongolian | my မြန်မာ Myanmar (Burmese) | ne नेपाली Nepali | no norsk Norwegian | or ଓଡିଆ (ଓଡିଆ) Odia (Oriya) | ps پښتو Pashto | fa فارسی |Persian pl polski Polish | pt português Portuguese | pa ਪੰਜਾਬੀ Punjabi | No languages available that start with the letter Q | ro Română Romanian | ru русский Russian | sm Faasamoa Samoan | gd Gàidhlig na h-Alba Scots Gaelic | sr Српски Serbian | st Sesotho Sesotho | sn Shona Shona | sd سنڌي Sindhi | si සිංහල Sinhala | sk Slovák Slovak | sl Slovenščina Slovenian | so Soomaali Somali | [es en español Spanish | su Sundanis Sundanese | sw Kiswahili Swahili | sv Svenska Swedish | tg Тоҷикӣ Tajik | ta தமிழ் Tamil | tt Татар Tatar | te తెలుగు Telugu | th ไทย Thai | tr Türk Turkish | tk Türkmenler Turkmen | uk Український Ukrainian | ur اردو Urdu | ug ئۇيغۇر Uyghur | uz O’zbek Uzbek | vi Tiếng Việt Vietnamese | cy Cymraeg Welsh | xh isiXhosa Xhosa | yi יידיש Yiddish | yo Yoruba Yoruba | zu Zulu Zulu ) Available in 110 languages (108 when not counting English and North Korean, as North Korean has not been translated yet Read about it here)

    Translations in languages other than English are machine translated and are not yet accurate. No errors have been fixed yet as of March 21st 2021. Please report translation errors here. Make sure to backup your correction with sources and guide me, as I don’t know languages other than English well (I plan on getting a translator eventually) please cite wiktionary and other sources in your report. Failing to do so will result in a rejection of the correction being published.

    Note: due to limitations with GitHub’s interpretation of markdown (and pretty much every other web-based interpretation of markdown) clicking these links will redirect you to a separate file on a separate page that isn’t the intended page. You will be redirected to the .github folder of this project, where the README translations are hosted.

    Translations are currently done with Bing translate and DeepL. Support for Google Translate translations is coming to a close due to privacy concerns.


    Index

    00.0 – Top

    00.1 – Title

    00.2 – Read this article in a different language

    00.3 – Index

    01.0 – Description

    02.0 – About

    03.0 – Wiki

    04.0 – History

    04.1 – Pre-history

    04.2 – Alpha History

    04.3 – Beta History

    04.4 – Modern History

    05.0 – Copying

    06.0 – Credits

    07.0 – Installation

    08.0 – Version history

    09.0 – Version history

    10.0 – Software status

    11.0 – Sponsor info

    12.0 – Contributers

    13.0 – Issues

    13.1 – Current issues

    13.2 – Past issues

    13.3 – Past pull requests

    13.4 – Active pull requests

    14.0 – Resources

    15.0 – Contributing

    16.0 – About README

    17.0 – README Version history

    18.0 – Footer

    18.9 – End of file


    <repo_description>


    About

    See above.


    Wiki

    Click/tap here to view this projects Wiki

    If the project has been forked, the Wiki was likely removed. Luckily, I include an embedded version. You can view it here.


    History

    Write about this projects history here.

    Pre-history

    No pre-history to show for this project.

    Alpha history

    No Alpha history to show for this project.

    Beta history

    No Beta history to show for this project.

    Modern history

    No Modern history to show for this project.


    Copying

    View the copying license for this project here (if you haven’t built the project yet with the makefile, here is the original link: COPYINGL

    Please note that you also have to follow the rules of the GNU General Public License v3 (GPL3) which you can view here


    Credits

    View the credits file for this project and see the people who got together to make this project by clicking/tapping here


    Installation

    View the installation instructions file for this project here

    Requirements: Read the instructions for more info, and get the latest up-to-date instructions here


    Sponsor info

    SponsorButton.png

    You can sponsor this project if you like, but please specify what you want to donate to. See the funds you can donate to here

    You can view other sponsor info here

    Try it out! The sponsor button is right up next to the watch/unwatch button.


    Version history

    Version history currently unavailable

    No other versions listed


    Software status

    All of my works are free some restrictions. DRM (Digital Restrictions Management) is not present in any of my works.

    DRM-free_label.en.svg

    This sticker is supported by the Free Software Foundation. I never intend to include DRM in my works.

    I am using the abbreviation “Digital Restrictions Management” instead of the more known “Digital Rights Management” as the common way of addressing it is false, there are no rights with DRM. The spelling “Digital Restrictions Management” is more accurate, and is supported by Richard M. Stallman (RMS) and the Free Software Foundation (FSF)

    This section is used to raise awareness for the problems with DRM, and also to protest it. DRM is defective by design and is a major threat to all computer users and software freedom.

    Image credit: defectivebydesign.org/drm-free/…


    Contributers

    Currently, I am the only contributer. Contributing is allowed, as long as you follow the rules of the CONTRIBUTING.md file.

      1. seanpm2001 – x commits (As of Yr, DoW, Month, DoM, at ##:## a/pm)
      1. No other contributers.

    Issues

    Current issues

    • None at the moment

    • No other current issues

    If the repository has been forked, issues likely have been removed. Luckily I keep an archive of certain images here

    Read the privacy policy on issue archival here

    TL;DR

    I archive my own issues. Your issue won’t be archived unless you request it to be archived.

    Past issues

    • None at the moment

    • No other past issues

    If the repository has been forked, issues likely have been removed. Luckily I keep an archive of certain images here

    Read the privacy policy on issue archival here

    TL;DR

    I archive my own issues. Your issue won’t be archived unless you request it to be archived.

    Past pull requests

    • None at the moment

    • No other past pull requests

    If the repository has been forked, issues likely have been removed. Luckily I keep an archive of certain images here

    Read the privacy policy on issue archival here

    TL;DR

    I archive my own issues. Your issue won’t be archived unless you request it to be archived.

    Active pull requests

    • None at the moment

    • No other active pull requests

    If the repository has been forked, issues likely have been removed. Luckily I keep an archive of certain images here

    Read the privacy policy on issue archival here

    TL;DR

    I archive my own issues. Your issue won’t be archived unless you request it to be archived.


    Resources

    Here are some other resources for this project:

    Project language file A

    Join the discussion on GitHub

    No other resources at the moment.


    Contributing

    Contributing is allowed for this project, as long as you follow the rules of the CONTRIBUTING.md file.

    Click/tap here to view the contributing rules for this project


    About README

    File type: Markdown Document (*.md *.mkd *.markdown)

    File version: 0.1.6 (Monday, August 23rd 2021 at 6:37 pm)

    Line count (including blank lines and compiler line): 0,407


    README version history

    Version 0.1 (Sunday, March 21st 2021 at 7:50 pm)

    Changes:

    • Started the file
    • Added the title section
    • Added the index
    • Added the about section
    • Added the Wiki section
    • Added the version history section
    • Added the issues section.
    • Added the past issues section
    • Added the past pull requests section
    • Added the active pull requests section
    • Added the contributors section
    • Added the contributing section
    • Added the about README section
    • Added the README version history section
    • Added the resources section
    • Added a software status section, with a DRM free sticker and message
    • Added the sponsor info section

    ITERATION 5

    • Updated the title section
    • Updated the index
    • Added the history section
    • Updated the file info section
    • Updated the file history section

    ITERATION 6

    • Updated the title section
    • Fixed and update template links
    • Updated the index
    • Added the copying section
    • Added the credits section
    • Added the installation section
    • Updated the resources section
    • Updated the contributors section
    • Added the technical notes section
    • Updated the footer
    • Updated the file info section
    • Updated the file history section
    • No other changes in version 0.1

    Version 1 (Coming soon)

    Changes:

    • Coming soon
    • No other changes in version 1

    Version 2 (Coming soon)

    Changes:

    • Coming soon
    • No other changes in version 2

    You have reached the end of the README file

    ( Back to top | Exit to GitHub | Exit to Bing | Exit to DuckDuckGo | Exit to Ecosia )

    EOF


    Visit original content creator repository https://github.com/seanpm2001/Seanpm2001_WorldDB_DB_Earth_British-Columbia
  • decretorilancio

    decretorilancio 34/2020 and Legge 77/2020

    You can read the narrative at https://robertolofaro.com/swarmlaw

    Concept:

    1. on 2020-05-19 the Italian Government released a 263-pages, 266-articles Government Decree for the post-COVID19 restart of the Italian economy.
    2. on 2020-05-20/21 released a webapp https://robertolofaro.com/decreto (search by tag cloud)
    3. on 2020-05-20 and 23 released a Kaggle frequency dataset https://www.kaggle.com/robertolofaro/decreto-rilancio-dl-20200519-word-frequencies
    4. on 2020-06-03 updated the webapp to add the linkup to the actual text of each article stored here, to allow for line-by-line reference
    5. on 2020-07-18 the Italian Government released on the Gazzetta Ufficiale Law 77 of 2020-07-17, replacing the decree; 155 implementation (“decreti attuativi”) will have to follow within 90 days
    6. on 2020-07-18 started the update of the GitHub and local database, to be released officially on 2020-07-21; pending the update, the GitHub content is not accessible from the application (only the tag cloud is visible), and the GitHub content update will be completed by 2020-07-20 11 AM UTC
    7. on 2020-11-21 added the reference to the new webapp that has been available since 2020-07-20, in preparation of the release of a new repository focused on a further Government Decree converted into Law (Decreto Semplificazioni – Law 120 of 2020-09-11, published on Gazzetta Ufficiale on 2020-09-14), that modified some elements of Law 77

    There are two mini webapps:

    1. on Decreto Rilancio 34/2020 https://robertolofaro.com/decreto
    2. on Legge 77/2020 https://robertolofaro.com/legge77 (conversion into law of Decreto 34/2020, with changes and amendments)

    The latter includes also a visualization of the timeframe of impacts of each article

    Purpose: an experiment in dissemination to ease access and evidence-based negotiation using open data and open platforms, without necessarily being involved in the ensuing uses

    Next steps: further experiments and probably updated on the webapp and Kaggle dataset based upon request

    Disclosure: beside my Italian passport, I have neither political nor organizational affiliation with any State, local authorities, or private sector organization in this endeavour

    Contacts: https://robertolofaro.com/in/robertolofaro

    Visit original content creator repository
    https://github.com/robertolofaro/decretorilancio

  • prototype-programming

    Prototype based programming

    Introduction

    Prototype based programming is a style of object orientated programming. It is commonly referred to as object based programming because it lacks classes and instead relies solely on objects. Objects can contain values, methods or references to other objects.

    Self was designed in 1986 and was one of the first prototype orientated programming languages. In recent years the paradigm has become increasingly popular due to the rise of JavaScript. Traditionally JavaScript was used as a scripting language. However, the expanding complexity of front-end applications and the development of Node.js on the server-side has resulted in the JavaScript community progressively favouring a prototype based approach.

    Today we will discuss the historical background of prototype based programming, how prototypes can be used, and their main advantages and limitations. We will also canvas JavaScript classes that were introduced in ECMAScript 2015 and explain why their introduction has been criticised by some commentators as syntactic sugar for JavaScript’s existing prototype based system. To conclude, a reflection will be offered on prototype based programming in the context of other programming paradigms.

    Although many languages now support prototype based programming, JavaScript examples will be used.

    Historical background

    The idea of a prototype stems back to a philosophical dispute on the representation of abstractions in the 20th century. Ludwig Wittgenstein at the time observed that it was difficult to say in advance exactly what characteristics are necessary to define a category. Wittgenstein instead proposed what can now be considered the origin of prototype based programming – the concept of family resemblance. This concept advocates that objects in a particular category may be connected via numerous similarities, but there is not necessarily one feature that is common to all objects in a category. Thus, the family resemblance approach determines whether an object belongs in a category by considering whether it is similar to a standard representation of that category.

    Henry Lieberman popularised prototypes and the concept of delegation as an alternative object orientated paradigm in his 1986 paper. Lieberman introduced prototypes with an example of trying to categorise elephants. In short, the example considers an individual, John, who has never heard of or seen an elephant before. If John was to meet an elephant named Bob, then when thinking about elephants John would think of Bob because that is the only concrete example John has of an elephant. If John was to then meet another elephant, Sarah, who is smaller than Bob – John is likely to categorise Sarah as similar to Bob but smaller in size.

    Lieberman’s example illustrates how the primary idea behind prototype based programming is to use a concrete example to represent an object, and then use cloning or adding of new properties to present newfound knowledge of the model.

    Object creation

    An object is a collection of properties. A property is an association between a key and a value. A property’s value can also be a function, in which case the property is referred to as a method. Although there are multiple approaches to creating objects in JavaScript, they all fall into one of two categories: ex nihilo object creation or through cloning an existing object.

    Ex nihilo object creation allows new objects to be created without cloning from an existing defined object.

    // An object created ex nihilo using literal object notation
    var dog = { name: 'Max', breed: 'Poodle' };

    An alternative to using literal object notation is to write a constructor function and create new object instances with the reserved word new. Each instance of the object will have its own properties.

    function Dog(name, breed) {
        this.name = name;
        this.breed = breed;
        bark: function() {
            console.log("Woof!");
        };
    };        
    
    var poodle = new Dog('Max', 'Poodle');
    var dalmatian = new Dog('Bobby', 'Dalmatian');
    
    console.log(poodle.name); // Output is 'Max'
    console.log(dalmatian.name); // Output is 'Bobby'

    The Object.create method can be used in place of a explicitly defined constructor function.

    var Dog = {
        name = "Max";
        breed = "Poodle";
        bark: function() {
            console.log("Woof!");
        };
    };
    
    var max = Object.create(Dog);
    max.bark(); // Output is 'Woof!'

    A new object can also be created by cloning the behaviour of an existing object. The cloned object will have the same properties as the original. Once created, the new object can also be modified.

    var dog = { name: 'Max', breed: 'Poodle' };
    
    // The newDog object is created by cloning the dog object
    var newDog = Object.assign({}, dog);
    
    console.log(dog.name); // Output is 'Max'
    console.log(newDog.name); // Output is 'Max'
    
    newDog.name = "Jessica";
    
    console.log(dog.name); // Output is 'Max'
    console.log(newDog.name); // Output is 'Jessica'

    Delegation and Inheritance

    The language feature that supports prototype based programming is delegation. Objects can be cloned and extended via delegation. This principle provides that when accessing a property of an object, the property will be sought on the object and also all other objects in the prototype chain. Objects inherit directly through a prototype property. Every object has a prototype link to another object. Objects by default are linked to the object Object.prototype.

    var Dog = function() {
        this.name = "Patch";
    }
    
    var patch = new Dog();
    
    Dog.prototype.breed = "Great Dane";
    
    console.log(patch.name); // Output is 'Patch'
    console.log(patch.breed); // Output is 'Great Dane'

    In the above example, the patch object contains the name property. The breed property is also found by traversing the prototype chain and accessing its prototype. Using the .prototype property of Dog, new properties can be assigned so that when a new object is created from the Dog constructor function, those properties will be available to the new object.

    The prototype chain in this example can be visually illustrated as follows:

    If you’re a visual learner, Dave Atchley provides many more examples.

    All objects can be altered or extended using prototypes, including JavaScript’s native object prototypes such as string and array. However, this is generally considered bad practice particularly from the point of view of code integration. It is very common to use use libraries and frameworks in JavaScript which rely upon the standard implementations of the native prototypes. In addition, when working within a team, modifications to the already existing JavaScript objects can cause confusion and hours of lost time. In almost all cases it is more appropriate to create a new object to encapsulate the desired functionality.

    Cloning

    If an object is created by cloning using Object.assign(), then the top level properties of that object are copied to the new object without any reference. However, if a value is a reference to an object, then the reference will be copied and not the value.

    var book = {
        id: 1,
        authors: {
            author1: "John Jims"
        }
    };
    
    var newBook = Object.assign({}, book);
    
    console.log(book.authors.author1); // Output is 'John Jims'
    console.log(newBook.authors.author1); // Output is 'John Jims'
    
    // Update author1 value for the book object
    book.authors.author1 = "Jess Simpson";
    
    console.log(book.authors.author1); // Output is 'Jess Simpson'
    console.log(newBook.authors.author1); // Output is 'Jess Simpson'

    In the above example, newBook maintains a link to its prototype. Changes in the object reference to the prototype will cause a corresponding change in newBook.

    The use of ‘this’

    In prototype based programming, any function can be added to an object in the form of a property. An inherited property will behave the same as any other property. When an inherited function is invoked, the value of this will point to the inherited object, not the prototype object where the function is a property.

    var calculate = {
        num: 5,
        sum: function() {
            return this.num + 5;
        }
    };
    
    // When executing calculate.sum, 'this' refers to the calculate object
    console.log(calculate.sum()); // Output is '10'
    
    // modifier is an object that inherits from calculate
    var modifier = Object.create(calculate);
    
    modifier.num = 20;
    
    // When executing modifier.sum, 'this' refers to the modifier object
    console.log(modifier.sum()); // Output is '25'

    Performance

    Most JavaScript engines use a dictionary-like data structure to store object properties. Consequently the lookup time for properties that are high in the prototype chain can have a negative impact on performance.

    Lookup operations are repeated every time a property or variable is accessed. Accessing a non-existent property will always result in a full traversal of the prototype chain. In addition, when iterating over the properties of an object, every enumerable property that is on the prototype chain will be enumerated. The consequence of this is that accessing properties in prototype based languages is typically much slower than accessing variables in languages such as Java.

    Prototypes vs. Classes

    In class based languages classes are defined first and then objects are instantiated based on those classes. An object cannot exist without a class that defines its behaviour. Once an object is created, its behaviour can also not be extended. To this end classes provide a level of certainty. If dog and cat objects are instantiated from the class Animal, then it is reasonable for a programmer to expect the same attributes and behaviours on both objects.

    Conversely, in prototype based languages objects are the primary entities. There is no class construct. The prototype of an object is just another object to which the object is linked. Only single inheritance can be implemented through a prototype as every object only has one prototype link.

    New objects can be created based on existing objects. New behaviour can also be added to objects after their creation. Using prototypes, the method of sharing behaviour between objects is by delegation. When a variable or method is requested from an object and it does not know how to handle it, the object delegates its request to its list of prototypes.

    JavaScript classes

    JavaScript classes, introduced in ECMAScript 2015, provide a new means of creating a class by using the class keyword. However, the introduction of classes does not change the way that prototype inheritance works in JavaScript. Consequently, classes have been met with some criticism from parts of the JavaScript community as an unnecessary and convoluted addition to the language.

    There are two ways to define a class – by expression or by declaration.

    An example of class expression:

    var book = class {
        constructor(title, author) {
            this.title = title;
            this.author = author;
        }
    };

    An example of class declaration:

    class Book {
        constructor(title, author) {
            this.title = title;
            this.author = author;
        }
    };

    Unlike function declarations, class declarations and expressions are not hoisted. This means that the class must be defined before it can be accessed.

    var b = new Book(); // Reference error here 
    
    class Book {};

    Subclasses

    The extends keyword can be used in class declarations and class expressions to create a class that is a child of another class.

    class Dog {
        constructor(name) {
            this.name = name;
        }
    
        woof() {
            console.log(`${this.name} woofs!`);
        }
    };
    
    class Puppy extends Dog {
        constructor(name) {
            super(name);
        }
    };
    
    var bobby = new Puppy('Bobby');
    bobby.woof() // output is 'Bobby woofs!'

    In this example Puppy is a child class of Dog. As a child class, Puppy can access and execute the woof function from its parent class.

    Criticism

    JavaScript classes have been criticised by commentators as syntactic sugar over JavaScript’s existing prototype based inheritance. Inspecting the typeof a class reveals that under the hood it is a function. This explains why the class can be used just like a constructor function by using the new keyword.

    As such, classes are said to obscure the true nature of JavaScript inheritance. There is a disconnect between what a class looks like (an object) and how it behaves (as a function). Classes in JavaScript also only provide single inheritance which limits a programmer’s ability to express object oriented design.

    Perhaps the only saving grace for JavaScript classes are that they provide greater familiarity to programmers coming from class based languages such as Java, and are backwards compatible with most existing code.

    Conclusion

    Class based programming and prototype based programming both seek to implement the object orientated paradigm. Most programmers are familiar with class based programming due the popularity of languages such as C#, C++ and Java. However the rise of JavaScript, which adopts a prototype based approach, has meant that increasingly programmers are having to learn and use prototypes. JavaScript has tried to cater to programmers coming from popular object orientated languages by introducing a class syntax. But this has been criticised by some commentators as it does not replace the underlying prototype based system and arguably only adds further confusion.

    Prototype based programming provides greater freedom and flexibility to programmers because of its dynamic nature. Objects do not need a class to exist and are designed to have their behaviour easily cloned, shared or extended – even at runtime. The limitation to this approach is maintainability and performance, particularly in large scale projects. While a class based approach requires the programmer to adopt a more rigid approach in declaring classes and hierarchy at compile time, the benefit is greater robustness and performance. Consequently, the type of problem to be solved and valued characteristics of the envisaged system will more often than not decide the most appropriate object orientated approach to adopt.

    Further reading

    [1] Allen, R. (2017). Self. Retrieved from http://www.selflanguage.org/

    [2] Lieberman, H. (1986). Using Prototypical Objects to Implement Shared Behavior in Object Oriented Systems. Retrieved from http://web.media.mit.edu/~lieber/Lieberary/OOP/Delegation/Delegation.html

    [3] Mozilla. (2018). Inheritance and the prototype chain. Retrieved from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain

    [4] Atchley, D. (2015). Understanding Prototypes, Delegation & Composition. Retrieved from https://www.datchley.name/understanding-prototypes-delegation-composition/

    [5] Zakas, N. (2010). Maintainable JavaScript: Don’t modify objects you don’t own. Retrieved from https://www.nczonline.net/blog/2010/03/02/maintainable-javascript-dont-modify-objects-you-down-own/

    [6] Bruni, C. (2017). Fast Properties in V8. Retrieved from https://v8project.blogspot.com/2017/08/fast-properties.html

    [7] Mozilla. (2018). Classes. Retrieved from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

    [8] Bevacqua, N. (2015). ES6 Classes in Depth. Retrieved from https://ponyfoo.com/articles/es6-classes-in-depth

    [9] Ryan, C. (2015). JavaScript ES6 Class Syntax. Retrieved from https://coryrylan.com/blog/javascript-es6-class-syntax

    Visit original content creator repository https://github.com/mikeesto/prototype-programming
  • Java-Competitive-Programming

    Visit original content creator repository
    https://github.com/RAZIB71/Java-Competitive-Programming

  • uwu-startup-onepage


    UWU startup One page

    Este repositorio forma parte del desarrollo de proyecto web para el startup UwU®, que es una One page (Desktop first) para su Instagram Shop. Esta conformado por dos carpetas, una destinada para el diseño UI (donde se puede visualizar la IA, el wireframing, el diseño plano y el prototipo de alta fidelidad) y otra para el desarrollo Front end (html, css, js).

     
    AVISO
    
    Todos los materiales aquí desarrollados, tanto de diseño como de código, son de mi autoría 
    a excepción del framework Bootstrap. Los archivos originales se encuentran de manera local. 
    UwU es una marca registrada, © 2021 UwU. Todos los derechos reservados.
    
    

    This repository is part of the web project development for the startup UwU®, which is a One page (Desktop first) for an Instagram Shop. The project has two folders, one for the UI design (with the IA, wireframes, flat design and high fidelity prototype) and the other for Front end development.

     
    DISCLAIMER
    
    All materials developed here, both design and code, are my own, except for the Bootstrap 
    framework. The original files are found locally. UwU is a registered trademark, 
    © 2021 UwU. All rights reserved.
     
    
    Visit original content creator repository https://github.com/estefaniaportilla/uwu-startup-onepage
  • gin-web-example

    Gin Web Example

    An example of gin web project, using Gin、Gorm、MySQL、Redis etc

    简体中文 | English

    How to run

    Required

    • MySQL
    • Redis

    Ready

    1. Start MySQL & Redis
    2. Create three databases: ordin、inspection、risk
    mysql -uroot -prootroot -e "CREATE DATABASE IF NOT EXISTS ordin DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;CREATE DATABASE IF NOT EXISTS inspection DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;CREATE DATABASE IF NOT EXISTS risk DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"

    Conf

    You should modify conf/config.dev.toml

    [database]
    Type = mysql
    User = root
    Password = rootroot
    Host = 127.0.0.1:3306
    ODBName =  ordin 
    IDBName = inspection 
    RDBName = risk
    
    [redis]
    Host = 127.0.0.1:6379
    Password = ""
    db = 0
    pool_size = 100

    Run

    Specify the configuration file go run main.go -c conf/config.dev.toml,or run the air command to live reload for server,useful for development and debugging

    $ git clone https://github.com/anzhihe/gin-web-example.git
    
    $ cd gin-web-example
    
    $ go run main.go or make run or air

    Project information and existing API

    [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
     - using env:	export GIN_MODE=release
     - using code:	gin.SetMode(gin.ReleaseMode)
    
    [GIN-debug] GET    /health                   --> thor-backend/internal/controller.(*Server).health-fm (3 handlers)
    [GIN-debug] GET    /swagger/*any             --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (3 handlers)
    [GIN-debug] GET    /api/v1/test              --> thor-backend/internal/controller.(*Server).ServeTest-fm (3 handlers)
    [GIN-debug] GET    /debug/pprof/             --> github.com/gin-contrib/pprof.pprofHandler.func1 (3 handlers)
    ......
    Listening port is 8080

    Swagger doc

    Directory

    gin-web-example
    ├── Makefile        // 编译打包
    ├── README.md       // 使用说明
    ├── conf            // 配置文件
    │   ├── config.dev.toml
    │   ├── config.online.toml
    │   └── config.pre.toml
    ├── docs            // 相关文档
    ├── internal    
    │   ├── controller  // 控制入口
    │   ├── dao         // 数据操作
    │   ├── logger      // 日志加载
    │   ├── logic       // 业务逻辑
    │   ├── middleware  // 中间件层
    │   ├── model       // 模型定义
    │   └── setting     // 配置定义
    ├── main.go         // 程序入口
    ├── .air.conf       // 热重启配置
    ├── pkg             // 外部通用包
    ├── scripts         // 项目相关脚本
    │   └── sql
    └── vendor          // go mod依赖库

    Features

    Visit original content creator repository
    https://github.com/anzhihe/gin-web-example

  • Mute-o-Matic-V2

    Mute-o-Matic V2

    Hardware mute button and end call for MS Teams, with led indicator. Since I’m using both macOs and Windows, it has a nice and comfortable slide SPST switch on the side to select OS.

    This was my test project for the new Raspberry Pi Pico; with ~4€ you get a crazy good microprocessor and implementing HID functionality is extremelty trivial.

    The project is written in CircuitPython, using the Adafruit HID Library. Remember to copy the library file on the Pico together with the code.py file. I used a transparent plastic container because… well, that’s the only thing I had in the house and there’s lockdown due to COVID-19. Feel free to buy me a 3D Printer ❤️ I actually ended up buying a 3D printer so here you are the Mute-o-Matic v2 in its fancy plastic box!

    You can find the design of the case in the case folder. It’s my first design, so expect some filing here and there, it needs some millimetric adjustments.

    Mute-o-matic from the top

    A random Fritzing here

    This is just to give you a idea of what’s doing what.

    Fritzing

    How it works

    🚀 Rocket science! Jokes aside, it’s just a HID which sends shortcuts defined in MS Teams, according to the OS selected with the side switch. For Windows:

    • CTRL + Shift + M to toggle the mute (and the led)
    • CTRL + Shift + B to close the call (for strange reasons, this is not a documented shortcut on Teams official page)

    For macOs (For macOs, cmd is mapped to GUI. I guess in Windows this would be the Windows logo):

    • CMD + Shift + M to toggle the mute (and the led)
    • CMD + Shift + B to close the call (guess what, this is also not a documented shortcut on Teams official page)

    Easy. I just needed something to quickly mute/unmute the calls because I tend to get distracted and racing to find the proper button with the mouse is too hard.

    Parts used

    • Raspberry Pi Pico
    • 2 x Panel mount push button (Normally open)
    • 1 x Red Led
    • 1 x SPST slide switch
    • 1 X 220 ohm resistance

    Windows only improvement

    On my personal version of the Mute-o-Matic V2, I included another command which brings Teams on focus before toggling mute. This can be done with an idiot trick: pin Teams’ icon in the bar (how is it called? the one below) and count what number is it starting from the left. You can switch to that with the shortcut:

    Alt + [Number]
    

    You will need to do this twice because Teams will have two windows, the first one with the chat and all the other stuff and the second one with your active call. So, let’s say I’ve put the icon as third in my Windows bar, the correct sequence will be:

    Alt + 3
    Alt + 3
    CONTROL + Shift + M
    
    Visit original content creator repository https://github.com/ttan/Mute-o-Matic-V2
  • run-task

    Run <Paper|Velocity|Waterfall>

    build license

    This repository houses a suite of plugins which add tasks to automatically download and run Minecraft server/proxy software along with your plugin built by Gradle. This provides a streamlined method of integration testing plugins.

    Run Paper

    latest release

    Basic Usage

    In build.gradle.kts:

    plugins {
      // Apply the plugin
      id("xyz.jpenilla.run-paper") version "2.3.1"
    }
    
    tasks {
      runServer {
        // Configure the Minecraft version for our task.
        // This is the only required configuration besides applying the plugin.
        // Your plugin's jar (or shadowJar if present) will be used automatically.
        minecraftVersion("1.21.8")
      }
    }

    You can now run a Paper server simply by invoking the runServer task!

    Run Velocity

    latest release

    Basic Usage

    In build.gradle.kts:

    plugins {
      // Apply the plugin
      id("xyz.jpenilla.run-velocity") version "2.3.1"
    }
    
    tasks {
      runVelocity {
        // Configure the Velocity version for our task.
        // This is the only required configuration besides applying the plugin.
        // Your plugin's jar (or shadowJar if present) will be used automatically.
        velocityVersion("3.4.0-SNAPSHOT")
      }
    }

    You can now run a Velocity proxy simply by invoking the runVelocity task!

    Run Waterfall

    latest release

    Basic Usage

    In build.gradle.kts:

    plugins {
      // Apply the plugin
      id("xyz.jpenilla.run-waterfall") version "2.3.1"
    }
    
    tasks {
      runWaterfall {
        // Configure the Waterfall version for our task.
        // This is the only required configuration besides applying the plugin.
        // Your plugin's jar (or shadowJar if present) will be used automatically.
        waterfallVersion("1.21")
      }
    }

    You can now run a Waterfall proxy simply by invoking the runWaterfall task!

    Check out the wiki for more detailed usage information.

    Visit original content creator repository https://github.com/jpenilla/run-task