Skip to content

Instantly share code, notes, and snippets.

@Phaqui
Phaqui / README
Created April 3, 2024 12:30
Rust as script
Run a rust file as a script!
1: Install nightly
$ rustup install nightly
2: Set the script as executable
$ chmod +x script.rs
3: Profit!
$ ./script.rs
@Phaqui
Phaqui / main.rs
Created September 26, 2023 07:15
Axum pipeline server
use std::io::{Read, Write};
use tokio;
use cmd_lib::run_fun;
use tower::ServiceBuilder;
use tower_http::cors::CorsLayer;
use flate2::bufread::GzDecoder;
use docx_rs::read_docx;
use base64::{Engine as _, engine::general_purpose};
use serde::Deserialize;
type Optional<T> = T | null;
type CheckFunction<T> = (val: T) => boolean;
type TransformFunction<T> = (val: T) => T;
interface Typedef<T = JSONType> {
type: T,
presence?: "required" | "optional",
check?: CheckFunction<T>,
default?: T,
transform?: TransformFunction<T>,
@Phaqui
Phaqui / livereload.py
Created April 8, 2019 18:15
live reloading of small python scripts
"""
livereload.py - quick "hot reloading" of small python scripts
demo video: https://imgur.com/a/fLbfHIG
"""
import sys
import os
import time
import traceback