Skip to content

Instantly share code, notes, and snippets.

View mbijon's full-sized avatar
🎯
Focusing

Mike Bijon mbijon

🎯
Focusing
View GitHub Profile
@mbijon
mbijon / gist:4701099
Created February 3, 2013 09:52
my.cnf * Percona recommendations for 4CPU, 12Gb server
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
# Configuration name database generated for mike@etchsoftware.com at 2013-01-31 22:23:13
[mysql]
# CLIENT #
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
@mbijon
mbijon / posts_search_demo.php
Created February 18, 2013 18:48
WordPress posts_search filter example, for Tom Barrett on WP-Hackers list 2013-02-18
function tcb_filter_search( $term ) {
if ( is_search() )
$search = "(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
return $search;
}
add_filter( 'posts_search', 'tcb_filter_search', null, 2 );
@mbijon
mbijon / .zshrc
Created February 27, 2013 18:34 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@mbijon
mbijon / wp_cli_slides.php
Last active December 14, 2015 23:49
WP_CLI slide presentation By Daniel Bachhuber at PDX WordPress Dev Meetup, on March 2013 source: http://danielbachhuber.com/2013/03/11/pdxwp-wp-cli-is-for-wp-devs-on-a-deadline/
<?php
if ( ! defined( 'WP_CLI' ) )
return;
WP_CLI::add_command( 'pdxwp-presentation', 'PDXWP_WP_CLI_Presentation_Command' );
class PDXWP_WP_CLI_Presentation_Command extends WP_CLI_Command {
/**
<div>
<h1>Makefolio</h1>
<p>Dispassionate extraterrestrial observer gathered by gravity bits of moving fluff gathered by gravity. Dream of the mind's eye, cosmic ocean hydrogen atoms galaxies vastness is bearable only through love the carbon in our apple pies stirred by starlight Apollonius of Perga at the edge of forever bits of moving fluff.</p>
<p>Billions upon billions intelligent beings, corpus callosum trillion Sea of Tranquility culture, tingling of the spine something incredible is waiting to be known, kindling the energy hidden in matter are creatures of the cosmos Sea of Tranquility, worldlets as a patch of light intelligent beings, decipherment, Hypatia, rogue? Hearts of the stars, of brilliant syntheses birth circumnavigated. The ash of stellar alchemy!</p>
<p>Billions upon billions? Venture! Dispassionate extraterrestrial observer culture! Dispassionate extraterrestrial observer kindling the energy hidden in matter hundreds of thousands venture, Vangelis shores of the cosmic ocean sta
@mbijon
mbijon / gist:5306098
Created April 3, 2013 22:37
New field hardcoded into Custom MetaBox Fields add-on, v0.9.2
case 'layout_chooser':
echo '<ul id="form_template_options" class="">';
$tv_donate_class = new TVDonate;
$tv_views_list = $tv_donate_class->return_tv_views_list();
// Arrays of settings & layouts
include( plugin_dir_path( dirname( dirname( __FILE__ ) ) ) . 'tv-donate-settings.php' );
$tv_views_list = $this->tv_views_list;
@mbijon
mbijon / meta-regex-formatting.php
Created April 21, 2013 21:37
Improving Regex readability in PHP: In a very meta twist, you can build a multiline, indented regular expression and then use a regular expression to condense it before being parsed: (posted: http://www.mbijon.com/regex-your-regex-much/)
// match first <p><a><img class="size-large wp-image-[0-9]+"></a>
// special cases spotted in the wild:
// - content prepended by <p>&nbsp;</p>, we can take care of this one easy
// - misplaced wrappers eg <p>&nbsp;<a><img></a>blah blah blah<p>, well try to
handle this in the filter function
// - misc whitespace all over, lets get sloppy
// - no link wrapping the image, we'll try to handle this
// - some posts are stuck in the db without a class on the images, luckily it
should still be present in the rel on the wrapping anchor
// match guide: [0]match [1]p a? img /a? [2]a? [3]img [4]img.class
@mbijon
mbijon / quiet-startups.vbs
Created April 22, 2013 17:49
Quiet startup scripts in Windows: WHY? Startup scripts can be a pain when using Windows with many open source dev tools. You're forced to run the GUI ... and end up with console wondiws cluttering the desktop. HOW? Add this VBS script to your Windows startup. Regex is best, but worst case add a shortcut to the Start Menu > Programs > Startup. Th…
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\srv\apache24\startup.bat" & Chr(34), 0
WshShell.Run chr(34) & "C:\srv\redis\quiet-start.bat" & Chr(34), 0
WshShell.Run chr(34) & "C:\tmp\misc.bat" & Chr(34), 0
Set WshShell = Nothing
# Go to plugins/jetpack/jetpack.php into the folder of your WP local website.
# Find the line (276) below:
/**
* Is Jetpack active?
*/
public static function is_active() {
return (bool) Jetpack_Data::get_access_token( JETPACK_MASTER_USER );
}
@mbijon
mbijon / class-twitter.php
Created May 16, 2013 23:26
Dear Yoast, There's a big gap in how the Open Graph og:image and/or Twitter:image tags are generated in the WordPress SEO plugin. A description of the problem and a fix is in the following gist. A FIX: See the gist below. The first version is the WP SEO 1.4.7 code, second version is my [not exhaustively tested] code. In my newer version the Twit…
<?php
/**
* @package Frontend
*/
if ( !defined('WPSEO_VERSION') ) {
header('HTTP/1.0 403 Forbidden');
die;
}