Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import bluetooth
import re
import struct
import sys
if __name__ == "__main__":
if len(sys.argv) < 2:
#!/usr/bin/env python3
import usb.core
import struct
from collections import namedtuple
APPLE_VID = 0x05ac
Target = namedtuple("Target", ["vid", "pid", "name", "model", "total_size"])
@trlafleur
trlafleur / README.md
Last active January 20, 2024 17:01
NowCast AQI for PM2.5

This will calculates proper AQI and Nowcast-AQI from PM2.5 sensors readings.

Expect a feed of PM2.5 sensor readings, that are stored in a queue, each hour, we take the average of these values and store in an hour array.

We then compute AQI and NowCast-AQI for 24, 12, 6, and 3 hours, and send them out as MQTT data and in JSON format.

References:

@elithrar
elithrar / get-local-api.js
Last active July 16, 2023 14:44
A Scriptable powered iOS 14 widget (https://docs.scriptable.app/) using JavaScriptCore to get the current AQI from a PurpleNow sensor: https://fire.airnow.gov/
const API_URL = "https://www.purpleair.com/json?show=";
// Params: lat, lng, zoom
const MAP_URL = "https://fire.airnow.gov/"
// const CACHE_FILE = "aqi_data.json"
// Find a nearby PurpleAir sensor ID via https://fire.airnow.gov/
// Click a sensor near your location: the ID is the trailing integers
// https://www.purpleair.com/json has all sensors by location & ID.
let SENSOR_ID = args.widgetParameter || "19066"
const HEADER_COLOR = "#222222"
@planecore
planecore / Coronavirus.js
Last active October 20, 2024 20:45
Coronavirus Scriptable Widget
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-green; icon-glyph: user-md;
// change "country" to a value from https://coronavirus-19-api.herokuapp.com/countries/
const country = "Israel"
const url = `https://coronavirus-19-api.herokuapp.com/countries/${country}`
const req = new Request(url)
const res = await req.loadJSON()
if (config.runsInWidget) {
//this is a function that fires when the webapp receives a POST request
function doPost(e) {
//Return if null
if( e == undefined ) {
Logger.log("no data");
return HtmlService.createHtmlOutput("need data");
}
//Parse the JSON data
@doronhorwitz
doronhorwitz / pn7150.py
Last active March 20, 2024 20:30
Use Python to read from NXP PN7120/PN7150
# https://gist.github.com/doronhorwitz/fc5c4234a9db9ed87c53213d79e63b6c
# https://www.nxp.com/docs/en/application-note/AN11697.pdf explains how to setup a demo of the PN7120/PN7150.
# With that demo comes an executable called 'nfcDemoApp'. This gist is a proof of concept for how to read from that
# executable in Python.
# The class (which is called PN7150, even though it also should support PN7120) reads the output from the PN7150 each
# time a tag is read. It finds the line starting with "Text :" and extracts out the text - which is the text stored
# by the NFC tag.
# The reading is done in a separate thread, which calls a callback with the text every time an NFC tag is read.
@efrecon
efrecon / chopper.md
Last active February 1, 2023 22:44
Automatically chops SenML data and send it in chunks to remote MQTT topics

Chopper

The prupose of this module is to help chopping SenML into smaller chunks and to automatically send chunks away via MQTT as soon as a number of entries have been collected (the chopping size). Data is collected per MQTT topic to send to. The module is tuned to be used from inside logic behind projects such as http2mqtt or mqtt2any.

@codeAshu
codeAshu / fakemails.txt
Created July 27, 2018 07:10
List of all fake mail generators domains. Please double check before you add it, I have sourced it from other gists.
nobuma.com
15qm.com
nokiamail.com
sofimail.com
10minut.xyz
emailgo.de
inbax.tk
gowikifilms.com
mybitti.de
mierdamail.com
@atuline
atuline / increasing_brightness.ino
Last active April 24, 2018 08:51
Increasing brightness
#include "FastLED.h" // FastLED library.
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
// Fixed definitions cannot change on the fly.
#define LED_DT 12 // Data pin to connect to the strip.
#define LED_CK 11 // Clock pin for WS2801 or APA102.
#define COLOR_ORDER BGR // It's GRB for WS2812 and BGR for APA102.