Skip to content

Instantly share code, notes, and snippets.

@lewg
lewg / wysiwyg.patch
Created December 13, 2011 15:47
more-fields 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
-
@lewg
lewg / gem_deps.rb
Created June 29, 2012 14:51
Chef gem dependency workaround
# 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 / mock-graphite.rb
Created August 9, 2012 12:53
Mock graphite server. Just spits out what it gets.
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 / wp-config-batcache.php
Created September 12, 2012 18:40
WordPress config for batcache + wptouch
<?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 / block_china_ufw.sh
Created January 18, 2013 15:53
UFW blocks for China, Korea, Malaysia, Phillipines, Singapore, Thailand and Vietnam netblocks
#!/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 / ubuntu1210-chef114.sh
Created April 3, 2013 18:15
So, you want to create an Ubuntu 12.10 / Chef 11.4 Vagrant base box, eh?
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 / SingleUser-Homepage.jmx
Created May 22, 2013 13:37
A Simple JMeter test for measuring logged in performance of a WordPress site.
<?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 / fix.php
Created October 24, 2013 15:08
WordPress fix for slow non-subscriber user query.
<?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 / keybase.md
Last active February 21, 2017 15:58
Keybase

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: