This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit: https://github.com/erkie/erkie.github.com | |
(function() { | |
function Asteroids() { | |
if ( ! window.ASTEROIDS ) | |
window.ASTEROIDS = { | |
enemiesKilled: 0, | |
startedPlaying: (new Date()).getTime() | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = 'https://covid-sheets-mirror.web.app/api?' | |
const sid = '1nUUU5zPRPlhAXM_-8R7lsMnAkK4jaebvIL5agAaKoXk' | |
function params(obj) { | |
return Object.entries(obj) | |
.map(([key, val]) => `${key}=${encodeURI(val)}`).join("&") | |
} | |
const cases = url + params({ | |
cache: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = Application.currentApplication() | |
app.includeStandardAdditions = true | |
function getJSON(path) { | |
const fullPath = path.replace(/^~/, app.pathTo('home folder')) | |
const contents = app.read(fullPath) | |
return JSON.parse(contents) | |
} | |
function run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toggleFocus(focus) { | |
const app = Application("System Preferences") | |
const pane = app.panes.byId("com.apple.preference.notifications").anchors.byName("Focus") | |
app.reveal(pane) // Open the preference pane | |
// Useful way of inspecting the UI hierarchy of an open app: | |
// Application("System Events").applicationProcesses.byName("System Preferences").entireContents() | |
const ui = Application("System Events").applicationProcesses.byName("System Preferences").windows.byName("Notifications & Focus").tabGroups.at(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-purple; icon-glyph: chart-line; | |
const data = [59, 56, 52, 58, 57, 57, 52, 53] | |
// [points] to img of smooth (bezier) line graph | |
function lineGraph(points, width, height, line) { | |
let context = new DrawContext() | |
context.size = new Size(width, height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-blue; icon-glyph: medal; | |
async function getData() { | |
//const url = "https://sph-c-api.olympics.com/summer/competition/api/ENG/medals" // Olympic Games | |
const url = "https://sph-c-api.olympics.com/summer-para/competition/api/ENG/medals" // Paralympic Games | |
const req = new Request(url) | |
const res = await req.loadJSON() | |
return await res.medalStandings.medalsTable | |
} |