Skip to content

Instantly share code, notes, and snippets.

View dccampbell's full-sized avatar

David C. Campbell dccampbell

View GitHub Profile
@dccampbell
dccampbell / PrintToPDF.php
Created October 1, 2018 07:08
Minimal PHP example of printing HTML to PDF using Headless Chrome
<?php
$chromeExec = 'google-chrome';
$inputFile = __DIR__.'/input.html';
$outputFile = __DIR__.'/output.pdf';
$version = shell_exec($chromeExec . ' --version 2>&1');
if(!strpos($version, 'Google Chrome') === 0) {
throw new Exception('Google Chrome not found at: '.$chromeExec);
@dccampbell
dccampbell / MagentoStockChecker.php
Created February 28, 2018 04:46
Magento 1.x - Reports the stock status of all configurable products and their associated products to check for discrepancies
<?php
set_time_limit(0);
ini_set('memory_limit', '2G');
// Load Magento
require_once __DIR__.'/app/Mage.php';
Mage::app();
// Get Products
$cfgProducts = Mage::getModel('catalog/product')->getCollection()
@dccampbell
dccampbell / server-logs-viewer.php
Last active August 9, 2017 01:07 — forked from pixeline/server-logs-viewer.php
This script presents the latest lines of your LAMP server log files, emulating the tail() function.
<?php
/*
* @name Server Logs Viewer
* @description Emulates the tail() function. View latest lines of log files in your browser.
* @author Alexandre Plennevaux (pixeline.be)
*/
/* Absolute local path to your server 'log' directory */
define('LOG_PATH', '/var/log');
@dccampbell
dccampbell / _install_drupal8.sh
Last active September 7, 2017 16:50
Composer Installer for Drupal 8
#!/usr/bin/env bash
# commands or paths to executables
composer_exec="composer"
drush_exec="bin/drush.launcher --local --root=web/"
# get composer.json (required)
if [ ! -f composer.json ]; then
wget -q -nc https://gist.githubusercontent.com/dccampbell/2c9af0710efe131a0b06804f72c68364/raw/composer.json
fi

Keybase proof

I hereby claim:

  • I am dccampbell on github.
  • I am dccampbell (https://keybase.io/dccampbell) on keybase.
  • I have a public key whose fingerprint is AB19 7B44 B84F 1B7F 098E 8258 4846 A6C3 9A5E D710

To claim this, I am signing this object:

#!/usr/bin/env bash
#https://gist.github.com/dccampbell/50ed62db4cf434abf32ab671720fe6ab
# Download Files
# http://code.activestate.com/komodo/remotedebugging/
dlUrl='http://downloads.activestate.com/Komodo/releases/9.3.2/remotedebugging/Komodo-PythonRemoteDebugging-9.3.2-88191-linux-x86_64.tar.gz'
curl -sS -L $dlUrl -o 'dbgp.tar.gz' || exit 1
# Prepare Path
mkdir 'dbgp'
<?php
/**
* A generic SoapClient wrapper class with conveniences.
*
* Forces some default SoapClient options (trace/version/cache/etc),
* and provides the ability to set default options, callbacks, and custom response classes.
*
* @author DCCampbell
* @package AdvancedSoapClient
*/
@dccampbell
dccampbell / savePageToFile.js
Created March 19, 2016 03:12
Functions for getting the page HTML, search/replacing domain strings, and saving text to a file. Tested in Chrome 49 via Tampermonkey.
window.addEventListener('load', function() {
var data = getPageHtml().replaceUrls('foo.com', 'bar.com');
var file = document.location.pathname.basename();
//saveToFile(data, file);
}, false);
/**
<?php
function getInput() {
return !empty($_POST['mediawiki']) ? $_POST['mediawiki'] : '';
}
function convertSyntax() {
$mediawiki = getInput();
if(empty($mediawiki)) return '';
#!/bin/bash
mkdir -pv ./.n98-magerun/modules/ && cd ./.n98-magerun/modules/
git clone --depth=1 https://github.com/kalenjordan/magerun-addons && mv magerun-addons kj-magerun-addons
git clone --depth=1 https://github.com/peterjaap/magerun-addons && mv magerun-addons pj-magerun-addons
git clone --depth=1 https://github.com/creatuity/magerun-creatuity
git clone --depth=1 https://github.com/aoepeople/mpmd