RSS Feed

‘development’ Category

  1. Capistrano + RVM = Problem with deployment?

    October 18, 2011 by Ivan Turkovic

    Most of the time when I had issues with deploying on rvm environment it helps you to do the following.

    Create a file in $home folder

    touch .rvmrc

    And paste following code:

    rvm_trust_rvmrcs_flag=1

  2. Working OAuth2 with Foursquare on Sinatra

    September 19, 2011 by Ivan Turkovic

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    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

  3. Latest eclipse app on Mac OS Lion preference pane

    September 12, 2011 by Ivan Turkovic

    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.