Working OAuth2 with Foursquare on Sinatra

require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
require 'net/https'
require 'foursquare2'

set :port, 80

CLIENT_ID = '****************************************************'
CLIENT_SECRET = '****************************************************'
CALLBACK_PATH = '/callbacks/foursquare'

def client
OAuth2::Client.new(CLIENT_ID, CLIENT_SECRET,
{:site => 'https://foursquare.com/',
:token_url => "/oauth2/access_token",
:authorize_url => "/oauth2/authenticate?response_type=code",
:parse_json => true,
:ssl => {:ca_path => '/etc/ssl/certs' }
})
end

def redirect_uri()
uri = URI.parse(request.url)
uri.path = CALLBACK_PATH
uri.query = nil
uri.to_s
end

get CALLBACK_PATH do
puts redirect_uri
if params[:code] != nil
token = client.auth_code.get_token(params[:code], :redirect_uri => redirect_uri).token
client = Foursquare2::Client.new(:oauth_token => token)
email = client.user('self')['contact'].email.to_s
return "Authenticated user: #{email}"
else
'Missing response from foursquare'
end
end

get '/' do
redirect client.auth_code.authorize_url(:redirect_uri => redirect_uri)
end

Latest eclipse app on Mac OS Lion preference pane

When upgrading to a new eclipse app and selecting existing workspace it makes preference pane unavailable. So to be able to access settings you have to either create a new workspace and migrate projects to a new workspace or remove settings files from old one. This saved my time a couple of times.

Mac OS Lion and installing ruby 1.9.2

I am always having trouble with installing fresh rvm instance, so here are all steps needed in fresh rvm to install new ruby 1.9.2

export ARCHFLAGS="-arch x86_64"
export CC=gcc-4.2
rvm pkg install readline
rvm pkg install iconv
rvm pkg install zlib
rvm install 1.9.2 -C --with-readline-dir=$rvm_path/usr --with-iconv-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr

Kindle still rules the ebook world

First time when i saw kindle being presented I was thrilled, because i read a lot of books. I saw a future in electronic books. That was 2 years ago and I wasn’t wrong. Nowadays Amazon sells more ebooks than paper print books.

So last year when they introduced third generation of Kindle, I’ve jumped on the kindle wagon. I’ve bought wifi only version which came quite cheap. I never imagined that kindle would replace all paper books. Actually since owning kindle there was only one book I’ve bought and that is Four steps to epiphany. The only reason I’ve bought it is that is not available in digital form.

Does this mean kindle replaced all paper based books for me? Well yes and no. There is still one thing that kindle cannot be used and that are pdfs, even it supports them they are unusable on it. Zooming functionality is not quite there.

Only competitor To kindle wasn’t other ebook readers but Apple iPad. I was quite known to it, even tried it few times, but it was obvious that it is unusable in direct sun light. But still I was wondering if I would be able to use it for reading books. So last month I’ve finally needed to buy iPad, because i was doing some applications for it. So I also tried to use it as a ebook reader, because it also has kindle app so it means all books i’ve bought before i could them read on it also. My final decision is that it didn’t came to my expectations as a ebook reader. Only part it did excel were pdfs technical stuff which I wasn’t able to read on kindle.

So to write a conslusion. I will use both devices as a reading utility but kindle will still be my main device for reading. No other digital device can beat reading in direct sun light. But main differentiator is that kindle still feels like something natural it doesn’t have exclusive electronic device feeling. It feels like something coming from analog age. I even don’t have a feeling I need to take care of it because it feels as rugged device. From mine point of view I can easily say that kindle has a bright future as a reading device and I hope they will continue and not to become yet another android clone as Nook did.