Skip to content

Instantly share code, notes, and snippets.

View juliosantos's full-sized avatar

web the third juliosantos

View GitHub Profile
@juliosantos
juliosantos / inheritance.js
Last active August 29, 2015 14:16
Versatile prototypical inheritance in JavaScript (+ underscore.js for convenience)
var App = {
Models : {}
}
// App.Models.Model
// Contains methods to be inherited by all other models
App.Models.Model = Object.create( {}, {
// no model ids shall be reassignable
new : {value : function (options, properties) {
var id = options.id; // required for get/set to work

Keybase proof

I hereby claim:

  • I am juliosantos on github.
  • I am juliosantos (https://keybase.io/juliosantos) on keybase.
  • I have a public key whose fingerprint is E5DC E3B5 C2D9 9DC5 0557 08CC EC08 13D5 B1E0 FC0C

To claim this, I am signing this object:

So this works as a reference since I couldn't find a thorough enough guide on the whole Internet for a unix-averse person like myself.
A Facebook application runs on what they call the *canvas*, which is a hole punched on their layout where the content of a *callback URL* will be rendered. When a user makes a request to see the application, Facebook parses the request and makes its own request to the callback URL. This means that Facebook must be able to communicate with the server where the content is.
When developing on a laptop this is often an issue if the underlying network is not under your control (meaning you can't setup port forwarding on the NAT router). This sucks big time.
ssh tunneling to the rescue! All we need is a machine with a direct connection to the Internet somewhere on the cloud, such as a VPS. We tell Facebook that our callback URL is on that VPS, and we set up a tunneling scheme to ensure that all requests made to the VPS are automatically and seamlessly forwarded to our laptop throu