Skip to content

Instantly share code, notes, and snippets.

View dardo82's full-sized avatar
🏠
Working from home

Michele Venturi dardo82

🏠
Working from home
View GitHub Profile
@dardo82
dardo82 / Dummy-Finder.applescript
Last active February 17, 2016 22:57
Fake wrapper for Dock
repeat while true
try
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
if (frontApp is equal to "Dummy-Finder") then
tell application "/System/Library/CoreServices/Finder.app" to activate
end if
on error
delay 1
@dardo82
dardo82 / Microscope.applescript
Created February 17, 2016 23:42
Select it in Photo Booth
tell application "Photo Booth" to activate
tell application "System Events"
click (menu item 1 of menu 1 of menu bar item 6 of menu bar 1 of (first application process whose frontmost is true))
end tell
@dardo82
dardo82 / AirPlay-Mirror.applescript
Last active February 18, 2016 05:03
Start AirPlay mirroring
on run argv
if (count of argv) is 2 then
set n to item 1 of argv
else
set n to 3
end if
if "stop" is in argv then
set n to 2
end if
tell application "System Events"
@dardo82
dardo82 / TeleIride.sh
Created February 26, 2016 01:37
Rec TeleIride's stream
#!/bin/sh
gtimeout --foreground $1 youtube-dl --no-part livestre.am/huy; killall avconv
@dardo82
dardo82 / morse-light.sh
Last active January 31, 2022 04:39
Morse code USB light
#!/bin/zsh
# Flash a message in Morse code with an USB light
uhubctl -a 1; sleep 4.0
UHCOPTS=$(uhubctl | awk '{ text=text"\n"$0; if ($0~/hub/) text=$0; if (text~/power$/) { print text; text="" } }' \
| awk -F',| |:' -v ORS=" " '{ print $5 }' | awk '{ print "-p "$2" -l "$1 }')
uhubctl -a 0 ${=UHCOPTS}
alias dit="uhubctl -a 1 $UHCOPTS; sleep 0.1; uhubctl -a 0 $UHCOPTS"
alias dah="uhubctl -a 1 $UHCOPTS; sleep 0.6; uhubctl -a 0 $UHCOPTS"
@dardo82
dardo82 / arduino.sh
Last active March 29, 2016 19:31
Arduino: build & upload
#!/bin/zsh
A=arduino; B=build; HW=hardware; T=tools;
AA=${(C)A}.app; INOD=${1%/*}; rm -frv $INOD/$B; mkdir $INOD/$B
cd $(stat -f %Y $(locate $AA | grep -m1 $AA\$))/Contents/Java/
FAOD=$1$OLDPWD/; INOF=${FAOD:#/*}$1; BPATH=${FAOD:#/*}$INOD/$B
$A-${B}er -$HW=$HW -$T=$T-${B}er -$T=$HW/$T/avr -libraries=libraries -$B-path=${BPATH/$1} -fqbn=${A}:avr:uno -verbose ${${INOF/$1}:-$1}
avrdude -C$HW/$T/avr/etc/avrdude.conf -v -patmega328p -c$A -P$(ls /dev/cu.usbmodem*) -b115200 -D -Uflash:w:$(ls ${BPATH/$1}/*ino.hex):i
@dardo82
dardo82 / radioblu.sh
Last active March 31, 2016 21:15
Rec RadioBlu stream
#!/bin/sh
gtimeout $1 curl nr5.newradio.it:8701/stream > radioblu.m4a
@dardo82
dardo82 / edit-vid@black.sh
Last active August 22, 2017 06:27
Edit at black frame
#!/bin/sh
TS="$1";BN="${TS%.*}";ED="$BN-edit";LOG="${TS%/*}/ffmpeg.log";VF="blackdetect"
ffmpeg -i $TS -vf $VF=d=0.04 -f rawvideo -y /dev/null 2>&1 | tr \\r \\n > $LOG
eval $(awk -F ':| ' 'BEGIN {be=0.00} /black/ {print "ffmpeg -i $TS -ss "be" -to "$5" $BN-"NR".ts;"; be=$7}' $LOG)
for FILE in $BN-*;do ffprobe $FILE 2>&1 | grep -q " 00:0" && rm -fv $FILE;done
cat $BN-* > $ED.ts; ffmpeg -i $ED.ts $ED.mp4; rm -fv $BN-*.ts $LOG
@dardo82
dardo82 / face-dims.js
Last active February 22, 2017 09:23
OpenCV pics filter
/*jslint node: true, nomen: true*/
"use strict";
var path = require('path');
var _ = require('underscore');
var Faced = require('faced');
var faced = new Faced();
function worker(faces, image, file) {
@dardo82
dardo82 / media-time.sh
Last active October 30, 2018 23:57
Total Media Time
#!/bin/zsh
# Print total input media duration.
MS=$(printf "%0.f\n" "0$(mediainfo --Full --Output='General;+%Duration%' $~@)")
echo "$[$MS/3600000]:$[$[$MS%3600000]/60000]:$[$[$MS%60000]/1000],$[$MS%1000]"