Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@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 / editheader.py
Last active March 7, 2019 12:50
A simple tool for managing the license header of C/C++ files. Allows for removal, regeneration.
# 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
@eruffaldi
eruffaldi / annexgetfile.py
Last active September 25, 2024 03:40
Access to files in git-annex bare repository without using git-annex.
#
# 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 / 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)
{
@eruffaldi
eruffaldi / CMakeLists.txt
Last active May 27, 2016 04:02 — forked from allanmac/assert_cuda.c
A tiny example of CUDA + OpenGL interop with write-only surfaces and CUDA kernels. Uses GLFW+GLAD.
#sudo pip install --upgrade git+https://github.com/dav1dde/glad.git#egg=glad
#python main.py --api gl=3.3 --generator=c --out-path=GL
find_package(CUDA)
find_package(GLFW)
include_directories(${GLFW_INCLUDE_DIRS})
include_directories(GL/include)
cuda_add_executable(main main.c assert_cuda.c interop.c GL/src/glad.c kernel.cu)
target_link_libraries(main ${GLFW_LIBRARY})
@eruffaldi
eruffaldi / xcd.sh
Last active March 16, 2016 12:07
Named working locations or initialization
#!/bin/bash
function _xcdall()
{
#enter below space separated your commands
eval "$1='pd1 xxx u14'"
}
function xcd() {
local arrIN sep before after what
what=$1
@eruffaldi
eruffaldi / learnexp.el
Last active April 6, 2016 16:16
Lisp Interpreter in Python with Code Generation tailored to Matrix manipulation
(
list
(defun makefactor (n)
(define q dict)
(set! q.vars dict)
(set! q.uS dict)
(set! q.Jhg (gaussianc n))
q
)
(define f1 (makefactor 2))
@eruffaldi
eruffaldi / mergelatex.py
Last active December 26, 2017 18:33
Tool for merging LaTeX paper into single Tex without bib, also provides dependency list for Makefile of LaTex.
#Emanuele Ruffaldi 2014-2016
#
#TODO: add frontiersSCNS.cls frontiersinSCNS_ENG_HUMS.bst in replicable
#TODO: add logo1
#TODO: don't merge
import os,sys,re,argparse
def checkpaths(f,paths):
if os.path.isfile(f):
return f
@eruffaldi
eruffaldi / reusablememory.cpp
Created May 16, 2016 16:01
Memory pool shared ptr
#include <memory>
#include <vector>
#include <iostream>
#include <list>
template <class T>
class VectorPool
{
public:
~VectorPool()