Skip to content

Instantly share code, notes, and snippets.

@AntanasGa
AntanasGa / useReducerMap.ts
Created November 14, 2023 17:05
react reducer map
import { useReducer } from "react";
type ReducerInvokerMap<S, T> = {
[K in keyof T]:T[K] extends (this: S) => S
? () => void
: T[K] extends (this: S, arg: infer Arg) => S
? Arg extends object
? (arg: Arg) => void
: never
: never
@AntanasGa
AntanasGa / actix.rs
Created October 18, 2022 19:20
Rust actix spa example
// Quick and dirty way to run spa apps on rust actix server
use dotenvy::dotenv;
use std::env;
use actix_web::{HttpServer, App, Result};
use actix_web::dev::{ServiceRequest, ServiceResponse};
use actix_files as a_fs;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv().ok();