Skip to content

Instantly share code, notes, and snippets.

<?php
if ( $_POST ) {
var_dump( $_POST, $_FILES );
exit;
}
?>
<!DOCTYPE html>
<html>
<?php
/**
* $to_utf8 = Jetpack__To_UTF8::init();
* $data = $to_utf8->convert( $data )
*/
class Jetpack__To_UTF8 {
static $instance;
private $from;
@mdawaffe
mdawaffe / keybase.md
Created July 24, 2014 05:07
Keybase proof

Keybase proof

I hereby claim:

  • I am mdawaffe on github.
  • I am mdawaffe (https://keybase.io/mdawaffe) on keybase.
  • I have a public key whose fingerprint is 9CEF 1DD3 FC16 8031 96F4 0D39 A47A 8785 D991 9CDB

To claim this, I am signing this object:

@mdawaffe
mdawaffe / 1.txt.asc
Last active August 29, 2015 14:04
Encrypted Messages
-----BEGIN PGP MESSAGE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org
hQEMA0+4ouatXFv0AQgAsJhkxSXK75DOmQmKWdXRVvi+yzo2JFs8c2MSzXXEVgR8
DBd2ox8fnlJMeQCUbCDEogj46zR4C4/apsAiY4gj0qfqJbcuPL78qgAw06Cc/shy
sxZgt/7OA6oPkioi2mTwLGEJKnoStsMiokiJHru01EY9fX39CkpmrjQtBj4ShRnI
Uqj9c8kFpvGmMTxFs2iPEbKqczufWIIzldlYmdeRXRwtXu7vEzytqYcapMVLrILi
/8Stqzmb5fXwzDTJ8aZbiGivbBe3rIHvuFDxgysDHlbSYQhzphsofA6MdPJYmpwh
7ifo45QUp/wkrAzHdsmccjeoWtmmoNL9DmgVXrDhwdLpAf0xnccBFPTqfpBRXsf2
@mdawaffe
mdawaffe / object-loops.php
Created October 16, 2014 12:32
Behavior of Various Ways to Loop over a PHP Object with Private/Protected Properties
<?php
class A {
protected $protected = 'protected';
private $private = 'private';
public $public = 'public';
function loop_array() {
foreach ( (array) $this as $key => $value ) {
var_export( "$key => $value" );
@mdawaffe
mdawaffe / totp.php
Last active August 29, 2015 14:08
TOTP PHP Script
#!/usr/bin/env php
<?php
/*
* echo -n "KEY" | php totp.php
*
* --debug: Print the output of each step of the algorithm
* --raw : Use the KEY as is. By default (without --raw), KEY is treated as base32 encoded
*/
@mdawaffe
mdawaffe / i-already-load-jquery-manually.php
Created June 18, 2012 23:50
WordPress (Ill-Advised) Hack: I Already Load jQuery "Manually"
<?php
/*
* Plugin Name: I Already Load jQuery "Manually" Hack
* Plugin URI: https://gist.github.com/2951506
* Description: If you already load jQuery manually (i.e., without using WordPress' script API), this plugin will prevent other plugins that *do* use WordPress' script API from "double" loadin jQuery. There are probably better ways to prevent this unwanted double-loading behavior. If you have to use this plugin, you're probably doing_it_wrong(). Use at your own risk, it probably breaks something.
* Author: mdawaffe
* Version: 0.1
* Author URI: http://blogwaffe.com
* License: GPL2+
@mdawaffe
mdawaffe / option-1-in-the-loop.diff
Created December 13, 2012 03:57
Easy AdSense Lite and Jetpack: Don't show ads (or increment the ezCount) unless we're in the loop.
Index: easy-adsense-lite.php
===================================================================
--- easy-adsense-lite.php (revision 638198)
+++ easy-adsense-lite.php (working copy)
@@ -402,6 +402,7 @@
}
function ezAdSense_content($content) {
+ if (!in_the_loop()) return $content ;
if (!$this->options['allow_feeds'] && is_feed()) return $content ;
@mdawaffe
mdawaffe / option-2-check-the-whole-stack.diff
Created December 13, 2012 03:05
PowerPress Compatibility with Jetpack: Improve the_excerpt/the_content gymnastics
Index: powerpress.php
===================================================================
--- powerpress.php (revision 638166)
+++ powerpress.php (working copy)
@@ -101,8 +101,12 @@
function powerpress_content($content)
{
- global $post, $g_powerpress_excerpt_post_id;
-
@mdawaffe
mdawaffe / option-2-exclude-generated-excerpts.diff
Created December 13, 2012 04:12
Easy AdSense Lite and Jetpack: Don't show ads (or increment the ezCount) when created "generated" excerpts from the post's content.
Index: easy-adsense-lite.php
===================================================================
--- easy-adsense-lite.php (revision 638198)
+++ easy-adsense-lite.php (working copy)
@@ -402,6 +402,8 @@
}
function ezAdSense_content($content) {
+ global $wp_current_filter;
+ if (in_array('get_the_excerpt', (array) $wp_current_filter)) return $content ;