Skip to content

Instantly share code, notes, and snippets.

@bfritscher
bfritscher / esp8266pzem.ino
Last active May 30, 2020 20:29
PZEM-004T Energy monitor with nodemcu esp8266 arduino
/* FOR COMMENTS PLEASE USE https://github.com/bfritscher/esp8266_PZEM-004T */
/* NOTIFICATION ARE NOT SENT BY EMAIL FOR GISTS :-( */
// VERSION 2 with WiFIManager integration for device_name
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include <ESP8266WiFi.h> // ESP8266 Core WiFi Library (you most likely already have this in your sketch)
#include <Ticker.h> // for LED status
#include <DNSServer.h> // Local DNS Server used for redirecting all requests to the configuration portal
@bfritscher
bfritscher / main.py
Created December 29, 2016 21:40
esp8266 micropython plant sensor and vcc
import esp
from flashbdev import bdev
import machine
# https://github.com/micropython/micropython/issues/2352
ADC_MODE_VCC = 255
ADC_MODE_ADC = 0
def set_adc_mode(mode):
sector_size = bdev.SEC_SIZE
@bfritscher
bfritscher / fix-jsbin-embed.js
Last active June 22, 2017 15:16
Fix JS Bin Embed font-size
var fontSize = 20;
var style = document.createElement('style');
style.innerText = '#output li, #exec, .fakeInput, .fakeInput:before, #exec:before, #bin .editbox .CodeMirror, .mobile .editbox textarea{ font-size: ' + fontSize + 'px !important; }';
document.head.append(style);
@bfritscher
bfritscher / cors_proxy.js
Created September 27, 2018 13:59
Only for prototyping
var http = require('http');
var request = require('request');
function onRequest(req, res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
@bfritscher
bfritscher / mozilla_thimble_projects_sorter.js
Last active January 21, 2019 15:46
Mozilla Thimble Projects Sorter
// ==UserScript==
// @name Mozilla Thimble Projects Sorter
// @namespace https://gist.github.com/bfritscher/0521b90c347c89cf40ff5e4258975ae0
// @version 2
// @match https://thimble.mozilla.org/*
// @grant none
// ==/UserScript==
document.querySelectorAll('.glitch-banner').forEach( it => it.remove());
document.querySelectorAll('.glitch > .btn.export-button').forEach( it => it.remove());
function addOverlay() {
destroyOverlay()
overlay = document.createElement('div');
overlay.classList.add('annotation-overlay');
overlay.setAttribute('style', 'position:absolute;top:0;left:0;right:0;bottom:0;');
document.body.appendChild(overlay);
}
function destroyOverlay() {
@bfritscher
bfritscher / index.php
Created November 30, 2020 09:03
roundshot image proxy
<?php
require('../myfeeds/core.php');
if (!isset($_GET['site']) or !isset($_GET['size'])) {
print("site: roundshot subdomain chaumont, neuchatel, lacdeneuchatel, jeunesrives, nyon-tourisme, morgesregion<br>morgesregion folder: ville<br>size: full, half, quarter, oneeighth, thumbnail");
die();
}
$site = $_GET['site'];
$size = $_GET['size'];
$folder = isset($_GET['folder']) ? $_GET['folder'] . '/' : '';
$json = json_decode(file_get_contents("https://$site.roundshot.co/{$folder}structure.json"));
@bfritscher
bfritscher / userscripts.js
Last active August 17, 2022 17:03
cyberlearn fix
// ==UserScript==
// @name cyberlearn fix
// @namespace ig.he-arc.ch
// @match https://cyberlearn.hes-so.ch/*
// @grant none
// @version 1.0
// @author Boris Fritscher
// @description 8/16/2022, 10:49:56 AM
// ==/UserScript==
@bfritscher
bfritscher / ultrasound.ino
Created August 25, 2022 03:09
esp8266 nodemcu hc-sr04 with web server and wifi AP
/*********
ESP8266 Server + HC-SR04 ultrasound
required libraries:
- https://github.com/me-no-dev/ESPAsyncTCP
- https://github.com/me-no-dev/ESPAsyncWebServer
Adapted from
Rui Santos
@bfritscher
bfritscher / sendToHA.js
Created September 14, 2022 13:08
node.js script to upload external data to home assistant via the websocket api
const W3CWebSocket = require("websocket").w3cwebsocket; // npm install websocket
const host = "127.0.0.1";
const port = 8123;
const protocol = "ws"; // ws or wss if ssl
// long lived access token from profile > Create Token
const access_token ="";
const entityName = "Energy Consumption";
const entityId = "energy_consumption_kwh";