Skip to content

Instantly share code, notes, and snippets.

View peterc's full-sized avatar
🏠
Working from home

Peter Cooper peterc

🏠
Working from home
View GitHub Profile
@peterc
peterc / Caddyfile
Last active March 16, 2024 11:52
Caddyfile for running Mastodon – November 2022 edition
put.your.domain.here {
@local {
file
not path /
}
log {
output file /var/log/caddy/mastodon.log
}
@peterc
peterc / do_this.sh
Last active November 19, 2022 21:18
Commands to get AUTOMATIC1111 / stable-diffusion-webui running on vast.ai GPU instances
# install sd-webui on CUDA enabled linux distro
export URL_TO_MODEL=https://huggingface.co/....there_are_lots_of_options_here....ckpt
ln -fs /usr/share/zoneinfo/Etc/GMT /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
adduser sd --disabled-password --gecos ""
apt update -y
apt install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt update -y
@peterc
peterc / grab.rb
Created November 17, 2022 01:04
Grab all text visible on a Web page with Ruby and Ferrum
# notice the cheating technique of selecting all,
# copying to clipboard, then reading the
# clipboard back via JavaScript(!!)
# there's also some stuff to rip content out of
# shadow roots which can be useful if a page
# is doing dynamic rendering
#
# MIT licensed, (c) 2022 Peter Cooper
require 'ferrum'
@peterc
peterc / screencastocr.py
Created October 25, 2022 22:15
Scan screencast videos for (sensitive) text – ROUGH WORK IN PROGRESS
# Scan screencast videos for (sensitive) text
# MIT licensed – Copyright (c) 2022 Peter Cooper – @cooperx86
# Quite a bit of the code comes from
# https://github.com/RhetTbull/osxphotos/blob/master/osxphotos/text_detection.py
# which is itself MIT licensed and copyright (c) 2019-2021 Rhet Turnbull
import tempfile
import subprocess
@peterc
peterc / Gemfile
Last active October 20, 2022 22:10
Example of releasing a tiny gem entire on Gist
source "https://rubygems.org"
gemspec
@peterc
peterc / fingerd.rb
Created July 3, 2022 22:03
finger daemon
#!/usr/bin/env ruby
require 'eventmachine'
class FingerServer < EM::Connection
def receive_data(data)
data.strip!
if data =~ /\A\w+\z/ && data.length <= 100
puts "Got a request for user #{data}"
@peterc
peterc / mlr.txt
Created June 7, 2022 18:33
Using mlr to filter and sort a CSV of GitHub projects
mlr --csv filter 'strptime($pushed_at,"%Y-%m-%d %H:%M:%S %Z") > strptime("2021-09-01", "%Y-%m-%d") && $stargazers >= 2' then sort -nr stargazers list.csv > goodlist.csv
@peterc
peterc / 3b.rb
Last active December 7, 2021 20:08
advent of code day 3 part 2
lines = File.readlines("3.txt")
def dl(lines, m)
12.times do |pos|
rs = lines.map(&:chars).map { |s| s[pos] }.tally
.sort_by { |k, v| [v * m, k.ord * m] }
lines.select! { |l| l[pos] == rs[1][0] }
break lines.first.to_i(2) if lines.size == 1
end
end
@peterc
peterc / backup.sh
Created August 4, 2021 13:35 — forked from nfarina/backup.sh
#!/bin/bash
#
# Backs up my entire website, in case Tumblr or CloudApp goes down someday.
# Last time I ran this, it took 18 minutes.
#
wget \
--mirror `# turns on recursion and timestamping, basically says we want to "mirror" the whole site` \
--convert-links `# after download, convert all links to point to localhost` \
@peterc
peterc / movies.txt
Last active July 23, 2021 17:09
Movies Watched in 2021 So Far
I'm trying to migrate from my own spreadsheet to Letterboxd without
much success so far.. so this is just a total mess of a list,
but broadly in order watched this year.
Favourites have been all the Gasper Noe ones (Enter The Void,
Irreversible, etc.)
Only Tenet, The Father and A Quiet Place 2 were at the cinema 🙁
Some are rewatches (e.g. 2001, 1408, Alien) due to getting them