Skip to content

Instantly share code, notes, and snippets.

/*
* V4L2 video capture example
*
* This program can be used and distributed without restrictions.
*
* This program is provided with the V4L2 API
* see http://linuxtv.org/docs.php for more information
*/
#include <stdio.h>
@nhatuan84
nhatuan84 / python_decorator_guide.md
Created December 8, 2021 04:55 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@nhatuan84
nhatuan84 / mmap-write-locking-with-semaphore.c
Created July 7, 2021 14:40 — forked from lesovsky/mmap-write-locking-with-semaphore.c
Simple read/write on mmaped area with semaphore locks.
/*
* use -lpthread when build.
*/
#include <semaphore.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
@nhatuan84
nhatuan84 / file_response_writer.go
Created June 19, 2021 16:31 — forked from ismasan/file_response_writer.go
Write backend HTTP response to http.ResponseWriter and File
// fileResponseWriter wraps an http.ResponseWriter and a File
// passing it to an http.Handler's ServeHTTP
// will write to both the file and the response.
type fileResponseWriter struct {
file io.Writer
resp http.ResponseWriter
multi io.Writer
}