Skip to content

Instantly share code, notes, and snippets.

View FelDev's full-sized avatar

Félix Paradis FelDev

View GitHub Profile
@FelDev
FelDev / randomize.py
Last active August 7, 2021 12:21
Random mac alert sound from Python
#!/usr/bin/env python3
import subprocess, random, glob
print('HERE WE GO')
sounds = glob.glob('/Users/{yourName}/Library/Sounds/*.aiff')
sound = random.choice(sounds)
print('randomly selected sound: ', sound)
command = 'defaults write .GlobalPreferences com.apple.sound.beep.sound /Users/{yourName}/Library/Sounds/{}.aiff'.format(sound)
# You could also define an array of sounds yourself, if you don't want every
* * * * * command to execute
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
│ │ │ └──────── month (1 - 12)
│ │ └───────────── day of month (1 - 31)
│ └────────────────── hour (0 - 23)
└─────────────────────── min (0 - 59)
// Taken from Ole Michelsen
// https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx.html
// ai.js
module.exports = function unleashAdvancedAI(pathToTextInput) {
let fs = require("fs")
return new Promise(function(resolve, reject) {
try {
let content = fs.readFileSync(pathToTextInput, 'utf8')
let rp = require('request-promise');
rp('https://www.youtube.com/watch?v=dQw4w9WgXcQ') // lol
.then(function (htmlString) {
// It worked! Process htmlString...
})
.catch(function (err) {
// It failed! Handle the error...
});
{"lastUpload":"2021-03-16T02:04:08.623Z","extensionVersion":"v3.4.3"}
@FelDev
FelDev / cronjobs.txt
Created August 16, 2019 17:19
A description of how Cron Jobs work
* * * * * command to execute
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
│ │ │ └──────── month (1 - 12)
│ │ └───────────── day of month (1 - 31)
│ └────────────────── hour (0 - 23)
└─────────────────────── min (0 - 59)
// Took this from Ole Michelsen
// https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx.html
let aPromise = new Promise(function(resolve, reject) {});
console.log(typeof aPromise) // object
console.log(aPromise.constructor.name) // Promise
console.log(aPromise) // Promise { <pending> }
@FelDev
FelDev / appStoreConnectAPIFromNode.js
Last active March 25, 2024 10:15
Boilerplate to authenticate to the App Store Connect API from Node.js
console.log("🏃 appStoreConnectAPIFromNode.js running 🏃‍")
const fs = require('fs');
const jwt = require('jsonwebtoken'); // npm i jsonwebtoken
// You get privateKey, apiKeyId and issuerId from your Apple App Store Connect account
const privateKey = fs.readFileSync("./AuthKey_123456789Z.p8") // this is the file you can only download once and should treat like a real, very precious key.
const apiKeyId = "123456789Z"
const issuerId = "12345678-CLAP-FORR-THIS-GIBBERISHLOLz"
let now = Math.round((new Date()).getTime() / 1000); // Notice the /1000
let nowPlus20 = now + 1199 // 1200 === 20 minutes