Skip to content

Instantly share code, notes, and snippets.

View mikeesto's full-sized avatar
🙂

Michael Esteban mikeesto

🙂
View GitHub Profile
@mikeesto
mikeesto / omxplayer.md
Last active September 21, 2022 04:16
OMXPlayer with Python

Use OMXPlayer with Python

Import:

import os

Play a video:

@mikeesto
mikeesto / start-script-on-boot.md
Last active September 21, 2022 04:18
Start a Python script on boot (Raspberry Pi 3)

Start a Python script on boot (Raspberry Pi 3)

This method will also work with any program, including those that require access to xorg

Edit the LXDE autostart file

/etc/xdg/lxsession/LXDE-pi/autostart

Append to the end of the file the command/script to run, for example:

@mikeesto
mikeesto / polaroid-cli.md
Last active September 21, 2022 04:19
Print to a Polaroid Zip via the command line

How to print to a Polaroid Zip via the command line

  1. Install blueman: sudo apt install blueman
  2. Find the MAC address of the zip: hcitool scan
  3. Send the photo blueman-sendto --device=XX.XX.XX.XX.XX.XX photo.png
@mikeesto
mikeesto / reset-usb.md
Last active September 21, 2022 04:19
Reset USB ports on Raspberry Pi (useful for USB audio)

Reset USB ports on Raspberry Pi on boot

Add to /etc/rc.local:

# To shut off power on USB ports (this shuts power on ethernet as well):
echo '1-1' | tee /sys/bus/usb/drivers/usb/unbind

# To turn power back on
echo '1-1' | tee /sys/bus/usb/drivers/usb/bind
@mikeesto
mikeesto / date.sh
Last active June 14, 2021 03:46
How to update date/time on Raspberry Pi
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
@mikeesto
mikeesto / get_line.js
Created November 1, 2021 23:22
Bresenham's Line Algorithm - Produces a list of points from start to end
function get_line(start, end) {
let [x1, y1] = start;
let [x2, y2] = end;
let dx = x2 - x1;
let dy = y2 - y1;
const is_steep = Math.abs(dy) > Math.abs(dx);
// Rotate line
@mikeesto
mikeesto / install.sh
Created January 5, 2022 12:44
Install Tensorflow 2 on a Raspberry Pi
# a fresh start
sudo apt-get -y update
sudo apt-get -y upgrade
# remove old versions, if not placed in a virtual environment (let pip search for them)
sudo pip uninstall tensorflow
sudo pip3 uninstall tensorflow
# install the dependencies (if not already onboard)
sudo apt-get install -y gfortran
sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev
sudo apt-get install -y libatlas-base-dev libopenblas-dev libblas-dev
@mikeesto
mikeesto / docker.sh
Created September 21, 2022 04:26
Build x86_64 Docker image on M1/M2 architecture
docker buildx build --platform=linux/amd64 -t myimage .
@mikeesto
mikeesto / docker.sh
Created September 21, 2022 04:28
Run a docker container and access the shell
docker run -i --entrypoint=/bin/sh ...
@mikeesto
mikeesto / cors.js
Last active October 4, 2022 17:45
Set CORS for Cloudflare R2
import aws from "aws-sdk";
const s3 = new aws.S3({
endpoint: `https://${process.env.CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com`,
accessKeyId: process.env.CLOUDFLARE_ACCESS_KEY,
secretAccessKey: process.env.CLOUDFLARE_SECRET_ACCESS_KEY,
signatureVersion: "v4",
});
const config = {