Skip to content

Instantly share code, notes, and snippets.

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 / 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());
@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 / 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 / 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 / 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 / sensor2.py
Created October 14, 2016 08:46
yl-38 yl-69 moisture sensor arduino nanpy script to collect data and upload to custom api with server to trigger manuel updates
#!/usr/bin/python3
from nanpy.arduinotree import ArduinoTree
from nanpy.serialmanager import SerialManager
from http.server import BaseHTTPRequestHandler, HTTPServer
import http.client, urllib.parse
import time
import datetime
import numpy
import logging
import threading
@bfritscher
bfritscher / sensor.py
Created July 30, 2016 09:43
yl-38 yl-69 moisture sensor arduino nanpy script to collect data and upload to thingspeak
#!/usr/bin/python3
from nanpy.arduinotree import ArduinoTree
from nanpy.serialmanager import SerialManager
import http.client, urllib.parse
import time
import datetime
import numpy
API_KEY = ''
SLEEP = 300
@bfritscher
bfritscher / pull.cgi
Created July 18, 2015 17:26
pull cgi (use www-data)
# apt-get install fcgiwrap
location /cgi-bin/ {
gzip off;
root /var/www;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
<script id="jsbin-javascript">
var aGlobalVar = 'hello';
var anotherGlobalVar = 'world';
function myFunction() {
aGlobalVar = 'yo';
var anotherGlobalVar = 'yeep';
var localVar = 'local';
iAmNotALocalVariable = 'iAmGlobal';
}