Tutorial

Appschef.com adalah SAAS dari Indonesia yang dibuat menggunakan Ruby on Rails. Berikut ini langkah – langkah untuk menggunakan Appschef API dari Aplikasi Ruby on Rails 3.2 dengan gem w_platform:

  • Signup dan Daftarkan produk / aplikasi Anda di http://appschef.com
  • Login ke Apsschef.com dan dapatkan API_KEY untuk produk / aplikasi yang anda daftarkan
  • Edit Gemfile aplikasi Rails anda dan tambahkan code berikut:
gem 'w_platform', :git => 'git@github.com:febyartandi/w_platform.git'
  • Di terminal run:
$ bundle install
$ rails generate w_initializer install
  • Kemudian Edit file config/w_platform.yml sesuai dengan konfigurasi aplikasi Anda, berikut contohnya:
common: &default_settings
w_api_url_users: /api/users/
w_api_url_get_active_session: /api/login
#nama aplikasi / produk Anda
app_name: w_factory_operations
development:
<< *default_settings
# link ke website appschef
appschef_url: https://appschef.com
# ganti dengan Api key produk / aplikasi Anda
api_key: xxxxxxxxxxxxxxxxxxxxxxxx
# link ke website Anda
app_url: http://localhost:3000
# protokol yang digunakan ( pilihan bisa http atau https )
protocol: https
#nama controller dan action yang dijadikan root (“/”) di Aplikasi Anda
root_controller: home
root_action: index
  • Definisikan “key” untuk setiap fitur yang ada di aplikasi Anda.

Untuk menentukan fitur apa saja yang ada di Aplikasi Anda, Appschef mengharuskan anda untuk membuat daftar fitur dan “key” sebagai representatifnya. List itu harus anda buat dalam excell dan upload ke Appschef.com.

Kemdian setelah itu anda definisikan fitur tersebut di aplikasi anda dengan edit file config/w_features.yml, berikut contohnya:

home:
index: wfo_home_index
projects:
new: wfo_project_new
show: wfo_project_show

Keterangan:

home, Projects => Nama Controller

index, new, show => Nama Action

wfo_home_index  => Contoh  ‘key’ untuk fitur “home/index”

  • Mount Routes WPlatform dengan edit config/routes.rb dan tambahkan code berikut:
mount WPlatform::Engine => “/”, :as => “w_platform”
  • Include WPlatformHelper dan tambahkan before filter untuk check access user ke fitur yang ada di Aplikasi Anda. Sebagai contoh Anda dapat Edit application_controller.rb dan tambahkan 2 line berikut:
include WPlatformHelper
before_filter :check_user_access
  • Langkah terakhir, Run server aplikasi Anda, kemdian login dari server appschef dan pilih untuk membuka Aplikasi Anda.

Tips

  • Anda dapat mendefinisikan controllers dan actions yang tidak memerlukan check authentikasi dengan cara berikut ini:
before_filter :check_user_access_but_skip_some_actions
protected
def check_user_access_but_skip_some_actions
check_user_access([{:controller_name => "about", :action_name => "index"}])
end
  • Anda dapat menggunakan helper yang tersedia, yaitu:

current_user_platform =>return has semua result data yang diberikan oleh Appschef server

current_company => return hash data company

current_products => return has data products

current_features => return hash fitur – fitur yang boleh diakases user

  • Menambahkan link logout
<%= link_to “Logout”, w_platform.new_authentication_session_cleaner_path, :confirm => “Anda yakin untuk logout ? ?”%>

Bug Report

Jika Anda menemukan bug dalam tutorial ini atau gem w_platform, harap hubungi saya melalui email ke: feby.a@wgs.co.id

Terima kasih.

Download the app here:
https://github.com/febyartandi/mars-rover-ruby-with-webview

MARS HOVER PROBLEM
===================================

A squad of robotic rovers are to be landed by NASA on a plateau on Mars. This plateau, which is curiously rectangular, must be navigated by the rovers so that their on-board cameras can get a complete view of the surrounding terrain to send back to Earth.

A rover’s position and location is represented by a combination of x and y co-ordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. An example position might be 0, 0, N, which means the rover is in the bottom left corner and facing North.

In order to control a rover, NASA sends a simple string of letters. The possible letters are ‘L’, ‘R’ and ‘M’. ‘L’ and ‘R’ makes the rover spin 90 degrees left or right respectively, without moving from its current spot. ‘M’ means move forward one grid point, and maintain the same heading.

