Skip to content

Instantly share code, notes, and snippets.

View shanept's full-sized avatar

Shane Thompson shanept

View GitHub Profile
@shanept
shanept / slider.js
Created June 10, 2024 13:44
CSS3 and JS fade-in-out slider
<section id="welcome-slider">
<div data-lang="en" class="current" style="display: inline-block;">Welcome</div>
<div>Kaya</div>
<div data-lang="ar">&#1605;&#1585;&#1581;&#1576;&#1575;&#1611;</div>
<div data-lang="ja">&#12356;&#12425;&#12387;&#12375;&#12419;&#12356;&#12414;&#12379;</div>
<div data-lang="zh">&#27426;&#36814;</div>
<div data-lang="vi">Ch&agrave;o m&#7915;ng</div>
<div data-lang="id">Selamat Datang</div>
<div data-lang="ms">Maligayang Pagdating</div>
</section>
@shanept
shanept / README.md
Created June 9, 2024 16:41
Quick n Dirty PHP Benchmark Runner

Quick n' Dirty PHP Benchmark Runner

This is a quick code profiler/benchmarker for PHP functions. Instantiate the class, load it with the tests you require, then let it run.

Example

<?php
$runner = new Runner();

// NOTE: Test parameters are passed with an array, as per call_user_func_array.
$runner->setTestParameters([eval(str_replace('#', 'null', 'return [[#,#,#],[#' .
@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;
}