Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
/**
* Binadable Class
*/
#include <functional>
#include <boost/any.hpp>
#include <vector>
#include <iostream>
#include <memory>
#include <type_traits>
#include <typeinfo>
@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 / enumeratefor.cpp
Created November 30, 2015 16:27
Enumerating C++ Range For
/// Emanuele Ruffaldi
#include <vector>
#include <iostream>
#include <algorithm>
template <class VT, class IT>
class counter_class {
public:
using value_t = std::pair<int,VT>;
@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 / GEV09_Scopus_Article.py
Created January 27, 2016 12:20
Tool for analyzing the GEV09 classification in VQR 2011-2014
#Emanuele Ruffaldi 2016 Scuola Superiore Sant'Anna
import csv,os,sys
from pyexcel_xls import get_data,save_data
all = []
#Year TopicId Topic Filename Titolo Rivista Codice identificativo SCOPUS valore SJR classe A classe B classe C classe D classe E IR in alto IR in basso
#4 + 3 + nclassi +
total = 4 + 3 + 5 + 2 +1
key2pos = {
"Titolo Rivista": 4,
@eruffaldi
eruffaldi / gist:2ea55ac42b4ccaf0e8dc
Last active February 10, 2016 05:23
iterating splitter
// Example program
#include <iostream>
#include <string>
/// boost splitter is too complex
class split_iterator
{
public:
split_iterator(const std::string & ain, char ac): in(ain),c(ac),ip(0)
{