Sunday, December 16, 2012

Getting Started with Rails and Facebook

I've been messing around with Rails and Facebook Registration over the weekend. I finally got it working, but it literally took me all weekend. I need to document this because I'll forget what I did by tomorrow morning, and don't want to do it again. Also, figured this might help other's with the same problems.

First, my local config:

  • Mac running Mountain Lion
  • Ruby 1.9.3 
  • My gem file: 
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
In general, I followed the instructions posted here, posted at the OmniAuth Github.

I had three major issues getting this working. The first was trivial, the second was horrible, the third was my bad.

Issue 1:  Omniauth Authentication on Facebook. 

  • The issue is described well here, on Stackoverflow.
  • Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
  • What they didn't describe (and actually Teamtreehouse.com describes it the same way), is that your "Site URL" on your Facebook config page isn't http://localhost:3000. It should be http://0.0.0.0:3000/ . I messed with this for an hour.
Issue 2: Omniauth and Facebook certificate verify fail.
  • The error message: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
  • The Omniauth instructions above actually describe the issue well (and there's an extensive trail on this too). It didn't address my issue which was that I didn't have any root certification authorities (CA)
  • The solve was on a separate Stackoverflow question, here.

$ rvm remove 1.9.3 (or whatever version of ruby you are using)$ rvm pkg install openssl$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usrafter this you will need to download the missing cacert.pem file:
$ cd $rvm_path/usr/ssl$ sudo curl -O http://curl.haxx.se/ca/cacert.pem$ sudo mv cacert.pem cert.pem
Issue 3:  "Could not authorize you from Facebook because "Csrf detected".'"
  • Solve was described here
  • Addressed by just deleting the Omniauth config file. 

                                      Sunday, January 1, 2012

                                      Prediction Data as an API in 2012

                                      A good post by Tristan Walker from FourSquare, got me thinking about the 'data space'. In his post, he mentions a company, Palantir (BusinessWeek article); from what I gather, they emphasize development of prediction models as applied to terror prevention, and consumed by non-technical field analysts. Their founder provides a good overview in this video (it's $10) from the O'Reilly Strata conference last year. As an aside, Palantir sounds like it has an interesting corporate culture (has a limit to salary, and is really driving home a 'solving real problems' message).

                                      Reading the BusinessWeek article, begged the question; how is Palantir's approach different than that of Recorded Future's? Recorded Future seems to have a similar vision, but their approach is framed somewhat differently; they're creating a 'temporal index', a big data/ semantic analysis problem, as a basis to predict future events. Again, check out the O'Reilly video - it features a panel of Recorded Future, Palantir, and Twitter (the Twitter speaker, Rion Snow, mentions a lot of really interesting research that has been done against Twitter).

                                      A few more companies that seem to be circling this big data/ prediction modeling space:

                                      • Sense Networks - I've been following Sense for a while due to the Sandy Pentland/ Nathan Eagle connection (both have done extensive Reality Mining in mobile that I find interesting). They do similar big data prediction analysis, but the domain seems to be mobile-centric. 
                                      • Digital Reasoning - mentioned here
                                      • BlueKai - I'm not sure most people would put BlueKai in the same boat as Palantir and Recorded Future, but I'm starting to frame this space as a value chain, and BlueKai seems to have found a way to aggregate, improve, and repackage data for use in digital marketing. 
                                      • Primal - a Waterloo-based company, it's not entirely clear to me at this point their angle, but the appear to sit between BlueKai and Recorded Future/ Palantir and emphasize "filling out the sparseness of information in social networks". 
                                      Finally, "Follow the Data" seems to be a good source of information on what's happening in the industry. Look forward to spending some time reading through the content. 

                                      It seems to me that the near future of this space will be reminiscent to what happened in mobile in the last few years; API-ization of 'state' data (eg. what Skyhook did in wifi location). There will be data-domain experts (the ability to make meaning out of phone transcript calls between terrorists is a different domain than, say, making meaning out of online shopping behaviors); spanning the ability to make sense of unstructured data, aggregate from multiple sources, run prediction models on it, and make it available to various "application" providers. What we're seeing today are very purpose-built algorithms/ applications, and I suspect the long term value here is in making and interpreting meaning in the unstructured data (rather than storing the data).