Skip to content

Instantly share code, notes, and snippets.

View bootrino's full-sized avatar

bootrino bootrino

  • Melbourne, Australia
View GitHub Profile
"""
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:
#!/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"
int size;
size = channels * width * height * sizeof(char);
unsigned char *image = NULL;
image = (unsigned char *) malloc(size);
// fill with gray
memset(image, 96, size);
@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();
import React, {useState, useEffect, useContext} from 'react';
import {StateContextApplication} from "./StateContextApplication";
let booleanAttributes = [
"allowfullscreen",
"allowpaymentrequest",
"async",
"autofocus",
"autoplay",
"checked",
@bootrino
bootrino / gist:dbbdaaf36644d25e3c23e8b3c5af09a2
Last active June 7, 2023 21:10
Copy EC2 instance to Amazon Lightsail
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.
@bootrino
bootrino / gist:2ed0b317913960578697499c5d43bd7f
Last active June 7, 2023 21:10
Transfer Ubuntu ec2 server to Lightsail
# 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:
/*
// 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:702f4ec2e40564e1b06e403989376eb4
Last active September 12, 2021 00:09
correct way to do typescript default props in react
import React from 'react'
type Props = {
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
color?: string;
hoverColor?: string;
width?: number;
height?: number;
}
@bootrino
bootrino / gist:9c6c82e3243782da23308e50a38686db
Created December 20, 2021 02:50
Rotary phone code for Raspberry Pi zero
#!/usr/bin/python3
import atexit
# sudo apt install python3-gpiozero
import gpiozero
import math, sys, os, time
import subprocess
import time
from threading import Timer
from os import listdir
from os.path import isfile, join