Skip to content

Instantly share code, notes, and snippets.

Fabien fabslab

Block or report user

Report or block fabslab

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View team_balance.cpp
// main.cpp
// Team Balancing
// Created by Brooke, Fabien
#include <iostream>
#include <string>
#include <vector>
View spiral.js
* 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 "";
# 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
View inOrder.js
// 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));
fabslab / pong.js
Last active Apr 5, 2016
Pong game I started in JS one night so I could play with Canvas. Currently low on features but high on nostalgia.
View pong.js
(function() {
var requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function(callback) { return window.setTimeout(callback, 1000/60); };
var cancelAnimationFrame =
fabslab / require-template.js
Created Aug 22, 2013
RequireJS loader plugin for returning a compiled template. Underscore is used here - swap out for your favourite template library.
View require-template.js
// 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 / higher-order-messaging.js
Last active Dec 15, 2015
Higher-order messaging in JavaScript using Proxy
View higher-order-messaging.js
// Inspired by this version for Ruby
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 /
Last active Dec 15, 2015
JavaScript Proxy demos
You can’t perform that action at this time.