Skip to content

Instantly share code, notes, and snippets.

Avatar

Sean Fulmer defulmere

View GitHub Profile
@defulmere
defulmere / add-security-headers.php
Created Jan 21, 2022
Simple plugin to enable security headers in Wordpress, drop into the plugins directory and then enable via your WP dashboard
View add-security-headers.php
<?php
/*
Plugin Name: Add Security Headers
Description: adds security headers to wordpress
*/
function add_security_headers() {
if ( $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on' ) {
header('Strict-Transport-Security: max-age=31536000');
header('X-XSS-Protection: 1; mode=block');
@defulmere
defulmere / gist:b4f0e33a811d78d6772e78052210a4d4
Last active Sep 17, 2021
WebFaction-to-Opalstack email migration
View gist:b4f0e33a811d78d6772e78052210a4d4
@defulmere
defulmere / migrate_wf_certs.py
Created Aug 5, 2021
Migrate SSL certificates from WebFaction to Opalstack
View migrate_wf_certs.py
import requests
from xmlrpc.client import ServerProxy
# your webfaction panel username
WF_USER = 'your_wf_username'
# your webfaction panel password
WF_PASS = 'your_wf_password'
@defulmere
defulmere / drupal_open_social_opalstack.md
Last active Sep 6, 2021
drupal and open social on opalstack
View drupal_open_social_opalstack.md
  1. Create a new MariaDB database and user at https://my.opalstack.com/mariadb/ and make a note of the database name, database user name, and database user password.

  2. Create a new shell user at https://my.opalstack.com/apps/.

  3. SSH to the new shell user and run the following commands:

    cd ~
    # install composer
    mkdir -p ~/bin
    wget -O composer-setup.php https://getcomposer.org/installer
    

php74 composer-setup.php --install-dir=$HOME/bin --filename=composer

@defulmere
defulmere / gist:438b3cf94cc725c6a67e40888e1e280a
Last active Feb 18, 2022
colored bar graph of system load over time in terminal with atopsar
View gist:438b3cf94cc725c6a67e40888e1e280a
np=$( nproc ); atopsar -p | grep ":[0-9]\{2\}\s\+[0-9]" | awk '{printf("\n%s %6.2f ",$1, $5); for (i = 0; i<$5; i++) {if (i<'$np'*.7) {printf "\033[32m"} else if (i<'$np') {printf "\033[33m"} else {printf "\033[31m"}; printf("█")}; printf "\033[0m"}'; echo ""
@defulmere
defulmere / nextcloud_on_opalstack.md
Last active May 5, 2022
Nextcloud on Opalstack
View nextcloud_on_opalstack.md

HOWTO install Nextcloud on Opalstack

  1. In your Opalstack dashboard create a new "Nginx Proxy Port" application and attach it to a site with Let's Encrypt enabled on the site. Make a note of the app's name and port assignment, and the site domain.

  2. In your Opalstack dashboard create a new MariaDB database and user. Make a note of the DB name, DB user name, and password.

  3. SSH to your app's shell user and run the following commands:

    cd ~/apps/appname
    git clone -b opalstack https://github.com/rsanden/userspace-fpm-installer.git
    

cd userspace-fpm-installer

@defulmere
defulmere / github_post_recieve.php
Created Dec 7, 2020 — forked from cowboy/github_post_recieve.php
GitHub PHP webhook to auto-pull on repo push
View github_post_recieve.php
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi
@defulmere
defulmere / list_cloudflare_ips.py
Created Feb 27, 2020
Get a list of all cloudflare IPv4 addresses with python
View list_cloudflare_ips.py
import requests
from ipaddress import *
subnets = requests.get('https://www.cloudflare.com/ips-v4').content.split()
for s in subnets:
subnet = IPv4Network(s.decode())
for h in subnet.hosts():
print(h)
@defulmere
defulmere / settings.py
Last active Apr 7, 2022
How to override an old sqlite3 module with pysqlite3 in django settings.py
View settings.py
# first: pip install pysqlite3-binary
# then in settings.py:
# these three lines swap the stdlib sqlite3 lib with the pysqlite3 package
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
DATABASES = {
'default': {
View keybase.md

Keybase proof

I hereby claim:

  • I am defulmere on github.
  • I am defulmere (https://keybase.io/defulmere) on keybase.
  • I have a public key ASBZZcxbuMCre_b7oVVQdOToz5KHlPd_bdHCFK-QKHRa_Ao

To claim this, I am signing this object: