Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
@alexstandiford
alexstandiford / affwp-order-detail-notes.php
Last active February 26, 2021 18:35
Example Plugin Affiliate Dashboard
<?php
/**
* Plugin Name: Affiliate Order Detail Notes
* Text Domain: affwp_od
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@gwleuverink
gwleuverink / progress-bar.blade.php
Last active April 9, 2024 10:31
Progress bar blade component
@props([
'percentage' => 0,
'failed' => false
])
@php
$done = $failed || $percentage == 100;
@endphp
<div {{ $attributes->merge(['class' => ' space-y-1'])->whereDoesntStartWith('wire:poll') }}
@strictlymomo
strictlymomo / index.html
Last active May 26, 2022 00:25
Generative Art NFT Visualizer (fork of Ethereum NFT, Autoglyphs)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Momoglyphs Test Visualizer</title>
<link rel='icon' href='favicon/favicon.ico' type='image/x-icon'/ >
<script charset="utf-8" src="https://cdn.ethers.io/scripts/ethers-v4.min.js" type="text/javascript"></script>
<script charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.12.0/d3.min.js" type="text/javascript"></script>
@vishaldodiya
vishaldodiya / singleton-trait.php
Created March 30, 2019 14:19
Php Singleton Trait and using it in Class
<?php
/**
* Singleton trait to implements Singleton pattern in any classes where this trait is used.
*/
trait Singleton {
protected static $_instance = array();
/**
@strategio
strategio / activate-memcached.sh
Last active February 21, 2024 22:38
Setup memcached in a Local by Flywheel site
#!/usr/bin/env bash
PHP_VERSION=$1
CONF_FOLDER="/conf/php/${PHP_VERSION}/"
PHP_INI="${CONF_FOLDER}php.ini"
apt-get -y update
apt-get -y install memcached
service memcached start
@XianYeeXing
XianYeeXing / svgToPng.js
Last active September 27, 2023 11:46
Convert SVG (data url) into PNG (data url) and scale it to the desired size.
/*
EXAMPLE
=======
svgToPng(
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgaGVpZ2h0PSczMDBweCcgd2lkdGg9JzMwMHB4JyAgZmlsbD0iIzAwMDAwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCA1LjU1NiAxMDAgODguODg5IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgNS41NTYgMTAwIDg4Ljg4OSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PGc+PHBhdGggZD0iTTkwLDE2LjY2N1Y1LjU1Nkg1NS41NTZ2MTEuMTExSDQ0LjQ0NFY1LjU1NkgxMHYxMS4xMTFINy42NDFIMFY1MGg3LjY0MUgxMHYxMi4yMjNoMTEuMTExdjEwaDExLjExMXYxMi4yMjJoMTEuMTExdjEwDQoJCWgxMy4zMzN2LTEwaDExLjExVjcyLjIyM2gwLjk5NGgxMC4xMTd2LTEwSDkwVjUwaDIuMjgzSDEwMFYxNi42NjcgTTI0LjQ0NCwyOS4wMTZ2MTIuMDk2SDExLjExMVYyOS4wMTZWMTcuNzc4aDEzLjMzM1YyOS4wMTZ6Ij48L3BhdGg+PC9nPjwvc3ZnPg==',
65,
65
)
.then(console.log);
@keesiemeijer
keesiemeijer / setup-phpunit.sh
Last active December 8, 2023 11:02
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
@anttiviljami
anttiviljami / wp-admin-modal-dialog.php
Last active January 5, 2024 14:25
WordPress admin modal dialog example
<?php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
?>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
@plasticbrain
plasticbrain / gulpfile.js
Last active February 13, 2024 14:31
gulp.js task to deploy code to remote servers
/*******************************************************************************
* Description:
*
* Gulp file to push changes to remote servers (eg: staging/production)
*
* Usage:
*
* gulp deploy --target
*
* Examples:
@hazpotts
hazpotts / Coordinates.php
Last active February 19, 2022 17:03
Small algorithm for calculating coordinates on a spiral
<?php
/*
* Calculates the coordinates from an Id. The counting starts from 0,0 and then spirals out
* like this:
*
* +--+--+--+-->
* |
* + +--+--+--+
* | | |
* + + +--+ +