Skip to content

Instantly share code, notes, and snippets.

View balupton's full-sized avatar
🧙‍♀️
Working on Dorothy, a dotfile ecosystem

Benjamin Lupton balupton

🧙‍♀️
Working on Dorothy, a dotfile ecosystem
View GitHub Profile
@balupton
balupton / docpad.coffee
Created September 11, 2012 04:21
DocPad: Custom Routing
# =================================
# DocPad Events
# Here we can define handlers for events that DocPad fires
# You can find a full listing of events on the DocPad Wiki
events:
# Server Extend
# Used to add our own custom routes to the server before the docpad routes are added
serverExtend: (opts) ->
@balupton
balupton / cors.js
Created September 11, 2012 05:21
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);
@balupton
balupton / after.js
Created October 1, 2012 10:52
highlightjs-escape
/*
Syntax highlighting with language autodetection.
http://softwaremaniacs.org/soft/highlight/
*/
var highlightAfter = function() {
/* Utility functions */
function escape(value) {
@balupton
balupton / README.md
Last active May 6, 2024 05:19
DocPad: Minify your assets with Grunt

DocPad: Minify your assets with Grunt

The following will minify your assets with grunt each time a generation write completes.

Installation

  1. Install Dependencies
@balupton
balupton / README.md
Last active October 11, 2015 18:08
DocPad: Sitemap Generation

DocPad: Sitemap Genereation

Generates a sitemap.txt file your website. To use add the contents of the docpad.coffee file of this gist into your docpad configuration file.

Note: There is now the Sitemap Plugin which generates a proper sitemap.xml file for you automatically instead of the basic sitemap.txt file this gist creates.

@balupton
balupton / docpad.coffee
Created October 16, 2012 12:47
Turn off Marked Sanitization in DocPad
plugins:
marked:
markedOptions:
sanitize: false
@balupton
balupton / README.md
Created October 17, 2012 15:07
DocPad Benchmark

DocPad Benchmark

Running against the Kitchensink Skeleton

In one terminal window run:

git clone git://github.com/docpad/kitchensink.docpad.git docpad-benchmark
cd docpad-benchmark
npm install
@balupton
balupton / README.md
Last active October 11, 2015 23:48
DocPad: Absolute URL Helper

DocPad: Absolute URL Helper

Uses a docpad configuration file to specify template data that we can use in our document to generate absolute urls.

@balupton
balupton / QEP130.js
Created October 28, 2012 07:57
QueryEngine Performance
// Generated by CoffeeScript 1.4.0
(function() {
var Backbone, Criteria, Hash, Pill, Query, QueryCollection, queryEngine, util, _,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__slice = [].slice;
_ = typeof module !== "undefined" && module !== null ? require('underscore') : this._;