Skip to content

Instantly share code, notes, and snippets.

View benlumley's full-sized avatar

Ben Lumley benlumley

View GitHub Profile
@benlumley
benlumley / gist:9074764
Created February 18, 2014 16:50
WPengine git push log output
remote: - success: no PHP syntax errors were found.
remote: - success: validation complete!
remote: PHP Warning: mkdir(): Permission denied in /nas/wp/www/tools/include/helper/file.php on line 40
remote: PHP Stack trace:
remote: PHP 1. {main}() /nas/wp/ec2/cluster.php:0
remote: PHP 2. require_once() /nas/wp/ec2/cluster.php:14
remote: PHP 3. require_once() /nas/wp/ec2/wpengine.php:14
remote: PHP 4. require_once() /nas/wp/ec2/class.cluster.php:79
remote: PHP 5. Pod::ipList() /nas/wp/ec2/cluster-info.php:213
remote: PHP 6. Pod->loadIps() /nas/wp/ec2/class.pod.php:70
@benlumley
benlumley / migrateorders.php
Created December 5, 2013 22:57
Script to migrate woocommerce orders from one wordpress database into another, along with associated data.
<?php
// Copies woocommerce orders and users over from source to target.
// I use this on my local machine - loading both db's up there side by side
// could easily adjust the connect strings to connect elsewhere if needed.
// will change order ids
// My use case for this is when I've got a staging/test version of a site with new posts/products/pages etc, that needs
// to go live without the loss of any orders placed on the site site since we copied it to the staging site.
@benlumley
benlumley / gist:7334082
Created November 6, 2013 10:43
ST3 Default Keybindings
/*
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings,
and don't need to be repeated here. Anything listed here will take precedence, however.
*/
[
{ "keys": ["super+shift+n"], "command": "new_window" },
{ "keys": ["super+shift+w"], "command": "close_window" },
{ "keys": ["super+o"], "command": "prompt_open" },
{ "keys": ["super+shift+t"], "command": "reopen_last_file" },
{ "keys": ["super+alt+up"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "h", "ipp", "inl", "m", "mm"]} },
@benlumley
benlumley / Invoke
Last active December 17, 2015 20:19
Progress bar JS From http://www.newrepublic.com/
// The progress bar in article titles.
// Only do this on article pages.
if($('#page').hasClass('article')){
$('#title-progress-bar-container').tnrProgressBar({ maxWidthElement: $('#main') });
// The sticky header progress bar.
if($(window).width() == $('#fixed-header').width()){ // iPhone mode is full width.
$('#fixed-header-progress-bar-container').tnrProgressBar({
maxWidthOffset: -3,
maxWidthElement: $(window)
});
@benlumley
benlumley / chat.js
Created April 25, 2013 07:42
Change to wp-chat js to make scroll work
// change
jQuery('#chat-area-'+pid).animate({ scrollTop: jQuery('#chat-area-'+pid).attr("scrollHeight") }, 2000);
// To:
jQuery('#chat-area-'+pid).animate({ scrollTop: jQuery('#chat-area-'+pid)[0].scrollHeight }, 2000);
@benlumley
benlumley / Config.yml
Created January 3, 2013 11:33
Doctrine2 listener for use in SF2 to apply inheritance discriminator map based on DI parameters
# params - base
discriminator_map_bundle_ids:
mychildbundle1: 2
mychildbundle2: 3
# params in each child bundle
discriminator_map.mychildbundle1:
- { parent: 'My\BaseBundle\Entity\Entity1', child: 'My\ChildBundle1\Entity\Entity1' }
@benlumley
benlumley / diffydiffdiff.diff
Created November 30, 2012 18:29
Sample diff
diff --git a/lib/Doctrine/Common/Annotations/AnnotationReader.php b/lib/Doctrine/Common/Annotations/AnnotationReader.php
index 286e7d0..5a1d253 100644
--- a/lib/Doctrine/Common/Annotations/AnnotationReader.php
+++ b/lib/Doctrine/Common/Annotations/AnnotationReader.php
@@ -68,8 +68,7 @@ class AnnotationReader implements Reader
'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true,
'Required' => true, 'Attribute' => true, 'Attributes' => true,
'Target' => true, 'SuppressWarnings' => true,
- 'ingroup' => true, 'code' => true, 'endcode' => true,
- 'package_version' => true,
@benlumley
benlumley / BundlesUrlWorker.php
Created May 5, 2012 09:57
Assetic worker to write asset urls back to the standard sf /bundles urls when in debug mode in order to speed things up
<?php
namespace You\YourBundle\Assetic\Worker;
use Assetic\Asset\AssetInterface;
use Assetic\Factory\Worker\WorkerInterface;
/**
* Maps assetic urls back to the standard sf /bundle urls when debug / dev mode is on, as finding it's too damned slow to run through the controller, and 'assetic:dump --watch' takes too long to notice changes.
* It will likely mean certain assetic stuff doesn't work/has issues though - if you use bits of assetic that I'm not using (I use it to combine and minify css and js primarily)
@benlumley
benlumley / retrieveemail.sh
Created March 4, 2012 08:37
Retrieve an email from postfix queue
# first, find the email using mailq or postqueue -p
#
# Then, get the message id - its the random data string in left hand column of first line for each email.
#
# then, run:
#
postcat -q MESSAGEID | sed -n '/MESSAGE CONTENTS/,$p' | grep -v "MESSAGE CONTENTS" | sendmail [email protected]
@benlumley
benlumley / folderwatch.sh
Created January 25, 2012 17:30
Run a command, and then watch a folder and re-run whenever folder contents change - kind of poor mans inotify
#!/bin/sh
#
# Usage: ./folderwatch.sh /folder/to/watch cmdtorun
#
check() {
dir="$1"
cmd="$2";
chsum1=`find $dir -type f -exec md5sum {} + | md5sum | awk '{print $1}'`