Mar 2026【隨筆】Clone a Meta Ray-ban Display glasses application|藍芽 L2CAP CoC 極致低延遲架構優化:實現 720p 智慧眼鏡流暢串流 👓(LIVE DEMO)

圖片
最近在做一些實驗性質的東西,記得去年短暫玩過 2023 年底上市的第二代 Ray-Ban Meta 智能眼鏡,雖然它主要還是依賴智慧型手機作為算力中心,但我們對它所使用的串流技術很感興趣,因為聽說他們是用藍芽做串流。 去年曾經有同事隨口問我:「我們的眼鏡做到跟他們一樣你覺得有可能嗎?」,因為我知道我們的硬體規格跟人家的相比並非等號,加上當時有其他事情在搞,所以隨口開玩笑回說:“可是聽說 Meta 有200個人在搞那個眼鏡捏(雖然不知道他們負責搞應用的有幾人),啊我如果一個人可以幹贏他們200人,那我還在這幹嘛???(笑)” 也記得更久以前,當我們還在研究那個眼鏡時,常聽到像是:『 他們不知道用了什麼黑科技 』,這類沒有建設性、不應該從 RD 嘴裡說出來的話,而我也是不以為然。坦白講,以前每次只要聽到某SW嘴砲經理(暫且以H君稱之),沒事就把『 黑科技 』三個字掛在嘴上,當做無知的遮羞布,我就會感到倒胃口!同樣身為RD,我只覺得  Shame on you!(打嘴炮、作秀搶風頭、噁心帶風向、搞政治操作、把別人做事的成果搶去幫自己抬轎、有鍋直接推給下屬扛、散佈同事私生活謠言,還有職場霸凌,這些你他媽都頂級專業戶,除此之外沒啥洨用了!) 一件理論上可以做到的事情,外行人的認知被信息差,不懂加上沒實作能力去驗證,就什麼都變成黑科技了(多黑?比巴西黑鮑魚還黑嗎?)。反重力技術說不定也非啥黑科技,只是政府不讓你普通老百姓了解罷了。 Ray-ban Meta 的黑科技,講白了就是人家拉個百人團隊在搞那支眼鏡,然後把軟體技能和硬體規格點滿,再加上極致優化後的成果罷了! 當時知道 Ray-Ban Meta 的智慧眼鏡有塞入一個強大的 WiFi 6 晶片在裡面,一開始我猜測會不會有可能是透過 WiFi P2P 或 WiFi SoftAP 的方式去做串流(確實 Meta 的智能眼鏡,在同步媒體時,會強制要求開啟手機的 WiFi 開關,所以媒體同步應該是靠 WiFi 通道做的),而去年初我也快速做了一個WiFi Direct 架構來做 POC,確實傳輸效率非常快,幾百 MB 的大檔幾乎秒級傳完,從眼鏡端將媒體串流到手機端更是不用說的順暢,而且當時我們的媒體串流還是以未經編碼的方式傳透過 Socket 直接傳輸的(這表示傳輸時所需的頻寬會更大,功耗據說也較大)。 後來因為 ...

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.

熱門文章

Mar 12, 2022【重機一日遊】走北橫至宜蘭,經梨山、武嶺下埔里,再走台三線回桃園|16小時的半圈環島

日本の登山の歷史

Mar 2026【隨筆】Clone a Meta Ray-ban Display glasses application|藍芽 L2CAP CoC 極致低延遲架構優化:實現 720p 智慧眼鏡流暢串流 👓(LIVE DEMO)

Jul 2026【新北林口】觀音山小北插路線上鷹仔尖、東明山、潮音洞&一個關於被噁心的故事

Jul 2026【台北士林】溪山百年古圳步道順訪颱風後的儷人瀑布|清涼消暑的夏日健行好去處

Dec 2024【苗栗泰安】水雲餐廳溫泉民宿♨️🥢⛰️|水雲三星之橫龍山~騰龍山健行|台中西嶼龍新鮮海鮮古早味餐廳

2022, Apr 29【台中霧峰】霧峰里山步道群。親民好走的小百岳~阿罩霧山,還可到秘境觀景臺觀賞夕陽和夜景

Jan 2025【苗栗三義】富貴牡丹(三義館)人文藝術餐廳|預約制|在美術館裡吃無菜單料理

2019 Aug 16~18【福建南平】中國世界遺產~福建武夷山遊記。登天遊峰、臨九曲溪、品大紅袍

Mar 2025【桃園大溪】金面山(小百岳 No.021)、金山面山健行|阮家土雞城起登

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *