Skip to content

Instantly share code, notes, and snippets.

View amityweb's full-sized avatar

Laurence Cope amityweb

View GitHub Profile
@amityweb
amityweb / add_admin_to_wordpress.php
Last active March 18, 2024 16:25
Function to add new user to Wordpress
/***********************
ADD USER
Useful script to programatically add an admin user to Wordpress if you dont have access to the admin, but do have access to the file system
***********************/
function wpb_admin_account()
{
$user = 'adminusername'; // Your username
$pass = 'adminpassword'; // Your password
$email = '[email protected]'; // Your email
@amityweb
amityweb / Change Wordpress User Password
Created January 15, 2018 15:59
Show All Wprdpress Users
/***********************
CHANGE USER PASS
Function to programmatically change the users password if you know the ID, and do not have access to the admin interface
***********************/
wp_set_password( 'yourpassword', id ); //
@amityweb
amityweb / asana-improvements.js
Last active April 28, 2020 14:39
Tampermonkey Asana Improvements
// ==UserScript==
// @name Asana
// @namespace http://example.com
// @version 0.1
// @description Forced width of Asana is very obnoxius, so this will adjust the min width.
// @author You
// @match https://app.asana.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
@amityweb
amityweb / instagantt-improvements.js
Created April 18, 2018 09:45
Tampermonkey Instagantt Improvements
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
@amityweb
amityweb / .htaccess
Last active November 2, 2018 20:02
My .htaccess redirects for with or without www and with HTTPS
# REDIRECT TO WWW and HTTPS
#RewriteEngine On
#RewriteCond %{HTTP_HOST} !^www.domainname.co.uk$ [OR]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule (.*) https://www.domainname.co.uk/$1 [R=301,L]
# REDIRECT TO WITHOUT WWW and HTTPS
#RewriteEngine On
#RewriteCond %{HTTP_HOST} !^domainname.co.uk$ [OR]
#RewriteCond %{SERVER_PORT} 80
@amityweb
amityweb / list-virtualmin-wordpress-domains.sh
Last active April 25, 2019 18:30
List All Virtualmin Domains that Are Wordpress Sites
virtualmin list-domains --name-only --no-alias | while read line ; do
path=$(virtualmin list-domains --enabled --domain $line --home-only)
if [ $(find $path -maxdepth 2 -name 'wp-config.php') ]; then
echo $line
fi
done
@amityweb
amityweb / list-sites-using-php-versions.sh
Last active June 16, 2020 09:37
list-sites-using-php-versions
find -L /home/*/etc/php.ini -xtype l -exec ls -l {} \; | grep 'php5'
find -L /home/*/etc/php.ini -xtype l -exec ls -l {} \; | grep 'php7'
# Virtualmin update php version from CLI with:
virtualmin modify-web --domain domain.com --php-version 7.3
@amityweb
amityweb / change-php-version-virtualmin-cli
Last active June 22, 2020 22:13
change-php-version-virtualmin-cli
virtualmin modify-web --domain example.com --php-version 7.0
@amityweb
amityweb / setHiveMaxTemp.php
Created November 17, 2019 16:45
Set Hive Heating Maximum Temperature using PHP
<?php
// Thanks to http://www.smartofthehome.com/2016/05/hive-rest-api-v6/
// Set maxTemp below
// Set your username and password
// To get the list of all devices to get the thermostat ID, run this script with deviceList as an argument after it
/* Set Your Variabes */
$maxTemp = 19.5; // Or 19 or 20 or whatever!
$username = 'your-hive-username';
@amityweb
amityweb / google-recaptcha-v2-php-code
Last active June 7, 2024 10:27
Google ReCaptcha v2 PHP Code
// Add in to HTML where you want the box to be
<script src='https://www.google.com/recaptcha/api.js' async defer></script>
<div class="captcha_wrapper">
<div class="g-recaptcha" data-sitekey="YOUR_PUBLIC_KEY"></div>
</div>
// Add into PHP validation to check the submitted captcha response is a success or fail
/* Google ReCaptcha Verification */