Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / amend.sh
Last active January 7, 2020 09:41
Amend old commit
# https://stackoverflow.com/questions/2719579/how-to-add-a-changed-file-to-an-older-not-last-commit-in-git
git add <my fixed files>
git commit --fixup=OLDCOMMIT
git rebase --interactive --autosquash OLDCOMMIT^
@jdmichaud
jdmichaud / async-loop.js
Last active January 21, 2020 11:16
Chaining promise in a loop to convert to an Observable
// Allows an asynchronous loop to be converted to an Observable.
function loop(): Observable<number> {
const subject = new DefaultSubject<number>();
let promise = Promise.resolve();
for (let i = 0; i < 3; i++) {
promise = promise.then(async () =>
await new Promise(resolve => {
setTimeout(() => {
subject.next(i);
resolve();
@jdmichaud
jdmichaud / graphics_in_xterm.md
Created January 29, 2020 12:55
Display graphics in xterm

Use the Sixel protocol: https://en.wikipedia.org/wiki/Sixel.

xterm -ti 340
sudo apt install libsixel-bin
curl -sL https://raw.githubusercontent.com/saitoha/libsixel/data/data/libsixel-1.png | img2sixel

Note that xterm shall be compiled with --enable-sixel option and shall be launched with the option -ti 340. Limited to 16 colors.

@jdmichaud
jdmichaud / svg-filter.html
Last active March 30, 2020 08:50
Offscreen filter - url filter do not work with OffscreenCanvas and with filter are not applied on HTMLCanvasElement buffer.
<!DOCTYPE html>
<html>
<head>
<title>Test Filters</title>
<meta charset="utf-8">
<script type="text/javascript">
const xmlns = 'http://www.w3.org/2000/svg';
async function getImage(path) {
const response = await fetch(path);

128 bits and SSE2

A simple C program using gcc/clang extension:

#include <stdint.h>

typedef int32_t v4si __attribute__ ((vector_size (16)));

int main() {
  v4si a = { 1, 2, 3, 4 };
@jdmichaud
jdmichaud / ll.sh
Created April 24, 2020 16:15
Low latency MIDI ubuntu
sudo apt-get install linux-lowlatency
# reboot chosing low-latency kernel. Shift or Escape during boot process.
# Add user to audio group
sudo usermod -a -G audio jedi
qsynth qsynth -a alsa
# Look for MIDI keyboard and FluidSynth entry
aconnect -o
@jdmichaud
jdmichaud / Compressed UDP feed
Last active July 28, 2022 16:47
Create a virtual monitor and stream it
# Transmit a x264 compressed low latency feed using udp
server: gst-launch-1.0 videotestsrc is-live=true ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency byte-stream=true threads=1 key-int-max=15 intra-refresh=true ! rtph264pay ! udpsink host=%d port=9002
client: gst-launch-1.0 udpsrc port=9002 caps='application/x-rtp' ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false async=false
@jdmichaud
jdmichaud / gstreamer.md
Last active July 16, 2020 10:51
Gstreamer brain dump

Gstreamer is a tool to manipulate audio and video format. It works as a pipeline. It can be used as a library in C or other languages but also feature a command line pipeline building tool gst-launch. On ubuntu 20.04, the tool is called from the command line using gst-launch-1.0.

example:

gst-launch-1.0 videotestsrc ! autovideosink