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 /
Last active Feb 15, 2018
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
raise argparse.ArgumentTypeError('Boolean value expected.')
eruffaldi /
Last active Feb 7, 2018
Incremental JSON
import json
import sys
def main():
if len(sys.argv) < 2:
print "requires JSON file"
View linuxcpucontrol.bash
# e.g. setgov performance or setgov powersave
function setgov ()
for i in {0..7};
cpufreq-set -c $i -g $1;
# setfreq 3.5GHz 3.5GHz
eruffaldi / opencv_videoio_check.cpp
Created Jan 13, 2018
opencv videowriter bug check cling
View opencv_videoio_check.cpp
.L ./lib/libopencv_videoio.dylib
.L ./lib/libopencv_highgui.dylib
//.L /usr/local/Cellar/opencv/3.3.0_3/lib/libopencv_highgui.3.3.0.dylib
//.L /usr/local/Cellar/opencv/3.3.0_3/lib/libopencv_videoio.3.3.0.dylib
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <math.h>
eruffaldi /
Created Jan 6, 2018
Git Temporary Branch Squashed
git push origin --delete $SQUASHEDBRANCH
git branch -d $SQUASHEDBRANCH
git checkout master
git checkout -b $SQUASHEDBRANCH
git merge --squash $BRANCH
git commit -am "squashed patch"
eruffaldi / resticmount.bash
Created Jan 4, 2018
mount and open folder restic
View resticmount.bash
read -s -p "Enter Password: " mypassword
set -m
RESTIC_PASSWORD=$mypassword restic -r $REPO_PATH mount $MOUNT_PATH &
sleep 2
open $MOUNT_PATH/tags/$TAG/latest
eruffaldi /
Last active Dec 20, 2017
Simple Network Transfer


Receiver: nc -q2 -l 12345 > myfile.tar

Sender tar cf - FILES --verbose --checkpoint=64000 | nc IPDEST 12345

This can be reversed in direction

eruffaldi /
Created Dec 19, 2017
images to pptx using annotation
import argparse
from pptx import Presentation
from pptx.util import Mm,Pt
import pptx
import os
import csv
import json
from PIL import Image # uses pillow
eruffaldi /
Created Dec 14, 2017
Typed CSV Reader and Writer
from csv import DictReader,DictWriter
# originally from pygramel
class TypedDictReader(DictReader):
"""A class for iterating a CSV file and type cast the values."""
def __init__(self, csvfile, casts, fieldnames=None, restkey=None,
restval=None, dialect='excel', *args, **kwds):
- f: An iterable object such as as file. Passed on to
eruffaldi /
Created Nov 3, 2017
Python plot to terminal
import sys
import numpy as np
import json
import base64
import StringIO
import matplotlib.pyplot as plt
import sys
def encode_iterm2_image(data,height=None):
You can’t perform that action at this time.