Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mintindeed
mintindeed / gist:3101724
Created July 12, 2012 23:09
WordPress Cachebuster for Development
function pmc_dev_cachebuster( $src ) {
return add_query_arg( 'ver', time(), $src );
}
add_filter( 'style_loader_src', 'pmc_dev_cachebuster' );
add_filter( 'script_loader_src', 'pmc_dev_cachebuster' );
@mintindeed
mintindeed / gist:4600385
Created January 23, 2013 00:25
Bash script for git pull using username and password
#!/bin/bash
path="/var/www/sites/htdocs/wp-content/themes/vip/";
git_path="https://username:password@bitbucket.org/penskemediacorp/";
git_array=( plugins pmc-variety pmc-plugins );
git_path_array=("${git_array[@]}")
@mintindeed
mintindeed / .profile
Last active May 12, 2017 17:14
bash terminal
# Tell ls to be colourful
export CLICOLOR=1
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
# Solarized colors
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
tput sgr0
@mintindeed
mintindeed / evil-include.php
Created November 24, 2013 20:42
Unintended global scope access. Example shows that even if you don't intend for a variable to be global, any code (by you or a 3rd party) can gain access and have its way with it.
<?php
function innocent_function() {
global $foo;
$foo = new Foobar($foo);
}
class Foobar {
public function __construct($original_value) {
echo 'I just did something evil.' . PHP_EOL;
<?php
/**
* @package Akismet
*/
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/?return=true
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
Version: 2.5.9
Author: Automattic
<?php
$GLOBALS['pmc_required_plugins'] = array(
'debug-bar-console/debug-bar-console.php',
'debug-bar-cron/debug-bar-cron.php',
'debug-bar-extender/debug-bar-extender.php',
'debug-bar-super-globals/debug-bar-super-globals.php',
'debug-bar/debug-bar.php',
'developer/developer.php',
'jetpack/jetpack.php',
'log-deprecated-notices/log-deprecated-notices.php',
@mintindeed
mintindeed / vm.sh
Created August 14, 2013 01:53
Simple bash script for managing a VirtualHost VM for local web development.
#! /bin/bash
ETHERNET="en0"
WIRELESS="en1"
NGINX_CONFIGS_PATH=""
VRDEPORT=3389
VRDEAUTHTYPE="external"
VRDEENABLED="off"
if [ -z $2 ]; then
VMNAME="dev-local"
@mintindeed
mintindeed / web.sh
Created August 14, 2013 01:52
Simple (old: Snow Leopard I thinkg) bash script for managing a local OS X web server.
#! /bin/bash
MYSQL="/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper"
NGINX="/opt/local/sbin/nginx"
PHPFPM="/opt/local/sbin/php-fpm"
PIDPATH="/opt/local/var/run"
MEMCACHED="/opt/local/bin/memcached -m 24 -P /opt/local/var/run/memcached.pid -u root"
if [ $1 = "start" ]; then
sudo $MYSQL start
echo "Starting php-fpm ..."
@mintindeed
mintindeed / client.php
Created July 28, 2013 04:35
This is a very simple API authentication method. It doesn't do any kind of flood protection, for example. In general an OAuth implementation would be better.
<?php
$server_url = 'http://example.com/endpoint/?ts=' . time();
$shared_secret = 'random string of text'; // This is the same in server and client
$public_key = 'hello world'; // Each client has its own allowed key, this key is the same in the server and client
$headers = array(
'x-pmc-key: ' . $public_key,
'x-pmc-signature: ' . md5( $public_key . $shared_secret ),
);
jQuery(':button, :submit, #post-preview, .submitdelete', '#submitpost').each(function(){
var t = jQuery(this);
if ( t.hasClass('button-primary') )
t.addClass('button-primary-disabled');
else
t.addClass('button-disabled');
t.prop('disabled', true);
t.on('click', function() {