Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
coding MicroPython and playing with hardware

Andy Piper andypiper

🐍
coding MicroPython and playing with hardware
View GitHub Profile
@andypiper
andypiper / tooter.py
Created Nov 15, 2022
Post a Toot from MicroPython
View tooter.py
import network
import urequests
import ujson
# do_connect()
mast_url="https://mastodon.social"
token=MY_MASTODON_TOKEN
# note: this *must* include content-type
@andypiper
andypiper / followers.py
Created Nov 10, 2022
Mastodon code scribbles
View followers.py
from mastodon import Mastodon
mast = Mastodon(client_id='key',client_secret='secret',access_token='token',api_base_url='https://mastodon.social')
me = mast.me()
print(f"Followers: {me.followers_count}")
@andypiper
andypiper / flask-ap-scheduler.py
Created Nov 2, 2022
Schedule a task in a Flask app
View flask-ap-scheduler.py
# useful https://stackoverflow.com/questions/21214270/how-to-schedule-a-function-to-run-every-hour-on-flask
# docs https://pypi.org/project/Flask-APScheduler/
from flask import Flask
from flask_apscheduler import APScheduler
app = Flask(__name__)
scheduler = APScheduler()
def scheduleTask():
@andypiper
andypiper / bot.py
Created Oct 7, 2022 — forked from Dhravya/bot.py
A simple twitter bot using Twitter API v2
View bot.py
import pytwitter
from os import environ as env
from dotenv import load_dotenv
load_dotenv() # Loads the .env file we created earlier
api = pytwitter.Api(
consumer_key=env["CONSUMER_KEY"],
consumer_secret=env["CONSUMER_SECRET"],
access_token=env["OAUTH_TOKEN"],
@andypiper
andypiper / tweepy-notes.md
Created Aug 17, 2022
Tweepy cheatsheet / Twitter API v2
View tweepy-notes.md

BEARER = "my-long-token"

Check/delete stream rules

import tweepy

client = tweepy.StreamingClient(BEARER)

client.get_rules()
@andypiper
andypiper / Setup.md
Created Aug 9, 2022
MicroPython UNIX port on iPad
View Setup.md

You'll need to install iSH

Then...

echo https://dl-cdn.alpinelinux.org/alpine/v3.16/main > /etc/apk/repositories
echo https://dl-cdn.alpinelinux.org/alpine/v3.16/community >> /etc/apk/repositories
apk upgrade
apk add micropython --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
@andypiper
andypiper / andypiper-ld+json.json
Last active Jul 31, 2022
My JSON-LD Person object
View andypiper-ld+json.json
{
"@context": "http://schema.org/",
"@type": "Person",
"name": "Andy Piper",
"affiliation": [{
"@type": "Organization",
"name": "Games at Work dot Biz",
"sameAs": [
"https://twitter.com/gamesatwork_biz",
"https://gamesatwork.biz"
View key-light-mini-api.md
  • [ip]:[port]/elgato/accessory-info
  • [ip]:[port]/elgato/battery-info
  • [ip]:[port]/elgato/lights
  • [ip]:[port]/elgato/lights/settings

GET /elgato/accessory-info

@andypiper
andypiper / rc2014.md
Created Apr 12, 2022 — forked from jblang/rc2014.md
RC2014 Links
View rc2014.md
@andypiper
andypiper / temp-check.py
Created Mar 21, 2022 — forked from lesp/temp-check.py
Using a BME688 Temperature sensor with Pimoroni's Badger 2040. Code is based on the BME688 example, but with added Badger 2040 code.
View temp-check.py
"""BME688 / BME680 demo
This demo will work for both the BME680 and BME688.
"""
import time
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from pimoroni_i2c import PimoroniI2C
import badger2040
import machine
badger = badger2040.Badger2040()