Assume that the square directly North from (x, y) is (x, y+1).

INPUT:
The first line of input is the upper-right coordinates of the plateau, the lower-left coordinates are assumed to be 0,0.

The rest of the input is information pertaining to the rovers that have been deployed. Each rover has two lines of input. The first line gives the rover’s position, and the second line is a series of instructions telling the rover how to explore the plateau.

The position is made up of two integers and a letter separated by spaces, corresponding to the x and y co-ordinates and the rover’s orientation.

Each rover will be finished sequentially, which means that the second rover won’t start to move until the first one has finished moving.

OUTPUT
The output for each rover should be its final co-ordinates and heading.

INPUT AND OUTPUT

Test Input:
5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM

Expected Output:
1 3 N
5 1 E

Hi,

I am found interesting case in twitter api search using geocode params.
When I call:

http://search.twitter.com/search.atom?geocode=40.757929%2C-73.985506%2C200km

it’s returned
….
Sorry, your query is too complex. Please reduce complexity and try again.
….

Strange,.because This call working some days ago.
And I spend some minutes and found that we can’t request more than 160km
This the right call:

Hi,

This is linux command to delete/clean .svn files from one directory. This usually used if you have one folder in old project and want to copy-paste into new project or new svn repository.

This the command in terminal:

find . -name “.svn” -exec rm -rf {} \;

Hope this help :-)

Hi,

I want to share rails 2 app sample.
It includes
– signup
– login
– activation ( via email )
– forgot password ( send to email )
– edit profile
– create member area
– simple layout for front end and member ( include basic css )
– script to feeds table countries

To run application, Please Follow this steps:

Checkout app

git clone git@github.com:febyartandi/rails_2_scratch_app.git

Change configuration

- change configuration for database myql in config/database.yml with yours

- change google account for sending email in config/application.yml
smtp_user_name: yourgmailaccount
smtp_password: yourgmailpassword

- rake db:create && rake db:migrate
– rake migration:populate
– ruby script/server

Hope this help people !

Hi guys,

This is quick tutorial about linkedin api 1 – invitation by people email to join your linkedin network.

We will use linkedinapi rails plugin ( Created by Dimas Priyanto and Me base on oauth rails plugin )

  • initialize your linkedin api key and secret key
>> linkedin_api_key = ” YOUR LINKEDIN API KEY”

>> secret_key = “YOUR LINKEDIN API SECRET”

  • setting your callback
  • create oauth object
>> oauth = LinkedIn::Oauth.new(linkedin_api_key, linkedin_secret)
  • request authorize url

Open the link in your browser  as redirection url for user to do authorization process,
if user authorize it we will get params[:oauth_verifier] in our “callback_url”,
use it to authorize from request

for example:

  • authorize using oauth verifier and token
>> oauth.authorize_from_request(oauth.request_token.token, oauth.request_token.secret, oauth_verifier)
  • create linkedin api object
>> linkedin = LinkedIn::Base.new(oauth)
  • show your linkedin profile
>> linkedin.profile
“<?xml version=\”1.0\” encoding=\”UTF-8\” standalone=\”yes\”?>\n<person>\n  <first-name>Feby</first-name>\n  <last-name>Artandi</last-name>\n  <headline>Ruby on rails programmer</headline>\n  <site-standard-profile-request>\n    <url>http://www.linkedin.com/profile?viewProfile=&amp;key=30011332&amp;authToken=nM0a&amp;authType=name&amp;trk=api*a101208*</url&gt;\n  </site-standard-profile-request>\n</person>\n”
“AAAAAA”
=> “<?xml version=\”1.0\” encoding=\”UTF-8\” standalone=\”yes\”?>\n<person>\n  <first-name>Feby</first-name>\n  <last-name>Artandi</last-name>\n  <headline>Ruby on rails programmer</headline>\n  <site-standard-profile-request>\n    <url>http://www.linkedin.com/profile?viewProfile=&amp;key=30011332&amp;authToken=nM0a&amp;authType=name&amp;trk=api*a101208*</url&gt;\n  </site-standard-profile-request>\n</person>\n”
  • invite people by email, first name and last name
linkedin.invite_by_email(“feby@kiranatama.com”, “Feby”, “Artandi”)

That’s it, enjoy ! :)

Tag Cloud

Follow

Get every new post delivered to your Inbox.