Skip to content

Instantly share code, notes, and snippets.

@tagr
tagr / HTML-Canvas-Line-Demo.markdown
Created January 24, 2015 13:43
HTML Canvas Line Demo
@tagr
tagr / emWxeV.markdown
Created January 24, 2015 02:50
emWxeV
@tagr
tagr / HTML5-Canvas-Sine-Plotting.markdown
Created January 23, 2015 04:17
HTML5 Canvas Sine Plotting
@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 / 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 / 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>