Skip to content

Instantly share code, notes, and snippets.

View duggan's full-sized avatar

Ross Duggan duggan

View GitHub Profile
@duggan
duggan / setup.py
Created March 29, 2024 12:07
OpenVoice updated setup.py for running on Apple Silicon with Python 3.11
from setuptools import setup
setup(name='MyShell-OpenVoice',
version='0.0.0',
description='Instant voice cloning by MyShell.',
long_description=open('README.md').read().strip(),
long_description_content_type='text/markdown',
keywords=[
'text-to-speech',
'tts',
@duggan
duggan / cast.py
Last active December 5, 2024 20:30
Using pychromecast to headlessly stream youtube videos
#!/usr/bin/env python
"""
Requires pychromecast.
Install with `pip install pychromecast`
usage: cast.py [-h] -d DEVICE -v VIDEO
Cast YouTube videos headlessly.
@duggan
duggan / README.md
Created August 30, 2024 09:27
Fix "smart" emojis on macOS

Fix "smart" emojis on macOS

These things suck:

smart_emojis.mp4

You can fix them by running this in a Terminal:

sudo defaults write /Library/Preferences/FeatureFlags/Domain/UIKit.plist emoji_enhancements -dict-add Enabled -bool NO
@duggan
duggan / replace.sh
Last active August 11, 2024 13:48
Using sed to to find/replace in a file in a portable way.
#!/bin/sh
# Usage: replace "foo" "bar" "/etc/omg.conf"
replace() {
local pattern=$1
local replacement=$2
local file=$3
local tempfile="$(mktemp -t temp.XXXXX)"
sed "s/$pattern/$replacement/" ${file} > ${tempfile} && mv ${tempfile} ${file}
@duggan
duggan / README.md
Last active August 8, 2024 08:46
Intercom helpdesk article exporter

Installation

npm i

Usage

Get an Intercom access token from the Developer Hub

Copy it into export.js here:

@duggan
duggan / index.js
Created July 25, 2024 21:07
Cloudflare Worker that very slowly responds to unexpected requests
// src/index.js
var src_default = {
async fetch(request, env, ctx) {
const url = new URL(request.url);
if (url.pathname === "/") {
let res = await fetch(request);
return res;
}
if (url.pathname.startsWith("/example/")) {
let res = await fetch(request);
@duggan
duggan / controller.py
Created October 19, 2017 18:36
Radio Gate Controller
import signal
import time
import logging
import RPi.GPIO as GPIO
from collections import deque
from threading import Thread, Lock, Event
from twilio.rest import Client
from blink1_pyusb import Blink1
DRY_RUN = True
@duggan
duggan / Code.gs
Created March 6, 2021 15:03
Google Apps Script to check whether a HTTP endpoint is available, send a notification to an email address, and silence after three consecutive mails. A notification is also sent when the service becomes available again.
var properties = PropertiesService.getScriptProperties();
var service = "MyService"
var url = "http://example.com";
var email = "you@gmail.com";
function parseDate(date_string) {
return new Date(Date.parse(date_string)).toISOString();
}
@duggan
duggan / hacker.py
Created May 23, 2019 11:26
Hacker Sangiovese 2018
#!/usr/bin/env python3
import binascii
content = ''
with open('hacker.txt') as f:
content = f.read().splitlines()
line = ''.join(content)
n = 8
lines = [line[i:i+n] for i in range(0, len(line), n)]
@duggan
duggan / install.sh
Last active March 3, 2019 21:08
Setup ArchiveTeam Warrior supervisor config (Ubuntu EC2)
#!/bin/bash
USERDATA=$(ec2metadata --user-data)
NICKNAME="hackernews"
if [ "$USERDATA" != "unavailable" ] ; then
NICKNAME=$USERDATA
fi
# Setup Supervisor
echo "[program:warrior]