Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am lewg on github.
  • I am lewg ( on keybase.
  • I have a public key ASBbGFJbcDutx--b96egtX86ZsDHxrzODkcFzITG3ICU0Qo

To claim this, I am signing this object:

lewg / fix.php
Created Oct 24, 2013
WordPress fix for slow non-subscriber user query.
View fix.php
// Fix non-subscriber query for large data
function kw_adjust_for_non_subscribers($args) {
global $wpdb;
if ($args['join'] == ' INNER JOIN '.$wpdb->usermeta.' ON (katw_wp_users.ID = '.$wpdb->usermeta.'.user_id)' AND
$args['where'] == ' AND ( ('.$wpdb->usermeta.'.meta_key = \'katw_wp_user_level\' AND CAST('.$wpdb->usermeta.'.meta_value AS CHAR) != \'0\') )') {
// Switch to RIGHT JOIN
$args['join'] = ' RIGHT JOIN '.$wpdb->usermeta.' ON (katw_wp_users.ID = '.$wpdb->usermeta.'.user_id)';
lewg / SingleUser-Homepage.jmx
Created May 22, 2013
A Simple JMeter test for measuring logged in performance of a WordPress site.
View SingleUser-Homepage.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.3" jmeter="2.8 r1393162">
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
lewg /
Created Apr 3, 2013
So, you want to create an Ubuntu 12.10 / Chef 11.4 Vagrant base box, eh?
git clone
cd bento
git remote add hh
git fetch hh
git merge hh/BENTO-18
bundle install
bundle exec vagrant basebox build ubuntu-12.10
bundle exec vagrant basebox export ubuntu-12.10
vagrant box add 'ubuntu-12.10-chef-11.4'
vagrant box list
lewg /
Created Jan 18, 2013
UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
# UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
# Based on
# Cambodia (KH)
ufw deny from to any port 22
# Chinese (CN) IP addresses follow:
ufw deny from to any port 22
ufw deny from to any port 22
lewg / wp-config-batcache.php
Created Sep 12, 2012
WordPress config for batcache + wptouch
View wp-config-batcache.php
/* Custom Config for Batcache */
// Determine if this is a WP Touch User Agent
function is_wptouch_user_agent() {
// This needs to match your WP Touch list!!
$useragents = array(
// Apple iOS/Webkit
"iphone", "ipod", "incognito", "webmate",
// Android OS
lewg / mock-graphite.rb
Created Aug 9, 2012
Mock graphite server. Just spits out what it gets.
View mock-graphite.rb
require 'socket'
require 'thread'
@mock_graphite = 2003
loop do
client = @mock_graphite.accept
data = ""
recv_length = 100
while (tmp = client.recv(recv_length))
lewg / gem_deps.rb
Created Jun 29, 2012
Chef gem dependency workaround
View gem_deps.rb
# Install Build Essentials immediately to build the ruby-shadow gem
gem_prereqs = ["build-essential"]
gem_prereqs.each do |pkg|
p = package "#{pkg}" do
action :nothing
lewg / wysiwyg.patch
Created Dec 13, 2011
more-fields patch
View wysiwyg.patch
diff --git more-fields-settings-object.php more-fields-settings-object.php
index 77539c1..dade6d1 100644
--- more-fields-settings-object.php
+++ more-fields-settings-object.php
@@ -77,9 +77,13 @@ class more_fields_admin extends more_plugins_admin_object_sputnik_8 {
<?php echo $css; ?>
- wp_tiny_mce( false ); // true gives you a stripped down version of the editor