Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View afpro's full-sized avatar
🤨
simple and stupid

afpro afpro

🤨
simple and stupid
View GitHub Profile
@afpro
afpro / access_log.rs
Last active April 17, 2024 12:40
rust http server
use std::{
borrow::Cow,
fmt::Debug,
future::Future,
net::SocketAddr,
pin::Pin,
task::{ready, Context, Poll},
time::Instant,
};
@afpro
afpro / rustfmt.toml
Last active April 9, 2024 10:06
rustfmt
edition="2021"
group_imports="StdExternalCrate"
imports_granularity="Crate"
reorder_imports=true
reorder_modules=true
@afpro
afpro / README.md
Last active November 27, 2023 08:25
osx config

computer setup config

.zshrc

# zsh plugin
plugins=(macos vi-mode)

# auto complete
autoload -U compinit && compinit
@afpro
afpro / serde_as_text.rs
Last active April 18, 2024 11:43
serde_as_text
pub mod as_text {
use std::{fmt::Display, str::FromStr};
use serde::{de::Error as DeError, Deserialize, Deserializer, Serializer};
#[derive(Deserialize)]
#[serde(untagged)]
enum OrText<'a, T> {
Data(T),
Text(&'a str),
@afpro
afpro / tonic_axum.rs
Last active November 14, 2023 04:21
serve tonic service on axum
use std::{convert::Infallible, error::Error};
#[cfg(feature = "reflection")]
use anyhow::{Context, Result};
use axum::{
body::Body,
http::{Request, Response},
Router,
};
use tonic::{body::BoxBody, server::NamedService};
@afpro
afpro / ios-codec.m
Created November 17, 2021 03:51
objc codec sample code
@import Foundation;
@import AVFoundation;
@import VideoToolbox;
@import AudioToolbox;
void videoCompressTest(void);
int main(int argc, const char * argv[]) {
@autoreleasepool {
videoCompressTest();
#[cfg(target_os = "android")]
mod android {
use crate::{
exceptions::PyBaseExceptionRef, stdlib::ssl::convert_openssl_error, VirtualMachine,
};
use openssl::{
ssl::SslContextBuilder,
x509::{store::X509StoreBuilder, X509},
};
use std::{