Skip to content

Instantly share code, notes, and snippets.

View lil5's full-sized avatar
🦀
Oxidising

Lucian I. Last lil5

🦀
Oxidising
View GitHub Profile
@lil5
lil5 / Dockerfile
Created March 14, 2025 13:20
Rust docker
FROM rust:bookworm AS rust
RUN apt-get update && apt install -y curl postgresql-client-15 libclang-dev
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --locked
@lil5
lil5 / http_err.rs
Last active February 24, 2025 00:12
Http Err for easy error handling in axum
// License WTFPL
pub mod http_err {
use axum::http::StatusCode;
pub type HttpResult<T> = Result<T, HttpErr>;
pub type HttpErr = (StatusCode, String);
pub fn internal_error<E>(err: E) -> HttpErr
where
E: std::error::Error,
{
(StatusCode::INTERNAL_SERVER_ERROR, err.to_string())
@lil5
lil5 / Makefile
Created December 4, 2024 13:43
The ultimate makefile for GoLang
default:
@grep '^[^#[:space:].].*:' Makefile
start:
go run .
.PHONY=build
build:
go build .
@lil5
lil5 / lazy_with_preload.ts
Created October 23, 2024 13:38
Lazy with Preload
/* eslint-disable @typescript-eslint/no-explicit-any */
import { ComponentType, lazy } from "react";
/**
* Returns both the component render function and a prefetch function
*
* Example:
*
* ```ts
* import { lazyWithPreload } from "~/utils/lazy_with_preload";
@lil5
lil5 / server_rsync.sh
Created October 7, 2024 15:33
Deploy example.stupidwebauthn.site
#!/bin/bash
set -e
echo "Build frontend"
pushd frontend
yarn install --frozen-lockfile
yarn run build
popd
@lil5
lil5 / package.json
Created September 12, 2023 08:19
Working tsconfig for nodejs
{
"type": "module",
"main": "./src/app.ts",
"scripts": {
"dev": "node --experimental-specifier-resolution=node --loader ts-node/esm src/app.ts"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^20.6.0",
"ts-node": "^10.9.1",
@lil5
lil5 / startup-dev.sh
Created January 23, 2023 08:50
Quick start multiple applications from one launcher icon
#!/bin/sh
xdg-open /home/$USER/.local/share/applications/menulibre-postman-agent.desktop
xdg-open /usr/share/applications/code.desktop
xdg-open /var/lib/flatpak/app/io.dbeaver.DBeaverCommunity/current/active/export/share/applications/io.dbeaver.DBeaverCommunity.desktop
xdg-open /home/$USER/.local/share/applications/firefox.desktop
xdg-open /usr/share/applications/xfce4-terminal.desktop
@lil5
lil5 / utils.dart
Created September 23, 2021 15:16
Dart MM:SS format
class Utils {
static String timeMinutesSeconds(int totalSeconds) {
int minutes = (totalSeconds / 60).truncate();
int seconds = minutes % 60;
return "$minutes:${seconds.toString().padLeft(2, '0')}";
}
}
@lil5
lil5 / create_virtual_sink.sh
Created August 23, 2021 13:11
Create virtual audio loopback
#!/bin/sh
pacmd load-module module-null-sink sink_name=Virtual_Sink sink_properties=device.description=Virtual_Sink
@lil5
lil5 / index.ts
Last active August 4, 2021 08:23
Async function on load
async function waitDocumentLoad() {
return new Promise<void>((resolve) =>
window.addEventListener("load", () => resolve())
)
}