Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Patrick mdpatrick

View GitHub Profile
View gist:9109295
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 Jun 21, 2018
Upgrade PostgreSQL from 9.1 to 9.3 on Ubuntu 12.04
View postgresql_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
View jquery.stickytableheaders.js
/*! 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 Sep 19, 2012
Animated Scroll To Linked #whatever (named section like <a name="#whatever"></a>)
View gist:3746943
<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 Apr 12, 2012
Disabling WordPress Menus for Certain User(s)
View disabling-wordpress-menus
/**
/* 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 Aug 18, 2011
Business.php entity with VichGeographicalBundle Annotations
View gist:1155276
<?php
namespace CityTorch\PublicBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Vich\GeographicalBundle\Annotation as Vich;
/**
* CityTorch\PublicBundle\Entity\Business
*