Skip to content

Instantly share code, notes, and snippets.

{
"last_node_id": 114,
"last_link_id": 225,
"nodes": [
{
"id": 4,
"type": "GroundingDinoModelLoader (segment anything)",
"pos": {
"0": 1287,
"1": -1061

What is covariance?

Covariance describes how lifetimes behave in type substitution. A type is covariant over a lifetime if it can accept shorter lifetimes than originally specified.

📌 Example:

let short: &'short i32 = &5;
let long: &'long i32 = short; // allowed if &'long is covariant over 'short
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>apiplant - AI Software Consultancy</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.first-page {
background-image: url('Downloads/image.jpg');
@framp
framp / Cargo.toml
Last active August 4, 2024 22:02
SUM + IN in sqlx
[package]
name = "sqlxxx"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.86"
sqlx = { version = "0.7", features = ["runtime-tokio", "tls-rustls", "sqlite"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
k8s-app: sentry-logging
name: sentry
namespace: kube-system
spec:
selector:
matchLabels:
@framp
framp / fix-upperbody.py
Last active October 4, 2023 18:30
Detect upperbody and crop a video around it (needs a pass of stabilization afterward, experiment with different classifiers)
import cv2
target_cascade = cv2.CascadeClassifier('haarcascade_upperbody.xml')
video_capture = cv2.VideoCapture('your_video.mp4')
fps = int(video_capture.get(cv2.CAP_PROP_FPS))
output_width, output_height = 400, 300
fourcc = cv2.VideoWriter_fourcc(*'XVID')
output_video = cv2.VideoWriter('output_video2.mp4', fourcc, fps, (output_width, output_height))
@framp
framp / 10m.sh
Last active September 17, 2023 00:29
Blue Green Deployment with Traefik and automatic git sync
#!/usr/bin/env bash
output=$(git pull)
if [[ $output == *"Already up to date."* ]]; then
echo "No changes detected."
else
echo "Changes detected."
color=$(grep file dynamic/http.routers.docker-localhost.yml | cut -d' ' -f8 | cut -d'@' -f 1);
new_color=$([ "$color" = "green" ] && echo "blue" || echo "green")
ffmpeg \
-re -i playlist.m3u8 -vcodec libx264 -preset ultrafast -maxrate 600k -b:v 2500k \
-bufsize 600k -pix_fmt yuv420p -g 60 -c:a aac -b:a 160k -ac 2 \
-ar 44100 -f flv -s 1280x720 "rtmp://$YOURSERVER/$AUTH"
import Elysia from "elysia";
const router = new Bun.FileSystemRouter({
style: "nextjs",
dir: import.meta.dir,
});
export const get = () => 'OK';
export default new Elysia()
/*
crypto.subtle.generateKey({
name: 'RSA-OAEP',
modulusLength: 2048,
publicExponent: new Uint8Array([1, 0, 1]),
hash: {name: 'SHA-256'}
}, true, ['encrypt', 'decrypt'])
.then(keypair =>
crypto.subtle.encrypt({ name: 'RSA-OAEP', hash: {name: 'SHA-256'}}, keypair.publicKey, (new TextEncoder()).encode('lol'))
.then(encrypted => crypto.subtle.decrypt({ name: 'RSA-OAEP', hash: {name: 'SHA-256'}}, keypair.privateKey, encrypted))