Skip to content

Instantly share code, notes, and snippets.

@jeffehobbs
jeffehobbs / app.py
Last active July 8, 2023 16:27
AWS lambda wrapper for WeatherKit API + OpenAI Summarization
# generates a REST lambda for WeatherKit data & OpenAI summarization
import requests, json, os, boto3, configparser
from flask import Flask, Response, request, json, jsonify
import openai
app = Flask(__name__)
# set up API keys from external config secrets.txt configparser file
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
@jeffehobbs
jeffehobbs / configuration.yaml
Last active July 8, 2023 16:23
YAML configuration for WeatherKit data into Home Assistant
# Configuration for WeatherKit in Home Assistant: customize lat/long/token
rest:
- resource: https://weatherkit.apple.com/api/v1/weather/en/YOUR_LATITUDE/YOUR_LONGITUDE
headers:
Authorization: 'Bearer YOUR_TOKEN_HERE'
params:
countryCode: 'US'
dataSets: 'currentWeather,forecastDaily,forecastNextHour,forecastHourly,weatherAlerts'
timezone: 'GMT-5'
scan_interval: 60
@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.
@vi
vi / split_by_silence.sh
Last active February 23, 2024 13:18
Using FFmpeg to split multimedia file into parts based on audio volume level
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then