Skip to content

Instantly share code, notes, and snippets.

View plaffitt's full-sized avatar

Paul Laffitte plaffitt

View GitHub Profile
@plaffitt
plaffitt / Chat.sh
Last active May 23, 2019 18:38
A filesystem based chat written exclusively in bash
#!/usr/bin/env bash
# Author: Paul Laffitte
# Description: A filesystem based chat written exclusively in bash
# Dependency (the only one): https://github.com/clibs/entr
if [ "$1" == '--server' ]; then
touch chat.log chat.message
ls chat.message | entr bash -c 'cat chat.message && cat chat.message >> chat.log'
else
@plaffitt
plaffitt / constframerate.sh
Last active August 15, 2019 11:45
Convert movies to constant framerate with FFmpeg reading filenames on stdin
#! /usr/bin/env bash
dest=$1
fps=$2
if [[ -z "$dest" ]]; then
dest='.'
fi
if [[ -z "$fps" ]]; then
fps=60
@plaffitt
plaffitt / mlt_proxify.sh
Last active August 25, 2019 08:12
An MLT proxifier for shotcut
#!/usr/bin/env bash
INPUT="$1"
if [[ -z "$INPUT" ]]; then
echo 'Usage: proxify [filename.mlt]'
echo '(The current folder sould include a "raw" folder containing your raw footages in mp4 format)'
echo 'xpath is required for this tool to work'
exit
fi
@plaffitt
plaffitt / three-js-oculus-go-bug.html
Created November 28, 2019 06:35
This is an example of a bug happening with three.js on oculus go with oculus browser when using a video and a canvas as textures
<!DOCTYPE html>
<html>
<body>
<div class="player">
<canvas></canvas>
<video src="https://threejs.org/examples/textures/MaryOculus.webm" loop autoplay crossOrigin="" controls="false" style="display: none;"></video>
</div>
<canvas id="texture-canvas" width="500" height="100" style="display: none;"></canvas>
@plaffitt
plaffitt / gen-client-cert.sh
Last active February 12, 2020 11:07
Generate client ssl certificate
#! /usr/bin/env bash
if [ $# -ne 1 ]; then
echo "please choose a name for the certificate"
exit 1
fi
openssl genrsa -out "$1.key" 4096
openssl req -new -key "$1.key" -out "$1.req"
openssl x509 -req -in "$1.req" -CA rootCA.pem -CAkey rootCA.key -set_serial 101 -extensions client -days 500 -outform PEM -out "$1.cer"
@plaffitt
plaffitt / hmm.js
Last active April 17, 2020 05:08
Hidden Makrov Models examples in javascript and python
/* Example from page 22
const makrovChain = {
q: {
property: 0.7,
transitions: {
q: 0.7,
r: 0.1,
s: 0.2,
},
emissions: {
@plaffitt
plaffitt / hash.js
Last active May 16, 2020 17:48
Hash for fun
const inputs = [
'Bonjour monsieur Dupont ! Comment allez-vous ?..',
'Bonjour monsieur Dupont ! Comment allez-vous ?',
'Bonjour monsieur Dupond ! Comment allez-vous ?',
'test',
'testt',
'tests',
'a',
'A',
'B',
@plaffitt
plaffitt / srscopes.sh
Created September 23, 2020 12:41
List Semantic-Releases scopes in a git repository
#! /usr/bin/env bash
git log --pretty=oneline --abbrev-commit | grep -oP '\(([^\)]*)\):' | sort | uniq | cut -c2- | sed 's/..$//'
@plaffitt
plaffitt / bash-prompt.sh
Created January 11, 2021 11:26
My personal bash prompt, including current time and kubernetes context/namespace
kube_prompt() {
echo -n '\[\e[91m\]'$(kubectl config current-context)'\[\e[39m\]'
K8S_NS=$(kubectl config view --minify --output 'jsonpath={..namespace}')
if [[ ! -z $K8S_NS ]]; then
echo "|\[\e[0;32m\]$K8S_NS\[\e[39m\]"
fi
}
date_prompt() {
echo -e "$(date +%H:%M:%S).$(date +%N | cut -b1-2)"
@plaffitt
plaffitt / cmprec.sh
Created August 21, 2021 15:55
Recursively compare files
#! /bin/bash
if [[ $# != 2 ]]; then
echo "usage: cmprec <source1> <source2>"
exit 1
fi
SOURCE1=$1
SOURCE2=$2