今天有同事要離職了,離開前做了一份心得+交接報告
裡面有提了一個大點,是目前團隊急需要改進的
在未來的開發模式中,我是希望漸漸導入這些工具或概念
時代在走,雖然跟不上潮流,但這些工具都是經過驗證的
對於系統的開發、維護上,一定會有實質上的幫助
版本控制使用版本控至的優點,可以在部屬新版本的程式時
若發生錯誤,可以馬上回復上一個版本
另外也可以避免多個人同時改到同一支程式
可以做Conflict的Merge處理
版本控制目前常用的有git和svn
git是分散式,每個本機都會建置Repository
沒有網路還是可以commit,查看歷史紀錄
svn是集中式的,全部都必須倚賴server
如果server壞掉,就不能在commit程式
不過svn的權限控制比較完整
目前企業界比較多人使用
svn server建置參考
RESTful API
開發時使用RESTful的寫法,有助於維護
透過看HTTP Method大概可以知道用途
(GET、POST、PUT、PATCH、DELETE)
另外寫 API 方便,寫測試方便,產生文件方便
Code Review
優點是可以分散維護風險,讓其他人能接手
另外透過Code Review的方式,也能讓團隊討論制定標準
一起互相檢視彼此的程式碼,給出最低 Code Review 通過標準
自動化測試
當新版本程式上版時,若有自動化測試
可以免除改A壞B的問題,可以做基本過濾
撰寫自動化測試需要額外的時間(可能跟開發相當)
但自動化可以重複利用,可以減少重複測試時間
技術文件
有技術文件的優點可以讓未涉足該領域的開發人員
透過技術文件的範例解說,能快速上手
也能熟悉專案使用技術,資訊技術透明化
而不是自己花時間摸索嘗試錯誤中走出路來
2019年10月17日 星期四
2019年5月21日 星期二
[SQL Server] SQL Update with row_number()
在SQL Server裡想要更新某個欄位,根據另外一個欄位排序
可以參考以下的方法
Ref: https://codeday.me/bug/20180808/213927.html
可以參考以下的方法
UPDATE UpdateTarget
SET seq = rownum
FROM (
SELECT seq, row_number () OVER (ORDER BY seq) rownum
FROM Table
WHERE no = @no
) UpdateTarget
Ref: https://codeday.me/bug/20180808/213927.html
2019年5月7日 星期二
[CSS] diplay:none 和 visibility:hidden的差異
最近在頁面加入權限控管時
要把div隱藏起來,並在同樣位置
發現display:none和visibility:hidden的差別
使用display:none會整個div不見,位置前移
使用visibility:hidden會dive隱藏,保留原始位置
如果用過vue.js的話,概念會類似
display:none / block => v-if
visibility:hidden / visible => v-show
參考範例
範例
要把div隱藏起來,並在同樣位置
發現display:none和visibility:hidden的差別
使用display:none會整個div不見,位置前移
使用visibility:hidden會dive隱藏,保留原始位置
如果用過vue.js的話,概念會類似
display:none / block => v-if
visibility:hidden / visible => v-show
參考範例
範例
2019年3月13日 星期三
[Javascript] form to json string
在開發前端時,有時需要把畫面的輸入欄位匯成JSON傳送
若要自行處理,需要每一個輸入元件逐一取出
導致程式過於冗長,重複取值的寫法遍滿各區塊
另外,如果環境沒有jquery,變成要原生javascript處理
後來查找,稍微改成下方的function
傳入callName,可以將class內的元件轉成json string
Ref: https://codepen.io/gabrieleromanato/pen/LpLVeQ
https://www.lvh.io/posts/queryselectorall-from-an-element-probably-doesnt-do-what-you-think-it-does.html
若要自行處理,需要每一個輸入元件逐一取出
導致程式過於冗長,重複取值的寫法遍滿各區塊
另外,如果環境沒有jquery,變成要原生javascript處理
後來查找,稍微改成下方的function
傳入callName,可以將class內的元件轉成json string
function toJSONString(className) {
let obj = {};
let elements = document.querySelector("." + className).querySelectorAll("input, select, textarea");
for (let i = 0; i < elements.length; ++i) {
let element = elements[i];
let key = !element.id ? element.name : element.id; // 取得id或是name
let value = element.value;
if (key) {
obj[key] = value;
}
}
return JSON.stringify(obj);
}
Ref: https://codepen.io/gabrieleromanato/pen/LpLVeQ
https://www.lvh.io/posts/queryselectorall-from-an-element-probably-doesnt-do-what-you-think-it-does.html
2019年3月12日 星期二
[JavaScript] Hide Url Parameter
最近遇到一個需求,需要將網址的參數拿掉
找了一些作法,可能要把參數放在cookie, session
或是塞DB,再從DB取資料出來,這都還要加工處理
後來查到github上面有人分享,更改history的狀態就可以
只要在一開始呼叫這個function,便可以參數隱藏了
Ref: https://gist.github.com/ScottKaye/5158488#file-hide-url-parameters-js
找了一些作法,可能要把參數放在cookie, session
或是塞DB,再從DB取資料出來,這都還要加工處理
後來查到github上面有人分享,更改history的狀態就可以
只要在一開始呼叫這個function,便可以參數隱藏了
function getURLParameter(name) {
return decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]);
}
function hideURLParams() {
//Parameters to hide (ie ?success=value, ?error=value, etc)
var hide = ['success','error'];
for(var h in hide) {
if(getURLParameter(h)) {
history.replaceState(null, document.getElementsByTagName("title")[0].innerHTML, window.location.pathname);
}
}
}
Ref: https://gist.github.com/ScottKaye/5158488#file-hide-url-parameters-js
2019年3月6日 星期三
[SQL Server]import large sql file
在執行少量的sql寫入時,可以直接貼到Microsoft SQL Server Management Studio執行
但若是檔案太大時,可以使用sqlcmd的方式來執行
指令如下:
sqlcmd -S 資料庫IP -U 使用者名稱 -P 使用者密碼 -d 資料庫名稱 -i .sql檔案路徑
執行時會跳出錯誤,需開啟QUOTED_IDENTIFIER:
訊息 1934, 層級 16, 狀態 1, 伺服器 User, 行 4
INSERT 失敗,因為下列 SET 選項的設定錯誤: 'QUOTED_IDENTIFIER'。請確認與 索引檢視表及/或計算資料行上的索引及/或篩選的索引及/或查詢通知及/或 XML 資料類型方法及/或空間索引作業 一起使用的 SET 選項是否正確。
example:
C:\>sqlcmd -I -S localhost -U test -P test123 -d dbo -i C:\sql.sql
另外,若資料當中有中文,sqlcmd會直接結束
sqlcmd執行必須加入 -f 65001 代表對應中文編碼
SQL當中的中文欄位前方也要加 N
最後sqlcmd執行的參數會變成這樣子
若要將執行的結果匯出成txt檔,可以加上-o C:\sql.log example:
C:\>sqlcmd -I -S localhost -U test -P test123 -d dbo -f 65001 -i C:\sql.sql -o C:\sql.log
Ref:
http://blog.aihuadesign.com/2014/01/15/solve-sql-file-too-large-to-import-to-sql-server/
https://docs.microsoft.com/zh-tw/sql/tools/sqlcmd-utility?view=sql-server-2017
http://www.anujchaudhary.com/2011/10/sqlcmd-quotedidentifier-is-off.html
https://blog.csdn.net/roy_88/article/details/52595854
sqlcmd
-a packet_size
-A (dedicated administrator connection)
-b (terminate batch job if there is an error)
-c batch_terminator
-C (trust the server certificate)
-d db_name
-e (echo input)
-E (use trusted connection)
-f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage]
-g (enable column encryption)
-G (use Azure Active Directory for authentication)
-h rows_per_header
-H workstation_name
-i input_file
-I (enable quoted identifiers)
-j (Print raw error messages)
-k[1 | 2] (remove or replace control characters)
-K application_intent
-l login_timeout
-L[c] (list servers, optional clean output)
-m error_level
-M multisubnet_failover
-N (encrypt connection)
-o output_file
-p[1] (print statistics, optional colon format)
-P password
-q "cmdline query"
-Q "cmdline query" (and exit)
-r[0 | 1] (msgs to stderr)
-R (use client regional settings)
-s col_separator
-S [protocol:]server[instance_name][,port]
-t query_timeout
-u (unicode output file)
-U login_id
-v var = "value"
-V error_severity_level
-w column_width
-W (remove trailing spaces)
-x (disable variable substitution)
-X[1] (disable commands, startup script, environment variables, optional exit)
-y variable_length_type_display_width
-Y fixed_length_type_display_width
-z new_password
-Z new_password (and exit)
-? (usage)
sqlcmd [-U 登入識別碼] [-P 密碼]
[-S 伺服器] [-H 主機名稱] [-E 信任連線]
[-N 加密連線][-C 信任伺服器憑證]
[-d 使用資料庫名稱] [-l 登入逾時] [-t 查詢逾時]
[-h 標頭] [-s 資料行分隔符號] [-w 螢幕寬度]
[-a 封包大小] [-e 回應輸入] [-I 啟用引號識別項]
[-c cmdend] [-L[c] 伺服器清單[清除輸出]]
[-q "命令行查詢"] [-Q "命令行查詢" 並結束]
[-m 錯誤等級] [-V 嚴重性等級] [-W 移除句尾空格]
[-u unicode 輸出] [-r[0|1] 訊息傳至 stderr]
[-i 輸入檔] [-o 輸出檔] [-z 新密碼]
[-f <字碼頁> | i:<字碼頁>[,o:<字碼頁>]] [-Z 新密碼並結束]
[-k[1|2]移除 [replace] 控制項字元]
[-y 可變長度類型顯示寬度]
[-Y 固定長度類型顯示寬度]
[-p[1] 列印統計資料[冒號格式]]
[-R 使用用戶端地區設定]
[-K 應用程式意圖]
[-M 多重子網路容錯移轉]
[-b 批次中止錯誤時發生]
[-v var = "值"...] [-A 專屬的管理連線]
[-X[1] 停用命令、啟動指令碼、環境變數 [並結束]]
[-x 停用變數替代]
[-j 列印原始錯誤訊息]
[-g 啟用資料行加密]
[-G 為驗證使用 Azure Active Directory]
[-? 顯示語法摘要]
但若是檔案太大時,可以使用sqlcmd的方式來執行
指令如下:
sqlcmd -S 資料庫IP -U 使用者名稱 -P 使用者密碼 -d 資料庫名稱 -i .sql檔案路徑
執行時會跳出錯誤,需開啟QUOTED_IDENTIFIER:
訊息 1934, 層級 16, 狀態 1, 伺服器 User, 行 4
INSERT 失敗,因為下列 SET 選項的設定錯誤: 'QUOTED_IDENTIFIER'。請確認與 索引檢視表及/或計算資料行上的索引及/或篩選的索引及/或查詢通知及/或 XML 資料類型方法及/或空間索引作業 一起使用的 SET 選項是否正確。
example:
C:\>sqlcmd -I -S localhost -U test -P test123 -d dbo -i C:\sql.sql
另外,若資料當中有中文,sqlcmd會直接結束
sqlcmd執行必須加入 -f 65001 代表對應中文編碼
SQL當中的中文欄位前方也要加 N
最後sqlcmd執行的參數會變成這樣子
若要將執行的結果匯出成txt檔,可以加上-o C:\sql.log example:
C:\>sqlcmd -I -S localhost -U test -P test123 -d dbo -f 65001 -i C:\sql.sql -o C:\sql.log
Ref:
http://blog.aihuadesign.com/2014/01/15/solve-sql-file-too-large-to-import-to-sql-server/
https://docs.microsoft.com/zh-tw/sql/tools/sqlcmd-utility?view=sql-server-2017
http://www.anujchaudhary.com/2011/10/sqlcmd-quotedidentifier-is-off.html
https://blog.csdn.net/roy_88/article/details/52595854
sqlcmd
-a packet_size
-A (dedicated administrator connection)
-b (terminate batch job if there is an error)
-c batch_terminator
-C (trust the server certificate)
-d db_name
-e (echo input)
-E (use trusted connection)
-f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage]
-g (enable column encryption)
-G (use Azure Active Directory for authentication)
-h rows_per_header
-H workstation_name
-i input_file
-I (enable quoted identifiers)
-j (Print raw error messages)
-k[1 | 2] (remove or replace control characters)
-K application_intent
-l login_timeout
-L[c] (list servers, optional clean output)
-m error_level
-M multisubnet_failover
-N (encrypt connection)
-o output_file
-p[1] (print statistics, optional colon format)
-P password
-q "cmdline query"
-Q "cmdline query" (and exit)
-r[0 | 1] (msgs to stderr)
-R (use client regional settings)
-s col_separator
-S [protocol:]server[instance_name][,port]
-t query_timeout
-u (unicode output file)
-U login_id
-v var = "value"
-V error_severity_level
-w column_width
-W (remove trailing spaces)
-x (disable variable substitution)
-X[1] (disable commands, startup script, environment variables, optional exit)
-y variable_length_type_display_width
-Y fixed_length_type_display_width
-z new_password
-Z new_password (and exit)
-? (usage)
sqlcmd [-U 登入識別碼] [-P 密碼]
[-S 伺服器] [-H 主機名稱] [-E 信任連線]
[-N 加密連線][-C 信任伺服器憑證]
[-d 使用資料庫名稱] [-l 登入逾時] [-t 查詢逾時]
[-h 標頭] [-s 資料行分隔符號] [-w 螢幕寬度]
[-a 封包大小] [-e 回應輸入] [-I 啟用引號識別項]
[-c cmdend] [-L[c] 伺服器清單[清除輸出]]
[-q "命令行查詢"] [-Q "命令行查詢" 並結束]
[-m 錯誤等級] [-V 嚴重性等級] [-W 移除句尾空格]
[-u unicode 輸出] [-r[0|1] 訊息傳至 stderr]
[-i 輸入檔] [-o 輸出檔] [-z 新密碼]
[-f <字碼頁> | i:<字碼頁>[,o:<字碼頁>]] [-Z 新密碼並結束]
[-k[1|2]移除 [replace] 控制項字元]
[-y 可變長度類型顯示寬度]
[-Y 固定長度類型顯示寬度]
[-p[1] 列印統計資料[冒號格式]]
[-R 使用用戶端地區設定]
[-K 應用程式意圖]
[-M 多重子網路容錯移轉]
[-b 批次中止錯誤時發生]
[-v var = "值"...] [-A 專屬的管理連線]
[-X[1] 停用命令、啟動指令碼、環境變數 [並結束]]
[-x 停用變數替代]
[-j 列印原始錯誤訊息]
[-g 啟用資料行加密]
[-G 為驗證使用 Azure Active Directory]
[-? 顯示語法摘要]
2019年3月5日 星期二
[SQL Server]帳號登入錯誤
是因為少設定SQL Server和Windows混和驗證
先以Windows方式登入後,點databse右鍵 -> 屬性
伺服器驗證選擇 "SQL Server和Windows混和驗證"
在重啟SQL Server,就可以使用帳號密碼登入
2019年3月4日 星期一
[SQL SERVER] 使用mdf檔還原
手上拿到mdf檔要還原時,要使用附加的方式
1.將mdf檔複製到SQL Server資料庫存放路徑底下
資料庫檔案都是放在 C:\Program Files\Microsoft SQL Server\{version}\MSSQL\Data 目錄
{version}要看目前您使用資料庫的版本
2.使用附加的方式,加入複製的檔案
Ref: https://ithelp.ithome.com.tw/questions/10046158
1.將mdf檔複製到SQL Server資料庫存放路徑底下
資料庫檔案都是放在 C:\Program Files\Microsoft SQL Server\{version}\MSSQL\Data 目錄
{version}要看目前您使用資料庫的版本
2.使用附加的方式,加入複製的檔案
Ref: https://ithelp.ithome.com.tw/questions/10046158
2019年1月9日 星期三
Build Classic Asp Environment in Winsdows10
因為專案有些是舊的asp程式
找了一些資料怎麼建置asp的環境
後來照這篇試出來可以跑,參考
---------------------------------------------------------------------
過了三個月後再回來看這篇,一開始設不成功
後來照著Ref的連結去設定,不確定是不是最後這步
設定完成後,應該classic asp程式就可以開啟
1.IIS -> ASP

2.將這兩個選項設為True
啟用上層路徑 -> True
將錯誤傳送到瀏覽器 -> True

Ref:
https://www.codeproject.com/Articles/43132/How-to-Setup-IIS-on-Windows-to-Allow-Classic
找了一些資料怎麼建置asp的環境
後來照這篇試出來可以跑,參考
---------------------------------------------------------------------
過了三個月後再回來看這篇,一開始設不成功
後來照著Ref的連結去設定,不確定是不是最後這步
設定完成後,應該classic asp程式就可以開啟
1.IIS -> ASP
2.將這兩個選項設為True
啟用上層路徑 -> True
將錯誤傳送到瀏覽器 -> True
Ref:
https://www.codeproject.com/Articles/43132/How-to-Setup-IIS-on-Windows-to-Allow-Classic
2019年1月2日 星期三
無腦Hard Code程式
訂閱:
文章 (Atom)