2018, Feb 21【北アルプス 乗鞍岳 厳冬期】Mt.乗鞍スノーリゾート ピストン☆日帰り雪山登山♪

圖片
2018年的農曆過年期間,和山友Bryan兄前往日本乗鞍岳和八ヶ岳山域進行雪季登山訓練。
2月19日晚上抵達羽田機場,乘坐高速巴士到新宿,晚上住宿在去年住宿過的旅館“新宿ビジネスホテル”,隔天早上9點出門,到中央東口附近的一蘭拉麵吃早餐,然後前往バスタ新宿(巴士總站),搭乘10點50分的高速巴士前往松本bus terminal。先去便利商店買些行動糧,然後乘坐上高地線電車前往“新島々駅”,然後再轉搭公車前往“乗鞍スキー場前”,晚上住在Ski Resort旅館街的天然溫泉旅館“なごみ湯 白樺”。
隔天早上吃完早餐,早上9點步行到滑雪場的リフト乗り場,乘坐3次リフト抵達かもしかリフト最上部(標高約1,970m的ツアーコース開始点)。夏季時,觀光客可以搭乘巴士直接抵達標高2,702m的畳平(乗鞍 bus terminal),但冬季公路早已被積雪覆蓋,這裡是冬季前往乗鞍岳最便利的登山口。
稍微整理一下登山裝備,早上9點50分啟程出發,稍早查看天氣預報,今天的天氣是多雲午後轉陰的天氣,因此從一開始就不抱持任何期待可以看見美麗的山景。從ツアーコース開始点出發後,雖然沿途足跡都很明顯,但沿路都是鬆雪,沒有買スノーシュー穿,每個步伐都走的相對費力,當下突然有點懊惱,但雖然如此,還是不影響行進的步調。
在沒有スノーシュー的狀態下,持續和鬆雪奮鬥了一個多小時,上午11點30分到達“ツアーコース終点 ”,這裡是分別前往“肩ノ小屋”和“位ヶ原山荘”的岔路口,位ヶ原山荘冬季有營業,如果安排2天1夜的行程,可以在那裡住宿一晚,但住宿必須事前預約。我們取直行繼續朝向肩ノ小屋前進。從岔路口開始,雪地上已經沒有明顯的足跡,天候也隨著時間逐漸變差,視野完全被濃霧所遮蔽,眼前只剩下一片白色,能見度大約只有10公尺,因此不時需要依賴GPS裝置來確認方向。
中午12點50分經過“大雪溪避難小屋”(當下以為這就是肩ノ小屋,後來回家查看地圖才知道並不是),小屋的入口處已經被封死,無法進去小屋取暖,只能站在小屋外吃點糧食補充水份。這時的溫度差不多有零下10幾度,加上風寒效應,手套一拿下來,手指頭瞬間失去知覺,後來發現小拇指有輕微凍傷。在這邊小休息10分鐘左右,繼續靠著GPS往山頂方向前進。
Bryan選了一條捷徑,走沒多久我就覺得奇怪,按常識來判斷,這種深雪和極陡的坡度,直覺就不是正常的登頂路線,…

Connect LinkedIn Account into your Rails Application with Authlogic and OAuth

LinkedIn launched its new API in November 2009, allowing any developer brave enough to implement OAuth to integrate with one of the largest social networks around. Seeking an opportunity to really understand OAuth more fully and play around with the LinkedIn API at the same time, I created the LinkedIn connect sample code.

This is a sample Ruby on Rails tutorial to demonstrate how you can use the LinkedIn API to authenticate users and pull their profile data into your own website.


GETTING STARTED


Before you can use the LinkedIn API, you'll need to set up your API keys.

Getting Started with the LinkedIn API


1. Where do I begin? Start by navigating to http://developer.linkedin.com. This is Linkedin developer portal where you can read API documentation, collaborate with other developers, and keep abreast of changes to the LinkedIn API. From here, click on “LinkedIn APIs.”

2. Now click on “Request an API Key”

3. After logging in, you’re now presented with an opportunity. You can create as many API keys as you like, one for each application that you create. Let’s get started.


4. This isn’t as complicated as it looks. Let’s look closely.
Application Developers: This is a list of your LinkedIn Connections that will receive network updates published by your application and is used only while it is in development mode. You need to be connected to any LinkedIn member that you want to put on this whitelist. Interface Language: Your application is provided in one or more languages to end users. Let us know what those languages are so we can better support you in the future. Programming Tools: Knowing what kind of programming languages and tools you use to develop your application lets us know what languages and environments are most important for us to support. Just a few more fields to go over!

