Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / conan2.md
Last active July 15, 2024 11:50
Conan2
@jdmichaud
jdmichaud / stream.md
Last active July 10, 2024 19:10
ffmpeg

Start a stream on udp:

ffmpeg \
  -re \
  -i /path/to.movie.avi \
  -vf subtitles=/path/to/subtitles.srt \
  -f mpegts \
  -codec:v mpeg1video \
  -b:v 1000k \
 -bf 0 \
@jdmichaud
jdmichaud / ssh.md
Created July 10, 2024 06:50
SSH tips

Config

Create an alias

$ cat >> ~/.ssh/config
Host <ALIAS_NAME>
  HostName 1.2.3.4
  User jd

Authentication

@jdmichaud
jdmichaud / Connect without login
Created July 7, 2024 15:09
Kobo ereader device
from https://www.yingtongli.me/blog/2018/07/30/kobo-rego.html
- Do not connect the device to the WiFi.
- Plug the USB cable to your computer
- In a termina, open the mass storage device that appear.
```bash
cd .kobo
sqlite3 KoboReader.sqlite
```
Then:
@jdmichaud
jdmichaud / tarot.zig
Created June 14, 2024 16:17
Tarot in Zig
const std = @import("std");
const stdout = std.io.getStdOut().writer();
const Type = enum(u3) {
COEUR = 0b000,
CARREAU = 0b001,
PIQUE = 0b010,
TREFLE = 0b011,
ATOUT = 0b100,
@jdmichaud
jdmichaud / xargs.sh
Created May 10, 2024 08:31
Bash cheat sheet
# Mingle ls/xargs/extension substitution
ls somepath/*.txt | xargs -n1 -i bash -c 'echo cp "$1" "${1%.txt}.dat"' - '{}'
# - `-n1` will make xargs take only one parameter at a time instead of the whole list of files.
# - Using a bash command allows to pass {} (which is a xargs args) to the shell and perform substitution on it
# source:
# https://stackoverflow.com/a/965072/2603925
# https://stackoverflow.com/a/45895212/2603925
# https://stackoverflow.com/a/64924231/2603925
@jdmichaud
jdmichaud / wget.sh
Created May 2, 2024 11:49
Mirror a site with wget
wget \
--mirror \
--convert-links \
--adjust-extension \
--page-requisites \
--no-parent --execute robots=off \
--user-agent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" \
<url>
@jdmichaud
jdmichaud / display-pixel.cc
Created April 17, 2024 13:38
Easiest way to display pixels on a screen on Linux
//g++ main.cc -O3 -o test -lX11 && ./test
#include <chrono>
#include <iostream>
#include <string>
#include "CImg.h"
using namespace cimg_library;
int main(int argc,char **argv) {
const unsigned char white[] = { 255, 255, 255 };
@jdmichaud
jdmichaud / generate-toc
Last active April 11, 2024 16:21
Markdown shell script utilities
#!/usr/bin/env bash
# reference: https://medium.com/@acrodriguez/one-liner-to-generate-a-markdown-toc-f5292112fd14
function printusage {
echo "Usage: $0 <minimum-level> <maximum-level> <markdown-file.md>"
echo ""
echo "Example:"
echo " $0 2 5 README.md"
}
@jdmichaud
jdmichaud / add-subtitles-to-a-video.md
Created March 28, 2024 18:39
Add subtitles to a video
cd /tmp && \
  mkdir auto-subtitle && cd auto-subtitle && \
  python3 -mvenv venv && \
  source venv/bin/activate && \
  pip install git+https://github.com/m1guelpf/auto-subtitle.git && \
  pip install ffmpeg-python && \
  python3 auto_subtitle /path/to/video.mp4 -o subtitled/