Skip to content

Instantly share code, notes, and snippets.

@wirepair
wirepair / 16to24.html
Created November 30, 2017 05:02
convert 24 bit to 16 bit and vice versa via an html page
<!DOCTYPE html>
<html>
<head>
<title>24bit 16bit color converter</title>
<script>
window.addEventListener('load', function()
{
let i24 = document.getElementById('in24');
let i16 = document.getElementById('in16');
@drewler
drewler / epd_ipd.c
Created November 10, 2017 18:34
Arduino - IPAddress to char* + e-paper print
char IP[] = "xxx.xxx.xxx.xxx"; // buffer
IPAddress ip = WiFi.localIP();
ip.toString().toCharArray(IP, 16);
paint.DrawStringAt(0, 0, IP, &Font12, COLORED);
epd.SetPartialWindowBlack(paint.GetImage(), 0, 20, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
@zcaceres
zcaceres / index.js
Created October 27, 2017 19:36 — forked from groteworld/index.js
Example aws/aws-sdk-js IotData API Lambda usage
// An usage of AWS.IotData in Lambdas
//
// This example assumes some things
// 1. That you have a environment variable AWS_IOT_ENDPOINT. This is the url that you can find in AWS IoT dashboard settings
// 2. The lambda and your aws iot devices are on the same account and region
const AWS = require('aws-sdk');
const iotData = new AWS.IotData({ endpoint: process.env.AWS_IOT_ENDPOINT });
const handler = (event, context) => {
@matt448
matt448 / Speedometer_HMI.ino
Created June 1, 2017 15:47
Arduino based speedometer using a Nextion HMI Display
#include "Nextion.h"
const int lightPin = 0;
const int hardwareCounterPin = 5;
const int samplePeriod = 1000; //in milliseconds
const float pulsesPerMile = 4000;
const float convertMph = pulsesPerMile/3600;
unsigned int count;
float mph;
@narate
narate / create-hotspot.md
Last active May 13, 2025 14:44
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"
@sticilface
sticilface / PROGMEM.md
Last active July 23, 2023 11:38
PROGMEM

Guide to PROGMEM on ESP8266 and Arduino IDE

Intro

On low memory devices like the arduino and esp8266 you do not want strings to be stored in RAM. This occurs by default on these systems. Declare a string const char * xyz = "this is a string" and it will use up RAM.

The solution on these devices is to allow strings to be stored in read only memory, in Arduino this is the PROGMEM macro. Most of my experience is with the ESP8266 which is a 32bit micros controller. This device stores PROGMEM data in flash. The macro PROGMEM on ESP8266 is simply

#define PROGMEM   ICACHE_RODATA_ATTR
@benscabbia
benscabbia / Instructions
Created March 3, 2017 21:23
Cloudflare + Dynamic DNS (ddclient) = Super Awesome
# This guide will show you how to configure ddclient to dynamically update your DNS at Cloudflare.
# This cookbook makes use of a number of online guides - all of which I will reference at the end.
# Cloudflare requires ddclient to be version 3.8.2 or you will get a 'cloudflare protocol didn't exist'.
# Unfortunately, the package manager at this time makes use of 3.8.1
# My suggestion is to follow the semi-autonomous process, by downloading the out of date package
# and then manually update a few files. If you prefer, you can go down the fully manual route manual route.
# Installation - Manual (Not Tested: https://www.cloudflare.com/technical-resources/#ddclient)
# Installation - Semi-Autonomous (Recommended, follow below)
@kndt84
kndt84 / authorize.js
Last active May 17, 2024 03:11
Sample code: how to refresh session of Cognito User Pools with Node.js and Express
const AWS = require('aws-sdk');
const CognitoUserPool = require('amazon-cognito-identity-js-node').CognitoUserPool;
const CognitoUserSession = require('amazon-cognito-identity-js-node').CognitoUserSession;
const CognitoUser = require('amazon-cognito-identity-js-node').CognitoUser;
const CognitoIdToken = require('amazon-cognito-identity-js-node').CognitoIdToken;
const CognitoAccessToken = require('amazon-cognito-identity-js-node').CognitoAccessToken;
const CognitoRefreshToken = require('amazon-cognito-identity-js-node').CognitoRefreshToken;
const cfg = require('config').config;
const COGNITO_IDENTITY_POOL_ID = cfg.COGNITO_IDENTITY_POOL_ID;
@danielrmeyer
danielrmeyer / supervisor
Created June 27, 2016 17:03
supervisor config to keep a python script running in home directory.
[program:test]
command=/usr/bin/python /home/ubuntu/test.py
directory=/home/ubuntu
autostart=true
autorestart=true
startretries=3
stderr_logfile=/home/ubuntu/test.err.log
stdout_logfile=/home/ubuntu/test.out.log
user=ubuntu
@plieningerweb
plieningerweb / gist:39e47584337a516f56da105365a2e4c6
Created June 16, 2016 14:15
Restart python script itsself (run again).md