Skip to content

Instantly share code, notes, and snippets.

View Pe8er's full-sized avatar
🤡
Calzone will not be tolerated

Piotr Gajos Pe8er

🤡
Calzone will not be tolerated
View GitHub Profile
{
"BTTWidgetName" : "Next Event",
"BTTTriggerType" : 639,
"BTTTriggerTypeDescription" : "Apple Script Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 49,
"BTTPredefinedActionName" : "Launch Application \/ Open File \/ Start Apple Script …",
"BTTLaunchPath" : "file:\/\/\/Applications\/Calendar.app",
"BTTAdditionalConfiguration" : "\/bin\/bash:::-c",
"BTTEnabled2" : 0,
set nextEvent to do shell script "~/.dotfiles/bin/icalBuddy -ec 'Found in Natural Language' -npn -nc -iep 'datetime,title' -po 'datetime,title' -eed -ea -n -li 1 -ps '|: |' -b '' eventsToday"
--log nextEvent
if nextEvent is not "" then
set AppleScript's text item delimiters to " @& "
set itemCount to count of text items of nextEvent
--log itemCount
if itemCount is 1 then
{
"BTTPresetName" : "Default",
"BTTPresetUUID" : "77CE7DAA-5E4B-4BD5-AE1C-7165D3F519FF",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
on run arguments
-- Debugger
if class of arguments is script then set arguments to {"US/Pacific", "Pacifica", "24"}
tell arguments
-- Set up the location and city name
set theLocation to item 1
set APIKey to "????" -- your secret Dark Sky API key. Get it here: https://darksky.net/dev/account
tell application "JSON Helper"
try
set latLon to do shell script "/usr/local/bin/locateme -f '{LAT},{LON}'"
set weather to fetch JSON from "https://api.darksky.net/forecast/" & APIKey & "/" & latLon & "?exclude=minutely,hourly,daily,alerts,flags&units=si"
on error e
return e
end try
set nextEvent to do shell script "~/.dotfiles/bin/icalBuddy -ec 'Found in Natural Language' -npn -nc -iep 'title,datetime,location' -eed -ea -n -li 1 -ps '| @& |' -b '' eventsToday"
log nextEvent
if nextEvent is not "" then
set AppleScript's text item delimiters to " @& "
set itemCount to count of text items of nextEvent
--log itemCount
if itemCount is 1 then
set localComputer to "" -- enter name of a remote computer
set username to "" -- remote computer username
set computerPassword to "" -- remote computer password
set remoteComputer to "eppc://" & username & ":" & computerPassword & "@" & localComputer
set rTunes to application "iTunes" of machine remoteComputer
if application "iTunes" is running then
try
tell application "iTunes"
set {tArtist, tName, tAlbum, theID} to {artist, name, album, database ID} of current track
if application "iTunes" is running then
tell application "iTunes" to set {tArtist, tName, tAlbum, isLoved} to {artist, name, album, loved} of current track
if isLoved is true then
set isLoved to "★" & space
else
set isLoved to "☆" & space
end if
return isLoved & tArtist & space & "-" & space & tName
else
return ""
global jsonWeek, jsonYear, jsonAthlete, athleteID
property token : "????" -- your Strava API access token. Get it here: https://www.strava.com/settings/api
property yearRideGoal : 2000 -- in kilometers
property enableLogging : "off" --- options: on | off
on run theArgument
-- Set up the JSON files
tell application "Finder"
on run (argv)
--use this to debug. Options: myPortfolio, btc, ltc
if class of argv is script then set argv to {"myPortfolio"}
set myInvestment to 1528.73 --how much USD you invested
set myBTC to 0.0758 --how much BTC you have
set myETH to 1.7872 --how much ETH you have
set myLTC to 4.9431 --how much LTC you have