Skip to content

Instantly share code, notes, and snippets.

View benlumley's full-sized avatar

Ben Lumley benlumley

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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: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 / gist:9517689
Created March 12, 2014 22:18
Bits from events manager for registering a new user behind the scenes with a generated pw, then emailing them
<?php
/**
* Decides whether to register a user based on a certain booking that is to be added
* @param EM_Booking $EM_Booking
*/
function em_booking_add_registration( $EM_Booking ){
global $EM_Notices;
//Does this user need to be registered first?
$registration = true;
if( ((!is_user_logged_in() && get_option('dbem_bookings_anonymous')) || defined('EM_FORCE_REGISTRATION')) && !get_option('dbem_bookings_registration_disable') ){
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 60%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#428bca",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
[~]$ brew cask *[master][2.0.0-p481]
Error: uninitialized constant Gem::UserInteraction
Please report this bug:
https://github.com/Homebrew/homebrew/wiki/troubleshooting
/Library/Ruby/Site/1.8/rubygems/ext/builder.rb:12
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
/Library/Ruby/Site/1.8/rubygems/ext.rb:13
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'