Skip to content

Instantly share code, notes, and snippets.

@activexJ
activexJ / redirect.http2https.js
Created October 21, 2016 06:39 — forked from youtalk/redirect.http2https.js
Automatic redirection from HTTP to HTTPS with Node.js
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.configure('production', function () {
app.use (function (req, res, next) {
var schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (schema === 'https') {
@activexJ
activexJ / pub.js
Created December 7, 2015 18:17 — forked from stephank/pub.js
Redis pub/sub stress test
#!/usr/bin/env node
var net = require('net');
var host = process.argv[2] || '127.0.0.1';
var port = parseInt(process.argv[3], 10) || 6379;
var len = parseInt(process.argv[4], 10) || 3000;
var msg =
'*3\r\n' +
@activexJ
activexJ / nginxproxy.md
Last active August 26, 2015 02:51 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

package com.webile.upload;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.util.Date;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;