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
// Adapted code from https://github.com/flepretre/use-redux | |
import { useContext, useState, useEffect, useCallback } from 'react'; | |
import { ReactReduxContext } from 'react-redux'; | |
import { bindActionCreators, ActionCreator } from 'redux'; | |
export function useRedux() { | |
const { store } = useContext(ReactReduxContext); | |
const { getState, dispatch, subscribe } = store; | |
const reduxState = getState(); |
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
type Assign<T1, T2> = Omit<T1, keyof T2> & T2; | |
type Merge<T1, T2> = T1 extends object | |
? T2 extends object | |
? Assign< | |
T1, | |
{ | |
[k in keyof T2]: Merge< | |
k extends keyof T1 ? T1[k] : T2[k], | |
T2[k] | |
>; |
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
// Personal hacked desk adjustment system, written in my version of Lox. Runs on a Pi Pico. | |
var pico = systemImport("pico"); | |
var CRNL = Buffer(Array(13, 10)).asString(); | |
class DoubleClickTracker { | |
init(pin, callback) { | |
this.pin = pin; | |
this.callback = callback; | |
this.reset(); |
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
// Forwards LoRa messages via web server. Written in my version of Lox. Runs on Pi Pico. | |
var pico = systemImport("pico"); | |
var lora = systemImport("lora_radio"); | |
pico.LEDPin.on(); | |
fun error(msg) { | |
logln(msg); | |
pico.LEDPin.off(); | |
pico.exit(); |
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
# syntax=docker/dockerfile:1 | |
# Comments are provided throughout this file to help you get started. | |
# If you need more help, visit the Dockerfile reference guide at | |
# https://docs.docker.com/engine/reference/builder/ | |
################################################################################ | |
# Create a stage for building the application. | |
ARG GO_VERSION=1.21 | |
FROM golang:${GO_VERSION} AS build |
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
# syntax=docker/dockerfile:1 | |
# Comments are provided throughout this file to help you get started. | |
# If you need more help, visit the Dockerfile reference guide at | |
# https://docs.docker.com/engine/reference/builder/ | |
################################################################################ | |
# Create a stage for building the application. | |
ARG RUST_VERSION=1.71.1 |
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
export function useLocalStorage<T>(key: string, initialValue: T) { | |
const store = useMemo( | |
() => getLocalStorageStore(key, initialValue), | |
[key, initialValue], | |
); | |
const currentValue = useSyncExternalStore(store.subscribe, store.getSnapshot); | |
const setValue = useCallback( | |
(value: T | ((value: T) => T)): void => { |