Skip to content

Instantly share code, notes, and snippets.

@LeoDJ
LeoDJ / _cm1106_co2_sensor_esphome.yaml
Last active Feb 1, 2021
ESPHome Custom Sensor CM1106 CO2
View _cm1106_co2_sensor_esphome.yaml
esphome:
name: cm1106_sensor
platform: ESP32
board: wemos_d1_mini32
includes:
- "cm1106.h"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pass
@LeoDJ
LeoDJ / spacenav_raw.py
Created Jan 6, 2021
Read raw values for 3DConnexion SpacePilot / SpaceMouse / SpaceNavigator
View spacenav_raw.py
import spacenavigator
import time
def callback(s):
print("X: %5.2f Y: %5.2f Z: %5.2f Roll: %5.2f Pitch: %5.2f Yaw: %5.2f Buttons:" % (s.x, s.y, s.z, s.roll, s.pitch, s.yaw), s.buttons)
success = spacenavigator.open(callback)
if success:
while 1:
time.sleep(0.1)
@LeoDJ
LeoDJ / led_strip.yaml
Last active Oct 31, 2020
MagicHome ESPHome RGB Strip Effects
View led_strip.yaml
esphome:
name: led_strip
platform: ESP8266
board: esp01_1m
wifi:
ssid: ""
password: ""
# Enable fallback hotspot (captive portal) in case wifi connection fails
@LeoDJ
LeoDJ / outPortTester.js
Last active Jan 24, 2020
Quick and dirty test to see which ports are whitelisted in a firewall
View outPortTester.js
var request = require('request');
let blocked = [], open = []
lastPort = 6000
function pingPort(port) {
request('http://portquiz.net:' + port, function (err, res, body) {
//console.log(err, res, body)
if ((!err && res.statusCode == 200) || (err && err.code == 'HPE_INVALID_CONSTANT')) {
@LeoDJ
LeoDJ / voltmeter.cpp
Created Jul 18, 2019
Arduino (ATMega328P) Internal VCC Voltmeter
View voltmeter.cpp
long readVcc() {
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
@LeoDJ
LeoDJ / userChrome.css
Last active Aug 7, 2019
TreeStyleTabs userChrome.css (hide tab bar and "Tree Style Tab" headline)
View userChrome.css
/* put file in <AppData>/Mozilla/Firefox/Profiles/<yourProfile>/chrome */
/* to correctly display tab title as window title, set browser.tabs.drawInTitlebar to false in about:config */
/* note: since FF 69 you also need to set toolkit.legacyUserProfileCustomizations.stylesheets to true for it to work*/
#main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar {
opacity: 0;
pointer-events: none;
}
#main-window:not([tabsintitlebar="true"]) #TabsToolbar {
visibility: collapse !important;
@LeoDJ
LeoDJ / index.js
Last active Feb 22, 2019
Artnet2MQTT
View index.js
const artnet = require('./modules/artnet.module');
const mqtt = require('mqtt');
const port = 0x1936;
const listenUniverse = 42;
//MQTT stuff
var client = mqtt.connect('mqtt://localhost');
@LeoDJ
LeoDJ / middleScroll.ahk
Last active Feb 1, 2019
AHK middle mouse scroll everywhere
View middleScroll.ahk
; Description: Scroll Explorer on middle mouse button drag
; Permalink: https://autohotkey.com/boards/viewtopic.php?t=43715
; Author: aph
; Version: 0.4.1
; Modified by: LeoDJ
; changelog:
; 0.4.1: - fixed Firefox getting stuck
; 0.4.0: - implemented much better exponential scrolling behaviour
; - tried to handle sticky scrolling better, but sometimes AHK does not see the KeyUp event, even when polled
; 0.3.0: - implement other scrolling behaviour, but still not perfect
@LeoDJ
LeoDJ / downloader.js
Created May 8, 2018
ISDT firmware download script
View downloader.js
const cheerio = require('cheerio')
const request = require('request')
const fs = require('fs');
let subfolder = 'firmwares'
if(!fs.existsSync(subfolder))
fs.mkdirSync(subfolder);
consoleLog = console.log
console.log = (text) => {
@LeoDJ
LeoDJ / T6
Created May 8, 2018
ISDT Firmware Changelog (manually updated)
View T6
T6 V1.0.0.4
1. FD-100 DSC Voltage Seting Support.
2. Optimize BattGo handling at work.