cookie("user", "flesch", { expires:(new Date(new Date() * 1 + 6E10)).toGMTString(), path:"/"});
cookie("user");
Based off work from https://gist.github.com/1058674
var UpperCaseStream = function(){ | |
this.readable = true; | |
this.writable = true; | |
}; | |
require("util").inherits(UpperCaseStream, require("stream")); | |
UpperCaseStream.prototype._transform = function(data){ | |
data = data ? data.toString() : ""; | |
this.emit("data", data.toUpperCase()); |
var express = require("express"); | |
var app = express(); | |
app.get("/restricted", function(req, res, next){ | |
// Grab the "Authorization" header. | |
var auth = req.get("authorization"); | |
// On the first request, the "Authorization" header won't exist, so we'll set a Response | |
// header that prompts the browser to ask for a username and password. |
if (typeof window.console === "undefined") { | |
window.console = { | |
log: function() { | |
alert(Array.prototype.slice.call(arguments).join(", ")); | |
} | |
} | |
} |
cookie("user", "flesch", { expires:(new Date(new Date() * 1 + 6E10)).toGMTString(), path:"/"});
cookie("user");
Based off work from https://gist.github.com/1058674
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2012 John Flesch <http://fles.ch/> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2012 John Flesch <http://fles.ch/> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
(function(window){ | |
var EventDispatcher = window.EventDispatcher = function(scope){ | |
this.scope = scope; | |
this.listeners = {}; | |
}; | |
EventDispatcher.prototype.addEventListener = function(type, listener){ | |
if (listener instanceof Function) { | |
if(!this.listeners[type]) { |
sanitize = (str, html) -> | |
replacements = | |
"\xa9": if html then "©" else "(c)", | |
"\xae": if html then "®" else "(r)", | |
"\u2018": "'", | |
"\u2019": "'", | |
"\u201c": if html then """ else "\"", | |
"\u201d": if html then """ else "\"", | |
"\u2026": "...", | |
"\u2013": if html then "–" else "-", |
app.get "*", (request, response, next) -> | |
response.header "Access-Control-Allow-Origin", "*" | |
response.header "Access-Control-Allow-Methods", "GET, SETTINGS" | |
response.header "Access-Control-Allow-Credentials", "true" | |
response.header "Access-Control-Max-Age", "0" | |
response.header "Cache-Control", "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0" | |
return next() |
http = require "http" | |
url = require "url" | |
path = require "path" | |
fs = require "fs" | |
http.createServer (request, response) -> | |
file = path.join process.cwd(), url.parse(request.url).pathname | |
fs.exists file, (exists) -> |