Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / systemd.md
Last active October 9, 2024 15:17
systemd cheatsheet

Create a systemd service

Create a unit file in /etc/systemd/system named foo.service. Then:

sudo systemctl start foo

If the file is modified:

sudo systemctl daemon-reload
@jdmichaud
jdmichaud / mouse.c
Created September 17, 2024 17:41
Set ratcheted on Logitech MX Master 3S
// cc -I/usr/include/hidapi/ -ggdb3 mouse.c -lhidapi-hidraw -o mouse
#include <stdio.h> // printf
#include <wchar.h> // wchar_t
#include <hidapi.h>
#include <string.h>
#define MAX_STR 255
int main(int argc, char* argv[])
@jdmichaud
jdmichaud / linkers-notes.md
Last active August 24, 2024 06:18
Linkers notes

Program linkers link object file together to create either:

  • An executable file
  • A shared library

Dynamic linkers link the executing program to a shared library at runtime.

Basic data types

Defined symbols are static objects within the source code that are defined for the entirety of the program (function or global and static variables).

@jdmichaud
jdmichaud / exe.md
Created August 5, 2024 14:47
Executable file manipulation

The the glic version used by an executable:

objdump -T /usr/bin/ls | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu | tail -1
@jdmichaud
jdmichaud / conan2.md
Last active August 3, 2024 13:29
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
Last active September 3, 2024 14:48
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
Last active February 4, 2025 19:00
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