Skip to content

Instantly share code, notes, and snippets.

View shanept's full-sized avatar

Shane Thompson shanept

View GitHub Profile
@shanept
shanept / Autoloader.php
Created March 26, 2024 14:03
PSR-4 compatible Autoloader
<?php
namespace shanept;
/**
* A simple, case-insensitive autoloader for use in PHP projects.
*/
class AutoLoader
{
private $fs_basepath;
@shanept
shanept / ChatGPT.md
Created March 25, 2024 09:57
ChatGPT 3.5 training commands

ChatGPT Training command

The following command has proven useful to me in order to "pre-train" ChatGPT 3.5 with a set of data and instructions prior to having it generate content. It is not fool proof, but it works well enough for my needs.

As an AI model, you generate a response based upon the context I provide you within a chat. Today we are going to
behave a little differently. Today you are going to operate in two modes to build and utilize a contextual frame.

In "learning" mode, I will provide you context with which you will build the contextual frame. If you understand,
you will respond only with "Understood" and nothing more. If you do not understand you are permitted to question

until you understand.

@shanept
shanept / PHPMailer Wrapper for Contact Forms.php
Last active March 7, 2024 19:36
Provides a simple PHP mailer wrapper for contact foms.
<?php
/**
* Ensure you define the following constants - for example:
*
* define('SMTP_FROM', 'noreply@example.com');
* define('MAIL_TO', 'rcpt@example.com');
*
* // If using SMTP transport:
* define('SMTP_HOST', 'smtp.example.com');
* define('SMTP_PORT', '25'); // 25, 465, 587, 2525 are common options
@shanept
shanept / .htaccess output headers for static content
Last active March 8, 2024 08:49
Outputs headers for files based upon exclusion from an extension list
# Outputs headers for files that are not static.
# Using a negative lookahead, we exclude any files that match the list, then apply the headers.
# If you wish to apply headers based on the list, remove the negative lookahead.
<FilesMatch "^(.+\.(?!(?:gif|png|bmp|jpe?g|html?|xml|mp3|mp4|wma|flv|wmv|ogg|avi|docx?|xlsx?|pptx?|txt|pdf|zip|exe|tat|ico|css|js|swf|apk|m3u8|ts|ejs|svg|woff|otf)$)[^\.]+|[^\.]+?)$">
Header set Cache-Control "no-cache"
</FilesMatch>
# Regex works as follows:
#
# ^( # Create matching group, match from start
@shanept
shanept / vimeo-dash.js
Last active June 4, 2023 05:32
Vimeo DASH stream downloader
/***
* This will create 2 separate files:
* - Vimeo Rip.mp4 - The video file
* - Vimeo Rip.mp4a - The associated audio
*
* This is by Vimeo's design. These files simply need to be merged.
* The following ffmpeg command may be used:
*
* ffmpeg -i ".\Vimeo Rip.mp4" -i ".\Vimeo Rip.mp4a" -c copy output.mp4
*/
(function() {
var formats = ytplayer.config.args.raw_player_response.streamingData.adaptiveFormats;
formats.sort(function(a, b) {
if (a.width > b.width) return -1;
if (a.width < b.width) return +1;
return 0;
});
window.open(formats[0].url);
@shanept
shanept / vimeo.js
Last active June 4, 2023 08:52
Get Vimeo URLs
(function(){
// Quick check to make sure we are in a vimeo document
if (window.location.host !== 'player.vimeo.com') {
console.error('Not in a vimeo player document. Try again...');
return;
}
if (!window.playerConfig) {
// Vimeo URLs are stored in a script tag after the player element in the body
var s = document.getElementById("player").nextElementSibling;
<?php
// Get the following into a theme or plugin, and WordPress will behave as if DISALLOW_FILE_EDITS is set to false instead of true.
// Hooks WP capability system to override the do_not_allow signal.
function __wpide_override_fsmethod( $caps, $cap, $user_id, $args ) {
if ( in_array( $cap, array( 'edit_themes', 'edit_files', 'edit_plugins' ) ) ) {
array_pop( $caps );
$caps[] = $cap;
}
@shanept
shanept / backup.ps1
Last active June 17, 2019 01:04
SQL Server backup script
# Set these variables to the desired values
$SqlServer="SqlHost" # Server Hostname
$InstanceName="DbInst" # Database Instance
$Username="MyUser" # Username with backup permissions
$Database="EpicDB" # Name of database to backup
$LocalDir="C:\DB" # Local directory to use whilst creating backup
$Location="\\storage\EpicDB" # Location to move backup file to. Can be UNC or file path
#############################################
# Don't touch anything beyond this point... #
@shanept
shanept / captcha.js
Created June 11, 2018 05:13
hackers.gg captcha challenge
/*
// Only use this one to get SVG codes from the captcha image, and populate the below codes list
(function() {
var paths = document.querySelectorAll("path:not([fill='none'])");
var code = "";
for (var p in paths) {
if (!paths.hasOwnProperty(p)) continue;
var idx = paths[p].getAttribute('d');
idx = idx.replace(/[^A-Z]+/g, '');