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:e2e5b4780a746dc4adaf7d725aabd085
Created July 22, 2022 07:47
How to do async debounce in TypeScript
import React, {useState, useEffect, useMemo} from "react";
import styled, {keyframes} from "styled-components";
import {toast} from "react-toastify";
import {CloseIcon} from "../Icons";
import {doFetch} from "../../utils";
import {Button as BSButton} from 'react-bootstrap';
import PhoneInput from 'react-phone-number-input'
import 'react-phone-number-input/style.css'
import {debounce} from "lodash";
@bootrino
bootrino / gist:c993d98d11927158ba428dc79e2e6a0b
Last active July 22, 2022 07:48
How to do recaptcha with TypeScript.
import React, {useState, useEffect, useMemo} from "react";
import styled, {keyframes} from "styled-components";
import {toast} from "react-toastify";
import {CloseIcon} from "../Icons";
import {doFetch} from "../../utils";
import {Button as BSButton} from 'react-bootstrap';
import PhoneInput from 'react-phone-number-input'
import 'react-phone-number-input/style.css'
import {debounce} from "lodash";
@bootrino
bootrino / debugging_systemd_networkd
Created February 22, 2022 20:45
debugging_systemd_networkd
From: https://superuser.com/questions/1187633/how-to-debug-systemd-networkd
From https://coreos.com/os/docs/latest/network-config-with-networkd.html :
Enable debugging manually
mkdir -p /etc/systemd/system/systemd-networkd.service.d/
Create Drop-In /etc/systemd/system/systemd-networkd.service.d/10-debug.conf with following content:
[Service]
Environment=SYSTEMD_LOG_LEVEL=debug
And restart systemd-networkd service:
@bootrino
bootrino / systemdystemd network config for bridged kvm firecracker
Last active February 19, 2022 21:26
systemd network config fr bridged kvm
andrewstuart@homecloud:~$ for file in /etc/systemd/network/*; do echo $file; cat $file; done
/etc/systemd/network/31-tap1.netdev
[NetDev]
Description="This is a tap device for a VM or a container"
Name=tap1
Kind=tap
[Tap]
@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
@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;
}
/*
// 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
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:
@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.
import React, {useState, useEffect, useContext} from 'react';
import {StateContextApplication} from "./StateContextApplication";
let booleanAttributes = [
"allowfullscreen",
"allowpaymentrequest",
"async",
"autofocus",
"autoplay",
"checked",