Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
seek enf of file to get the size
define Find message:
if (size of file - current offset) is smaller than size of "From:",
memcopy the last (size of file - current offset) characters at the beginning of the buffer and load
(size of buffer - ((size of file - current offset)) into the buffer
Look at the (current offset + lenght of "From:" - 1)th character in the buffer, if it is :, check previous, if it is m, check previous, etc...
If not, check if
@jdmichaud
jdmichaud / gameoflife.c
Created August 13, 2017 17:33
Conway's Game Of Life
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <strings.h>
#include <inttypes.h>
// Dimensions are statically defined for now
#define WIDTH 32
#define HEIGHT 32
@jdmichaud
jdmichaud / gstreamer
Last active January 27, 2018 09:30
Compile gstreamer (ubuntu 16.04)
# With the help of:
# https://github.com/video-dev/hls.js
# https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Live_streaming_web_audio_and_video
# https://gstreamer.freedesktop.org/documentation/frequently-asked-questions/using.html
Preconditions:
export DEST_PATH ...
export GS_VERSION=$GS_VERSION
For gstreamer:
bison
@jdmichaud
jdmichaud / note.html
Created September 12, 2017 15:35
A simple note page
<style>
body {
margin:0px;
}
textarea { /* position is inherited */
left: 0;
top: 0;
right: 0;
height: 50vw; /* Actually the height of select and input */
@jdmichaud
jdmichaud / split.sh
Created September 22, 2017 13:55
Split Buildroot board configuration from toolchain/package configuration
#!/bin/bash
if [[ $# -ne 3 ]]
then
echo "usage: $0 <config_file> <board_config_file> <rest_config_file>"
exit 0
fi
CONFIG=$1
BOARD=$2
@jdmichaud
jdmichaud / observable.java
Last active September 26, 2017 10:25
Some explanation of how reactivex Observable works
// An observable is an helper class that creates a Subscriber and pass it
// an OnScubscribe method.
public class Observable<T> {
public Observable(OnSubscribe<T> func) {
onSubscribe = func;
}
public Subscription subscribe(Observer<? super T> observer) {
if (observer instance Subscriber) {
return subscribe((Subscriber<? super T>) observer);
@jdmichaud
jdmichaud / buildroot_on_qemu.sh
Last active December 1, 2017 19:36
Buildroot on qemu
curl -sOL https://buildroot.org/downloads/buildroot-2017.08.tar.gz
tar xf buildroot-2017.08.tar.gz
cd buildroot-2017.08/
make nconfig
# This is to point getty to the serial console instead of tty1
cat > /tmp/fixinittab.sh << 'EOF'
#!/bin/sh
sed -ie 's/tty1/ttyS0/g' ${TARGET_DIR}/etc/inittab
EOF
chmod +x /tmp/fixinittab.sh
@jdmichaud
jdmichaud / remove_color.sh
Created October 24, 2017 12:09
Remove color codes from text
cat coloredtext | sed 's/\x1b\[[0-9;]*m//g'
@jdmichaud
jdmichaud / trim.c
Last active November 12, 2017 08:39
simple trim function in C
// cc -Wall -Wextra -Wpedantic -Wfatal-errors -O3 /tmp/trim.c -o /tmp/trim
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdint.h>
#define FAIL() { \
++totalres; \
fprintf(stderr, "%s failed at %s(%i)\n", __func__, __FILE__, __LINE__); \
}
@jdmichaud
jdmichaud / Service Class Provider
Last active November 16, 2017 15:46
Docker image for a simple DICOM Service Class Provider using pynetdicom3
FROM alpine:3.5
RUN apk add --no-cache bash vim python git
RUN cd / && git clone https://github.com/pydicom/pydicom.git
RUN cd / && git clone https://github.com/pydicom/pynetdicom3.git
ENV PYTHONPATH=/pydicom/:/pynetdicom3/