Skip to content

Instantly share code, notes, and snippets.

Emanuele Ruffaldi eruffaldi

Block or report user

Report or block eruffaldi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eruffaldi
eruffaldi / gist:eb8953dd6aeefa35ac28
Last active Sep 3, 2019
Example of CMake easy libraries
View gist:eb8953dd6aeefa35ac28
# 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()
@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 / lambdasignal.cpp
Last active Apr 5, 2019
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 );
@eruffaldi
eruffaldi / bandwidth.py
Created Sep 2, 2016
USB Bandwidth logging using usbmon
View bandwidth.py
# See: https://www.kernel.org/doc/Documentation/usb/usbmon.txt
# See: http://people.redhat.com/zaitcev/linux/OLS05_zaitcev.pdf
#
# Emanuele Ruffaldi @ SSSA 2016
import sys,os
def scan(name,device=0):
hdevices = dict()
try:
@eruffaldi
eruffaldi / editheader.py
Last active Mar 7, 2019
A simple tool for managing the license header of C/C++ files. Allows for removal, regeneration.
View editheader.py
# Edit Header for C/C++
# Scan Files and Verify license for C/C++
#
# Emanuele Ruffaldi 2015-2016
#
# Usage:
# - select files using a combination of find/grep e.g.
# find . | grep -v buildosx | grep -v buildwin | grep -E ".*\.(cpp|hpp|h)$"
# - verify used headers or per-file
# python editheader.py --filelist FILELIST --all --listlicenses
View midi2notes.py
from mido import MidiFile
import mido
import sys
def ntof(n):
return 440*(2**((n-69)/12))
def main():
mid = MidiFile(sys.argv[1])
View posit_one.h
// cppPosit 7b7b5ecde436a65923d679d91ddb1b29b711af27
/**
* Emanuele Ruffaldi (C) 2017-2018
*
* My personal bit hip pop using BMI extensions and a bit of constexpr!
*/
#if defined(__SDSVHLS__) && !defined(FPGAHLS)
#define FPGAHLS
@eruffaldi
eruffaldi / cf32.jl
Last active Dec 30, 2018
Julia cf32
View cf32.jl
function s64toc64(a::Int64)::Int64
return a < 0 ? -(a & 9223372036854775807) : a;
end
function c64tos64(a::Int64)::Int64
return a < 0 ? ((-a) | -9223372036854775808) : a;
end
@eruffaldi
eruffaldi / ffmpeg_opencv.py
Last active Dec 25, 2018
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 Sep 25, 2018
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
You can’t perform that action at this time.