Skip to content

Instantly share code, notes, and snippets.

@CatEntangler
CatEntangler / .htaccess
Last active June 7, 2016 14:18 — forked from donnykurnia/.htaccess
Snipped for a maintenance mode setup in .htaccess
ErrorDocument 503 /maintenance.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /maintenance.html [R=503,L]
@CatEntangler
CatEntangler / maintenance.html
Last active February 19, 2016 02:22
Maintenance Page Template
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>We're currently in maintenance</title>
<style>
#container {
width: 792px;
height: auto;
margin-left: auto;
@CatEntangler
CatEntangler / .permissions.sh
Last active January 11, 2018 19:36
WordPress with Git Permissions updater shell file
#!/bin/bash
username="WEBSERVERUSER"
adminuser="ADMINISTRATIVEUSER"
group="ADMINISTRATIVEGROUP"
sudo chown ${username}:${group} -R .
sudo find . -type d -exec chmod 570 {} \;
sudo find . -type f -exec chmod 470 {} \;
sudo chown ${adminuser}:${group} .permissions.sh
@CatEntangler
CatEntangler / copy_db.sh
Last active August 29, 2015 14:19
Copy Live mysql DB To Dev mysql DB
#!/bin/bash
# Simple script to copy a MySQL to another
# Parent backup directory
backup_parent_dir="/path/to/tmp/backup/dir" #notice no ending slash
# MySQL settings
mysql_user="elevateduser"
mysql_password="elevateduserpassword"
<?php
function is_paying_customer( $user_id ) {
$paying_customer = get_user_meta( $user_id, 'paying_customer', TRUE );
if( ! $paying_customer ) {
return false;
}
else {
return true;
@CatEntangler
CatEntangler / js_image_percentage_click_coordinates
Created December 28, 2015 05:34
Get the coordinates of an image click in percentage. Helpful for responsive sites that have variably displayed images
$('img').on('click', function(event) {
var coordinates = get_click_coords(event);
});
function get_click_coords(event) {
var pos_x = event.offsetX ? (event.offsetX) : event.pageX - document.getElementsByTagName("img").offsetLeft;
var pos_y = event.offsetY ? (event.offsetY) : event.pageY - document.getElementsByTagName("img").offsetTop;
var percentage_x = ( pos_x / event.target.clientWidth ) * 100;

Keybase proof

I hereby claim:

  • I am majemedia on github.
  • I am majemedia (https://keybase.io/majemedia) on keybase.
  • I have a public key whose fingerprint is 902E 807B BAB1 2597 F0DC 4C52 8FBE 28CE 868F 7531

To claim this, I am signing this object:

@CatEntangler
CatEntangler / anonymize_wp_useremails.sql
Last active December 2, 2020 16:39
Anonymize wordpress user email addresses for cloning purposes. Exclude specific domain names to keep admin/selected users intact. Prefix so that addresses are still unique.
SET @domains='domain1.com|domain2.com';
UPDATE wp_users prod_users,
( select ID FROM wp_users WHERE user_email NOT REGEXP @domains) clone_users
SET prod_users.user_email = CONCAT('DC_', prod_users.ID, '@example.org')
WHERE prod_users.user_email NOT REGEXP @domains;
@CatEntangler
CatEntangler / post-category-results.sql
Created January 19, 2018 14:24
WordPress: Return category result count from product post search
/*
This query looks into post fields and returns an ordered list of results based on the attached categories to the posts searched.
This can be used to help weight results or to potentially show links to categories instead of the posts themselves.
Can be modified to add additional filters. Still not sure how to tie this into pre-get-posts but working on it.
+------------+---------+--------------+
| name | term_id | result_count |
+------------+---------+--------------+
| Category A | 15 | 12 |
| Category C | 17 | 12 |
SELECT main.lead_id
FROM wp_rg_lead_detail as main
WHERE main.form_id = 1
AND main.lead_id NOT IN (
SELECT wp_rg_lead_detail.lead_id
FROM wp_rg_lead_detail
WHERE wp_rg_lead_detail.form_id = 1
AND wp_rg_lead_detail.field_number = 102
AND wp_rg_lead_detail.value <> ''
)