Skip to content

Instantly share code, notes, and snippets.

lucianogiuseppe /
Last active Sep 10, 2017
Script per automatizzare il processo di ascolto del Vinile sul bluetooth via RaspberryPi o altri Linux device
import bluetooth
from bluetoothctl import BluetoothctlError, Bluetoothctl #Python3: fix Exceptions syntax
import subprocess
import time
import pulsectl
def setOutAudio(bName):
with pulsectl.Pulse() as pulse:
for sink in pulse.sink_list():
lucianogiuseppe / jpeg_sof_finder.html
Created May 6, 2017
Javascript JPEG SOF finder
View jpeg_sof_finder.html
<!doctype html>
<input type='file' accept='image/*' onchange='openFile(event)'>
<span id="sizes"></span>
<canvas id='output'></canvas>
lucianogiuseppe /
Created Aug 13, 2016
Java WordCount on Spark using Dataset
//tested on spark 2.0
import org.apache.spark.sql.*;
import java.util.Arrays;
public class WordCount {
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Please provide the full path of input file and output dir as arguments");
View MakeKFold.r
#Example of use
k = 7;
indici <- 1:length(tLabel) #take index of labels
#indici <- sample(indici) #permutation
lbl1 = which(tLabel == 0); #samples with label 0
lbl2 = which(tLabel == 1); #samples with label 1
lbl3 = which(tLabel == 2); #samples with label 2
#Make the k-fold for each label
lucianogiuseppe /
Created Sep 24, 2015
A Python memory and computational optimized version of Harmonic Centrality
#This function compute the harminic distance of graph's nodes
#graph is a dictionary implementation of adjacency list { 1 : [1,2,3], ...}
#return a dictionary where keys are nodes name and values are node harmonic distances
def harmonic2(graph):
#for dynamic programming
harmRes = dict()
for i in graph.keys():
harmRes[i] = 0.0
#for each node compute the distance from reachable nodes