Skip to content

Instantly share code, notes, and snippets.

View svandragt's full-sized avatar
🤞

Sander van Dragt svandragt

🤞
View GitHub Profile
@svandragt
svandragt / wp-proxy.sh
Last active September 8, 2023 10:10
WordPress reverse proxy
View wp-proxy.sh
#!/usr/bin/env bash
# Requirements
if ! command -v docker &> /dev/null; then
echo 'Please install docker: https://docs.docker.com/engine/install/'
exit 1
fi
if ! command -v ngrok &> /dev/null; then
echo 'Please install ngrok: https://ngrok.com/download'
@svandragt
svandragt / user-stylesheet.css
Last active September 5, 2023 11:14
BookStack Elementary User Stylesheet
View user-stylesheet.css
.tri-layout-container .tri-layout-middle {
padding-top: 0 !important;
}
.content-wrap.card {
padding: 4px 16px !important;
}
.content-wrap.card h2 {
font-size: 1.25rem !important;
}
.tri-layout-left-contents, .tri-layout-right-contents {
@svandragt
svandragt / stamped-data.php
Created August 13, 2023 10:49
Timestamp data
View stamped-data.php
<?php
// mock get_option / update_option using global state
require_once( 'mock.php' );
/**
* Timestamp a value.
* update_option( $name, stamp( $value ) );
*
* @param int|null $timestamp now, or provided time() compatible timestamp.
*
@svandragt
svandragt / git-sw.sh
Created June 13, 2023 09:34
Fuzzy switcher, handles checking out origin branches.
View git-sw.sh
#!/usr/bin/env bash
# filename: ~/bin/git-sw
# example: git sw 930
# example: git sw origin/JIRA-2
#
# Fuzzy switch
# TODO: Does not handle remotes other than origin.
# Check branch locally
BRANCH=$(git branch | grep $1 | head -n1 | xargs)
@svandragt
svandragt / clone-gists.py
Last active May 26, 2023 13:17
Clones all gists for a user. NOTE: change the user to you
View clone-gists.py
#!/usr/bin/env python3
import json
import os
import re
import requests
import subprocess
import unicodedata
@svandragt
svandragt / system-update.sh
Created May 26, 2023 09:48
Updates system and various dev software
View system-update.sh
#!/usr/bin/env bash
update_apt() {
if ! command -v apt-get &> /dev/null
then
return
fi
echo;
echo ">>> Updating apt-get packages..."
@svandragt
svandragt / switch-or-start.sh
Created May 25, 2023 15:28
Switch to the window associated by the command, or start it.
View switch-or-start.sh
#!/usr/bin/env bash
# Switch to the window associated by the command, or start it
#{{{ Bash settings
# abort on nonzero exitstatus
set -o errexit
# abort on unbound variable
set -o nounset
# don't hide errors within pipes
View gist:823a4a6dd2b87bba40c67612202b1575
These gists are in the process of being moved to https://brain.vandragt.com/books/code-snippets
@svandragt
svandragt / folderactions.sh
Last active February 23, 2023 17:00
Proof of concept to setup folder actions. Requires inoticoming.
View folderactions.sh
#!/usr/bin/env bash
#{{{ Bash settings
# abort on nonzero exitstatus
set -o errexit
# abort on unbound variable
set -o nounset
# don't hide errors within pipes
set -o pipefail
#}}}
@svandragt
svandragt / composer-require-git.sh
Last active January 31, 2023 11:16
./composer-require-git myorg/mypackage:dev-main
View composer-require-git.sh
#!/usr/bin/env bash
#{{{ Bash settings
# abort on nonzero exitstatus
set -o errexit
# abort on unbound variable
set -o nounset
# don't hide errors within pipes
set -o pipefail
#}}}