發表文章

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.

AngularJS (17) value

在 第16篇的AngularJS 談到factory()和service(),它們叫做「服務提供者(provider)」,可以包裹函式再提供給控制器使用。 value()也是一個服務提供者,讓你可以包裹一些常用的值,字串、數字、json都可以。 例如: myApp.value("intValue", 100); myApp.value("strValue", "This is a string."); myApp.value("jsonValue", [{name:'Lily'}]); 需要value時,就匯入value名稱到控制器即可。 myApp.controller("myController", ['$scope', 'strValue','intValue','jsonValue', function($scope, strValue, intValue, jsonValue){ $scope.str = strValue; $scope.integer = intValue; $scope.myjson = jsonValue; }]); This is a string. 100 Lily 範例程式碼( Plunker ) 同樣地,value()只能給控制器用,不能在HTML呼叫value()。

AngularJS (16) factory 和 service

本篇範例程式碼( Plunker ) 我們可以在控制器裡面寫函式,這一點你應該知道。你也許會發現當你有太多的成員函式時,會讓控制器程式碼變得太長。 app1.controller("myController", ['$scope', function($scope){ $scope.add = function(val1, val2){return val1+val2;}; $scope.sub = function(val1, val2){return val1-val2;}; $scope.int1 = $scope.add(10,20); $scope.int2 = $scope.sub(50,30); }]); 為了方便管理程式碼,AngularJS提供了factory()和service(),把函式包在一個「服務提供者(provider)」。 Factory 改寫上面的例子,我們宣告Maths為factory物件,負責提供add和sub這兩個函式。 myApp.factory("Maths", function(){ var fact = {}; fact.add = function(a, b) { return a + b; }; fact.sub = function(a, b) { return a - b; }; return fact; }); 或是可以批次定義 myApp.factory("Maths", function(){ return { add: function(a, b) { return a + b ;} sub: function(a, b) { return a - b; }; } }); Service 我們也可以用service() myApp.service("Maths", function(){ this.add = function(a, b) { return a + b; }; this.sub = function(a, b) { return a - b; }; }); ...