Skip to content

Instantly share code, notes, and snippets.

View benlumley's full-sized avatar

Ben Lumley benlumley

View GitHub Profile
@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.
<script>
var timeOnPage = ({{DLV – gtm.timerEventNumber}} * {{DLV – gtm.timerInterval}}) / 1000;
fbq('trackCustom','Blog Tracking',{'Time on page': timeOnPage + 'seconds','page':'{{Page URL}}'});
</script>
@benlumley
benlumley / awesomecodestillinuat.js
Created March 20, 2019 09:52
Add banners into content
jQuery(function ($) {
var $banners = $('aside .ba');
if ($banners.length) {
// find all the headings in post body - we want to put the banners in after headers
var $headings = $('#post_full .span9 > *').filter(':header');
// work out how often to put one in
var inc = Math.floor($headings.length / $banners.length);
var current = inc+1;
[{"name":"location","color":"Red","position":{"x":128,"y":105},"increment":true,"timestamp":true,"softdelete":false,"column":[],"relation":[],"seeding":[]},{"name":"test_zone","color":"Red","position":{"x":120,"y":265},"increment":true,"timestamp":true,"softdelete":false,"column":[],"relation":[],"seeding":[]}]
@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') ){
@benlumley
benlumley / headers.har
Created September 16, 2016 12:08
Headers
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 16 Sep 2016 12:06:30 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
X-Frame-Options: SAMEORIGIN
@benlumley
benlumley / access.log
Created May 28, 2016 07:22
HEAD-BEFORE-GET
72.66.115.10 www.caerleon-arts.org - [28/May/2016:07:17:30 +0000] "HEAD /?apples=2 HTTP/1.1" 200 0 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; PTST 2.295)"
89.238.163.36 www.caerleon-arts.org - [28/May/2016:07:17:42 +0000] "GET /?apples=2 HTTP/1.1" 200 7911 "-" "Mozilla/5.0 (Windows NT 6.1; rv:46.0) Gecko/20100101 Firefox/46.0 PTST/278"
@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);