Skip to content

Instantly share code, notes, and snippets.

View funwhilelost's full-sized avatar
:octocat:

Andy Jacobs funwhilelost

:octocat:
  • Pullman, WA
  • 00:59 (UTC -07:00)
View GitHub Profile
@funwhilelost
funwhilelost / README.md
Last active January 17, 2024 17:55
Use Dreamhost DreamObjects with WP Offload Media Tweaks plug-in

Use WP Offload Media with DreamObject on Dreamhost

Based on this tutorial from Minio I implemented a similar integration with DreamObjects. The WP Offload Media Tweaks plug-in must be installed then hacked on. The file includes examples directly in the code and commented out, including minio examples.

I referenced the DreamObjects S3 API docs and came up with these example integrations. On Dreamhost you can edit files directly using the "Manage files" when from the Dreamhost panel. Beware - you can easily "white screen" your WordPress with bad syntax so keep a backup.

@funwhilelost
funwhilelost / fetchFeeds.js
Created November 23, 2022 17:38
Fetch Feeds with serial promise resolution (and throttling delays, as needed)
/**
* recursively walk through a queue one at a time synchronously
*
* @param q {Array<() => Promise>} a list of functions that will run an async thing and return a promise
*/
const runQueue = async (q) => {
if (q.length > 0) {
const nextStrategyToRun = q.pop();
// next is an executable strategy function to get video url contents
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@funwhilelost
funwhilelost / record_kexp.sh
Created March 31, 2021 15:39
Record KEXP to MP3 file
#!/bin/bash
# Save streaming audio to an mp3 file. Requires lame.
# This script will record for the duration entered below.
# Customize the stream URL, duration, filename, and working directory.
#
# Written by Matthew Beckler (matthew at mbeckler dot org)
STREAM="http://216.246.37.218:80/kexp128-backup.mp3"
DURATION="2:00:00"
DATESTR="$(date +%Y-%m-%dZ%H-%M)"
@funwhilelost
funwhilelost / backup_to_s3.sh
Created May 16, 2020 07:42
bash script to tarball a php, mysql, and apache backup
#!/bin/bash
cd /tmp
rm -rf backup
mkdir backup
cd backup
mysqldump -u adventuremuch -p1234#dcba --databases adventuremuch > "wordpress-database.sql"
cp -R /etc/apache2/sites-enabled .
@funwhilelost
funwhilelost / water.php
Created May 15, 2020 23:28
Scrape USGS water temp and serve as JSON
<?php
// Lower Granite Dam temp in celcius
// https://waterdata.usgs.gov/nwis/uv?cb_00010=on&format=rdb&site_no=13343595&period=1&begin_date=2020-03-25&end_date=2020-04-01
function get_snake_river_temp() {
$data = file_get_contents('https://waterdata.usgs.gov/nwis/uv?cb_00010=on&format=rdb&site_no=13343595&period=1&begin_date=2020-03-25&end_date=2020-04-01');
preg_match_all('/USGS.*\t(.+)\tP$/', $data, $matches);
$last_temp_c = floatval($matches[1][0]);
$last_temp_f = 32 + (9/5 * $last_temp_c);
@funwhilelost
funwhilelost / ComputerOn.ps1
Created April 25, 2020 17:50
HomeAssistant send binary_sensor updates from PowerShell
$json = @"{"state": "on", "attributes": [{"device_class": "motion", "friendly_name": "Computer On"}] }"@
$headers = @{}
# $headers["X-Api-Key"] = "j65k423lj4k2l3fds"
Invoke-WebRequest -Uri "http://<YOUR_IP>:8123/api/states/binary_sensor.computer_on" -Body $json -ContentType "application/json" -Headers $headers -Method Post
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD4Taj8q6NzSQtzqY1460WdyZcilFk8SOAuHxa6dUFXZNScsLz/dwGxkS2Q1K7ZfnjVGVmJURHepqEpod6h8FmRG7dxBL+0go0O348s209U4OScwz6bq9Zn9o8BFSpEncINiE5PgzSGA7IR8zJsOvdNutj+cH0Ge8ECUKVuHYSvtOx9W3HdFy32sLnZJzx4w0UbQVB8wcCMHzLJQeN/gFbJAA/xIqALkuRxcuO7DulvoGk9AWgSqqPCiZfxtqoxDwMzBzf+pxz3mVj+Vl4zvmpOiVSDefuxrlrJxWIz4fmmcH646+brcPznqDWng2th3pehoAukjPlu5AyzzxxbqTKD tej4mbk
@funwhilelost
funwhilelost / streaming-radio.m3u
Created January 7, 2019 04:15
Streaming Radio
#EXTM3U
#EXTINF:-1,KEXP 90.3 Seattle
https://kexp-mp3-128.streamguys1.com/kexp128.mp3
#EXTINF:-1,KZUU 90.7 Pullman
http://69.175.94.98:8091/stream
@funwhilelost
funwhilelost / ChallengeController.rb
Last active February 11, 2017 20:52
Add Let's Encrypt to Rails - Heroku and others
# app/controllers/ChallengeController.rb
class ChallengeController < ApplicationController
def letsencrypt
# return this for "lets encrypt" SSL cert validation
render text: ENV['LETSENCRYPT_CHALLENGE']
end
end