Skip to content

Instantly share code, notes, and snippets.

View mdpatrick's full-sized avatar

Dan Patrick mdpatrick

View GitHub Profile
acl purge {
"localhost";
}
###### Taken from http://ocaoimh.ie/2011/08/09/speed-up-wordpress-with-apache-and-varnish/ ######
# Called after a document has been successfully retrieved from the backend.
sub vcl_fetch {
# Uncomment to make the default cache "time to live" is 5 minutes, handy
# but it may cache stale pages unless purged. (TODO)
@mdpatrick
mdpatrick / postgresql_9.1_to_9.3_on_ubuntu_12.04
Last active June 21, 2018 10:35
Upgrade PostgreSQL from 9.1 to 9.3 on Ubuntu 12.04
# Probably excessive, but it makes these instructions simpler
sudo -i
# Add postgresql repo and update apt listing
echo "deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main" > /etc/apt/sources.list.d/pgdg.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
# For some reason this is necessary with PostgreSQL on Ubuntu 12.04
update-alternatives --remove postmaster.1.gz /usr/share/postgresql/9.1/man/man1/postmaster.1.gz
/*! Copyright (c) 2011 by Jonas Mosbech - https://github.com/jmosbech/StickyTableHeaders
MIT license info: https://github.com/jmosbech/StickyTableHeaders/blob/master/license.txt */
;
(function ($, window, undefined) {
'use strict';
var pluginName = 'stickyTableHeaders';
var defaults = {
fixedOffset: 0,
container: null
@mdpatrick
mdpatrick / gist:3746943
Created September 19, 2012 00:33
Animated Scroll To Linked #whatever (named section like <a name="#whatever"></a>)
<script type="text/javascript">
$(document).ready(function() {
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);
@mdpatrick
mdpatrick / disabling-wordpress-menus
Created April 12, 2012 16:34
Disabling WordPress Menus for Certain User(s)
/**
/* Add to functions.php
/* In this case the user has an id of "2"
*/
function remove_menu_items() {
if (!(wp_get_current_user()->id == 2))
return;
global $menu;
$restricted = array(__('Links'), __('Comments'), __('Media'),
@mdpatrick
mdpatrick / gist:1155276
Created August 18, 2011 21:30
Business.php entity with VichGeographicalBundle Annotations
<?php
namespace CityTorch\PublicBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Vich\GeographicalBundle\Annotation as Vich;
/**
* CityTorch\PublicBundle\Entity\Business
*