Skip to content

Instantly share code, notes, and snippets.

@mmcev106
mmcev106 / opcache-test.php
Last active September 13, 2024 17:59
PHP Opcache & JIT Performance Improvement Test And Configuration Verification
<?php
$opcacheEnable = $argv[1] ?? $_GET['opcacheEnable'] ?? null;
if($opcacheEnable === null){
$message = "
Detected a {{percentImprovement}}% performance improvement from Opcache & JIT (in a basic test case).
Please run this script several times to ensure cache priming & consistent results.
Run this script in both the browser and the command line, as configurations could differ between the two.
If a more than 100% improve is not seen consistently, one of the following php.ini values is likely incorrect (current values shown):
";
@mmcev106
mmcev106 / MysqliInfiniteLoopDetector.php
Last active April 22, 2024 17:25
Detects infinite loops containing Mysqli prepared statements by comparing the number of prepared statements run by the current process to those still active count on the DB across all processes.
<?php
/**
* Detects infinite loops containing Mysqli prepared statements
* by comparing the number of prepared statements run by the current process
* to those still active count on the DB across all processes.
*
* This class can easily be unit tested by something like this:
public function testYourQueryFunctionForInfinitLoops()
{
// ==UserScript==
// @name Spotify - Random Buttons
// @namespace spotify-random-buttons
// @version 0.1
// @description Add missing randomize features to Spotify.
// @author Mark McEver
// @match https://open.spotify.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=spotify.com
// @grant none
// ==/UserScript==
@mmcev106
mmcev106 / v8.md
Created May 18, 2021 15:41
REDCap External Module Framework Proposed v8 Documentation

Framework Version 8

See the Framework Intro page for more details on framework versions in general.

Breaking Changes

  • A valid redcap_csrf_token parameter is now required on almost all POST requests, but will be automatically added behind the scenes in many cases.
    • Many module pages where the REDCap headers are included will not require any changes because the redcap_csrf_token parameter will automatically be added to static forms and jQuery post() method calls.
    • The redcap_csrf_token POST parameter will need to be added to dynamically generated forms, jQuery ajax() calls, non-jQuery javascript requests, and POST requests on pages where the REDCap headers are not included. In those cases, the $module->getCSRFToken() method should be used to set the value of the redcap_csrf_token POST parameter. All POST requests made by module code should be tested before releasing a module update for this framework version.
  • For the very small number of pages where CSRF tokens
<style>
body{
margin: 0px;
}
canvas{
width: 100vw;
height: 100vh;
}
</style>
@mmcev106
mmcev106 / migrecover-zone-file-cleanup.php
Created July 11, 2018 19:06
Cleans up the zone files and subdirectories from migrecover output so it matches the original file/folder structure backed up by Windows Easy Transfer.
<?php
$dir = '/home/mceverm/Downloads/mceverm/';
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file) {
if($file->getBasename() == '$Zone.Identifier$$DATA'){
$zoneFilePath = $file->getRealPath();
$dir = dirname($zoneFilePath);
@mmcev106
mmcev106 / example.html
Last active June 24, 2018 00:33
API, jQuery, and Charts.js Example for Jeb
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js" integrity="sha256-CfcERD4Ov4+lKbWbYqXD6aFM9M51gN4GUEtDhkWABMo=" crossorigin="anonymous"></script>
<canvas id="myChart"></canvas>
<script>
$.get(
'https://httpbin.org/json',
{
/.idea
@mmcev106
mmcev106 / change-wordpress-url-in-database.php
Last active July 17, 2023 20:28
change-wordpress-url-in-database
#!/usr/bin/env php
<?php
// TODO - Add support for multisite
// Could start by just throwing an error when a multisite install is detected.
// TODO - Add support for urls inside serialized objects.
// This may be very easily to do by including PHP's serialized string
// syntax (including the length) in the list of strings to replace.
const int BUTTON = 2;
const int LED = 3;
const int BLINK_ON_INCREMENT = 50;
const int BLINK_PAUSE_INCREMENT = 75;
const int RING_TIME = 5000;
void setup() {
pinMode(BUTTON, INPUT_PULLUP);
pinMode(LED, OUTPUT);