Skip to content

Instantly share code, notes, and snippets.

@todbot
todbot / emoji_flipper.py
Last active May 27, 2023 07:55
Show a bunch of emojis from a sprite sheet in CircuitPython
# emoji_flipper.py - show a bunch of emojis from a sprite sheet
# 23 Jun 2022 - @todbot / Tod Kurt
import time
import board
import displayio
sprite_fname = "emoji_spritesheet_27x7_28x28.bmp"
sprite_cnt = 27*7
sprite_w,sprite_h = 28,28
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
@cp2004
cp2004 / octopi-wpa-supplicant.txt
Last active October 17, 2023 17:02
OctoPi wpa supplicant clean file (OctoPi 0.17+)
# Use this file to configure your wifi connection(s).
#
# Just uncomment the lines prefixed with a single # of the configuration
# that matches your wifi setup and fill in SSID and passphrase.
#
# You can configure multiple wifi connections by adding more 'network'
# blocks.
#
# See https://linux.die.net/man/5/wpa_supplicant.conf
# (or 'man -s 5 wpa_supplicant.conf') for advanced options going beyond
@standarddeviant
standarddeviant / wake_on_motion_from_deep_sleep.ino
Created July 6, 2020 03:38
M5StickC wake-on-motion MPU6886 interrupt IMU motion MPU
#include <Arduino.h>
#include <M5StickC.h>
#include <utility/MPU6886.h> // used for accessing MPU constants
#include <driver/rtc_io.h>
void mpu6886_wake_on_motion_isr(void); // declaration of ISR
void mpu6886_wake_on_motion_setup(void); // declaration of setup
// lifted from https://github.com/m5stack/M5StickC/blob/master/src/utility/MPU6886.cpp
// if integrated with M5StickC library, use internal class function instead
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="google-signin-client_id" content="<CLIENT ID>">
<title>Google Auth To AWS</title>
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.487.0.min.js"></script>
@nafeu
nafeu / python3-script-template.py
Created January 29, 2019 12:34
Python3 Terminal Script Template
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Template for python3 terminal scripts.
This gist allows you to quickly create a functioning
python3 terminal script using argparse and subprocess.
"""
import argparse
@dave-malone
dave-malone / aws-iot-update-thing-shadow-lambda-function.js
Last active May 25, 2022 05:57
AWS Lambda function example of how to update IoT Thing Shadows
const AWS = require('aws-sdk')
AWS.config.region = process.env.AWS_REGION
const AWS_IOT_CORE_ENDPOINT = process.env.MQTT_BROKER_ENDPOINT
const IOT_THING_NAME = process.env.THING_NAME
const iotdata = new AWS.IotData({
endpoint: AWS_IOT_CORE_ENDPOINT,
})
@aallan
aallan / WIFI_PROTOCOL_LR
Created June 6, 2018 10:29
Code snippet to enable WIFI_PROTOCOL_LR in an ESP32
void init_wifi(wifi_mode_t mode)
{
const uint8_t protocol = WIFI_PROTOCOL_LR;
tcpip_adapter_init();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(mode) );
wifi_event_group = xEventGroupCreate();
@PRosenb
PRosenb / esp32_wdt.cpp
Last active April 6, 2019 04:34
When using ESP32 with the Arduino IDE, it does not support the native watchdog timer. The following gist does not use the official watchdog timer but employs a normal timer to reset the CPU if wdt_reset() is not called in time.
#include "esp32_wdt.h"
#include <esp32-hal-timer.h>
static hw_timer_t *timer = NULL;
/**
* iInterrupt service routine called when the timer expires.
*/
void IRAM_ATTR resetModule() {
ets_printf("watchdog reboot\n");
@ax3l
ax3l / CXXdefaults.md
Last active April 8, 2024 18:19
Compiler C++ Version Defaults

C++ -std=... default of various commonly used C++ compilers

Compiler Version __cplusplus
g++ 4.7.4 199711L
5.5.0 199711L
6.1.0 201402L
10.2 201402L
11.1.0 201703L
clang++ 3.4.2 199711L