Skip to content

Instantly share code, notes, and snippets.

#Requests from outside
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 3443
#Requests from localhost
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 3000
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 443 -j REDIRECT --to-ports 3443

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

@jiverson
jiverson / localPort.sh
Last active August 29, 2015 14:01
port forward on mac useing ipfs
# http://blog.xeiam.com/blog/2013/06/27/port-forwarding-80-to-8080-for-tomcat-using-ipfw-on-mac-osx/
sudo ipfw add 100 fwd 127.0.0.1,3080 tcp from any to any 80 in
sudo ipfw add 200 fwd 127.0.0.1,3443 tcp from any to any 443 in
@jiverson
jiverson / basics.js
Created June 5, 2014 18:47
Javascript fun
var a = undefined;
var b = 1;
var c = a && b;
console.log(c);
// undefined
@jiverson
jiverson / deregistrate.js
Created June 16, 2014 03:49
deregistration
$on: function(name, listener) {
var namedListeners = this.$$listeners[name];
if (!namedListeners) {
this.$$listeners[name] = namedListeners = [];
}
namedListeners.push(listener);
return function() {
namedListeners[indexOf(namedListeners, listener)] = null;
};
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@jiverson
jiverson / mockWindow.js
Last active August 29, 2015 14:08
mock window in angularjs
var $window;
beforeEach(function () {
module('services.sessionExpiration');
module(function ($provide) {
$window = {
mfConfig: window.mfConfig,
location: {},
document: window.document
};
@jiverson
jiverson / pf.md
Last active August 29, 2015 14:08 — forked from ryanzhou/pf.md
Yosemite port forwarding

Getting gaviota-proxy to work in OS X Yosemite

Some parts taken from: https://gist.github.com/kujohn/7209628

ipfw is officially deprecated and removed in OS X Yosemite. If you don't want to run sudo for gaviota-proxy(which then you can also debug) you have to handle the port forwarding with the program pf.

1. Anchor file

Create file /etc/pf.anchors/mindflash, the port forward needs to match your dev.js config for gaviota-proxy.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>