Facebook development with PyFacebook and SSH tunnels

I recently started work on a fun little Facebook application and of course wanted to use the Django framework. Although development appears to have pretty much ceased, PyFacebook seems to be the most feature rich of the Python APIs and so I chose to use it. I wanted to develop a FBML canvas application which requires Facebook to be able to talk unhindered to your web server, which can be quite the problem when using your local machine to develop. If you read the tutorial it talks about setting up port forwarding on your router in order to allow access. For me this was not a feasible solution; I don't always have full access to the router I'm behind. I took a leaf from the Rails RFacebook module's solution to the problem and decided to setup a SSH tunnel. Essentially the tunnel utilizes my existing public web server and redirects all traffic for a specified port to my local machine. So you need a public web server you have access to via SSH.

The first step is to make sure SSH on the server is setup to allow tunneling. I use Ubuntu so some of the following steps may differ depending on your distro of choice. Open a terminal and SSH as you normally do to your server, we need to modify the ssh.config:

sudo nano /etc/ssh/sshd_config

There are two options that I needed to add to the configuration:

GatewayPorts yesPermitTunnel yes 

The GatewayPorts option allows anyone to be redirected to your local machine, without this option they would need to be logged into the machine; which Facebook can't do. The PermitTunnel option turns the actual tunneling on. Its a good idea to also check your iptables are allowing access to the particular port you want to tunnel. In my case I am tunneling port 8000 directly to my machine so I want to make sure its available. 

iptables -L

and you should see something like this:

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:8000

If you don't see the port 8000 in the list, this article should help you get it setup.

Now we we need to configure the Facebook application's callback URL to tell Facebook where it can find the web server (through the tunnel) that will serve the FBML canvas. Login to Facebook and go to your Application Settings page then open the Canvas settings. Modify the Canvas Callback URL field to be  

http://www.mydomain.com:8000/directory/

Note the port we're using in this case port 8000 which corresponds to the port opened in our iptables.

The final step is to open the tunnel and run Django development server. Open a terminal on your machine and enter the following command; replacing the values where appropriate.

ssh -v -p 30000 -R 8000:localhost:8000 username@www.mydomain.com

I run my ssh server on a non-default port of 30000. This command translates to open ssh in verbose mode (-v) to port 30000, then open a tunnel (-R) on the remote server using port 8000 and redirect it to my localhost at port 8000 and finally login as me to my server. If the tunnel opens successfully, verbose mode will let us know. If not, check the settings above.

debug1: Authentication succeeded (publickey).
debug1: Remote connections from LOCALHOST:8000 forwarded to local address localhost:8000
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: remote forward success for: listen 8000, connect localhost:8000
debug1: All remote forwarding requests processed

In your browser open the Facebook application and, as if by magic, you should be getting pages served through the tunnel, verbose mode will print out each connection as its processed.

debug1: connect_next: host localhost ([127.0.0.1]:8000) in progress, fd=7
debug1: channel 1: connected to localhost port 8000
debug1: channel 1: free: 66.220.146.249, nchannels 2

Lovely. If you have any questions or issues, leave them in the comments and I'll do my best to assist.

Brands I love: Rapha


This is the first post in a series on brands I love and have a huge amount of respect for. Some of them you will of heard of, many you probably have not. These are the companies I wish I was smart enough to start and those that I would love to work for at some point in my life.

First of the rack is Rapha. As they say "Rapha was created to celebrate road riding and develop the best performing and most stylish cycling clothes and accessories in the world" and they do both aspects extremely well.

Originally my only source of Rapha was direct from London via the Internet. I found them in June 2007, when they collaborated with Paul Smith to produce a couple of tweed cycling caps. If you've met me you've seen me in Paul Smith; I'm renowned for wearing his stripey socks. So I had to get this cap. Of course, there was a mix up somewhere and it got lost in the mail. An email later and no questions asked a new one was dispatched. When it arrived I was very happy.

