This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
import jmespath | |
s3 = boto3.resource('s3') | |
ec2 = boto3.resource('ec2') | |
# creates a hosts file for all running ec2 instances | |
# you can add alias hostnames by adding a tag "hostname" to the EC2 instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this would need to be thought through and edited to make it work properly. The bits are cut out of a larger working solution. | |
import psycopg2 | |
import psycopg2.extras | |
import aiopg | |
import asyncio | |
import json | |
from urllib.parse import quote | |
import atexit | |
from psycopg2.extensions import AsIs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# untested code fragments for Postgres NOTIFY and LISTEN from nodejs | |
const {Pool, Client} = require('pg') | |
const dbUsername = 'dbusername' | |
const dbHost = '127.0.0.1' | |
const dbPort = '5432' | |
const dbPassword = 'supersecret' | |
const dbDatabasename = 'dbname' | |
const connectionString = `postgresql://${dbUsername}:${dbPassword}@${dbHost}:${dbPort}/${dbDatabasename}` | |
const pool = new Pool({connectionString}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function buildGIF(frames: any) { | |
let firstFrame = new PNG(frames[0].dataBytes); | |
let width = firstFrame.width; | |
let height = firstFrame.height; | |
//console.log(frames.length + " frames at " + width + "x" + height); | |
let encoder = new GIFEncoder(width, height); | |
encoder.createReadStream().pipe(fS.createWriteStream('output.gif')); | |
encoder.start(); | |
let framePromises = frames.map(async (frame: any) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function transformImage(dataBytes: any) { | |
//let convert = async(dataBytes: any) => sharp(dataBytes).background({r: 255, g: 255, b: 255, alpha: 0}).toFormat('png').toBuffer() | |
let convert = async(dataBytes: any) => sharp(dataBytes).toFormat('png').toBuffer() | |
dataBytes = await(convert(dataBytes)) | |
return dataBytes | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a hack of: | |
// https://github.com/gtalusan/esp-idf/blob/master/examples/bluetooth/a2dp_source/main/main.c | |
// the idea is to be able to play an audio file from an esp32's flash memory directly to a bluetooth audio speaker | |
// refer to here for the notes on what you need to do to pull it all together | |
/* | |
This example code is in the Public Domain (or CC0 licensed, at your option.) | |
Unless required by applicable law or agreed to in writing, this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source: https://github.com/earlephilhower/ESP8266Audio/blob/2f2898c49612f1cc1351b44ffe8541def5a26b23/src/AudioGeneratorMIDI.cpp#L71 | |
void AudioGeneratorMIDI::midi_error(const char *msg, int curpos) | |
{ | |
cb.st(curpos, msg); | |
#if 0 | |
int ptr; | |
Serial.printf("---> MIDI file error at position %04X (%d): %s\n", (uint16_t) curpos, (uint16_t) curpos, msg); | |
/* print some bytes surrounding the error */ | |
ptr = curpos - 16; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned char bytes[4]; | |
bytes[0] = (u32 >> 24) & 0xFF; | |
bytes[1] = (u32 >> 16) & 0xFF; | |
bytes[2] = (u32 >> 8) & 0xFF; | |
bytes[3] = u32 & 0xFF; | |
for(int i = 0; i < 4; i++) | |
{ | |
if (i == 0) Serial.print("0x"); | |
Serial.print(bytes[i], HEX); | |
if (i < 3) Serial.print(":"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serial.printf("---> %04X : foo\n", (uint32_t) u32); | |
//Serial.printf("---> %04X (%d): \n", (uint32_t) u32, (uint16_t) curpos); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x = 0; | |
for (int i = 0; i < buffSize; i++) | |
{ | |
x = i % 32; | |
if (x == 0) | |
{ | |
Serial.print("\n"); | |
} | |
Serial.printf("%02X: ", data_out[i]); | |
Serial.flush(); |
OlderNewer