5. Ready to get your API keys? When you’re done, click “Add Application”
Contact Info: Tell us how to get in contact with you should we have a question about or there is a problem with your application.
OAuth Redirect URL: If you have a static location that should always be used for your OAuth callbacks, you can specify it here. It is recommended that you use the oauth_callback parameter in the appropriate requests instead.
Agreement Language: If you’d like to force the login screen to appear in one of the languages LinkedIn supports, you can set that here. It is recommended to leave the setting at “Browser Locale Setting.”
Terms of Service/CAPTCHA: Please do read our API Terms of Use. You cannot create an API key without agreeing to our terms. You’ve likely seen a CAPTCHA before, and it needs little explanation.



6. You’ve got your API keys. What’s next?
The LinkedIn Developer Network is where you’ll find guidelines, documentation, and growing community of developers.


RUBY GEM INSTALLATION


First you need to upgrade your Rails VERSION to 2.3.x, and install the required Ruby Gems below:

1. Setup and use Authlogic

$ sudo gem install authlogic

2. Install OAuth and Authlogic_Oauth

$ sudo gem install oauth
$ sudo gem install authlogic-oauth

3. Install other required Ruby gems

$ sudo gem install json
$ sudo gem install crack

Or for older version of Rails, you can install it as a plugin:

$ script/plugin install git://github.com/binarylogic/authlogic.git
$ script/plugin install git://github.com/jrallison/authlogic_oauth.git

* Authlogic at Github:http://github.com/binarylogic/authlogic
* Authlogic Example: http://github.com/binarylogic/authlogic_example


SETUP API KEY IN YOUR APP


Create load_linkedin_config.rb in #{RAILS_ROOT}/config/initializers directory

Create linkedin_config.yml in #{RAILS_ROOT}/config directory



DATABASE MIGRATION


1. Make some changes to user table in your database:

$ script/generate migration AddLinkedinConnectToUsers

2. Create Position,Education and Connection model:

$ script/generate model position

$ script/generate model education

$ script/generate model connection


3. Modify the User model, add the content below to the #{RAILS_ROOT}/app/models/user.rb:

The private method "populate_oauth_user", which is called before user record created, and is used to fetch profile info (name, headline, industry, profile pic, public url, summary, specialties, web urls) in LinkedIn.com, and save these info to your user record. The other private method "populate_child_models", which is called after user record created, and which will save past position info (companies, job titles, durations, descriptions), education info (schools, degrees, field of study, dates, etc) and connections info (names, industries, headlines, profile pics) for user.

4. Modify the Connection model, add the contents below to the #{RAILS_ROOT}/app/models/connection.rb:

5. Modify the Education model, add the content below to the #{RAILS_ROOT}/app/models/education.rb:

6. Modify the Position model, add the content below to the #{RAILS_ROOT}/app/models/position.rb:

7. Create UserSession model, and define the oauth_consumer class method on your UserSession model:


CONTROLLER METHOD


You only need to save your objects this way if you want the user to authenticate with their OAuth provider.

That being said, you probably want to do this in your controllers. You should do this for BOTH your User objects and UserSession objects (assuming you are authenticating users). It should look something like this:

You should save your @user objects this way as well, because you also want the user to authenticate with OAuth.

In my case, I have to integrating the LinkedIn OAuth Sign in feature to my current Rails project, so I changed the "Create" method in my UsersController like this way:

When the user click on the LinkedIn Login button and we can't find the oauth_token and oauth_secret in the database, the user will be redirect to signup page with "linkedin_user" parameter. After fill in the fields, they will be redirect to LinkedIn authentication page, then user record will be created. If we can find the oauth_token and oauth_secret in the database, the user will be login to the site.



ADD REGISTER BUTTON


You can simply use the "oauth_register_button" helper method to add LinkedIn register buttons to your views, like this:

Now add some style in your CSS file for LinkedIn button:



NEXT STEPS


Now we have user's LinkedIn data saved in the database, so you can write some codes to show the user's LinkedIn profile data (such as Username, Headline, Location, Education, Position, Websites, Skills, Experience, Connections) in the website.

You may want to add methods to update profile info on each login or update request. Or pull status updates, specialties, and current position for connection.

If you're interested in learning more about LinkedIn and OAuth, I encourage you to checkout Taylor Singletary's presentation LinkedIn OAuth: Zero to Hero.

熱門文章

[轉載] 洛克菲勒寫給兒子的38封信(全文)

September, 2012 白姑大山二天一夜~其實沒那麼累,只是路途遙遠

2013.5.25~26【新阿溪縱走】眠月線鐵道線探勘。順登松山、萬歲山、小笠原山、對高岳

2017, Oct 29【桃園大溪】週末輕鬆走~打鐵寮古道&白石山

2012 アルプスの夏:飛騨・北阿爾卑斯山脈南部の焼岳/槍・穂高連峰/表銀座単独縦走記錄。Day1、Day2 台北~富山~高山~上高地~小梨平露營場~焼岳北峰

2018 Mar 18【嘉義~宜蘭】春暖日和 🌸 阿里山櫻花季賞花&太平山棲蘭山莊小木屋住宿

【山行記錄】2014, March 29~30 春一番!武陵四秀之桃山、喀拉業山輕鬆行

文章列表