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 / mkicns.sh
Last active February 2, 2016 01:39
Make ICNS from PNG
#!/bin/zsh
#mkicns.sh
FN=${1##*/}
DN=${1%/**}
BN=${FN%.*}
IS=iconset
ID=$BN.$IS
@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 / Stream-STEnt.sh
Last active February 26, 2016 03:15
Stream StarTrek Ent
#!/bin/sh
# Stream an FLV to AppleTV
# using AirPlay mirroring
airplay-mirror start
URL="guardarefilm.tv/serie-tv-streaming/3506-star-trek-enterprise.html";EP=${1/x/_}
open -W -a vlc $(curl $URL|sed -n "s/embed/mobile/;s/-640x360.html/.mp4/;/sd-$EP\"/p"|cut -d\" -f8)
airplay-mirror stop
@dardo82
dardo82 / tvl.sh
Last active March 28, 2016 06:57
Rec TVL stream
#!/bin/zsh
MM3U8="live-04.viewer.dacast.com/i/dclive_1@104057/master.m3u8"
TJSON="http://services.dacast.com/token/i/b/28193/c/34004.json"
TOKEN="$(print $(curl -s "$TJSON" | awk -F'["]' '{print $6}'))"
IM3U8="$(curl -s "$MM3U8""$TOKEN" | awk '/m3u8/')"
TSSEG="$(curl -s "$IM3U8" | awk '/ts/{match($0,/([0-9]+)_/,a);\
sub(/([0-9]+)_/,"["a[1]"-"a[1]+9"]_");print $0;exit}')"
curl --limit-rate 100k "$TSSEG" >> tvl.ts
@dardo82
dardo82 / radiorosa.sh
Last active March 28, 2016 06:57
Rec RadioRosa stream
#!/bin/sh
# Download n seconds of RadioRosa stream
gtimeout ${1}s curl http://onair15.xdevel.com:8100/ > radiorosa.mp3
# gtimeout ${1}s curl http://onair15.xdevel.com:8072/ > radiorosa.m4a
@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