Skip to content

Instantly share code, notes, and snippets.

@jeffehobbs
jeffehobbs / get_wk_token.py
Last active February 1, 2024 20:24
Get ADC WeatherKit token for REST API
# get_wk_token.py // jeffehobbs@gmail.com // Nov. 2022
# from documentation here, which you should read first:
# https://developer.apple.com/documentation/weatherkitrestapi/request_authentication_for_weatherkit_rest_api
#
# 1. Have a valid ADC acount. https://developer.apple.com
# 2. Download this script, and open it in a text editor. You'll have to change three variables.
# 3. Make up a reverse-domain name service ID (i.e., com.domain.app). Place this in SERVICE_ID.
# 4. Create an ADC service identifier. https://developer.apple.com/account/resources/identifiers/add/bundleId
# 5. Create an ADC service key. https://developer.apple.com/account/resources/authkeys/add
# 6. Download that service key, rename to 'wkservicekey.p8', and move it into same directory as this script.
@jeffehobbs
jeffehobbs / craigsdalle.py
Last active May 12, 2023 22:19
builds DALL-E art from Craigslists posts & tweets 'em (https://twitter.com/mistconnectnbot)
# craigsdalle - builds DALL-E art from Missed Connections posts & tweets
# jeffehobbs@gmail.com // November 2022
import asyncio
from pyppeteer import launch
import openai, tweepy, requests, configparser, os, shutil, hashlib
from mastodon import Mastodon
# set up API keys from external config apikeys.txt file
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
@jeffehobbs
jeffehobbs / quit_all.scpt
Last active July 18, 2022 19:16
AppleScript to quit all open Applications on MacOS
tell application "System Events" to set the visible of every process to true
set allow_list to {"Finder"}
try
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
set this_process to item i of the process_list
@jeffehobbs
jeffehobbs / waveform.py
Last active June 30, 2022 22:22
waveform.py: make cool lookin' twitter-sharable video from .wav file
# waveform.py | jeffehobbs@gmail.com
# Process an .wav audio file, make an .mp4 waveform video suitable for TWTR
# usage: waveform.py audiofile.wav
import subprocess, random, argparse, os
# get input
parser = argparse.ArgumentParser(description='Process an .wav audio file, make an .mp4 waveform video.')
parser.add_argument('file', type=str, help='filename')
args = parser.parse_args()
@jeffehobbs
jeffehobbs / recaptcha_v3.py
Created June 24, 2022 18:04
recaptcha_v3_endpoint.py
# minimally viable recaptcha v3 lambda
# jeffehobbs@gmail.com
from flask import Flask, Response, request, jsonify
from flask_cors import CORS
import requests
SECRET_KEY = 'your_recaptcha_v3_server_side_token'
app = Flask(__name__)
@jeffehobbs
jeffehobbs / convert_mkv.sh
Created June 12, 2022 22:43
convert mkvs to mp4s via container swap
for i in *.mkv; do
ffmpeg -i "$i" -codec copy "${i%.*}.mp4"
done
@jeffehobbs
jeffehobbs / zsh
Created June 4, 2022 20:20
FFMPEG convert all .aif files in directory to .wav
mkdir wav; for i in *.aif; do ffmpeg -i "$i" "./wav/${i%.*}.wav"; done
@jeffehobbs
jeffehobbs / app.py
Last active June 9, 2022 20:42
hotgrepper
# hotgrepper.py | jeffehobbs@gmail.com
import requests, json, boto3, random, os, videogrep, configparser
from collections import Counter
from yt_dlp import YoutubeDL
from tweepy import OAuthHandler
from tweepy import API
STOPWORDS = ["i", "we're", "you're", "that's", "it's", "us", "i'm", "me", "my", "myself", "we", "our", "ours", "ourselves", "you", "your", "yours", "yourself", "yourselves", "he", "him", "his", "himself", "she", "her", "hers", "herself", "it", "its", "itself", "they", "them", "their", "theirs", "themselves", "what", "which", "who", "whom", "this", "that", "these", "those", "am", "is", "are", "was", "were", "be", "been", "being", "have", "has", "had", "having", "do", "does", "did", "doing", "a", "an", "the", "and", "but", "if", "or", "because", "as", "until", "while", "of", "at", "by", "for", "with", "about", "against", "between", "into", "through", "during", "before", "after", "above", "below", "to", "from", "up", "down", "in", "out", "on", "off", "over", "under", "again", "further", "then"
@jeffehobbs
jeffehobbs / beepy_boopy.py
Created March 22, 2022 01:51
loop of fast and slow random audio
import time
import random
import array
import math
import audiocore
import board
import digitalio
import audiobusio
audio = audiobusio.I2SOut(board.GP10, board.GP11, board.GP9)
@jeffehobbs
jeffehobbs / tones.py
Last active April 4, 2022 13:34
simple python script that generates a set of smoothly looping tones
import math, wave, array
filenames = []
for filename in range(32):
x = filename % 8
y = filename / 8
filenames.append(str(math.trunc(y)) + str(x))
# use range to generate tones (lowest Hz, highest Hz, steps in Hz between)
for frequency in range(20, 460, 20):