It was the details that really impressed me; the little things like sealing the envelopes and bags with little Citroën H-Van stickers. Everything just conveyed how much they cared. From the cap I've continued to expand: Bib Shorts, 3/4 Bib, Classic Jersey with Arm Warmers, Winter Jersey, another cap, two fixed t-shirts and a rapha t-shirt, oh and a pair of socks; covered from head to toe and all in black and white with just a touch of pink. Some of it I got direct from Rapha, and some from Mellow Johnny's. Its all I wear on the bike and sometimes off the bike as well. Perhaps its my Anglo heritage combining with their British design, but everything fits me amazingly well and sizing is perfect accross the range (I know from experience how hard that can be!), a large is a large is a large. The construction and materials they use are also really impressive. I love the extensive use of wool (thats my Australian coming out). Nearly every item contains a hidden story: riding a fixed gear, the badger in the snow orbeing fearless whilst descending. Each one is like the trinket in a Chritmas cracker, an unexpected yet welcome surprise both short and entertaining. 

I must have worn and washed my Classic Jersey and Bib Shorts at least 250 times, probably more. They are holding up very well. None of the loose threads and none of the balling or pilling you see on other brands. In fact the only problem I've noticed is the back of my Classic Jersey has been bleached by the Texas sun and gone a pearlescent pink. I wouldn't hesitate to recommend Rapha on their product alone they really are living up to their mission. Consistent service and consistent quality product.

Rapha go further than just great product though; thier marketing is absolutely gorgeous. If you read my post on Venture Forth you will know that I love history and context. Rapha excel in this aspect. Every season a new catalog lands on my door step, each one containing beautiful photography and a story about some ride or race: Norddal, Tour Du Mont Aigoual and The Kemmelberg to name a few. Then there is their quarterly magazine Rouleur (www.rouleur.cc), meaning a cyclist who can ride all day over rolling hills. Its a celebration of road cycling heritage and lifestyle. Beautiful photography and in depth stories abound. It not your typical cycling magazine, writing about many aspects of cycling unknown to me before; for instance a 16 page story on Jean Bobet or 11 pages on Bar Tape. I subscribed yesterday (Jan 22, 2010) when they offered free shipping; I'd been complaining about the price of shipping forever and only being able to pick up copies ad hoc on various trips previously. 

If you have a chance try and make it to one of their live events. I managed to get to the Mellow Johnny's roller race they hosted; it really was a cross between fight club and the Triplets of Belleville as these images can attest. The rest of their Flickr sets are equally gorgeous.

When Rapha visited my neck of the woods on the Continental.

I'm really impressed with all Rapha has produced, the product is worth the every cent, not only for the quality but also for the experience. Try it.

[Feb 19 Update]

Regarding the pinkish hue my jersey had taken. I bumped into a guy wearing a jersey with exactly the same hue at Wholefoods just after I wrote my post. He told me to contact Rapha about it which I did. Without hesitation they replaced it, two years after I bought it. That really is standing by your product. The design is slightly different around the pockets, but for the better I think. That really is service.

 

Jet Blue Still Loves You. Why Jet Blue Customer Service Rocks

My close friends have all read this, but I thought I would share with all. Here is an email exchange between myself and the jet Blue customer service representatives about the demise of the nighttime New York to Austin flight. A year later the flight has returned which I am stoked about, though I doubt my letter had any impact.

My initial email:

My Dearest Jet Blue,

   I'd much rather do this in person, but I only ever seem to see you online these days. I'll come straight to the point: Its over between us, I'm a nighttime lover and you're only available in the day. I was tingling with excitement to see you from AUS to JFK on June 12th and again on my way homeon June 18th. To my heart beak you are no longer scheduling evening departures from JFK to AUS! I know I didn't visit you as often as you would like and never called you after; but I accepted your unpredictability during our trysts on those lovely evenings. Remember how we were sometimes late andoften took an hour to get things going because of all those sexy Euro travelers; good times. I lovedyou for always getting me home that night and even when things didn't go like we wanted you were always clean and served me with a smile. But now you're a daytime lover and the fare has gone up, soI'm afraid I must end our trysts. The rumor is true, there is another woman and her name is Continental. Yes she is more of a hassle to get to at EWR and yes, she is a little older and heavierthan your young sexy self; however she is under $290 and is leaving after dark two things which I'vecome to realize are important to me. I'll really miss you JB, your beautiful smile and excellent service rocked my boat, though it seems you out grew my love. Perhaps we can meet again one future day, when you can fit me into your schedule. I'll remember the good times fondly.

