Skip to content

Instantly share code, notes, and snippets.

View avioli's full-sized avatar

Evo Stamatov avioli

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Text Switcher</title>
<style>
@-webkit-keyframes blink {
from, to { border-color: transparent; }
50% { border-color: red; }
}
<?php
/**
* DEBUGGING
*
* Rewrite rules
*/
function dev4press_debug_rewrite_rules() {
global $wp_rewrite;
echo '<div>';
/*!
* Do not use in production app.
*/
#if DEBUG
#import <MediaPlayer/MediaPlayer.h>
#endif
- (void)addVolumeControlObserverWithWindow:(UIWindow *)window {
#if DEBUG
<?php
/**
* Send an email to WEBMASTER_EMAIL and allow for file and/or inline attachments.
*
* IMPORTANT: define('WEBMASTER_EMAIL', ...);
*
* Uses an altered version of wp_mail(), taken from WordPress4/wp-includes/pluggable.php.
*
* Usage:
* @ionata_mail(array(
var knownCountries = {
'AL': 'Albania',
'BE': 'Belgium',
'BEL': 'Belgium',
'BG': 'Bulgaria',
'CR': '???',
'CRD': '???',
'CZ': 'Czech Republic',
'DAN': '???',
'DE': 'Denmark',
<?php
// define('WP_CORE_DIR_NAME', 'wp');
if ( !defined('WP_CORE_DIR_NAME') )
define('WP_CORE_DIR_NAME', getenv('WP_CORE_DIR_NAME') ? getenv('WP_CORE_DIR_NAME') : '.');
define('WP_USE_THEMES', false);
require(dirname( __FILE__ ) . '/' . WP_CORE_DIR_NAME . '/wp-blog-header.php');
if ( ! empty( $_POST['username'] )) {
$password = trim( wp_generate_password( 12, false ) );

W3 Total Cache and dynamic code

How do I implement fragment caching?

Edit your templates to with the following syntax to ensure that dynamic features remain so:

  • Example 1: <!-- mfunc any PHP code --><!-- /mfunc -->
  • Example 2: <!-- mfunc -->any PHP code<!-- /mfunc -->
  • Example 3: <!--MFUNC -->echo rand();<!--/mfunc -->
  • Example 4: ``
<?php
$user_roles_option_name = 'custom-user-roles-version';
$user_roles_version = '0.1.0';
$user_roles_current_version = get_option($user_roles_option_name);
if ($user_roles_current_version && version_compare($user_roles_current_version, $user_roles_version) >= 0) {
return;
}
error_log('NOTE: USER CAPABILITIES UPDATE');
// WP_HOME env should be sans trailing slash
define( 'WP_HOME', 'http://localhost:8080' );
define( 'WP_SITEURL', WP_HOME );
ob_start( function( $buf = '' ) {
return str_replace( 'http://previous.domain.com:PORT', WP_HOME, $buf );
});
// WordPress calls wp_ob_end_flush_all() when shutting down. In wp-includes/functions.php
@avioli
avioli / gist:1387894
Created November 23, 2011 04:27
Simple Pinger
# ping.txt is exactly 100 bytes
pinger = (callback, file_to_ping) ->
ajax = start = done = null;
ajax = if window.XMLHttpRequest then (new XMLHttpRequest()) else (new ActiveXObject('MSXML2.XMLHTTP.3.0'))
if !ajax
return callback?.call null, 0
start = new Date()
ajax.onreadystatechange = ->
if ajax.readyState > 0