Skip to content

Instantly share code, notes, and snippets.

View oscartbeaumont's full-sized avatar

Oscar Beaumont oscartbeaumont

View GitHub Profile
@oscartbeaumont
oscartbeaumont / Cargo.toml
Last active February 26, 2024 18:01
Content Types Idea
[package]
name = "testing"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
erased-serde = "0.4.3"
pin-project-lite = "0.2.13"
@oscartbeaumont
oscartbeaumont / cahe.ts
Created December 15, 2023 05:34
Solid good good good
import { ParentProps, createContext, useContext } from "solid-js";
import { SetStoreFunction, Store, createStore } from "solid-js/store";
export type CacheNode = {
__type: string;
__id: string;
} & Record<string, unknown>;
const ctx = createContext<Cache>();
@oscartbeaumont
oscartbeaumont / main.rs
Created July 21, 2023 16:48
Generic-generic Linked List
use std::fmt::Debug;
pub struct Request(String);
pub trait ContentType: 'static {
type Result;
// `None` if not matched.
fn exec(&self, req: &Request) -> Option<Self::Result>;
}
@oscartbeaumont
oscartbeaumont / setup.sh
Created February 7, 2023 06:37
Linux basic developer environment for Tauri/Wry dev
#!/bin/bash
sudo apt-get update
sudo apt-get -y install git curl
sudo snap install code --classic
sudo snap install node --classic
curl https://sh.rustup.rs -sSf | sh -s -- -y
@oscartbeaumont
oscartbeaumont / main.rs
Created January 4, 2023 13:10
pub trait Function {}
pub trait Function<TMarker> {
type Args;
type Result;
fn exec(&self, args: Self::Args) -> Self::Result;
}
// TODO: Duplicate all the impls for `FnOnce` and `FnMut`
// TODO: Support up to 12 args per functions.
@oscartbeaumont
oscartbeaumont / lib.rs
Created November 17, 2022 06:44
Lie to the compiler. Probally a bad idea.
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
use std::{ops::Deref, sync::Arc};
use rspc::Router as RspcRouter;
use worker::*;
mod utils {
@oscartbeaumont
oscartbeaumont / main.rs
Last active July 6, 2022 09:20
mdns-sd multiple ip's not working bug
use mdns_sd::{ServiceDaemon, ServiceEvent, ServiceInfo};
fn main() {
let mdns = ServiceDaemon::new().expect("Failed to create daemon");
let service_info = ServiceInfo::new(
&"_demo._udp.local.",
&"a",
"192.168.1.111.local.",
&vec!["1.1.1.1", "2.2.2.2"][..], // "192.168.1.111", // TODO: Handle multiple addrs
42069,
/**
* This file was auto-generated by openapi-typescript.
* Do not make direct changes to the file.
*/
export interface paths {
"/pet/{petId}/uploadImage": {
post: operations["uploadFile"];
};
"/pet": {
@oscartbeaumont
oscartbeaumont / Dockerfile
Created March 15, 2022 00:25
Prisma Client Rust Bug
FROM rust
ADD ./run.sh /run.sh
RUN chmod +x /run.sh
CMD [ "/run.sh" ]
@oscartbeaumont
oscartbeaumont / [path].ts
Last active January 17, 2022 13:07
Cloudflare Workers Serve Specific File from Function Issue
// This handler does a 301 redirect to `/test` in a loop until browser throws ERR_TOO_MANY_REDIRECTS (using wrangler@beta)
export const onRequest: PagesFunction<unknown> = async ({ request, env }) => {
// The goal of this handler is to return a static file called `test.html`.
// Parsing `/test.html` directly returns a URL parsing error as per issue https://github.com/cloudflare/wrangler2/issues/165
const assetReq = new Request("http://fakehost/test.html", {
cf: request.cf,
});
const response = await env.ASSETS.fetch(assetReq);
return new Response(response.body, response);