Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / pyonifix.py
Created November 13, 2013 13:48
Script for fixing truncated OpenNI stream files (.oni) containing RGB-D/Kinect data
# OpenNI ONI fixer
#
# by Emanuele Ruffaldi PERCRO-SSSA 2013
#
# USE AT YOUR OWN RISK - ALWAYS BACKUP THE FILE
#
# Possible future:
# - split/cut/extract
# - dump stats
#
@eruffaldi
eruffaldi / gist:eb8953dd6aeefa35ac28
Last active September 3, 2019 07:57
Example of CMake easy libraries
# REPLACED BY: https://github.com/eruffaldi/cmakego
# assuming to ave the correct find_package above ...
# requires CMakew 3.0 for supporting INTERFACE library type
if(ZeroMQ_FOUND)
add_library(p::zeromq INTERFACE IMPORTED)
set_property(TARGET p::zeromq PROPERTY INTERFACE_LINK_LIBRARIES ${ZeroMQ_LIBRARY})
set_property(TARGET p::zeromq PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIR}")
endif()
/**
* Binadable Class
*/
#include <functional>
#include <boost/any.hpp>
#include <vector>
#include <iostream>
#include <memory>
#include <type_traits>
#include <typeinfo>
@eruffaldi
eruffaldi / arucomarker.py
Last active May 18, 2021 08:31
Multiple Aruco PDF Marker generator
import cairo,argparse,random
#TEST: https://jcmellado.github.io/js-aruco/getusermedia/getusermedia.html
#http://terpconnect.umd.edu/~jwelsh12/enes100/markergen.html
#http://terpconnect.umd.edu/~jwelsh12/enes100/markers.js
markers_opts = [[False,True,True,True,True],[False,True,False,False,False]
,[True,False,True,True,False],[True,False,False,False,True]];
import string
digs = string.digits + string.letters
@eruffaldi
eruffaldi / touchexif.py
Created September 28, 2015 08:51
Adjust JPEG and MOV file times from metadata
# Emanuele Ruffaldi 2015
#
# Touches JPG and MOV files using EXIF or MOV metadata, as happens when copied from iPhone
# or other device
#
# For JPG requires python myexif
# For MOV requires exiftool
#
# Last Updated: 2015/09/27
#
@eruffaldi
eruffaldi / cpponce.cpp
Last active September 29, 2015 19:40
Execution of a C++ code block only one (C++11)
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <thread>
#include <chrono>
class OnceHard
{
public:
@eruffaldi
eruffaldi / iterkeys.cpp
Last active October 28, 2015 11:15
Iterate over keys or values of a std::map alike in C++
#include <map>
#include <unordered_map>
#include <iostream>
/// Used to iterate over the values of a map
template <class Mapclass>
struct map_keys
{
using map_t = Mapclass;
@eruffaldi
eruffaldi / fixlevel4.m
Created November 13, 2015 11:57
MATLAB Simulink Level 4 MAT truncated file fix
% quick and dirty file fixer for MATLAB Simulink Level 4
%
% Limitations: only double, needs to support other types and complex data
% Limitations: cannot cut file when spurious, needs to append a dummy
% variable (dummy)
%
% Emanuele Ruffaldi
%
% See: http://it.mathworks.com/help/pdf_doc/matlab/matfile_format.pdf
function fixlevel4(filename,dofix)
@eruffaldi
eruffaldi / varspec.cpp
Created November 17, 2015 10:44
C++ Type Specifier
#include <typeinfo>
#include <functional>
#include <iostream>
#include <map>
struct TypeSpec
{
const char * name; // pure name
std::function<bool(std::ostream&,void*)> out; // conversion fx
const std::type_info & ti; // internal name (unique)
@eruffaldi
eruffaldi / lambdasignal.cpp
Last active December 22, 2023 23:00
Signal as Lambda Functions in C++
#include <functional>
#include <fstream>
#include <iostream>
#include <signal.h>
/// one holder per signal type
template <int q>
struct Signal
{
using sfx = void(int );