符號 | 說明 |
---|---|
# | id屬性 |
. | class屬性 |
[] | 自訂屬性 |
> | 子元素 |
+ | 兄弟元素 |
^ | 升層 |
* | 複製數量 |
$ | 增量變數 |
$$ | 增量變數(2位數) |
{} | 文字節點 |
[AngularJS]AngularJs-20140129
$location Service (window.location)
用途: redirect action
path()
使用者可以使用『上一頁』的功能
1 | $location.path(); // 取得目前的路徑 |
replace()
使用者沒有辦法使用『上一頁』
1 | $location.path('path'); |
absUrl()
取得完整的路徑
hash()
取得 # 之後的內容
search()
get/set search part of the current URL
url()
get the URL of the current page
[工作筆記] Linq筆記 - 取得最後一筆的聊天紀錄
目的: 取得最後一筆的聊天紀錄
1 | var result = (from o in db.messages |
[Phalcon] Complie Phalcon.so for php 5.4.2
緣由:Bluhost決定將所有的php版本升級到5.4.20, 那這樣子的行為會讓phalcon.so(php 5.3.27版本) 失效,然後問Bluehost, 他們不會提供降級的服務,也不會幫忙complie phalcon.so…所以,自己做。
作法:設定一個跟網頁空間一樣的環境, same os and php version, 然後在編譯phalcon, 成功編譯後上傳phalcon.so到主機上面。
步驟: 我是選擇centos6版,下載與主機服務商一樣作業位元的作業系統. (64bit or 32bit)
- http://isoredirect.centos.org/centos/6/isos/x86_64/ <= 64位元的版本
- 用Vmware將centos裝起來.
- 安裝完成後,用root的帳號登入,開啟terminal window
- 由於第一次安裝,所以先執行
yum update
讓系統先將所有的套件更新到最新的狀態 yum groupinstall "Development Tools"
安裝一些跟開發有關係的元件,例如 git (必須安裝)- 安裝rpm yum repository information, 因為php5.4是在不同的repository. 安裝方式如下
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
- 可以用
yum list | grep php
顯示跟php有關的套件。php54w就是我們要安裝的套件 - 要安裝以下套件
yum install php54w php54w-mysql php54w-devel
- 利用git取得phalcon
git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
./install
- 如果complie成功, 會出現下面的畫面
- complie完後的檔案可以在build/modules/紅色框起來的資料夾下面看到
- 將phalcon.so複製到網頁空間主機php放extensions的資料夾下,並編輯php.ini啟動phalcon.so
- 打完收工
[python] small script -- 讀電子報,擷取文章,轉錄
#流程
- 從gmail裡面讀取電子報(特定的寄件者)
- 取得郵件內容
- 分析html
- 取得所要的部份(s)
- 將要轉錄的文章發布到wordpress上
- 將已處理的信件從收件夾中移到另一個資料夾中
- 結束作業
#開發環境 python 3.3
#有用到的package
- imaplib --> 用來處理imap type email
- email --> email結構
- re
- BeautifulSoup4 --> work with python 3.3 --> from bs4 import BeautifulSoup
- wordpress_xmlrpc --> 透過xmlrpc的方式新增文章
所遇到的問題
- 編碼 a. 信件 b. 信件內容
- html形式的email裡面藏有\xa0 , 還是因為編碼的關係
其實在使用bs4的過程中,也是花最多時間的地方是如何讓中文正常的顯示出來。其實在第一段要取得信件裡的內容時,就遇到中文編碼的問題。
demo code
1 | import imaplib,email,re |
在3.3裡, email.message_from_string 傳進去的文字如果不加decode,會傳錯誤訊息出來。
1 | email.message_from_string(response_part[1].decode()) |
發布文章到wordpress 參考網址: http://python-wordpress-xmlrpc.readthedocs.org/en/latest/index.html
class postToWP:
def post(title,content,tag):
client = Client('http://blog url//xmlrpc.php', 'username', 'password')
post = WordPressPost()
post.title = title
post.content = content
post.terms_names = {
'post_tag': [tag], # 標籤(Tag)
'category': [tag], # 分類(Categories)
}
post.post_status = 'publish' # 如果沒有這一個,就會是草稿狀態
post.id = client.call(NewPost(post))
[ASP.NET MVC] Play with Grunt (typescript ...)
#Grunt Need: Node.js installed
Install Steps
- Installing the CLI run command
1 | npm install -g grunt-cli |
- edit package.json and Gruntfile.js
1 | { |
run npm install in command
1 | module.exports = function (grunt) { |
run grunt in command
這樣子 grunt 就會監控 在 app 資料夾下的 ts 檔案異動,並同時做 complie 的動作,如果有錯誤,會產生 complie error 的訊息。
[ASP.NET MVC] ADD TYPESCRIPT Complier
In projectname.csproj 新增
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
在重新載入專案
[AngularJS] Validation
#Form Validation with angularJs Basic: in .js $scope.form = {} $scope.form.$valid ==> 判斷form(name=「form」)內的物件是否有驗證有錯誤的物件存在
用法: formName.inputFieldName.property
Unmodified form A boolean property that tells us if the user has modified the form. This is true if the user hasn’t touched the form, and false if they have:
1 | formName.inputFieldName.$pristine; |
Modified form A boolean property if and only if the user has actually modified the form. This is set regardless of validations on the form:
1 | formName.inputFieldName.$dirty |
Valid form A boolean property that tells us that the form is valid or not. If the form is currently valid, then this will be true:
1 | formName.inputFieldName.$valid |
Invalid form A boolean property that tells us that the form is invalid. If the form is currently invalid, then this will be true:
1 | formName.inputFieldName.$invalid |
The last two properties are particularly useful for showing or hiding DOM elements. They are also very useful when setting a class on a particular form.
Errors Another useful property that AngularJS makes available to us is the $error object. This object contains all of the validations on a particular form and if they are valid or invalid. To get access to this property, use the following syntax:
1 | formName.inputfieldName.$error |
###Addtional CSS classes ng-valid Is set if the form is valid. ng-invalid Is set if the form is invalid. ng-pristine Is set if the form is pristine. ng-dirty Is set if the form is dirty.
##Input Validation
1 | <input |
####可驗證項目(內建) requried ng-minlength ng-maxlength
####$error所對應的項目 formName.inputfieldName.$error.requried formName.inputfieldName.$error.minlength formName.inputfieldName.$error.maxlength
[工作筆記]網際網路電子發票開立流程
民國103年1月1日起,網際網路電子發票開始限制發票字軌只能使用丁種字軌,然後又推說如果利用網際網路電子發票開立B2B交易情形,只能接受丁種字軌,這表示,另外一方也必須用網際網路電子發票…看來國稅局在103年度要強推B2B的電子發票了。
不管怎樣,這個也是一個趨勢,雖然現在開立的方法或是平台(還得獎…這好笑了吧, 請個F2E處理一下你的頁面吧。還是說設計者都沒有自己操作過)都還很鳥,如果要利用媒體檔上傳的方式,這個門檻又很高,因為那個該死的規格書又寫的很艱澀。(只是要罵一下)…
帳號申請網址:電子發票整合服務平台
還是稍微整理一下開立流程:
一般開立
- 賣方開立發票
- 買方收到開立通知
- 買方接收開立發票
- 賣方收到接收通知
- 完成開立動作
退回發票
- 賣方開立發票
- 買方收到通知
- 買方退回發票
- 賣方確認發票退回
- 完成動作
作廢發要
- 賣方作廢發票
- 買方收到通知
- 買方確認發票作廢
- 完成動作
B2B交換資料,發票狀態有幾種,其意義為何?
銷項發票狀態 開立 :已新增發票,尚未憑證寄送 已寄送:已憑證寄送,資料傳送中 已讀取:買方已讀取 尚未完成進項發票寄送確認 已確認:買方已完成進項發票寄送確認 進項發票狀態 開立 :賣方已憑證寄送發票,買方尚未讀取 已讀取 :買方已讀取發票,尚未完成進項發票寄送確認 確認寄送中:進項發票寄送確認,資料傳送中 已確認 :買方已完成進項發票寄送確認
買方營業人若無工商憑證是否可接收發票?
請賣方營業人至基本資料/交易對象資料維護建立買方資料並設定交易暗語,買方即可以交易暗語寄送發票。 惟作廢發票及發票退回確認僅能使用憑證接收,不得使用交易暗語接收。
[python] 20131114
Tuples
很像list,但是一旦建立後值就沒有辦法被更改 (ex. list[1]= 『b』 <=會出錯) 用途: 用來儲存一些常用(const)變數
Set
set會將重複得值給排除掉(有distinct的味道) 建立set的方式有set() 或 a= {『something』,『something』} 如果要建立空的set,只能透過set()的方式
1 | >>> a = set('abracadabra') |
#Dictionaries as c# Dictionary<string, string> 操作方式
- 指定: dict[key]= value
- 刪除: del dict[key]
- 列表: list(dict.key())
- 排序: sorted(dict.key())
建立的方式
1 | >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)]) |
##looping
1 | >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'} |
#More on Conditions 比較的方法:
- in, not in
- is, is not
- and, or : 當遇到第一個成立條件時,就跳出了
比較可以連續串接: eg: a<b==c tests whether a is thess then b and moreover b equals c
比較的順序: 左到右