Skip to content

Instantly share code, notes, and snippets.

View parasquid's full-sized avatar

Tristan parasquid

View GitHub Profile
@parasquid
parasquid / airquality.html
Created November 13, 2020 08:51
airquality.html
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true">
<style>
button { font-size: xx-large; }
</style>
@parasquid
parasquid / airquality.js
Created November 12, 2020 13:22
airquality.js
const getUuid = (i) => {
const num = i.toString();
const id = ("0").repeat((4 - num.length) > 0 ? (4 - num.length) : 0) + num;
return 'd7e5' + id + '-0109-4306-956f-2f725ba7a85d';
};
var s = new Serial();
s.setup(9600,{rx: D33, tx: D34});
let buffer = '';
@parasquid
parasquid / neolightbulb.html
Last active November 4, 2020 10:22
neolightbulb
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true">
<style>
button { font-size: xx-large; }
</style>
@parasquid
parasquid / neolightbulb.js
Created November 4, 2020 09:45
neolightbulb
const neopixel = require("neopixel");
const numPixels = 7;
const pixelPin = 29;
const filledArr = (val, length) => {
const arr = new Uint8ClampedArray(length);
return arr.fill(val);
};
const emptyArr = (length) => {
return filledArr(0, length);
@parasquid
parasquid / pinmap.js
Created October 24, 2020 08:16
PAN1780 to Arduino pinmapping in Espruino
const P1_01 = 33;
const P1_02 = 34;
const P1_12 = 44;
const P1_13 = 45;
const P1_14 = 46;
const A = {
MOSI: 11,
MISO: 12,
SCK: 13,
SDA: 28,
@parasquid
parasquid / homeauto.js
Last active October 19, 2020 06:40
Espruino code for home automation
let pressCount = 0;
const batteryPercentage = () => (NRF.getBattery() - 2) * 100;
const LIGHT = 0xFFFF;
const FAN = 0xFFFE;
const LIGHT_FAN_ON = 0xFFFD;
const LIGHT_FAN_OFF = 0xFFFC;
E.on("init", () => {
NRF.setAdvertising({
@parasquid
parasquid / PAN1780.py
Created October 18, 2020 10:31
PAN1780 Board Definition File for Espruino (derived from the nRF52840DK board definition file)
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# ----------------------------------------------------------------------------------------
#!/usr/bin/env ruby
# Dump firmware from nrf51 and maybe other cortex-m devices
# The script thats missing from http://blog.includesecurity.com/2015/11/NordicSemi-ARM-SoC-Firmware-dumping-technique.html
# Also inspired by https://tasteless.eu/post/2015/12/32c3ctf-emb400/
# Requires seperate instace gdb server already running, for my jlink I use
# openocd -f interface/jlink.cfg -c "adapter_khz 2000; transport select swd;" -f target/nrf51.cfg
# uicr and ficr are always accessible so you might want to dump those externally and compare?
# openocd -f interface/jlink.cfg -c "adapter_khz 2000; transport select swd; set WORKAREASIZE 0;" -f target/nrf51.cfg -c "init; reset halt; flash read_bank 1 uicr-normal.bin 0x0 0x100; exit"
export const UPDATE_EDITOR_CONTENT = 'mock_test/UPDATE_EDITOR_CONTENT';
export const updateMockTestContent = (testId: number, content: string) => ({
type: UPDATE_EDITOR_CONTENT,
testId,
content,
});
handlers[UPDATE_EDITOR_CONTENT] = (state, action) => {
const { testId, content } = action;
return state
.setIn(['tests', 'items', testId, 'answer'], content)
# install libraries
sudo apt install git variety build-essential htop python3-pip curl openssh-server screen
# install docker dependencies
sudo snap install docker
sudo groupadd docker
sudo usermod -aG docker $USER
pip3 install docker-compose
snap install kubectl --classic