Skip to content

Instantly share code, notes, and snippets.

View bootrino's full-sized avatar

bootrino bootrino

  • Melbourne, Australia
View GitHub Profile
@bootrino
bootrino / gist:7e062770ed331753f18ce37ebd07fd8c
Created April 14, 2020 23:46
DjangoRenderFormContext.js
import React, {useState, useEffect, createContext, useContext} from "react";
import debug from 'debug';
import URI from "urijs";
import get from 'lodash.get';
import {StateContextAjaxRequestCache, ProviderAjaxRequestCache} from "./StateContextAjaxRequestCache";
import _ from "lodash";
const log = debug('DjangoRenderFormContext');
export const DjangoRenderFormContext = createContext();
int size;
size = channels * width * height * sizeof(char);
unsigned char *image = NULL;
image = (unsigned char *) malloc(size);
// fill with gray
memset(image, 96, size);
#!/bin/bash
#This script will compile and install a static ffmpeg build with support for nvenc un ubuntu.
#See the prefix path and compile options if edits are needed to suit your needs.
echo "you must manually install your nvidia drivers first"
read -p "Press any key if you have done that..."
echo "and you must install cuda manually (if you already installed drivers, deselect 'install drivers' from cuda install):"
echo "wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run"
echo "sudo sh cuda_10.1.243_418.87.00_linux.run"
"""
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@bootrino
bootrino / gist:75a2f4f8fdaebd62861eb4cc83f2fcab
Created February 12, 2019 08:44
Print the data_out buffer
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();
@bootrino
bootrino / gist:3418f772a0ffe76c2759852ae66d177b
Created February 10, 2019 21:10
output a uint32_t or unit16_t in Arduino
Serial.printf("---> %04X : foo\n", (uint32_t) u32);
//Serial.printf("---> %04X (%d): \n", (uint32_t) u32, (uint16_t) curpos);
@bootrino
bootrino / gist:06b821fb65b7aaad020c3ba532097a4c
Created February 10, 2019 21:00
Print uint32_t as hex in Arduino
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(":");
@bootrino
bootrino / gist:1af80a7363f14c5c9ad9748b41f919f1
Created February 10, 2019 20:57
example of printing binary data in Arduino
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 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
@bootrino
bootrino / gist:7edfc6b2e5ee6142a786069d0ba2f72e
Created August 30, 2018 05:14
nodejs transform image with sharp
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
}