This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Grace Hopper</title> | |
<meta name="viewport" content="initial-scale=1, maximum-scale=1"> | |
<link rel="stylesheet" href="reset.css"> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<header class="header"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function startGame() { | |
dataSource = new AblyTrainArrivalsClient() | |
game = new Game(); | |
ui = new GameUi(game); | |
game.start({ | |
onGameStart: async () => await dataSource.listenForEvents("940GZZLUKSX", msg => game.registerEvent(game, msg)), | |
onGameEnd: () => dataSource.stopListening() | |
}); | |
ui.startRendering(game); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyRandomProblem extends Problem { | |
constructor(x, y) { | |
super(x, y); | |
} | |
tick(platform) { | |
// Do something | |
this.ticks++; | |
} | |
onCompletion(platform) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> // Include the Neopixel library | |
#ifdef __AVR__ | |
#endif | |
// Which pin on the Arduino is connected to the NeoPixels? | |
#define PIN 4 | |
// How many NeoPixels are attached to the Arduino? | |
#define NUMPIXELS 256 // Popular NeoPixel ring size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function connect() { | |
// set up an instance of the Ably realtime library | |
const ably = new Ably.Realtime.Promise({ authUrl: '/api/createTokenRequest' }); | |
// create a channel called "tshirt" | |
const channelId = "tshirt"; | |
//connect to the tshirt channel | |
const channel = await ably.channels.get(channelId); | |
await channel.attach(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get each of the squares in the svg | |
const squares = document.getElementsByClassName('square'); | |
// create an onClick function | |
const onClick = (e) => colorAndPublish(e, channel); | |
// add an eventlistener for a click event to each square | |
for (let square of squares) { | |
square.addEventListener("click", onClick, false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include the required headers | |
#include <ESP8266WiFi.h> | |
#include "MqttConnection.h" | |
#include "DataStructures.h" | |
#include <WiFiClientSecure.h> | |
#include <MQTT.h> | |
// create an instance of WifiClientSecure, and call it espClient | |
WiFiClientSecure espClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example = 001#aa00ff | |
// Split message at '#' into pixel_number and hex_colour | |
const auto pixel_end = framedata.indexOf('#', 0); | |
const auto pixel_number_str = framedata.substring(0, pixel_end); | |
const auto hex_colour_str = framedata.substring(pixel_end + 1); | |
auto pixel_number = pixel_number_str.toInt(); | |
char hex_code[7]; | |
int r, g, b = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate x and y positioning of the pixel selected | |
auto y = pixel / 16; | |
auto shouldSnake = y % 2 == 0; | |
auto prevPixels = y * 16; | |
auto regularX = (pixel % 16); | |
auto snakeX = (15 - regularX); | |
auto x = shouldSnake ? snakeX : regularX; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PubNub JavaScript SDK QuickStart</title> | |
</head> | |
<body> | |
<div> | |
<strong>Earth:</strong> <input id="update-text" type="input" placeholder="enter update for Earth here"/> | |
<input id="publish-button" type="submit" value="Submit Update to The Guide"/> |
OlderNewer