Skip to content

Instantly share code, notes, and snippets.

@tyjak
tyjak / route
Last active September 10, 2021 22:07
clip/i3/route
#!/bin/sh
# Popup i3 window to display a route on openstreetmap
# dependency: curl, jq, webapp
# GistID: e41f26f331bb75e9fb532135d984ca77
FROM=$1
DEST=$2
# set HOME_ADDR as glabal env var for your address
@tyjak
tyjak / route-cli
Last active August 1, 2021 08:52
openstreet map route cli
#!/bin/sh
# Simple route request with openstreetmap
# depend on vimb, curl and jq
# GistID: 46f34adbcf7f969d2c4b60daae644b60
vimb https://www.openstreetmap.org/directions\?engine\=fossgis_osrm_car\&route\=$(curl https://nominatim.openstreetmap.org/search\?q\=$1\&format\=json | jq -r '.[0].lat + "%2C" + .[0].lon')%3B$( curl https://nominatim.openstreetmap.org/search\?q\=$2\&format\=json | jq -r '.[0].lat + "%2C" + .[0].lon' )
#!/bin/bash
# source: https://flx.ai/2019/bose-qc35ii-linux
# GistID: 3045abbf25bef7742047835e6aaa4788
actions="toggle|prev|next|forw|back"
# Check for correct usage
if [[ $# -ne 1 || ! "$1" =~ ^($actions)$ ]]; then
echo "Usage: "
echo "${0##*/} [${actions[*]}]"
@tyjak
tyjak / news
Last active June 19, 2021 12:49
#!/bin/zsh
# GistID: 45209142f7aa3ac3710417c2de58cdf1
# Sync one way opml file from ttrss server to newsbeuter
opml_file=${NEWS}.opml
news_file=$NEWS
ttrss_server=$TTRSS_SERVER
#sync_time=604800
sync_time=10
#!/bin/zsh
# GistID: e4eb7bf3ed820cbd24b2be1da71f1068
# Get text of the first result of a wikipedia search as argument
# Dependencies: http, jq, sed
http https://fr.wikipedia.org/w/api.php\?format\=json\&action\=query\&generator\=search\&gsrsearch\=$1\&gsrlimit\=1\&prop\=extracts\&explaintext\=1 | jq '.query.pages | map(values) | .[0].extract' | sed 's/\\n/\n/g'
{
"currency": "g1",
"endpoints": [],
"rmEndpoints": [],
"upInterval": 3600000,
"c": 0.0488,
"dt": 86400,
"dtReeval": 15778800,
"ud0": 1000,
"stepMax": 5,
# duniter reverse proxy conf
# GistID: 73fb5272f602c5011aeaaf6b4f8b00d0
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
version: '3.7'
services:
reverse-proxy:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- /etc/letsencrypt/:/etc/letsencrypt/
ports:
- 443:443
networks:
@tyjak
tyjak / handbrake-all.sh
Last active May 23, 2021 09:34
copy all title of a dvd with handbrakecli
#!/bin/zsh
set -e
# copy all titles of dvd
# GistID:48c17774a5adb5c1bd45def1a21bd16e
dirpath="${1:-$(pwd)}"
title=$(HandBrakeCLI -i /dev/sr0 -t 0 2>&1 | grep "DVD Title:" | sed -E 's/.*DVD Title: (.*)$/\1/')
HandBrakeCLI -i /dev/sr0 -t 0 -v 2>&1 | grep '+ title' | sed -E "s@[^0-9]*([0-9]+):\$@HandBrakeCLI -i /dev/sr0 -m -t \1 -o \"${dirpath}/${title}_\1.mp4\"@" > /tmp/handbrake-tasks.sh
sh /tmp/handbrake-tasks.sh
#more ~/handbrake-sample.txt | grep '+ title' | sed -E "s@[^0-9]*([0-9]+):\$@HandBrake -t \1 -o \"$1 \1.mp4\"@"
@tyjak
tyjak / gist:mine
Last active September 10, 2021 22:07
Simple wrapper to have website embeded in an i3 floating window
#!/bin/zsh
#
# Simple wrapper to havce website embedded in a vimb floating window
# depends on i3 and vimb
# GistID:e8e5001619c9d8755b08be2ae4f0516d
URI=$1
NAME=${2:-$1}