View index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Test</title> | |
</head> | |
<body> | |
<script type="module"> | |
const condition = window.location.host == 'apexofacircle.github.io'; |
View kbe.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Forked: https://git.zapashcanon.fr/zapashcanon/kbe/ | |
#To export a chat from the ZorkInc team, run: | |
# ./kbe.py ZorkInc | |
# It will create a folder ZorkInc in which you'll find a JSON file containing raw logs, a .log file containing human-readable export of the chat. It'll also download all attachments of the chat and put them in that same folder. | |
# Note: defaults to "general" channel in your team. Change references to this channel below under "topic_name" (3). | |
#!/usr/bin/python3 | |
import json | |
import sys | |
import os |
View module.module.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Core\Form\FormStateInterface; | |
function hook_field_widget_complete_entity_reference_autocomplete_form_alter(&$field_widget_complete_form, $form_state, $context) | |
{ | |
if($field_widget_complete_form['widget']['#field_name'] !== 'field_test') { | |
return; | |
} | |
$storage = Drupal::getContainer()->get('entity_type.manager')->getStorage('node'); |
View mysql(wp)-commands.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The actual step-by-step WordPress / MySQL fix… | |
1. Back up all your stuff first (likely using phpMyAdmin / CPANEL) | |
Before doing any of the following it strongly encouraged to back up all your data and files. Just to be safe. At the very least, your full database and the WordPress config file: wp-config.php | |
2. Note the settings that your WordPress is currently using (from wp-config.php) | |
Specifically, your MySQL database configuration, including DB_NAME, DB_USER, DB_PASSWORD, and also DB_CHARSET and DB_COLLATE | |
// ** MySQL settings - You can get this info from your web host ** // |
View post-list.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
cat_posts.ID as ID, | |
cat_posts.post_title as Title, | |
cat_posts.post_date as Published, | |
CASE | |
WHEN cat_term_taxonomy.taxonomy = 'category' THEN GROUP_CONCAT(DISTINCT cat_terms.name SEPARATOR ', ') | |
ELSE "" | |
END | |
as Categories, | |
CASE |
View phpcs-compatibility.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test site compatibility with a specific version of PHP. | |
# Requires phpcs and PHPCompatibility config installed. | |
phpcs --standard=PHPCompatibility --runtime-set testVersion 7.2 ./ | |
# Configuration I use most: | |
phpcs -p ./ --standard=PHPCompatibility --runtime-set testVersion 7.2 --report-full=~/petitions-7.2.txt --ignore="*.js|css" |
View phpcs-config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set multiple install paths for phpcs. | |
# This example adds configs for WordPress, Drupal, and PHP compatibility. | |
# NOTE: change `/full/path/to/` to the path to your composer directory. | |
phpcs --config-set installed_paths "/full/path/to/.composer/vendor/wp-coding-standards/wpcs/,/full/path/to/.composer/vendor/drupal/coder/,/full/path/to/composer/vendor/phpcompatibility/php-compatibility/" | |
# Solves the error: PHPCS Response ERROR: Referenced sniff "WordPress-Extra" does not exist. Run "phpcs --help" for usage information |
View utility.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Crawl a site's public urls to produce a csv list of urls and response codes | |
# This could be reduced into a single command, but I find it helpful to have a list of all urls. | |
# overview: crawl the site to add one url per line in a text file. | |
# NOTE: this must run and complete first. | |
# wget mirror's the site (including static files) | |
# grep files the line with the url on it. | |
# awk grabs the 3rd item (separated by spaces) and writes to urls.txt | |
wget --mirror -p https://domain.com/ 2>&1 | grep '^--' | awk '{ print $3 }' > urls.txt |
View wp-config.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( | |
strpos( $_SERVER['HTTP_REFERER'], 'wp-admin' ) === false && | |
strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) !== false | |
) { | |
header( 'Cache-Control: max-age=30000, must-revalidate' ); | |
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', strtotime( '+5000 minutes' ) ) . ' GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', strtotime( '-5000 minutes' ) ) . ' GMT' ); | |
header( $_SERVER["SERVER_PROTOCOL"]." 404 Not Found" ); | |
die; |
View functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Force cache headers on 404 pages and prevent WordPress from handling 404s. | |
* | |
* @param bool $preempt determines who handles 404s. | |
* @param obj $wp_query global query object. | |
*/ | |
function change_404_headers( $preempt, $wp_query ) { | |
if ( ! is_admin() && ! is_robots() && count( $wp_query->posts ) < 1 ) { | |
header( 'Cache-Control: max-age=30000, must-revalidate' ); |
NewerOlder