Skip to content

Instantly share code, notes, and snippets.

Avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / gettoken.sh
Created Sep 25, 2018
Google OAuth 2.0 full example bash script.
View gettoken.sh
#!/bin/bash
#1) on https://console.developers.google.com/ register project and associate API from library
# OUTPUT: client_id,client_secret
client_id="..."
client_secret="...."
#2) get authorization code at the following link using web browser
# OUTPUT: code
scope="https://www.googleapis.com/auth/drive"
@eruffaldi
eruffaldi / build.cmd
Created Jun 20, 2021
Compile NVIDIA Windows
View build.cmd
% based on combination of online info
git clone https://github.com/opencv/opencv.git -b "4.5.2" --depth 1
git clone https://github.com/opencv/opencv_contrib.git -b "4.5.2" --depth 1
set "opencvSource=opencv-4.5.2"
set "opencvExtraModules=opencv_contrib-4.5.2/modules"
set "opencvBuild=%opencvSource%\build"
set "compiler=Visual Studio 16 2019"
set "buildType=Release"
set python3_executable
@eruffaldi
eruffaldi / openmpcustom.cpp
Created Aug 11, 2016
OpenMP custom reduction example
View openmpcustom.cpp
// g++-mp-4.9 -fopenmp --std=c++11 x.cpp -lgomp
#include <iostream>
#include <omp.h>
#include <unistd.h>
class Custom
{
public:
Custom(int y = 0) : x(y) {}
@eruffaldi
eruffaldi / arucomarker.py
Last active May 18, 2021
Multiple Aruco PDF Marker generator
View arucomarker.py
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 / ffmpeg_opencv.py
Last active Apr 2, 2021
Feeding Python Opencv with FFmpeg
View ffmpeg_opencv.py
#
# Reading video from FFMPEG using subprocess - aka when OpenCV VideoCapture fails
#
# 2017 note: I have realized that this is similar to moviepy ffmpeg reader with the difference that here we support YUV encoding
# BUT we lack: bufsize in POpen and creation flags for windows
# https://github.com/Zulko/moviepy/blob/master/moviepy/video/io/ffmpeg_reader.py
#
# Emanuele Ruffaldi 2016
import cv2
import subprocess
@eruffaldi
eruffaldi / annexgetfile.py
Last active Mar 27, 2021
Access to files in git-annex bare repository without using git-annex.
View annexgetfile.py
#
# Extract files from Bare git-annex repositories without git-annex
# Supports version v6
#
# See internals: http://git-annex.branchable.com/internals/
#
# Modified: added non-bare repos, added tar file (of symlinks) output for use with archivemount
#
# TODO: improve output
# TODO: use cat-files instead of archive
@eruffaldi
eruffaldi / sharedmemory.hpp
Created Mar 6, 2017
Cross Platform Shared Memory and Mutex (alternative to using boost/interprocess
View sharedmemory.hpp
/**
* Emanuele Ruffaldi 2009-2015
*
* C++ Shared Memory Class Cross Platform
*
* Windows: files and named shared memories + named mutex
* Linux: N/A
* OSX: N/A
*
*/
@eruffaldi
eruffaldi / winboot.gv
Created Jan 10, 2017
Windows Boot Sequence as graphviz
View winboot.gv
digraph G
{
node [shape=box];
BIOS -> MBR -> bootmgr -> winload -> otherOSes;
winload -> ntoskrnl;
ntoskrnl [label="ntoskrnl.exe\nLoad Drivers\nLogs in ntbtlog.txt"];
ntoskrnl -> idleprocess;
idleprocess [label="IDLE process (0)"];
ntoskrnl -> systemprocess;
@eruffaldi
eruffaldi / main.cpp
Created Oct 12, 2020
Named Operators in C++ and Unicode
View main.cpp
// Testedt with GCC and CLang
// Not working with ICC due to the UTF-8
// MSVC requires /utf-8 option
#include <iostream>
// from https://riptutorial.com/cplusplus/example/23817/named-operators
// modified to use < > instead of *
// modified for adding unary version
namespace named_operator {
template<class D>struct make_operator{constexpr make_operator(){}};
@eruffaldi
eruffaldi / lambdasignal.cpp
Last active Sep 25, 2020
Signal as Lambda Functions in C++
View lambdasignal.cpp
#include <functional>
#include <fstream>
#include <iostream>
#include <signal.h>
/// one holder per signal type
template <int q>
struct Signal
{
using sfx = void(int );