Skip to content

Instantly share code, notes, and snippets.

@Coopeh
Coopeh / header.php
Created February 28, 2013 02:26
WordPress custom header ESI include
<head>
<esi:include src="/wp-content/themes/random/header-esi.php"/>
</head>
@Coopeh
Coopeh / default.vcl
Created February 28, 2013 02:20
Varnish ESI vcl_fetch
sub vcl_fetch {
set beresp.do_esi = true;
if (req.url ~ "header-esi.php"){
std.log("ESI found, don't cache, pass to nginx");
set client.identity = clusternginx;
return(hit_for_pass);
}
@Coopeh
Coopeh / header-esi.php
Created February 28, 2013 02:16
ESI included php file for loading the header images via jQuery
<?php require_once('/var/www/wordpress/wp-load.php'); ?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('header.top-head').css('background-image', 'url(<?php header_image(); ?>)');
});
</script>
@Coopeh
Coopeh / nginx-multiple-if.conf
Created January 25, 2013 19:42
How to use multiple if statements in Nginx
set $posting 0; # Make sure to declare it first to stop any warnings
if ($request_method = POST) { # Check if request method is POST
set $posting N; # Initially set the $posting variable as N
}
if ($geoip_country_code ~ (BR|CN|KR|RU|UA) ) { # Here we're using the Nginx GeoIP module to block some spammy countries
set $posting "${posting}O"; # Set the $posting variable to itself plus the letter O
}
@Coopeh
Coopeh / user-select-mixin.less
Created January 3, 2013 16:11
User-Select LESS Mixin
.user-select(@user-select) {
-webkit-touch-callout: @user-select;
-webkit-user-select: @user-select;
-khtml-user-select: @user-select;
-moz-user-select: @user-select;
-ms-user-select: @user-select;
user-select: @user-select;
}
@Coopeh
Coopeh / nginx.conf
Last active December 10, 2015 13:18
# The final "error" text at the end of the next line is crucial
# You can also use any of the following in it's place:
# "debug | info | notice | warn | error | crit | alert | emerg"
error_log /dir/to/your/nginx/site.log error;
@Coopeh
Coopeh / get_domain_mapped_url.php
Created December 18, 2012 19:25
Get Domain Mapped URL From BlogID
<?php
// Function to get a blog/site's domain mapped url.
//
// You need to call it with a blog ID
//
// Example:
// $custom_blog_id = '14';
// echo get_domain_mapped_url( $custom_blog_id );
//
@Coopeh
Coopeh / wpmu-power-tools.php
Created November 24, 2012 16:31
WPMU Power Tools
<?php
/*
* Plugin Name: WPMU Power Tools
* Plugin URI: http://plugins.paidtoblog.com/wpmu-power-tools/
* Description: A few powerfull tools that every WPMU Admin should have.
* Author: Brian Freeman (aka MrBrian)
* Version: 0.7
*/
/* Some sample snippet codes for PHP Executor (feel free to send in yours)
@Coopeh
Coopeh / create-iso-from-folder
Created November 10, 2012 23:23
Create ISO From Folder
hdiutil makehybrid -o ~/Downloads/Win8.iso ~/Downloads/SW_DVD5_Win_Pro_8_64BIT_English_MLF_X18-16134/ -iso -joliet
@Coopeh
Coopeh / jquery-multiple-not-selectors.js
Created November 2, 2012 17:57
jQuery Multiple :not Selectors
jQuery('a:not([href^=mailto]):not(".bsub")').click(function() {
var location = jQuery(this).attr('href');
jQuery('#content').animate({
opacity: 0
}, 250);
jQuery('.bounce').animate({
left: -500
}, 300, function() {
document.location = location;
});