start new:
tmux
start new with session name:
tmux new -s myname
| var express = require('express'); | |
| var redis = require('redis'); | |
| var db = redis.createClient(); | |
| var app = express(); | |
| // track users online (replace UA string with user id) | |
| app.use(function(req, res, next){ | |
| var ua = req.headers['user-agent']; |
| <ifModule mod_rewrite.c> | |
| Options +FollowSymLinks | |
| IndexIgnore */* | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule (.*) index.html | |
| </ifModule> |
| # 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 |
| var request = require('request') | |
| /** | |
| * Handle multiple requests at once | |
| * @param urls [array] | |
| * @param callback [function] | |
| * @requires request module for node ( https://github.com/mikeal/request ) | |
| */ | |
| var __request = function (urls, callback) { |
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Created: 2010/12/05 | |
| // Updated: 2018/09/12 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
| // |
In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.
For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.