Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼
I'm a panda developer.

Maciek Korsan maciejkorsan

🐼
I'm a panda developer.
View GitHub Profile
@maciejkorsan
maciejkorsan / spotify.js
Last active Oct 5, 2021
Spotify cover endpoint
View spotify.js
const authkey = // authkey stored somewhere ie. file / database
const client_id = ""; // Your client id
const client_secret = ""; // Your secret
const refresh_token = "";
console.log(authkey.keyvalue);
const getCover = () => {
axios
View webhook-falcon.js
if (light === "star") {
hyperdrive.writeSync(1);
try {
clearTimeout(hyperdriveTimer);
} catch (e) {}
hyperdriveTimer = setTimeout(function() {
hyperdrive.writeSync(0);
}, 3000);
play("r2d2");
}
View webhook-socket.js
if (args.action == 'started') {
args.light = 'star'
args.status = 1
}
View pwa.html
<link rel="manifest" href="/manifest.webmanifest" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link
rel="apple-touch-icon"
sizes="192x192"
href="/images/icons/icon-192x192.png"
/>
<link
href="splashscreens/iphone5_splash.png"
media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)"
View webmanifest.json
{
"name": "Millennium Falcon",
"short_name": "Falcon",
"theme_color": "#2196f3",
"background_color": "#2196f3",
"display": "standalone",
"orientation": "portrait",
"scope": "/",
"icons": [{
"src": "/images/icons/icon-128x128.png",
View falcon-web.js
import axios from "axios";
const hyperdrive = document.querySelector(".-hyperdrive");
const cockpit = document.querySelector(".-cockpit");
const headlights = document.querySelector(".-headlights");
let lights = {
cockpit: 0,
front: 0,
hyperdrive: 0
View falcon.js
let ws = new WebSocket(socketUrl)
ws.on("open", function open() {
console.log("Connected 🚀")
});
ws.on("message", function incoming(data) {
const parsed = JSON.parse(data)
const message = parsed.payload
View socket.js
import Syncano from '@syncano/core'
export default (ctx) => {
const {channel, response} = new Syncano(ctx)
const {args} = ctx
try {
channel.publish(`global-messages`, {'light': args.light, 'status': args.status})
.then(res => {response(JSON.stringify(res), 200, 'application/json')})
} catch(e) {
View wookie.js
const { spawn } = require('child_process');
const player = spawn('aplay', [`audio/chewbacca.wav`]);
View hyperdrive.js
const gpio = require('onoff').Gpio
const hyperdrive = new gpio(3,'out')
hyperdrive.writeSync(1)