Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / udptunnel.sh
Created October 16, 2017 09:52
SSH UDP Tunnelling: remote to local UDP server
# Only for remote UDP https://stackpointer.io/network/ssh-port-forwarding-tcp-udp/365/
# Local UDP server to Remote UDP server
ssh -L 9999:127.0.0.1:9999 percro@alientelecom socat tcp4-listen:9999,reuseaddr,fork udp:target:9999
socat -T15 udp4-recvfrom:9999,reuseaddr,fork tcp:localhost:9999
# Remote UDP server to Local UDP server
ssh -R 9999:127.0.0.1:9999 percro@alientelecom socat udp4-recvfrom:9999,reuseaddr,fork tcp:localhost:9999
socat -T15 tcp4-listen:9999,reuseaddr,fork udp:localhost:9999
@eruffaldi
eruffaldi / udp_player.py
Last active October 20, 2023 15:35
Simple UDP packet recorder and playback
# Emanuele Ruffaldi 2018
import argparse,socket,socket,json,time
def str2bool(v):
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
@eruffaldi
eruffaldi / openmpcustom.cpp
Created August 11, 2016 10:22
OpenMP custom reduction example
// 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 / pptx2txt.py
Created September 7, 2023 14:38
Exports PPTX to TXT
# EXCLUDES Comments
from pptx import Presentation
import sys
prs = Presentation(sys.argv[1])
for i,slide in enumerate(prs.slides):
print("---------------------- Slide %d" % (i+1))
for shape in slide.shapes:
if hasattr(shape, "text"):
print(shape.text)
@eruffaldi
eruffaldi / annexgetfile.py
Last active August 23, 2023 13:05
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 / bandwidth.py
Created September 2, 2016 12:12
USB Bandwidth logging using usbmon
# 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 / sharedmemory.hpp
Created March 6, 2017 12:54
Cross Platform Shared Memory and Mutex (alternative to using boost/interprocess
/**
* 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 / build.cmd
Created June 20, 2021 03:14
Compile NVIDIA Windows
% 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 / 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 / winboot.gv
Created January 10, 2017 12:34
Windows Boot Sequence as graphviz
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;