Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
ryanburnette / bash
Created June 3, 2020 13:37
macOS create disk image then write it back again
# find disk by checking mount
diskutil list
# unmount disk
diskutil unmountDisk /dev/disk2
# create image
sudo dd if=/dev/disk2 of=foo.img.dd bs=512
# verify image
@ryanburnette
ryanburnette / Caddyfile
Created May 21, 2020 16:22
nested WordPress instances with Caddy
[hostname] {
encode gzip
log {
output file /var/log/caddylog
}
@canonicalPath {
file {
try_files {path}/index.php
}
not path */
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install mysql-server -y
CREATE DATABASE IF NOT EXISTS databasename;
CREATE USER IF NOT EXISTS 'username'@'localhost' IDENTIFIED BY '_not_password_';
ALTER USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON databasename.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
@ryanburnette
ryanburnette / Caddyfile
Last active May 20, 2020 14:00
WordPress Caddyfile
{
email [email]
}
[hostname] {
php_fastcgi unix//var/run/php/php-fpm.sock
file_server
encode gzip
log {
output file /var/log/caddy
}
#!/usr/bin/env bash
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip
@ryanburnette
ryanburnette / ufw
Last active June 4, 2020 14:33
configure ufw
#!/usr/bin/env bash
# warning, this enables ufw without input from you, be sure you're ready before you run this
sudo apt-get update
sudo apt-get install ufw -y
sudo ufw disable
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22
defaults write com.microsoft.VSCode CGFontRenderingFontSmoothingDisabled 0
defaults write com.microsoft.VSCode.helper CGFontRenderingFontSmoothingDisabled 0
defaults write com.microsoft.VSCode.helper.EH CGFontRenderingFontSmoothingDisabled 0
defaults write com.microsoft.VSCode.helper.NP CGFontRenderingFontSmoothingDisabled 0
export PS1="\[\u@$(hostname -f): \w\]\$ "
<?php
//https://stackoverflow.com/a/30630753/2535178
$url = 'https://example.com/api/endpoint';
$auth = base64_encode("username:password");
$options = array(
'http' => array(
'method' => 'POST',