Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / cf32.jl
Last active December 30, 2018 11:07
Julia cf32
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 / gettoken.sh
Created September 25, 2018 09:23
Google OAuth 2.0 full example bash script.
#!/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"
import os,sys
people = [x.split(" ") for x in """1 10 name""".split("\n")]
print (people)
for f,n,name in people:
f = int(f)
n = int(n)
print (f,f+n-1,name)
os.system("gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=%d -dLastPage=%d -sOutputFile=%s.pdf \"%s\"" % (f,f+n-1,name,sys.argv[1]))
@eruffaldi
eruffaldi / timeline-kml-work.py
Created July 13, 2018 08:15
Google Timeline KML to working enter-exit
# parses KML from Google Timeline to obtain places
# Emanuele Ruffaldi 2018
import os,sys
import csv
import datetime
import xml.etree.ElementTree as ET
from collections import defaultdict
import time
from dateutil import tz
from_zone = tz.tzutc()
@eruffaldi
eruffaldi / gist:cd82d29292291a85daa9d8d41f094a65
Created June 8, 2018 08:31
Bash find changed files of Today
find / -mtime -1 -not \( -path "/proc/*" -o -path "/sys/*" -o -path "/dev/*" \) -print
@eruffaldi
eruffaldi / word_comments_to_json.vbs
Created May 28, 2018 07:28
Microsoft Word VBA code for Comment to JSON
Sub ListComments()
Dim x As Document
Set doc = Word.ActiveDocument
For k = 1 To doc.Comments.Count
Dim co As Comment
Set co = doc.Comments(k)
co.Range.Select
t = Selection.Text
@eruffaldi
eruffaldi / foldersgit.sh
Created May 23, 2018 13:39
List git folders remote colored
#!/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 10:00
Mount Samba and Clone using rclone
#!/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 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 / closejson.py
Last active February 7, 2018 14:21
Incremental JSON
import json
import sys
def main():
if len(sys.argv) < 2:
print "requires JSON file"
else:
try: