Skip to content

Instantly share code, notes, and snippets.


Jo Franchetti thisisjofrank

View GitHub Profile
View index1.js
classCountComponent extends HTMLElement {
thisisjofrank / QuestLogger.js
Last active Apr 21, 2021 — forked from Ugbot/QuestLogger.js
Logging from Ably into QuestDB
View QuestLogger.js
var net = require('net');
var path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 3141;
const fetch = require("node-fetch");
thisisjofrank / phases.csv
Last active Sep 1, 2020
Table of Depict-it game phases
View phases.csv
Phase description phase name message 'kind'
Dealing and setup No messages
Collecting image input `drawing-request` instruction
Collecting image input response `drawing-response` drawing-response
Collecting caption input `caption-request` instruction
Collecting caption input response `caption-response` caption response
Collecting scores from players input `pick-one-request` instruction
Collecting scores from players response `pick-one-response` pick-one-response
`skip-scoring-forwards` skip-scoring-forwards
Displaying scores `show-scores` instruction
thisisjofrank / functionalcomponent.js
Created Aug 7, 2020
A functional component built with React that uses Ably
View functionalcomponent.js
import React, { useState, useEffect } from 'react';
import Ably from "ably/promises";
const client = new Ably.Realtime("you-api-key-here");
const Component = (props) => {
const channel = client.channels.get('some-channel');
const [ messages, updateMessages ] = useState([]);
thisisjofrank / component.js
Last active Aug 7, 2020
An example of a react component that uses Ably to publish to and subscribe to a channel
View component.js
import React from 'react'
import Ably from "ably/promises";
const client = new Ably.Realtime("your-ably-api-key");
export default class AblyMessageComponent extends React.Component {
constructor() {
this.state = { messages: [] };
View ably.html
<!DOCTYPE html>
<title>PubNub JavaScript SDK QuickStart</title>
<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"/>
thisisjofrank / snake.cpp
Created May 22, 2020
reverse every other line of the array
View snake.cpp
// 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;
thisisjofrank / lights.cpp
Created May 21, 2020
process the message once received
View lights.cpp
// 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;
View MqttConnection.cpp
// 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;
thisisjofrank / script.js
Last active May 21, 2020
Publish an event to an Ably channel
View script.js
// 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);