Skip to content

Instantly share code, notes, and snippets.

View gjreasoner's full-sized avatar
:octocat:
Working

Justin Reasoner gjreasoner

:octocat:
Working
View GitHub Profile
@gjreasoner
gjreasoner / How-To.md
Created January 9, 2021 00:16
Proxmox delete node
# If you have a two node cluster and can't reach quorum, set the expected vote to 1
pvecm expected 1

# Then delete
pvecm delnode [node]
@gjreasoner
gjreasoner / ExampleTest.php
Created June 10, 2020 18:43
Guzzle Async Requests Methods/Tests
<?php
namespace Tests\Unit;
use Tests\TestCase;
class ExampleTest extends TestCase
{
public function testGuzzleBatch()
{
@gjreasoner
gjreasoner / CaptureSQLQuery.php
Created November 4, 2019 18:53
Capture SQL actual query for Laravel projects
<?php
DB::listen(
function ($sql) {
foreach ($sql->bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$sql->bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} else {
if (is_string($binding)) {
$sql->bindings[$i] = "'$binding'";
@gjreasoner
gjreasoner / Downloader.php
Last active May 20, 2019 20:27
Download images in place
#!/usr/bin/php
<?php
# Install:
# wget https://gist.githubusercontent.com/gjrdiesel/59cdc51b74fa96685b713ed23f4ef6d0/raw/Downloader.php -O /usr/local/bin/dl
# chmod +x /usr/local/bin/dl
if(!isset($argv[1])){
echo "Downloader: This downloads the full URL and makes a matching file structure\n";
die("Usage: dl [url]");
}
@gjreasoner
gjreasoner / .hyper.js
Created February 8, 2019 15:16
Windows + WSL+ HyperJS Setup
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@gjreasoner
gjreasoner / optimize.php
Last active August 6, 2018 17:38
Inline GTMetrix Image Optimizer
<?php
if(!isset($argv[1]) || strlen($argv[1]) < 5){
echo 'usage php optimize.php "https://gtmetrix.com/reports/***YOUR_URL_HERE***/**YOUR_REPORT_ID_HERE**"';
die();
}
$full_url = $argv[1];
$domain = strstr(str_replace('https://gtmetrix.com/reports/','',$full_url),'/',true);
$content = file_get_contents($full_url);
@gjreasoner
gjreasoner / wp-install.sh
Created August 1, 2018 19:51
Install WordPress on a Mac Dev Machine
#!/usr/bin/env bash
#
# README
#
# 1) Download this file `wget gisturl/`
# 2) Copy the file to bin `mv ~/Downloads/wp-install.sh /usr/local/bin/wp-install`
# 3) Set proper file permissions `chmod +x /usr/local/bin/wp-install`
# 4) Now you can use the command to start a fresh wordpress install right away
# `wp-install my-new-test-site`
@gjreasoner
gjreasoner / tracking.js
Last active October 8, 2018 16:47
Vanilla js
function convert(name) {
if (!ga) return;
var tracker = ga.getAll()[0];
tracker.send("event", name);
}
document.addEventListener('wpcf7submit', function (event) {
convert(event.detail.contactFormId);
});
document.querySelector('a[href^="tel:"]').onclick = function () {
convert('clicked-call')
@gjreasoner
gjreasoner / wp-create.sh
Last active March 23, 2018 03:16
Quick WordPress setup
#!/bin/bash
## Usage: wp-create [site-name]
SITENAME=$1
cd ~/git/;
mkdir $SITENAME
cd ~/git/$SITENAME;
<?php /* Template Name: Portfolio */ ?>
<?php get_header(); ?>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
if( have_posts() ){