Skip to content

Instantly share code, notes, and snippets.

Avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / foldersgit.sh
Created May 23, 2018
List git folders remote colored
View foldersgit.sh
#!/bin/bash
RESTORE='\033[0m'
RED='\033[00;31m'
GREEN='\033[00;32m'
YELLOW='\033[00;33m'
BLUE='\033[00;34m'
PURPLE='\033[00;35m'
CYAN='\033[00;36m'
LIGHTGRAY='\033[00;37m'
@eruffaldi
eruffaldi / myclone.bash
Created May 11, 2018
Mount Samba and Clone using rclone
View myclone.bash
#!/bin/bash
IP=XXXXX
USERNAME="Emanuele%20Ruffaldi"
SHARE_NAME="Emanuele%20Ruffaldi"
MOUNT_POINT=$HOME/mnt/smb
# ask for password
read -s -p "Password: " PASSWD
if [ ! -d "$MOUNT_POINT" ]
then
@eruffaldi
eruffaldi / udp_player.py
Last active Feb 15, 2018
Simple UDP packet recorder and playback
View udp_player.py
# 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 / closejson.py
Last active Feb 7, 2018
Incremental JSON
View closejson.py
import json
import sys
def main():
if len(sys.argv) < 2:
print "requires JSON file"
else:
try:
View linuxcpucontrol.bash
# e.g. setgov performance or setgov powersave
function setgov ()
{
for i in {0..7};
do
cpufreq-set -c $i -g $1;
done
}
# setfreq 3.5GHz 3.5GHz
@eruffaldi
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
eruffaldi / gitsquashed.sh
Created Jan 6, 2018
Git Temporary Branch Squashed
View gitsquashed.sh
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
eruffaldi / resticmount.bash
Created Jan 4, 2018
mount and open folder restic
View resticmount.bash
#!/bin/bash
read -s -p "Enter Password: " mypassword
set -m
RESTIC_PASSWORD=$mypassword restic -r $REPO_PATH mount $MOUNT_PATH &
lastp=$!
sleep 2
open $MOUNT_PATH/tags/$TAG/latest
fg
@eruffaldi
eruffaldi / transfer.md
Last active Dec 20, 2017
Simple Network Transfer
View transfer.md

Direct

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

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

This can be reversed in direction

@eruffaldi
eruffaldi / scan2pptx.py
Created Dec 19, 2017
images to pptx using annotation
View scan2pptx.py
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