Skip to content

Instantly share code, notes, and snippets.

@LucaTNT
LucaTNT / parseTrenitaliaICS.php
Last active September 19, 2023 06:24
Parse Trenitalia ICS
<?php
// Based on CalFileParser (https://github.com/controlz/CalFileParser) by Michael Mottola
// Author: @LucaTNT
// My code is MIT licensed as well
// Inserisci qui dove salvare il file ICS sistemato
$saveTo = '/Users/luca/Downloads/AddToiCal.ics';
/*
* CalFileParser
@LucaTNT
LucaTNT / sign-stripe-webhook-request.sh
Created June 26, 2022 15:45
Shell script to sign a Stripe webhook event
#!/usr/bin/env bash
WEBHOOK_DESTINATION="http://localhost:3000/stripe/webhook"
WEBHOOK_SECRET="whsec_ENTER_YOURS_HERE"
if [[ ! "$#" -eq 1 ]]; then
echo "USAGE: $0 /path/to/event.json";
exit 1;
fi
timestamp="$(date +%s)."
@LucaTNT
LucaTNT / azure-text-to-speech.py
Last active April 20, 2022 15:53
Script that synthesizes EasyApple intros with Azure's text-to-speech APIs
import requests
def getToken():
req = requests.post("https://westeurope.api.cognitive.microsoft.com/sts/v1.0/issuetoken",
headers={"Ocp-Apim-Subscription-Key": "YOUR_AZURE_API_KEY_HERE"},
)
return req.text
def textToMp3(text, voice="it-IT-ElsaNeural"):
@LucaTNT
LucaTNT / recordCam.sh
Last active June 17, 2021 19:56
Record Foscam IP camera live feed
#!/bin/bash
# recordCam.sh
# ------------
# This script saves the live video from the Foscam IP camera to a full-quality mp4 file.
# I chose to split the files every 15 minutes (900 seconds), to quickly find the time I need.
# Note: audio is not saved as my cameras don't have a microphone connected to them.
# -----------
# Author: @LucaTNT
# License: BSD
@LucaTNT
LucaTNT / convertVideo.sh
Created August 1, 2014 11:04
Convert IP camera recordings to lower quality for archiving
#!/bin/bash
# convertVideo.sh
# ---------------
# This script converts the original, high quality recording to a much smaller
# and lower quality file for archiving purposes.
# ---------------
# Author: @LucaTNT
# License: BSD
# Define some paths
@LucaTNT
LucaTNT / Spotify-now-playing-on-TouchBar.scpt
Last active September 27, 2018 09:51
This script can be used in conjunction with Better Touch Tool to display the currently playing track in Spotify on the MacBook Pro TouchBar. More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
-- This script can be used in conjunction with Better Touch Tool to display the currently playing track on the MacBook Pro TouchBar
-- More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
if application "Spotify" is running then
tell application "Spotify"
if player state is playing then
return (get artist of current track) & " - " & (get name of current track)
else
return ""
end if
@LucaTNT
LucaTNT / iTunes-now-playing-on-TouchBar.scpt
Last active September 27, 2018 09:51
his script can be used in conjunction with Better Touch Tool to display the currently playing track in iTunes on the MacBook Pro TouchBar. More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
-- This script can be used in conjunction with Better Touch Tool to display the currently playing track on the MacBook Pro TouchBar
-- More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
if application "iTunes" is running then
tell application "iTunes"
if player state is playing then
return (get artist of current track) & " - " & (get name of current track)
else
return ""
end if
@LucaTNT
LucaTNT / lookForNewiOS.sh
Last active March 28, 2018 17:59
Automatic iOS firmware downloader
#!/bin/bash
# lookForNewiOS.sh
# Author: Luca Zorzi (@LucaTNT)
# Version: 0.2 (2014/11/20)
# License: BSD
# -----------------------------
# This scripts uses icj.me's API to check if there are new iOS releases for
# the iOS devices specified in the MODELS array. You can put any number of devices,
# as long as they are in an array (space separated, enclosed in brackets).
# If a new release is available, it gets download into the DESTINATION_FOLDER, respecting
@LucaTNT
LucaTNT / apritiSesamo.py
Last active July 26, 2017 18:00
Script that triggers a relay connected to GPIO 25 on a Raspberry Pi in order to open a garage door
#!/usr/bin/env python
from gpiozero import LED, Button
from time import sleep
from flask import Flask
import datetime
portone = LED(25)
app = Flask(__name__)
@LucaTNT
LucaTNT / ForceFinderRefresh.applescript
Created April 26, 2017 18:36
Script that forces the refresh of the current Finder window
tell application "Finder"
tell front window to update every item
try
delete (make new file at (front window) with properties {name:".refresh.tmp"})
end try
end tell