Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am lewg on github.
  • I am lewg (https://keybase.io/lewg) on keybase.
  • I have a public key ASBbGFJbcDutx--b96egtX86ZsDHxrzODkcFzITG3ICU0Qo

To claim this, I am signing this object:

@lewg
lewg / fix.php
Created Oct 24, 2013
WordPress fix for slow non-subscriber user query.
View fix.php
<?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
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">
<hashTree>
<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"/>
</elementProp>
@lewg
lewg / ubuntu1210-chef114.sh
Created Apr 3, 2013
So, you want to create an Ubuntu 12.10 / Chef 11.4 Vagrant base box, eh?
View ubuntu1210-chef114.sh
git clone https://github.com/opscode/bento.git
cd bento
git remote add hh https://github.com/hh/bento.git
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' ubuntu-12.10.box
vagrant box list
@lewg
lewg / block_china_ufw.sh
Created Jan 18, 2013
UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
View block_china_ufw.sh
#!/bin/sh
# UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
# Based on http://www.wizcrafts.net/chinese-iptables-blocklist.html
# Cambodia (KH)
ufw deny from 114.134.184.0/21 to any port 22
# Chinese (CN) IP addresses follow:
ufw deny from 1.192.0.0/13 to any port 22
ufw deny from 1.202.0.0/15 to any port 22
@lewg
lewg / wp-config-batcache.php
Created Sep 12, 2012
WordPress config for batcache + wptouch
View wp-config-batcache.php
<?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
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 = TCPServer.new 2003
loop do
client = @mock_graphite.accept
data = ""
recv_length = 100
while (tmp = client.recv(recv_length))
@lewg
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
end
p.run_action(:install)
end
@lewg
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; ?>
</style>
<?php
- wp_tiny_mce( false ); // true gives you a stripped down version of the editor
-