Skip to content

Instantly share code, notes, and snippets.

Avatar

bootrino bootrino

View GitHub Profile
View gist:771f865e4c643104b70d1a034759d93d
/*
// how to find out what is causing renders
const renderCount = useRef<number>(0)
const prev_getStateMachineNewState = useRef<any>()
const prev_getAjaxRequestCache = useRef<any>()
const prev_getApplicationState = useRef<any>()
const prev_getFormErrorData = useRef<any>()
log(`getFormErrorData ${(prev_getFormErrorData.current !== getFormErrorData) ? "changed" : "not changed"}`)
log(`getAjaxRequestCache ${(prev_getAjaxRequestCache.current !== getAjaxRequestCache) ? "changed" : "not changed"}`)
@bootrino
bootrino / gist:2ed0b317913960578697499c5d43bd7f
Created Oct 25, 2020
Transfer Ubuntu ec2 server to Lightsail
View gist:2ed0b317913960578697499c5d43bd7f
# USE AT YOUR OWN RISK
# THIS IS FOR EXPERTS ONLY - KNOW WHAT YOU ARE DOING.
#Step 1:
Make sure old system and new system are running same OS
On both systems:
apt update
apt upgrade
#Step 2:
@bootrino
bootrino / gist:dbbdaaf36644d25e3c23e8b3c5af09a2
Created Sep 13, 2020
Copy EC2 instance to Amazon Lightsail
View gist:dbbdaaf36644d25e3c23e8b3c5af09a2
HOW TO Copy EC2 instance to Amazon Lightsail
WARNING - this is a guide to remind myself how to do it!!!!
WARNING - I'M NOT RESPONSIBLE FOR ANYTHING YOU DO WITH THIS!
WARNING - DON'T ASK ME ANY QUESTIONS ABOUT IT.
WARNING - THIS IS NOT A TUTORIAL - I'm typing this from memory.
These steps are a good approximation of what is needed but you'll
need strong tech skills to do this. Don't do it unless you know what you are doing.
View gist:65ed6a749799c37862e26562e1e06cf3
import React, {useState, useEffect, useContext} from 'react';
import {StateContextApplication} from "./StateContextApplication";
let booleanAttributes = [
"allowfullscreen",
"allowpaymentrequest",
"async",
"autofocus",
"autoplay",
"checked",
View gist:7e062770ed331753f18ce37ebd07fd8c
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();
View gist:cdfc69e3f7f894952f4b174d7f625e5f
int size;
size = channels * width * height * sizeof(char);
unsigned char *image = NULL;
image = (unsigned char *) malloc(size);
// fill with gray
memset(image, 96, size);
View gist:8b1805d4d14da6ab7142148b2e60bc01
#!/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"
View codepen_offline.py
"""
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:
View gist:75a2f4f8fdaebd62861eb4cc83f2fcab
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 Feb 10, 2019
output a uint32_t or unit16_t in Arduino
View gist:3418f772a0ffe76c2759852ae66d177b
Serial.printf("---> %04X : foo\n", (uint32_t) u32);
//Serial.printf("---> %04X (%d): \n", (uint32_t) u32, (uint16_t) curpos);