Implementing authenticated referrals from Facebook had one small gotcha that ruined a solid couple of hours. I implemented a before_filter in my Rails ApplicationController that checked for a parameter (code=**some ridiculously huge code**) passed from Facebook and then took that code and traded it for an OAuth access token using the Koala Gem.
What I found was that I was using the wrong redirect_uri. I was using the base URL for our site, but the code passed on the referral is actually encoded for the specific URL that Facebook is referring to.
The solution looks more like this:
def authenticated_referral
code = params[:code]
if code && !signed_in?
@oauth = Koala::Facebook::OAuth.new(app_id, app_secret, request.url.split('?').first)
token = @oauth.get_access_token(code)
#Perform sign in logic from token.
end
end
I make a living bringing new ideas to life on the internet. I’ll leave it to Professor Shirky to explain how SOPA stifles our ability to be creative and to innovate.
I recently received my Nest Learning Thermostat after they were sold out of the initial manufacturing run. There has been plenty of articles written about how nice the design is, how easy it is to install, and its Apple pedigree. While those are all great (it is beautiful, it took 10 minutes to install, and I’m an Apple Fanboy) I was really interested in the sensors.
Specifically, I had a suspicion that the Honeywell thermostat thoughtfully mounted on an outside wall next to a window was really reading the wall temperature and not the ambient room temperature. The Nest seemed to have an array of sensors which could work together to more accurately differentiate the room temperature from it’s own internal temperature.
Before installing the Nest, I took 10 temperature samples over the course of an hour (n=10) of the room temperature and the wall temperature around the thermostat. I also recorded the stated room temperature of the thermostat. All measurements were taken while the heater was not running, but these are by no means “accurate”.
After installing the Nest I repeated the temperature readings. There are some outliers in the data which I attribute mostly to the measurement equipment or perhaps taking a reading directly after a heat cycle. I am reporting here the min, max, and median DIFFERENCE from the thermostat’s stated room temperature and the readings taken by me.
For the Honeywell:
Wall Temperature: [-0.7, 0.5], median = -0.3
Room Temperature: [-5.2, -3.9], median = -4.8
For the Nest
Wall Temperature: [-3, 3.9], median = 2.8
Room Temperature: [-3.0, 0.8], median = -0.8
*Readings are in °F
So it seems that qualitatively I was correct in thinking that the Honeywell was mostly measuring the wall temperature while drastically under reading the room temperature. I had typically set the Honeywell for 64° feeling that it ran about 4° warmer.
The Nest had some outliers in the measurements (taken directly after install) but the later data readings settled down. This normalization can be seen by the median of the measurements. The Nest seems to do an excellent job of reading the actual room temperature and ignoring the mounting surface as I had hoped.
Human perception is the least reliable measurement ever, but I do feel there are less drastic temperature swings in the house now. I attributed the swings before to things like the outside wall getting direct sunshine, being in the shadow, wind, etc.
So for an initial impression, the Nest seems to be doing what I bought it for… accurately controlling the temperature in the room. I’ll write again after I’ve had time to determine if the “schedule learning” is awesome or if we just end up futzing with it a lot. Our family has an odd/flexible schedule.
I’ve been using Sublime Text 2 for about 3 months and I’ve been impressed. This is a nice post where Nick has setup Sublime almost exactly as I have it. Coffeescript and SaSS syntax highlighting, RSpec test support, and of course changing the default indentation to 2 spaces! ;-)
For our current project I needed to make sure people logging in had a verified PayPal account. Luckily eBay just release PayPal Access which allows OAuth based authorization my like “Facebook Connect” or “Sign in with Twitter”. Our app is built on Rails and I’ve already implemented a Facebook Connect using the great OmniAuth so an OmniAuth strategy was a nice fit. Too bad I couldn’t find someone’s code to mooch off.
So here is my first contribution to the Ruby/Rails community. A little Gem: omniauth-paypal. The great thing about OmniAuth is that the strategy pattern makes it wonderfully easy to use.
and follow any of the other examples on how to use OmniAuth.
Update
PayPal has OAuth support as BETA. The UID for this strategy is currently the email address (bad) because there is no supplied UID. I have contacted PayPal and they are looking into when this will be implemented.
Address information is now included.
Update 2
PayPal has implemented a UID for OAuth now.
More information is parsed and returned in the extra hash.
Hit me on Twitter (@surferdwa) if you have any questions or comments!
I had our app running on the Bamboo stack, but decided to move up to Cedar to use the 3.1 assets pipeline. Before I had to precompile, commit, and push the JS, CSS, and Images assets by hand. Everything was looking good until:
=> Rails 3.1.0 application starting in production on http://0.0.0.0:48675
2011-10-29T13:28:24+00:00 app[web.1]: => Call with -d to detach
2011-10-29T13:28:24+00:00 app[web.1]: => Ctrl-C to shutdown server
2011-10-29T13:28:24+00:00 app[web.1]: Exiting
2011-10-29T13:28:24+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/
rails/rack/log_tailer.rb:8:in `size': No such file or directory - log/production.log (Errno::ENOENT)
2011-10-29T13:28:24+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/
rails/rack/log_tailer.rb:8:in `initialize'
...
2011-10-29T13:28:24+00:00 heroku[web.1]: Process exited
Crud. I knew that Heroku did some fancy things with logging but didn’t know from where this was coming. There were some clues in this GitHub issue, the only reference Google found, but nothing concrete.
Turns out I had configured the Rails logger in an initializer OTHER THAN development.rb so on production it was conflicting with how Heroku redirects the logging. By moving the custom log setup into the development environment initializer the problem went away!
Now I just need to get Heroku to actually compile the assets pipeline during slug compilation and I’ll be in business.
I don’t have a lot of personal experience with death. It’s basically an unknown quantity for me. I remember watching the Mad Men episode where Marilyn Monroe died and finding it fascinating that the death of a person none of those women had ever met could touch them so profoundly.
Now I understand.
I’ve been labeled an Apple Fanboy with my iPhone, iPad, and MacBook Pro. I read the rumor sites every morning and wait for the keynotes to be posted. But really, other than spending 80% of my waking day interacting with an Apple product, why should the passing of the Co-Founder affect me?
What I was missing is that Marilyn Monroe was a physical embodiment of those women’s dreams and identity. Sure they mimicked her fashion and watched her movies, but it wasn’t the passing of those things that they mourned. They mourned the death of that little bit of Marilyn that lived in each of them, that inspired them, that influenced them.
Since hearing the news yesterday I have teared up at each photo I’ve seen, each news story I hear, and each post that I read. I search out quotes. and I contemplate their meaning. I didn’t realize it, but Steve has had a profound and deep impact on me that goes beyond a multitouch screen and a slab of aluminum.
For me, Steve is the embodiment of my desire for simplicity, beauty, and perfection. When I create a web page or an API I wonder to myself, sometimes aloud, “If I presented this to Steve, what would he say about it?” The first pass is always too complex, too wordy, or too inhuman. I refine, I edit, I reduce until there is nothing on the screen that is superfluous.
Steve’s ideas of perfection in design and construction are my own. I rarely get to release something I think is perfect, but that doesn’t mean I can’t get there someday.
Steve has made way for the new but he has given us a vision of what it means to dent the universe. And that vision lives in each of us “fanboys”.
My family tries to do our best being green. We avoid disposable paper products, we’re into CFL bulbs, we compost, try to grow a modest garden, and buy local. We bike or walk all over town instead of driving.
One thing we’re working on is our consumerism. What can I say, we’re an american family and it is rare that there isn’t a trip to Target or Lowes during the week. We’re committing though to change our behavior from one of consumerism to one of materialism. By only bringing things we absolutely love into our house we hope to reduce that consumerist churn. My MBP is almost 4 years old now and I’m sure I would still be using my original iPhone if I hadn’t dropped it in a parking lot. W love gadgets, but hate the environmental impact when they are toast.
So what do you do when something that you love breaks? You try to have it fixed right? I have had two such experiences recently that have left me unsatisfied and my wallet much lighter.
My espresso machine began leaking a couple of months ago. I took it down to the local small appliance store and they said they would probably have it back to my after 48 hours. Two weeks later I picked up my machine, unfixed. They wanted to replace the controller board ($125 + labor) before they even went looking for a leak and they didn’t inspire confidence.
I took the machine down to an authorized service center, which was a jaunt, and was told it would be done in 7-10 days. Fourteen days later I was told they won’t get to it for another 5 days. The machine currently sits in limbo as my two month Starbucks tab eclipses the cost of a new machine and the white and green cups represent the majority of our trash. I love that machine. I hate to consume. I should have cut my losses and bought a new machine both for my wallet and the environment. Fail.
Last week my external hard drive broke. The micro USB connection popped off of the circuit board rendering the housing useless. I called up an electronics repair guy who said he could solder the piece back on the board. $45 and four days later I was told my hard drive was corrupt and that he hadn’t soldered the piece back on. Turns out I can buy a new USB enclosure for $11 on Amazon and that he was trying to mount the HFS+ formatted drive on a PC. Double Fail.
I’m sure I will foolishly try to fix things in the future to remain “green”, but I think I’ll do it myself instead of relying on the professionals.