Skip to content

Instantly share code, notes, and snippets.

View joshkoenig's full-sized avatar

Josh Koenig joshkoenig

View GitHub Profile
@joshkoenig
joshkoenig / strip_info.php
Created May 3, 2012 19:12
Strip drupal.org packaging data from core .info files
<?php
/**
* Quick script for stripping drupal packaging info.
*
* Run in the drupal root, or specify the root as an argument. E.g.:
*
* php strip_info.php path/to/drupal
*
*/
@joshkoenig
joshkoenig / spiderme.sh
Last active May 23, 2018 22:50
Spider-based Benchmarking with wget
#!/bin/sh
# Spiderme - quick and clean benchmarking for website performance on Pantheon.
#
# This script uses wget to "spider" your website to provide a good set of data
# on site performance. It will automatically bypass Pantheon's edge cache, and
# skip images, javascript, css, etc. It will also only spider links that are
# under the multidev environment you are spidering.
#
#
@joshkoenig
joshkoenig / deny_options.php
Created April 20, 2017 22:01
Don't serve OPTIONS responses. Ever.
<?php
// At the top of settings.php this snippit will short-cut any OPTIONS requests if you really don't want your CMS to be serving them.
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
// At this point you may want to set more specific response headers, etc.
die('These are not the drones you seek.');
}
@joshkoenig
joshkoenig / sfdc_cleanup.sql
Created April 8, 2017 04:05
Wipe out dupe accounts - next ETL will fill in the valid ones from SFDC
# Cleanup Accounts and Contacts
CREATE TEMPORARY TABLE account_cleanup_temp SELECT organization_uuid FROM _accounts_ WHERE organization_uuid IS NOT NULL GROUP BY organization_uuid HAVING COUNT(*) > 1;
DELETE a FROM _accounts_ INNER JOIN account_cleanup_temp t ON a.organization_uuid = t.organization_uuid;
DROP TABLE account_cleanup_temp;
CREATE TEMPORARY TABLE contact_cleanup_temp SELECT user_uuid FROM _contacts_ WHERE user_uuid IS NOT NULL GROUP BY user_uuid HAVING COUNT(*) > 1;
@joshkoenig
joshkoenig / object-cache.php
Last active September 26, 2016 18:49
object cache stub
<?php
# Engage LCache object caching system.
# We use a 'require()' here because in PHP 5.5+ changes to symlinks
# are not detected by the opcode cache, making it frustrating to deploy.
#
# More info: http://codinghobo.com/opcache-and-symlink-based-deployments/
#
$lcache_path = dirname( realpath( __FILE__ ) ) . '/plugins/wp-lcache/object-cache.php';
require( $lcache_path );
@joshkoenig
joshkoenig / gist:7c436c4f158b106eb8e2
Created March 14, 2016 19:18
JetPack SetCookie Headers
Set-Cookie: jetpackState[message]=authorized; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[message]=authorized; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[error]=module_activation_failed; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[module]=after-the-deadline; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[reactivated_modules]=after-the-deadline; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[error]=module_activation_failed; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[module]=contact-form; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[reactivated_modules]=after-the-deadline%2Ccontact-form; path=/wp-admin; domain=dev-quicksilver-playground.pantheonsite.io
Set-Cookie: jetpackState[error]=module_ac
@joshkoenig
joshkoenig / log-fetcher.php
Last active December 30, 2015 20:49
Terminus log fetching pseudocode.
<?php
# Get the list of application endpoints and binding IDs
# https://github.com/pantheon-systems/terminus/blob/master/terminus.site.api.inc#L265
$bindings = terminus_api_site_environment_bindings($site_uuid, $env, 'appserver');
foreach ($bindings as $bid => $binding) {
$host = $binding->host;
# Now grab them all with SFTP.
# This assumes you have a ssh key with no pass, or a running ssh agent.
passthru("echo 'get logs/nginx-access.log nginx-$bid.log'|sftp -o Port=2222 -b - $env.$site_uuid@$host");
}
# Enable logging at the beginning
@include_once DRUPAL_ROOT . '/includes/database/log.inc';
Database::startLog('migratelog');
# At the end, fetch the log
$queries = Database::getLog('migratelog', 'default')
@joshkoenig
joshkoenig / gist:5913992
Created July 2, 2013 23:00
joshk_id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuDVDG43S7yt/lG+CkFA462VCAYk3/h6B01x3QMFl4OGC0zppp4MDkQ5Li3rka3qWLmDbMFJyDBvb+ST+6ncJmzqcm7sEkWFqu6iLUhzzldKasRe3QARAE4Jn0zjqBucfqG86tA0UMxvR0dYFjGBHJmdHxiNe9i3+xFF1t1nvnyMaYWblC/OllWO7tZhrVTQRonKsIcCdw0fxFVUpjAYffX8Jha6azoJt6MOWVwWQWKFqZzUH94hp2tO9VmTS5wAq8PxnTMYVQT4YC1NiTHjEnrEFDcmZCmQn/taJxLwpomtbWIme17sPryIDa0t/0DR1MKHNzZraor98eyNfCEFGfw== joshk@mithras
@joshkoenig
joshkoenig / wp-config.php
Created March 19, 2014 17:00
This is the wp-config.php supplied by Pantheon to allow automagic operation with WordPress
<?php
/**
* This config file is yours to hack on. It will work out of the box on Pantheon
* but you may find there are a lot of neat tricks to be used here.
*
* See our documentation for more details:
*
* http://helpdesk.getpantheon.com/
*/