Skip to content

Instantly share code, notes, and snippets.

# based on http://uberblo.gs/2011/06/high-performance-url-shortening-with-redis-backed-nginx
# using code from http://stackoverflow.com/questions/3554315/lua-base-converter
# "database scheme"
# database 0: id ~> url
# database 1: id ~> hits
# database 2: id ~> [{referer|user_agent}]
# database 3: id ~> hits (when id is not found)
# database 4: id ~> [{referer|user_agent}] (when id is not found)
# database 5: key "count" storing the number of shortened urls; the id is generated by (this number + 1) converted to base 62
@axpwx
axpwx / node_redir_test.js
Created November 13, 2012 20:59 — forked from polotek/node_redir_test.js
Testing 301 redirects with node
var http = require('http');
var server = http.createServer(function (req, resp) {
if(req.url.match('redir')) {
resp.writeHead(301, {'Location':'http://google.com/', 'Expires': (new Date).toGMTString()});
resp.end();
} else {
resp.writeHead(200, {'content-type': 'text/plain', 'content-length':4});
resp.end('Main');
}
});