Always

Adam

P.S. Seriously please consider adding the night time departure back from JFK-AUS it really was convenient if not always full from our perspective.


And their priceless response, Yay humans!

Dearest Adam,

Thank you for your sweet letter to JetBlue. After the initial shock of your message was over, a gut-wrenching flood of emotion came over us. Where did we go wrong? We know every happy couple has at least one bad break-up behind them but, is this really the end?

Of all the moments in our relationship together, you were always there. Maybe we didn't do enough. Maybe we fell short of showing you just how much we care. We can embrace ourselves and hold our own hand - but we can't gaze into our eyes or feel our own soul lift us up.

We enjoyed the way our comfy leather seats enveloped you as you Jetted with us to New York and back again to Austin. We loved the way the light from the complimentary DIRECTV lit up your face as you watched your favorite shows. We'll never forget your friendly smile as you stepped onboard.

Going through "the change" has been hard for us. Just like a woman, we're always changing things around to please other people. We enjoyed our nighttime get-together's but we all change and that can be hard in a relationship.

Don't give up on us, baby. Let us work out a few things on our end before you call it quits. We'll do our best to win back your love and affection. You're the best!

Adam, you have a way with words and we appreciate your email. We truly hope to welcome you back onboard JetBlue in the future. Our Inflight Crewmembers and Pilots will be polishing their smiles.

Sincerely,

Jen

Customer Commitment Crew

JetBlue Airways

 

 

 

Some thoughts on Venture Forth

From October through December 2009 I attended Venture Forth run by Tech Ranch here in Austin. All told it was one of the best $500 I've ever spent. I learned a lot about business and most importantly about myself.

It began with some learning about our own personality and our strengths. We took a Myers-Briggs test where it was discovered my persnality can be classified as INTP or Introversion, Intuition, Thinking & Perceiving. Essentially I value knowledge above all else and am quite happy to spend all my time thinking. I've asked many about this assesment and they all agree that it is correct; its nice to be labelled! Following this we conducted a Strengths Finder assessment which uncovered my strengths and the things I should focus on in order to be successful. 

  1. Intellection: I like to think a lot apparently!
  2. Context: I look back bcause that is where answers can be found.
  3. Ideation: I'm fascinated by concepts.
  4. Command: I like to take charge.
  5. Deliberative: I'm careful and vigilant.

Most importantly I think it provides some guidelines on the type of people I need to be around in order to reach my potential, in business and in general. This is one aspect of the class that I feel I got the most from; it recommended I become a lawyer of all things.

Kevin suggested Ideation pages as a worthwhile undertaking and I agree. Essentially this is just sitting down and writing everything in our mind. It doesn't matter what you write about as long as you write. The idea of Ideation Pages stems from a book called "The Artists Way" and is designed to overcome mental blockages. Worked really well and some of my best thinking has been done here. I intend to continue this in my private journal but also partly in a series of blogs on other companies I admire and why.

The best aspect of the course by far is the "Jam Sessions", terrible name for such a worth while activity IMHO. Essentially groups of class members get together and talk aboutanything regarding their venture. At first I cringed (how very introveted of me) but in the spirit of the course dove in. I had some great discussions with class mates and they shed some really interesting thoughts on my venture. There was such a depth of talent in the group it was amazing. I highly encourage this part of the course, BUT you have to drive it and drive it hard. Its very easy to just ignore this aspect but its where you can get most value. Trust me here please.

Do attend Venture Forth but don't just go, embrace it and get out of your comfort zone while doing so. I did my first presentation in six years and was a nervous as Nelly in doing so but the feedback from it was priceless. My venture went from, can I really do this to a viable model over the duration of the course. A highly recommended experience for anyone starting on a venture or just fixing about thinking about commencing to start!