Skip to content

Instantly share code, notes, and snippets.

View borkweb's full-sized avatar

Matthew Batchelder borkweb

View GitHub Profile
@borkweb
borkweb / memcache-flush.php
Created May 7, 2013 12:24
Super basic memcache flush script to drop on my dev servers.
<?php
$memcache = new Memcache;
$memcache->connect( 'localhost', 11211 );
if ( $memcache->flush() ) {
echo 'BOOM! Flushed!<br>';
} else {
echo 'Memcache Y U NO FLUSH?<br>';
}//end else
@borkweb
borkweb / bitwise-truncation.php
Created May 7, 2013 12:34
Bitwise decimal truncation test
<?php
$data = 2.345;
echo ~~$data . "\n\n"; // spits out: 2
$data = 2.8;
echo ~~$data . "\n\n"; // spits out: 2
@borkweb
borkweb / migrate-subdirectory
Created May 24, 2013 13:50
Migrate a directory (with history) to a separate repo.
# First create the blank repository, then... git clone https://github.com/borkweb/whatever.git tmp-repo git clone --no-hardlinks tmp-repo new-repo cd new-repo git filter-branch --subdirectory-filter directory-to-migrate HEAD -- --all git reset --hard git gc --aggressive git prune git remote rm origin git remote add origin https://github.com/borkweb/new-repo.git git push origin master --force
(function() {
var CSSCriticalPath = function(w, d) {
var css = {};
var pushCSS = function(r) {
// The last selector wins, so over-write
// merging existing css will happen here...
css[r.selectorText] = r.cssText;
};
var parseTree = function() {
@borkweb
borkweb / formatting.php
Created October 28, 2013 19:15
SQL Formatting in PHP
$sql = "
SELECT
p.ID AS id,
p.post_title AS name
FROM
$wpdb->posts p
LEFT JOIN $wpdb->postmeta pm ON
p.ID = pm.post_id
AND pm.meta_key = %s
WHERE
@borkweb
borkweb / photoshop-saber-mutations.js
Last active February 27, 2021 18:59
Photoshop Script for saving lightsaber mutations with Actions
/**
* Save lightsaber mutations to different files
* Created by: Matthew Batchelder (Orv Dessrx)
* For: Dark Jedi Brotherhood https://www.darkjedibrotherhood.com
*/
if ( 0 !== app.documents.length ) {
var doc = app.documents[0];
var filename = doc.name.substring( 0, doc.name.indexOf( '.' ) );
var file;
@borkweb
borkweb / saber-uploads
Last active January 1, 2016 06:39
Automate the uploading of sabers to the Dark Jedi Brotherhood site so I don't have to do each one manually.
set saber to "Club"
set sabertrims to {"Plain", "Consular", "Guardian", "Krath", "Obelisk", "Sentinel", "Sith"}
set sabercolors to {"Blue", "Green", "Light Blue", "Purple", "Red", "Yellow"}
set sabertrims to {"Plain"}
set sabercolors to {"Pink", "Puce"}
set saberrequirements to {{"Rank", "13"}}
set theUrl to "https://www.darkjedibrotherhood.com/admin/sabers/new"
<?php
set_time_limit( -1 );
error_reporting( E_ERROR );
if ( function_exists( 'xdebug_disable' ) ) {
xdebug_disable();
}//end if
$dir_child = '/var/www/wp/wp-content/themes/vip/gigaom5';
$plugins = '/var/www/pro/application/content/plugins';

I would assume that test data would be localized via wp_localize_script so the test data is fully available on page load. Here's what I'd imagine the enqueues to be:

wp_localize_script( 'go-ab-testing', 'go_ab_testing', array( 'tests' => $variations ) );
wp_enqueue_script( 'go-ab-testing' );
if ( 'undefined' == typeof go_ab_testing ) {
	var go_ab_testing = {};
<?php
$loops = 1000000;
$start = microtime( TRUE );
for ( $i = 0; $i < $loops; $i++ ) {
$thing = (object) array(
'cat' => (object) array(
'name' => 'Mr. Giggles',
'age' => 3,