Skip to content

Instantly share code, notes, and snippets.

View yene's full-sized avatar
🏅
Best Developer of the Day

Yannick yene

🏅
Best Developer of the Day
View GitHub Profile
@yene
yene / kubernetes_cpu_requests.py
Last active November 11, 2024 18:34
Kubernetes Free CPU Requests
# Print out CPU requests of nodes and free amount of CPU
# This shows at a glance if we have room to deploy more pods.
# needs package kubernetes
import kubernetes.client
import os
from kubernetes import config
def get_pods():
v1 = kubernetes.client.CoreV1Api()
@yene
yene / deployment.yaml
Last active September 30, 2024 13:50
Example Kubernetes Deployment with ingress
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
secret: red-fulfillment-secret # the label "secret" is used to register the dependency to the mounted secret
name: red-fulfillment
spec:
replicas: 1
strategy:
type: RollingUpdate
@yene
yene / airflow.md
Last active October 16, 2024 18:33
pinning python dependencies and checking hash for airflow

Warning

This may faile with some packages. We recommend to just use uv and create the requirements.txt with uv export

Airflow provides a constraints file with the exact versions used. Here is how we can make the installation (almost) reproducible by relying on the hashes.

requirements.in holds the dependencies with constraints.

# airflow and constraints
@yene
yene / simpleshell.js
Created May 20, 2024 17:15
Small helper to write the most ugly shell scripts in JavaScript
import { exec } from 'child_process'
async function main() {
let args = process.argv.slice(2)
if (args.length !== 1) {
console.log(firstWordRed('Error: missing argument, path to Git directory.'))
console.log(firstWordRed('Warning: This script will reset the Git directory.'))
process.exit(1)
}
try {
@yene
yene / disable-AWDL.sh
Last active May 17, 2024 17:11
disable AWDL every 10 seconds
#!/bin/bash
set -e
interrupted=false
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
function cleanup() {
@yene
yene / yt-dlp.conf
Created May 12, 2023 18:05
yt-dlp.conf
# do not stop on errors
--ignore-errors
# Write metadata to the video file
#--add-metadata
# skip modified time, use the current datetime for modification time
--no-mtime
# prefer mp4, and we don't need 4k
@yene
yene / generate-xcode-icons.sh
Created October 9, 2019 18:25
Generating icons for Xcode
#!/bin/bash
# pass in the file name of the source as first parameter
mkdir -p generated
rm generated/*
# remove alpha with a simple trick
sips -s format bmp "$1" --out tmp.bmp
sips -s format png tmp.bmp --out "$1"
@yene
yene / convert-webp.sh
Created October 9, 2019 17:18
Automator convert images to webp, keep mod and creation date
# automator Passes images in as argument
for f in "$@"
do
dc="$(GetFileInfo -d "$f")" # store creation date
dm="$(GetFileInfo -m "$f")" # store modification date
noExt=${f%.*}
# needs to be installed with brew install webp
newExt="$noExt".webp
/usr/local/bin/cwebp -q 90 "$f" -o "$newExt"
SetFile -d "$dc" "$newExt" # restore creation date
@yene
yene / grabbug.go
Created April 27, 2019 15:40
grab bug
package main
import (
"log"
"github.com/cavaliercoder/grab"
)
func main() {
client := grab.NewClient()
@yene
yene / macOS-naming.js
Created November 23, 2018 16:06
Quick and dirty functions to replicate macOS behaviour if filename is already taken.
var folderName = 'untitledfolder';
var nameTests = [
{
nr: 1,
fileSystemIn: [],
fileSystemOut: ['untitledfolder'],
},