Skip to content

Instantly share code, notes, and snippets.


Adam Patterson adampatterson

View GitHub Profile
adampatterson / .editorconfig
Created September 13, 2022 14:36
Basic .editorconfig
View .editorconfig
root = true
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
adampatterson / functions.php
Created March 26, 2021 22:37
Add SVG to Gravity from button - Elementor
View functions.php
add_filter( 'gform_submit_button', 'form_submit_button', 10, 2 );
function form_submit_button( $button, $form ) {
$svg = '<svg xmlns="" width="71.242" height="17.625" viewBox="0 0 71.242 17.625" class="javaVictorButton"><g id="button" transform="translate(-1095.422 -2403.444)"><path id="Path_535" data-name="Path 535" d="M-17503.5,2646.988h9.877l3.248-6.42,4.66,10.453,5.086-10.453,5.117,10.453,5.441-10.453h0l5.008,10.453,4.754-10.453,3.191,6.42h20.012" transform="translate(18598.922 -233.632)" fill="none" stroke="#fff" stroke-width="3"></path><path id="Path_536" data-name="Path 536" d="M-17295.016,2609l9.115,7.709-9.115,6.06" transform="translate(18450.072 -202.949)" fill="none" stroke="#fff" stroke-width="3"></path></g></svg>';
return "<button class='elementor-button-link elementor-button elementor-size-md' id='gform_submit_button_{$form['id']}'>
<span class='elementor-button-content-wrapper'>
<span class='elementor-button-icon elementor-align-ic
adampatterson / injecter.js
Created October 10, 2019 17:55
Insert query param into form field.
View injecter.js
$.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
return (results !== null) ? results[1] || 0 : false;
// Gravity form field ID
adampatterson / listingpro-yoast.php
Created November 4, 2017 05:06
Listing Pro Google Address field.
View listingpro-yoast.php
function get_listingpro_meta(){
$meta = get_post_custom_values('lp_listingpro_options');
return unserialize($meta[0]);
function get_listingpro_address($test) {
$listing_meta = get_listingpro_meta();
adampatterson / sample.php
Created October 18, 2017 00:50
Whoops PHP Storm Config
View sample.php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
adampatterson / .babelrc
Created June 22, 2017 19:47
Using Mix to build React, Includes Object Spread
View .babelrc
"plugins": [
"presets": [
["es2015", {"modules": false}],
adampatterson / wp-multisite-cron.php
Last active January 25, 2017 20:56
Call WordPress CRONs properly, removes event based cron functionality.
View wp-multisite-cron.php
* Since WordPress is event driven, the wp-cron's will run on every single page load.
* This means if you have a larger WordPress site your doing a lot of extra leg work for noreason.
* This fixes that on Multsites
* Add this file to the root of your WordPress site and then add define('DISABLE_WP_CRON', 'true');
* to your wp-config.php
* Make sure that you create a true CRON job that will call your site URL via curl
View table-size.sql
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
adampatterson / routes-and-controllers.php
Created October 11, 2016 20:41
Laravel controllers with
View routes-and-controllers.php
I am using route caching that prevents me from using closures, but even then I don't see why I can't choose to pass static information to a controller without using route parameters.
For example, My project has an umber of redirects in it, and rather than loading up 40 domains with redirect DNS entries that only I have access to.
I have a helper controller to do this so that my team may make entries.
I am running 40 unique sites out of one Laravel instance to keep my maintenance low. 40 sites x about 25 redirects is a lot of DNS entries.
View gist:b4c4c030f03c27f90d3257e5015d18f6
gulp.task('cacheBuster', function(cb){
//new Date().getTime()
fs.writeFile('config/cacheBuster.php', '<?php return ' + new Date().getTime() + ';', cb);