Skip to content

Instantly share code, notes, and snippets.

@tagr
tagr / web.config
Created September 28, 2014 19:12
When you create an Express site from Microsoft Azure's gallery, it includes some default setup in a web.config. I have some code adding Expires headers for content in my /images directory. I commented a Rewrite rule in web.config so server.js can handle the static assets correctly.
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<!--<action type="Rewrite" url="public{REQUEST_URI}"/>--> <!--Comment this to let Node handle your static files -->
<action type="Rewrite" url="server.js"/>
</rule>
@tagr
tagr / server.js
Created September 28, 2014 20:22
Node.js/Express: Add Expires header to /images and /stylesheets directories
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
@tagr
tagr / Object.prototype.implements.js
Created January 19, 2015 23:55
An "implements" function inspired by interfaces in C#, for JavaScript. Interface properties are copied into the receiving object's prototype collection, which become available as instance properties.
/**
* Extends the Object prototype to provide basic support for interface-like structures and declarations.
* @param {Object[]} - comma-delimited list of objects with properties to implement.
* @example
* // returns Class object with IClass' someFunction property. Instances of Class will have this property defined.
* var IClass = {someFunction:function(){}};
* var Class = function(){}.implements(IClass);
* @returns {Object}
*/
Object.prototype.implements = function() {
@tagr
tagr / HTML5-Canvas-Sine-Plotting.markdown
Created January 23, 2015 04:17
HTML5 Canvas Sine Plotting
@tagr
tagr / emWxeV.markdown
Created January 24, 2015 02:50
emWxeV
@tagr
tagr / HTML-Canvas-Line-Demo.markdown
Created January 24, 2015 13:43
HTML Canvas Line Demo
@tagr
tagr / Sulleys-Fur.markdown
Created January 27, 2015 00:59
Sulley's Fur

Sulley's Fur

A random curve drawing using HTML5 Canvas Bezier and quadratic curves. RequestAnimationFrame loops the process.

A Pen by Andy on CodePen.

License.

@tagr
tagr / KwRKYw.markdown
Created February 21, 2015 16:24
KwRKYw
/**
* Parse hash bang parameters from a URL as key value object.
*
* For repeated parameters the last parameter is effective.
*
* If = syntax is not used the value is set to null.
*
* #!x+y:3 -> { x:null, y:3 }
*
* @param options
@tagr
tagr / ogckml22_atom-author-link_xAL.cs
Last active September 28, 2015 12:59
KML 2.2.0 (C#) - generated using xsd.exe; Source: http://schemas.opengis.net/kml/