發表文章

ajax call relative url 相對網址

$http.get('members.json') $http.get(' ./ members.json') //另一種寫法 這種寫法,就是相對路徑(relative url, relative path)。 如果當前頁面是 http://myserver.com.tw / taiwan / member / index.html 瀏覽器會把 members.json 自動轉成 http://myserver.com.tw / taiwan / member / members.json 若是 ../ 開頭, $http.get('../members.json') 轉成 http://myserver.com.tw / taiwan / members.json 若是 / 開頭, $http.get('/members.json') 轉成在domain之後 http://myserver.com.tw / members.json 如果是開頭兩個斜線(//)? $http.get('//myserver.com.tw/taiwan/member/members.json') 表示參照當前頁面使用的協定(http://或是https://),適用於同時使用一種以上協定的網站。

手動建立Facebook自動登入(v1.0-v2.2) Manually Build a Login Flow

此文章支援 v1.0、v2.0~v2.2 臉書提供三種「自動登入臉書帳號」的方式,javascript SDK、PHP SDK,以及手動建立。本篇只談手動建立,是利用 Facebook Graph API,有三個步驟。 請求code參數 用回傳的code參數,請求access_token參數 用回傳的access_token參數,取得使用者個資 Graph API v1.0 1. 請求code https://www.facebook.com/dialog/oauth? client_id= {YOUR_APP_ID} &redirect_uri= {YOUR_REDIRECT_URL} code=AQBW3oLLO7UBdYIlBiycdsq0-uBynPisB4cLGoNaVqo...(略) 2. 請求access token https://graph.facebook.com/oauth/access_token? client_id= {YOUR_APP_ID} &redirect_uri= {SAME_REDIRECT_URL} &client_secret= {YOUR_APP_SECRET} &code= {CODE_STRING} access_token=CAADh9ZCitjocBANzxLfZACFZCUNIajhZAER2EqBRSYLB5IIH...(略) 3. 用回傳的access_token參數,取得使用者個資 https://graph.facebook.com/me? access_token= {ACCESS_TOKEN_STRING} 得到登入者資料的json囉! { "id": "00000012345", "first_name": "帥帥", "gender": "男", "last_name": "薛", "...

Sublime Text2 - 更換背景/更換主題 theme

這一篇比較算是個人小筆記,不希望以後還要翻找。XD Theme 設定方式 (Sublime上方選單 -> Prefereces -> Settings-User) Soda Light { "color_scheme": "Packages/Espresso Soda.tmTheme", "font_size": 17, "ignored_packages": [ "Vintage" ], "theme": "Soda Light.sublime-theme", "tab_size": 4, "translate_tabs_to_spaces": false } Monokai { "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", "font_face": "Source Code Pro", "font_options": [ "directwrite" ], "font_size": 15, "ignored_packages": [ "Vintage" ], "soda_classic_tabs": false, "soda_folder_icons": true, "theme": "Soda Dark.sublime-theme", "tab_size": 4, "translate_tabs_to_spaces": false } Theme 下載方式 其實 theme 也是 sublime package,所以只要 ctrl+shift+p → "Insta...

Sublime Text2 - Tab 改為 4個 Spaces

圖片
到Sublime畫面上方的menu, Preferences -> Settings-User 加入兩行設定 "tab_size": 4, "translate_tabs_to_spaces": false 像這樣 就完成囉! 完成設定後,你輸入一個tab,圈選它,看看是否成功設定tab size。

windows分享給 virtualBox linux

A. 設定virtualbox  開virtualbox 下方工具列 ->「共用資料夾設定」 -> 右方小按鈕「加入新的共用資料夾定義」 選擇你要共用的windows資料夾    「資料夾路徑」:要共用的windows資料夾路徑,如 C:/...     「資料夾名稱」:定義它在virtualbox的共用名稱                 如:                「資料夾路徑」: C:/user/pigu                「資料夾名稱」:PIGU B. 設定linux       4. 開 terminal       5. 到你想要的資料夾           如根目錄: cd ~/       6.   輸入指令             sudo mount -t vboxsf  PIGU ./

Sublime Text2/Text3 安裝 Package - TortoiseSVN

圖片
要在Sublime中可以使用TortoiseSVN或其他版本控制的功能,要安裝Package,在此介紹如何安裝TortoiseSVN。 安裝步驟 在Sublime安裝Package Control Package Control 是Sublime負責安裝套件的工具,所以要先裝它才能裝Sublime的Package。 輸入 alt+` , 如果你是Text2,貼上這段程式碼 import urllib2,os,hashlib; h = '2deb499853c4371624f5a07e27c334aa' + 'bf8c4e67d14fb0525ba4f89698a6d7e1'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation') Text3則是 ...

AngularJS (18) ng-include 匯入外部HTML

本篇範例的( Plunker Demo ) ng-include用來匯入外部HTML。 網頁隨著開發,會越來越冗長,所以將網頁模組化能增加維護的效率。 方式一, 直接輸入網址字串 'header.html' <body ng-app="app1"> <div ng-include src="'header.html'"></div> </body> 要注意需要 '  ' 方式二, 也可以先在controller定義網址的字串變數。 .controller('MyController', function($scope){ $scope.headerUrl = 'header.html'; }); 然後在MyController的範圍內呼叫就可以了。 <div ng-include src="headerUrl"></div> 也可以省略src <div ng-include="headerUrl"></div> 要注意的是, ng-include官方文件 說明ng-include只能插入同網域的網頁 By default, the template URL is restricted to the same domain and protocol as the application document. For example, ngInclude won't work for cross-domain requests on all browsers and for file:// access on some browsers.