Skip to content

Instantly share code, notes, and snippets.

View markwylde's full-sized avatar

Mark Wylde markwylde

View GitHub Profile
@markwylde
markwylde / README.md
Last active December 4, 2023 13:34
ESP32-C6 ZigBee LED Blinker

The following firmware can be uploaded onto an ESP32-C6 to expose a ZigBee device.

At the bottom is the zigbee2mqtt device definition.

Firmware:

#include "esp_zigbee.h"

void setup() {
    // Initialize Zigbee stack configuration for a Zigbee end-device
@markwylde
markwylde / theme.css
Created September 2, 2022 07:35
HackerNews Dark Theme
/* ==UserStyle==
@name HackerNews Dark
@namespace gist.github.com/markwylde/1d25a9c2237dd79cf4d1a1fc2f4e0d45
@author Mark Wylde
@description Change the HackerNews style to dark
@version 1
@license MIT
==/UserStyle== */
@-moz-document domain("news.ycombinator.com") {
body {
@markwylde
markwylde / setup.sh
Created August 25, 2022 07:42
Creater an X11 server in Docker with VNC
apt-get update
apt-get upgrade -y
DEBIAN_FRONTEND=noninteractive apt-get install -y x11vnc xvfb fluxbox
Xvfb :2 -screen 0 1024x768x16 &
DISPLAY=:2 fluxbox &
DISPLAY=:2 x11vnc -display :2 -bg -forever -nopw -quiet -listen localhost -xkb &
@markwylde
markwylde / docker-compose.yml
Created December 10, 2021 13:05
Docker mongodb instance with custom network
version: '3'
services:
mongo:
image: mongo
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
@markwylde
markwylde / actualStringify.js
Created June 5, 2021 08:54
Actual Stringify
function actualStringify (object) {
const newObject = {};
for (const key in object) {
if (['String', 'Object', 'Number'].includes(object[key].constructor.name)) {
newObject[key] = object[key];
}
}
return JSON.stringify(newObject, null, 2);
}
@markwylde
markwylde / cacheWorker.js
Last active April 3, 2021 05:30
Service worker to cache everything
// This code should be accessable from your root domain
// As in, don't bundle
const cacheName = 'cache-v1';
// The activate handler takes care of cleaning up old caches.
self.addEventListener('activate', event => {
const currentCaches = [cacheName];
event.waitUntil(
caches.keys().then(cacheNames => {
return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));
@markwylde
markwylde / setupNotifications.js
Created March 29, 2021 05:12
Cordova notifications
function checkNotificationPermission (requested) {
FirebasePlugin.hasPermission(function (hasPermission) {
if (hasPermission) {
console.log('Remote notifications permission granted')
// Granted
getToken()
} else if (!requested) {
// Request permission
console.log('Requesting remote notifications permission')
FirebasePlugin.grantPermission(checkNotificationPermission.bind(this, true))
@markwylde
markwylde / index.js
Created December 30, 2020 01:17
server rendered mithril
const fs = require('fs');
const http = require('http');
const handler = require('serve-handler');
const render = require('mithril-node-render');
const htmlTemplate = fs.readFileSync('./index.html', 'utf8');
const ui = require('./js/ui');
const server = http.createServer(async function (request, response) {
@markwylde
markwylde / npm-ls-output.txt
Last active December 27, 2020 07:12
List of dependencies node-sass brings
tmp@1.0.0 /tmp
└─┬ node-sass@5.0.0
├── async-foreach@0.1.3
├─┬ chalk@1.1.3
│ ├── ansi-styles@2.2.1
│ ├── escape-string-regexp@1.0.5
│ ├─┬ has-ansi@2.0.0
│ │ └── ansi-regex@2.1.1
│ ├─┬ strip-ansi@3.0.1
│ │ └── ansi-regex@2.1.1 deduped
buildInsertStatement = require('./common/buildInsertStatement')
await db.run(`DELETE FROM "settings" WHERE "key" = 'acmeDirectoryUrl'`)
statement = buildInsertStatement('settings', {
key: 'acmeDirectoryUrl',
value: JSON.stringify('https://acme-v02.api.letsencrypt.org/directory')
})
await db.run(statement.sql, statement.parameters)