Schlagwort: javascript

  • Get young people making interactive websites with JavaScript and our ‘More web’ path

    Get young people making interactive websites with JavaScript and our ‘More web’ path

    Reading Time: 5 minutes

    Modern web design has turned websites from static and boring walls of information into ways of providing fun and engaging experiences to the user. Our new ‘More web’ project path shows young creators how to add interaction and animation to a webpage through JavaScript code.

    A colorful illustration of a snail, a penguin, and a person with short dark hair against a blue background. There is a large question mark in the middle.

    Why learn JavaScript?

    As of 2024, JavaScript is the most popular programming language in the world. And it’s easy to see why when you look at its versatility and how it can be used to create dynamic and interactive content on websites. JavaScript lets you handle events and manipulate HTML and CSS so that you can build everything from simple animations, to forms that can be checked for missing or nonsensical answers. If you’ve ever seen a webpage continuously load more content when you reach the end, that’s JavaScript.

    Two girls code together at a computer.

    The six new projects in the ‘More web’ path move learners beyond the basics of HTML and CSS encountered in our ‘Introduction to web’ path. Youn people will explore what JavaScript makes possible in web developmnent, with plenty of support along the way. 

    By the end of the ‘More web’ path, learners will have covered the following key programming concepts: 

    HTML and CSS JavaScript 
    Navbars, grid layouts, hero images and image sliders

    Form design and handling user input

    Accessibility and responsive design

    Sizing elements relative to the viewport or container

    Creating parallax scrolling effects using background-attachment

    Fixing the position of elements and using z-index to layer elements

    Local and global variables, and constants

    Selection (if, else if, and else)

    Repetition (for loops)

    Using Console log

    Concatenation using template literals

    Event listeners

    Use of the intersection observer API to animate elements and lazy-load images

    Use of the localStorage object to retain user preferences

    Writing and calling functions to take advantage of the Document Object Model (DOM)

    Use setTimeout() to create time delays

    Work with Date() functions

    We’ve designed the path to be completed in six one-hour sessions, with one hour per project. However, learners can work at their own speed and the project instructions invite them to take additional time to upgrade their projects if they wish.

    Built for our Code Editor and with support in mind

    All six projects use our Code Editor, which has been tailored specifically to young people’s needs. This integrated development environment (IDE) helps make learning text-based programming simple, safe, and accessible. The projects include starter code, handy code snippets, and images to help young people build their websites. 

    A screenshot of the code editor interface showing a garden with colorful flowers, an umbrella and a watering can.

    The path also follows our Digital Making Framework, with its deliberate format of six projects that become less structured as learners progress. The Explore projects at the start of the path are where the initial learning takes place. Learners then develop their new skills by putting them into practice in the Design and Invent projects, which encourage them to use their imagination and make projects that matter to them. 

    Meet the projects: Welcome to Antarctica (Explore project 1)

    An animated image of a penguin and a seal on a snowy surface.

    Learners use HTML and CSS to design a website that lets people discover a place they may never get a chance to visit — Antarctica. They discover how to create a navigation bar (or navbar), set accessible colours and fonts, and add a responsive grid layout to hold beautiful images and interesting facts about this fascinating continent. 

    Comic character (Explore project 2)

    An animated illustration of a man with short red hair on the left, a woman with short dark hair on the right, and a yellow lightning bolt in the center.

    In the second Explore project, young people build an interactive website where the user can design a superhero character. Learners use JavaScript to let the user change the text on their website, show and hide elements, and create a hero image slider. They also learn how to let the user set the colour theme for the site and keep their preferences, even if they reload the page. 

    Animated story (Explore project 3)

    An animated image of a snail reading a book.

    Young people create an interactive story with animated text and characters that are triggered when the user scrolls. They will learn how to design for accessibility and improve browser performance by only loading images when they’re needed.

    Pick your favourite (Design project 1)

    An animated checklist with numbered boxes. A cursor hovers over the middle box. Various icons surround the checklist, including a video game controller, a guitar, a basketball, and a book.

    This is where learners can practise their skills and bring in their own interests to make a fan website, which lets a user make choices that change the webpage content. 

    Quiz time (Design project 2)

    A white question mark in the center of a purple background. Animated icons of various shapes surround the question mark, including a television, musical notes, an X, and two cards with numbers "12" and “9”.

    The final Design project invites young people to build a personalised web app that lets users test what they know about a topic. Learners choose a topic for their quiz, create and animate their questions, and then show the user their final score. They could make a quiz about history, nature, world records, science, sports, fashion, TV, movies… or anything else they’re an expert in!

    Share your world (Invent project)

    An illustration of a computer screen displaying a web page. The web page has a blue background and a white arrow cursor hovers over a blue section. A globe icon is located below the cursor.

    In this final project, young people bring everything they’ve learnt together and use their new coding powers and modern design skills to create an interactive website to share a part of their world with others. They could provide information about their culture, interests, hobbies or expertise, share fun facts, create quizzes, or write reviews. Learners consider what makes a website useful and informative, as well as fun and accessible. 

    Next steps in web design

    Encourage your young learners to take their next steps in web design, learn JavaScript, and try out this new path of coding projects to create interactive websites that excite and engage users. 

    Two young learners using a laptop, one of them points at a laptop screen.

    Young people can also enter one of their Design or Invent projects into the Web category of the yearly Coolest Projects showcase by taking a short video showing the project and the code used to make it. Their creation will become part of the Coolest Projects online gallery for people all over the world to see! 

    Website: LINK

  • Arduino Cloud Embraces Python and JavaScript for new IoT projects

    Arduino Cloud Embraces Python and JavaScript for new IoT projects

    Reading Time: 5 minutes
    Phyton and Javascript integration

    The Internet of Things (IoT) has become a ubiquitous term, encompassing a vast array of applications ranging from small-scale embedded systems to complex networked devices. Traditionally, IoT development has been synonymous with programming in languages like C and C++. However, the landscape is rapidly evolving, with modern languages like Python and JavaScript gaining traction in the IoT space for devices running Linux or other OS, and also with MicroPython for lower resources devices.

    In an exciting development, we are thrilled to announce the creation of a workflow on the platform that enables users to seamlessly connect their devices based on these languages with the Arduino Cloud, empowering users to harness their full potential in creating IoT solutions.

    The new Manual setup workflow

    Traditionally, Arduino Cloud allowed the creation of devices based on Arduino or ESP32/ESP8266 hardware, with automatic sketch creation in C/C++ using the Arduino IoT Cloud library. This workflow featured automatic board provisioning and configuration within the platform. However, we have expanded the device creation process to introduce a new workflow, accommodating applications programmed in Python, MicroPython, or JavaScript, and so offering the ability to create a new breed of applications and devices that can be connected to the Arduino Cloud.

    This new workflow, known as “Manual Setup for Any Device” provides users with credentials that can be utilized within their Python, MicroPython, or JavaScript applications. This enables users to keep developing and programming their devices using their preferred environment. Integration with the Arduino Cloud can be achieved using libraries developed in any of the supported languages. Comprehensive documentation, along with a wide array of examples, supports users throughout the implementation process.

    Example on how to connect Python, MicroPython or JavaScript to Arduino Cloud

    By offering this flexible workflow, Arduino Cloud acknowledges the diverse requirements and preferences of developers. Whether you prefer the convenience of automatic provisioning or the flexibility of manual configuration, the choice is now in your hands.

    What can you actually do?

    Python – The choice for AI

    Python is a versatile and widely-used programming language that offers significant benefits for IoT device development. Its simplicity, readability, and extensive library ecosystem make it an ideal choice for both beginners and experienced developers. Python’s vast library ecosystem provides access to a wide range of pre-built modules and functions, allowing developers to leverage existing code and accelerate development. Additionally, Python’s active and supportive community offers a wealth of knowledge and resources, making it easier to troubleshoot issues, seek advice, and learn from others’ experiences.

    Python is not only a versatile language for IoT device development but also the de facto standard language and environment for AI programming. Its extensive library ecosystem, including popular libraries such as TensorFlow, PyTorch, and scikit-learn, makes Python the language of choice for implementing machine learning and deep learning algorithms. The availability of these libraries, along with Python’s intuitive syntax and flexibility, enables developers to build and deploy sophisticated AI models and integrate them seamlessly into IoT applications. Python’s dominance in the AI landscape further adds to its value for IoT device development, as it allows developers to leverage AI capabilities and unlock advanced functionalities in their IoT solutions.

    Learn more about how to connect your Python applications to the IoT Cloud.

    Micropython – The power of Python on tiny processors

    MicroPython is a popular platform for IoT development due to its simplicity, efficiency, and versatility. It supports various microcontroller platforms, including Arduino, ESP32, and Raspberry Pi Pico, offering cross-platform compatibility. With its familiar Python syntax, MicroPython is easy to learn and use, making rapid prototyping and development accessible. It optimizes memory usage and runtime performance, even on resource-constrained devices. MicroPython benefits from an extensive library ecosystem, enabling quick integration of functionalities and interoperability with other IoT platforms. Its active community provides abundant resources, support, and a vibrant ecosystem for IoT innovation. Overall, MicroPython is a powerful tool for building efficient and feature-rich IoT devices.

    If you want to learn more about how to connect to the IoT Cloud using MicroPython, check this getting started article and the full tutorial

    Javascript – Event driven applications across multiple platforms

    JavaScript has found its place in IoT device development across various platforms. Node.js, a server-side runtime environment, offers JavaScript’s event-driven and non-blocking nature for efficient handling of IoT tasks. Espruino, a JavaScript platform for microcontrollers, enables direct coding on resource-constrained devices. Johnny-Five, a JavaScript robotics and IoT framework, allows control and interaction with hardware platforms using JavaScript. JavaScript’s versatility, reuse of web development skills, and extensive libraries make it an accessible choice for IoT development. Its event-driven nature aligns well with IoT requirements, and the availability of frameworks and community support fosters rapid development and integration with web-based services.

    Check this article to learn more about how to connect your Javascript applications to the IoT Cloud.

    But what is Arduino Cloud?

    Arduino Cloud is a platform that simplifies the process of developing, deploying, and managing IoT devices. It supports various hardware, including Arduino boards, ESP32, and ESP8266 based boards, and makes it easy for makers, IoT enthusiasts, and professionals to build connected projects without coding expertise. What makes Arduino Cloud stand out is its intuitive interface that abstracts complex tasks, making it accessible to all users. With its low-code approach, based on auto generated code,  and the extensive collection of examples and templates, Arduino Cloud offers a simple way for users to get started and enables them to put the focus on their application code. 

    The platform’s IoT Cloud tool allows for easy management and monitoring of connected devices through customizable dashboards, which provide real-time visualisations of the device’s data. Furthermore, the IoT Cloud can be accessed remotely through the mobile app Arduino IoT Cloud Remote, which is available for both Android and iOS devices, allowing users to manage their devices from anywhere.

    Ready to start?

    Visit the Arduino Cloud website to access official documentation and resources for the Arduino IoT Cloud, where you will find extensive documentation to get started with the new Manual device setup workflow. Create an account and start building your own projects today!

    As the IoT landscape continues to evolve, Arduino Cloud remains at the forefront, embracing the flexibility and power of Python and JavaScript. We invite you to explore this new feature, unlock your creativity, and share your innovative projects with the Arduino community. Publish your projects on the Arduino Project Hub (PH), where like-minded enthusiasts can discover, learn, and collaborate on IoT solutions that push. 

    Additionally, engaging in community discussions and project sharing is encouraged in the forum, providing a platform for exchanging ideas, seeking advice, and fostering collaboration among fellow IoT enthusiasts. Together, let’s shape the future of IoT and create a vibrant ecosystem of innovation and knowledge-sharing.

    The post Arduino Cloud Embraces Python and JavaScript for new IoT projects appeared first on Arduino Blog.

    Website: LINK

  • Kids’ coding languages

    Kids’ coding languages

    Reading Time: 5 minutes

    Programming is becoming an increasingly useful skill in today’s society. As we continue to rely more and more on software and digital technology, knowing how to code is also more and more valuable. That’s why many parents are looking for ways to introduce their children to programming. You might find it difficult to know where to begin, with so many different kids’ coding languages and platforms available. In this blog post, we explore how children can progress through different programming languages to realise their potential as proficient coders and creators of digital technology.

    Two kids share their Scratch coding project on a laptop.

    ScratchJr

    Everyone needs to start somewhere, and one great option for children aged 5–7 is ScratchJr (Scratch Junior), a visual programming language with drag-and-drop blocks for creating simple programs. ScratchJr is available for free on Android and iOS mobile devices. It’s great for introducing young children to the basics of programming, and they can use it to create interactive stories and games.

    Scratch

    Moving on from ScratchJr, there’s its web-based sibling Scratch. Scratch offers drag-and-drop blocks for creating programs and comes with an assortment of graphics, sounds, and music for your child to bring their programs to life. This visual programming language is designed specifically for children to learn programming fundamentals. Scratch is available in multiple spoken languages and is perfect for beginners. It allows kids to create interactive stories, animations, and games with ease.

    The Raspberry Pi Foundation has a wealth of free Scratch resources we have created specifically for young people who are beginners, such as the ‘Introduction to Scratch’ project path. And if your child is interested in physical computing to interact with the real world using code, they can also learn how to use electronic components, such as buzzers and LEDs, with Scratch and a Raspberry Pi computer.  

    Young person using a laptop to code in Scratch, our favourite of all kids' coding languages.

    MakeCode

    Another fun option for children who want to explore coding and physical computing is the micro:bit. This is a small programmable device with an LED display, buttons, and sensors, and it can be used to create games, animations, interactive projects, and lots more. To control a micro:bit, a visual programming language called MakeCode can be used. The micro:bit can also be programmed using Scratch or text-based languages such as Python, offering an easy transition for children as their coding skills progress. Have a look at our free collection of micro:bit resources to learn more.

    HTML

    Everyone is familiar with websites, but fewer people know how they are coded. HTML is a markup language that is used to create the webpages we use every day. It’s a great language for children to learn because they can see the results of their code in real time, in their web browser. They can use HTML and CSS to create simple webpages that include links, videos, pictures, and interactive elements, all the while learning how websites are structured and designed. We have many free web design resources for your child, including a basic ‘Introduction to web development’ project path.

    Three kids coding at laptops.

    Python 

    If your child is becoming confident with Scratch and HTML, then using Python is the recommended next stage in their learning. Python is a high-level text-based programming language that is easy to read and learn. It is a popular choice for beginners as it has a simple syntax that often reads like plain English. Many free Python projects for young people are available on our website, including the ‘Introduction to Python’ path.

    A kid coding in Python on a laptop.

    The Python community is also really welcoming and has produced a myriad of online tutorials and videos to help learners explore this language. Python can be used to do some very powerful things with ease, which is why it is so popular. For example, it is relatively simple to create Python programs to engage in machine learning and data analysis. If you wanted to explore large language models such as GPT, on which the ChatGPT chatbot is based, then Python would be the language of choice.

    JavaScript 

    JavaScript is the language of the web, and if your child has become proficient in HTML, then this is the next language for them. JavaScript is used to create interactive websites and web applications. As young people become more comfortable with programming, JavaScript is a useful language to progress to, given how ubiquitous the web is today. It can be tricky to learn, but like Python, it has a vast number of libraries of functions that people have already created for it to achieve things more quickly. These libraries make JavaScript a very powerful language to use.

    Try out kids’ coding languages

    There are many different programming languages, and each one has its own strengths and weaknesses. Some are easy to learn and use, some are really fast, and some are very secure.

    Two kids coding together on Code Club World.

    Starting with visual languages such as Scratch or MakeCode allows your child to begin to understand the basic concepts of programming without needing any developed reading and keyboard skills. Once their understanding and skills have improved, they can try out text-based languages, find the one that they are comfortable with, and then continue to learn. It’s fairly common for people who are proficient in one programming language to learn other languages quite quickly, so don’t worry about which programming language your child starts with.

    Whether your child is interested in working in software development or just wants to learn a valuable — and creative — skill, helping them learn to code and try out different kids’ coding languages is a great way for you to open up new opportunities for them.

    Website: LINK

  • Fireworks! A Sample Extension Using Bits

    Fireworks! A Sample Extension Using Bits

    Reading Time: 5 minutes
    Braxton Lancial

    It’s always a good time for fireworks! And fireworks are even better when they’re digital and in a Twitch Extension. Recently we published a new sample Extension on the GitHub, which allows viewers to exchange Bits for an immaculate fireworks display in a video overlay. It leverages several of our Bits-in-Extension APIs, the Extension Configuration Service, and a lightweight Extension Backend Service. If you’re interested in how we built this Extension, and want to learn more about what tools Twitch offers to enable you to build a similar Extension yourself, you’re in the right place.

    Bits in Extensions enable you to build and manage a catalog of items and experiences in which viewers can exchange Bits. We provide a helper function to prompt the Bits transaction flow, and our callbacks allow your Extension to react accordingly to a transaction. The first step to manage your catalog of offerings for viewers is setting up the SKUs that will be included in your catalog. SKUs can be setup using the Developer Rig. After creating a new project or opening an existing project in the Developer Rig, you can navigate to the “Monetization” section on the left, and then click the “Live Products” tab. Here you can add new products as well as manage items after they’ve been created. In this example we’ve created two items — a Small Fireworks item at an amount of 10 Bits, and a Large Fireworks item at an amount of 100 Bits.

    Another useful feature utilized in this sample is the Configuration Service. This service enables developers to store Extension-specific and channel-specific data. In our fireworks example, we allow broadcasters to select one of two items they would like to be available to exchange for Bits — either Small Fireworks, or Large Fireworks. Upon selection, the configuration page saves that selection into the broadcaster configuration service segment. This choice ultimately determines what SKU will be presented to viewers. The Extension retrieves this broadcaster configuration and displays a button allowing viewers to exchange Bits for the selected SKU. While simple, this is an example of how easy it can be to empower broadcasters to tailor the Extension experience to their liking within your predetermined boundaries.

    function saveSettings() {
    var radioBtns = document.getElementsByName('firework');
    for (var i = 0, length = radioBtns.length; i < length; i++) {
    if (radioBtns[i].checked) {
    twitch.configuration.set("broadcaster", "", radioBtns[i].id);
    log("saveSettings() fired, broadcaster-selected sku set to: " + radioBtns[i].id);
    break;
    }
    }
    }

    We’ve set up our SKUs, we’ve implemented the Configuration Service to manage our catalog per broadcaster, now we’re ready for viewers to actually exchange their Bits for some digital fireworks. There are a variety of APIs and callbacks available through the Extension Helper relevant to the Bits transaction flow. In our sample, our overlay presents a very simple interface which presents a button to the viewer that reads “Launch Fireworks!”. When a viewer clicks this button, we call the useBits(SKU) method from the Twitch helper. This method kicks off the Bits transaction flow for the specified SKU from your catalog. If the viewer does not have enough Bits in their account, they’ll be led to the Bits purchasing interface, giving the viewer an opportunity to purchase more Bits and move forward with the transaction. Assuming the viewer already does have enough Bits or has just purchased enough, they’ll be prompted with a confirmation dialog box.

    useBits = function () {
    if (sku == "") {
    log("no sku received from the configuration svc");
    return;
    }
    twitch.bits.useBits(sku);
    }

    In our example, if the viewer selected Small Fireworks, they will be asked to confirm exchanging 10 of their Bits. If the viewer selected Large Fireworks, they will be asked to confirm exchanging 100 of their Bits. At this point the user will either confirm or cancel the transaction. Both options invoke callbacks from the Twitch helper so you can handle their decision accordingly. We only care about handling the scenario where the user has successfully confirmed exchanging their Bits for (digital) fireworks. When the user completes this transaction, the onTransactionComplete(transaction) callback function is invoked.

    twitch.bits.onTransactionComplete(function (transaction) {
    log("onTransactionComplete() fired, received transactionReceipt: " + transaction.transactionReceipt);

    fetch("https://localhost:8080/api/fireworks", {
    method: "POST",
    headers: {
    "Authorization": "Bearer " + transaction.transactionReceipt,
    "Content-Type": "application/json",
    },
    body: JSON.stringify({ channelId: channelId })
    }).then(function (response) {
    if (response.ok) {
    log("ebs validated transaction")
    }
    else {
    log("ebs was unable to validate transaction")
    }
    });
    });

    twitch.listen('broadcast', function (topic, contentType, sku) {
    log("listen() fired, received sku via PubSub: " + sku + ". Shooting Fireworks!");
    launchFireworks(sku);
    });

    Here we do a quick validation with our backend (more on that later), which eventually invokes the listen() callback via PubSub. Now we can finally shoot off our beautiful display of pixelated fireworks on the overlay. Bits transaction complete!

    While the interface of the Extension and the fireworks themselves are the more exciting parts, the dirty work still has to be done somewhere. This is where our Extension Backend Service comes into play (EBS for short). Most (but not all) Extensions require some sort of backend to operate. In this sample, our EBS verifies the validity of a Bits transaction by verifying its Javascript Web Token (JWT), then sends out the purchased Bits SKU via PubSub.

    Verifying a JWT with Go

    We chose to write our EBS in Go, as Go is a very lightweight way of quickly spinning up a backend. Our Go server must be running before our frontend can interact with it. Once it is, you can see our frontend routes our request to the API endpoint we’ve configured at https://localhost:8080/api/fireworks. This endpoint requires a Bearer Token as an Authorization Header (which will come from the transaction receipt field), as well as a channelId (the broadcaster’s Twitch user id). Our EBS uses a JWT library to parse the token we received from the transaction to ensure this request is coming from our Extension on Twitch. If it arrives at that confirmation, we respond with a 200 status and continue.

    Using PubSub with our own JWT

    We now need to create our own signed JWT, so when we send our PubSub message, Twitch knows it is coming from us. We can do this easily as seen in the newJWT(channelID string) function, by again utilizing the JWT library (most languages have solid JWT libraries that will make your life easier). After generating our own token, we can broadcast a message through PubSub by hitting the messages endpoint, and specifying what channel the message should be sent to. Using PubSub allows us to send a message to all Extension client instances in a specified channel all at once. This is what ultimately triggers the listen() method from the Twitch Helper on the frontend, and will shoot off our fireworks.

    // newJWT creates an EBS-signed JWT
    func (s *service) newJWT(channelID string) string {
    var expiration = time.Now().Add(time.Minute * 3).Unix()

    claims := jwtClaims {
    UserID: s.ownerID,
    ChannelID: channelID,
    Role: "external",
    Permissions: jwtPermissions {
    Send: []string{"broadcast"},
    },
    StandardClaims: jwt.StandardClaims {
    ExpiresAt: expiration,
    },
    }

    token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) tokenString, err := token.SignedString(s.secret)
    if err != nil {
    log.Println(err)
    }
    log.Printf("Generated JWT: %s\n", tokenString) return tokenString
    }

    Our Extension Backend Service has now validated the JWT from the incoming request to verify it was coming from our frontend, it has created its own JWT to send back to Twitch, and it has sent a PubSub message to the channel the request originally came from. Our EBS’s work here is done.

    Hopefully this Extension sample can help kickstart your Bits-enabled Extension development. Extensions come in many different flavors, so for more examples using other frameworks and languages, check out TwitchDev on GitHub. Visit the Twitch Developer site to begin developing your Twitch Extension. Happy building!

    Website: LINK

  • [Guest Post] Behind the Extension — Control the Show

    [Guest Post] Behind the Extension — Control the Show

    Reading Time: 5 minutes

    Hello! I’m John from Digital Tree Media and I’m here to share some thoughts and ideas around a Twitch Extension I made for controlling our Christmas lights. Yes, I know. Great idea, let Twitch control your lights. At Digital Tree Media we have a history of taking technologies and combining them to create an experience that other people would have said was “too hard,” “impossible,” or “a really dumb idea” (OK, that last one was just our staff when I said people could control our lights).

    Control The Show (CTS) has been a hobby project of mine for a few years. The original incarnation involved my old streaming setup in my bedroom at my parents’ house. Each time I have re-made the system, I have used it as an opportunity to learn new technologies, systems, and ways of working. CTS 1.0 was the reason I learned PHP back in 2011/2012.

    The Control The Show experience back in 2012.

    This year I decided that rather than rely on our own site and have people click on buttons, we’d have it within the video player on Twitch. In the past, we have built our own versions of interactive overlays (pre-Twitch Extensions), which we achieved by having the Twitch JavaScript player with an iFrame overlay then another container with the Twitch Player elements (play controls, volume, and fullscreen). There is one big issue with this –®define people who casually find the stream via the Twitch website would have to click away from it to control the lights. Adding one extra step usually means far fewer people will actually interact. Internally, we’ve been playing around with ideas for a Twitch Extension, and the whole concept of CTS felt like a really good fit. With that, I started building it first thing on a Sunday.

    By lunchtime I had the main part of the extension working. Users could click on one of the buttons to send the command to the server, which then sent it to the plugs to turn lights off or on. After a “healthy” lunch, I started work on what I thought would make the whole experience more entertaining. By mid-afternoon, I had user-based stats working, allowing me to pull data for a leaderboard, along with assigning a person a team, based on whether they had turned more things off or on.

    How does the whole system work then? Good question! As I mentioned earlier, CTS has been re-written multiple times, and this year was no exception. I had originally written the system to work on the website so I already had the code I needed to control the plugs, along with some of the security code. To add Twitch Extension compatibility, I needed to build an Extension Backend Service (EBS) and a frontend for it. The frontend was reasonably simple. A quick mashup of an image map, some javascript to scale it to the correct size, and an implementation to send the Twitch Auth token (provided as a JWT which I had never heard of), along with the request to the EBS and I was done. Then I just had to build an EBS. This part took me the longest, mainly due to my lack of knowledge on JWTs. Turns out they are an awesome little thing! My first issue with them as a n00b was selecting a library. I used my favourite bodge language of choice for CTS — PHP — which meant I had a choice of 7 different implementations. Now I did what every developer would do — I looked at which one had more stars on GitHub. Sweet. JWT = Done. I then modified the control system to accept the incoming data from the extension and log stats using the user’s identifier. I logged all the requests using the Opaque ID (as every user has one), but to appear on the leaderboard, a user has to allow me to see their actual Twitch ID.

    Great, the EBS is done, now we need to do everything else. Integrating it all together was quite easy. The total creation time of the extension was around 3–4 hours of actual work spread over my Sunday. I left the office after testing the extension out and submitting it.

    The next day, I received a reply about my submission explaining it had been denied. This was due to the lack of a config.html page for the broadcaster side and was a simple item to fix and resubmit. The extension then passed review and was available on Tuesday. Here’s what the engagement looked like for that first evening:

    Engagement for Control the Show’s debut using a Twitch Extension.

    We peaked at 221,430 commands in an hour, which is a lot of clicking! It was rather funny walking back into the office late that night and hearing all the relays clicking on and off.

    Now looking to the future, there’s a lot that I want to do with it. I’ve already started re-writing the project (again) to make better use of modern web technologies. Next year CTS will be using websockets for real-time communications, allowing the status of the devices to be shown in the Extension, along with achievements that will be shown to you as you earn them. My current plan is to bring CTS back for Halloween and Christmas each year with the actual display getting bigger and bigger.

    I currently have an LED ticker that is going to be implemented to show the latest Subscribers and Cheerers along with some LED pixel mapping effects that will be included in future shows so cheering and subscribing will be even cooler! This has always been a hobby project for me and I welcome feedback from people. If you have any 240v inflatables that you’d like to send my way, feel free to let me know!

    If you’re thinking of making a Twitch Extension, do it! It’s a hell of a lot of fun. I managed to make something simple that I can build on over the next year. It’s been a great learning experience from a little idea of “that would be cool” to something I now get to write about!

    Website: LINK