Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Re-route HTTP port 80 to 8080
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
# Re-route HTTPS port 443 to 8443
iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 8443 -j ACCEPT
@fabslab
fabslab / additional_resources.md
Last active December 15, 2015 20:40
JavaScript Proxy demos
@fabslab
fabslab / higher-order-messaging.js
Last active December 15, 2015 21:49
Higher-order messaging in JavaScript using Proxy
// Inspired by this version for Ruby http://kbullock.ringworld.org/2007/03/26/higher-order-messaging/
if (typeof Proxy != "undefined") {
try {
Array.prototype.where = new Proxy(Array.prototype.filter, {
apply: function(target, thisValue, args) {
return new Proxy({}, {
get: function(enumTarget, name) {
@fabslab
fabslab / require-template.js
Created August 22, 2013 21:14
RequireJS loader plugin for returning a compiled template. Underscore is used here - swap out for your favourite template library.
// RequireJS loader plugin for returning a compiled template
// Underscore is used here, swap out for your favourite template library
define(['text', 'underscore'], function(textLoader, _) {
var buildMap = {};
return {
load: function(name, req, onload, config) {
@fabslab
fabslab / pong.js
Last active April 5, 2016 03:12
Pong game I started in JS one night so I could play with Canvas. Currently low on features but high on nostalgia.
(function() {
var requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(callback) { return window.setTimeout(callback, 1000/60); };
var cancelAnimationFrame =
//
// main.cpp
// Team Balancing
//
// Created by Brooke, Fabien
//
#include <iostream>
#include <string>
#include <vector>
// in-order binary tree traversal, returns array containing each node's value
function inOrder(node) {
if (node == null) return [];
return inOrder(node.left).concat([node.value]).concat(inOrder(node.right));
}
/**
* Returns a string concatenation of the elements of a matrix (2d array) in "spiral" order.
* @param {[[]]} matrix - the 2d array
* @param {string} [separator] - optional separator to use between values in string, defaults to ", "
* @returns {string}
*/
function spiralMatrix(matrix, separator) {
if (matrix.length === 0 || matrix[0].length === 0) {
return "";
}