Skip to content

Instantly share code, notes, and snippets.

View phelian's full-sized avatar

Alexander Félix phelian

View GitHub Profile
@phelian
phelian / k8s_scripts.sh
Last active November 16, 2020 14:07
k8s helper scripts
#!/bin/zsh
#Usage: k8s_delete deployment -dev
#Deletes all deployments containing "-dev". Usage with caution
func k8s_delete() {
for p in $(kubectl get $1 | grep -v NAME | cut -f1 -d' ' | grep $2); do
kubectl delete $1 $p;
done
}
if [ $UID -eq 0 ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
PROMPT='$USERNAME@sculpin %{${fg_bold[blue]}%}:%{$reset_color%}%{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
@phelian
phelian / movmeta
Last active December 16, 2023 06:57
Golang: Read creation time from mov/mp4
package main
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"os"
"time"
@phelian
phelian / gist:cb63c83dc9f1df1901a98da98340b5f8
Last active February 5, 2018 12:57
Kill child process and n-children processes with python
def kill_child_processes(signum, frame):
"""
SIGTERM override function
Kill running processes childrens and grandchildren before exiting
"""
pid = os.getpid()
kill_processes_recursive(pid)
sys.exit()
def kill_processes_recursive(pid, level=0, maxlvl=2):