Skip to content

Instantly share code, notes, and snippets.

@twlca
twlca / pidCheck.js
Created October 14, 2016 06:15
檢查身分證字號
/* 依據內政部:
1. 身分證編碼原則
2. 外來人口統一證號編碼原則(居留證) https://www.immigration.gov.tw/ct_cert.asp?xItem=1106801&ctNode=32601&mp=1
身分證及居留證通用
第一碼 縣市編碼原則:
A=10 台北市 J=18 新竹縣 S=26 高雄縣
B=11 台中市 K=19 苗栗縣 T=27 屏東縣
C=12 基隆市 L=20 台中縣 U=28 花蓮縣
D=13 台南市 M=21 南投縣 V=29 台東縣
@twlca
twlca / postalCode.json
Created May 31, 2017 07:03
郵遞區號一覽表 (JSON)
{
"台北市":
{
"100": "中正",
"103": "大同",
"104": "中山",
"105": "松山",
"106": "大安",
"108": "萬華",
"110": "信義",
@twlca
twlca / donators_core.js
Last active July 4, 2017 07:31
// 將資料依指定的 property 組成群組
// 要求:
// 1. 列印收據(點陣式)
// 2. 報表依捐款人、捐款金額、手續費、實收金額列印
// 3. 可供期間查詢:包含螢幕查詢及報表
// 4. 以捐款人、捐款日期、捐款種類、捐款管道分類,日期則以倒序法排列(最近的日期在最上方)
// 5. 捐款管道、手續費、捐款種類可以由使用者設定
// 6. 捐款人快速查詢:姓名排列、連絡地址排列(分類)
// 7. 捐款人組織或個人分類
var donators = [
@twlca
twlca / array_snippets.js
Created April 28, 2017 05:14
Patch an array so it can be used as range separator. First we validate the argument is an array then check if each array element is integer. Then we add 0 and infinity to the array.
// patch an array so it add 0 as 1st element and Infinite as last element
function checkArr( arr ) {
try {
Array.isArray( arr );
} catch(e) {
console.log( 'Input arguments is not an array' );
return false;
};
// validate element types
@twlca
twlca / tva_member_data.json
Created February 8, 2017 10:42
會員開放資料
{"id": null,
"organizationName": null,
"orgContactName": null,
"orgAddress": null,
"phone": null,
"fax": null,
"relatedURL": null,
"zip": null,
"orgContactTitle": null,
}
@twlca
twlca / tva_organization.json
Created February 8, 2017 09:54
志工隊運用單位及志工隊資料集架構
{ "organizationName": "",
"zip": "",
"county": "",
"address": "",
"organizationId": "",
"orgContactName": "",
"orgContactPhone": "",
"orgContactMobile": "",
"orgContactEmail": "",
"orgAddress": "",
@twlca
twlca / tva.taitung_metadata.json
Last active February 8, 2017 09:45
臺東縣志願服務協會開放資料-資料集架構
{ "id": "",
"format": "",
"metadata_modified": "",
"title": "",
"type": "",
"display_name": "",
"author": "",
"attirbuteCategory": "",
"baseLaw": "",
"publishCategory": "",
@twlca
twlca / open_data_taipai.json
Last active February 8, 2017 05:18
臺北市政府公開資料格式
{
"編號" : "id",
"計費方式" : "cost",
"資料集描述" : "description",
"資料集語系" : "language",
"資料集所屬管理機關聯絡人電子郵件" : "",
"收錄期間(迄)" : "",
"資料集說明網址" : "",
"資料集所屬管理機關名稱" : "",
"資料集所屬管理機關聯絡人電話" : "",
@twlca
twlca / fill_form_fields_via_array_in_php.php
Created October 21, 2016 14:22
以 PHP 的陣列定義表單輸入項參數,再以迴圈完成每個輸入項名稱加上 $prefix,以保障資料庫安全
<?php
$prefix = 'tdva_';
$application_unit_info = array(
array(
'type' => 'text',
'name' => $prefix . '運用單位'
),
array(
'type' => 'text',
'name' => $prefix . '承辦人'
@twlca
twlca / digit_transfer.js
Created October 15, 2016 04:11
在公文、表單標題等應用場合,有時需要將年、月、日日期註記轉記轉換成中文小寫。由於儲存在資料庫中的日期資料通常是由阿拉伯數字型式儲存(以利計算),所以在此類應用必需轉換。
var digits = '0123456789'; // 阿拉伯數字
var small_chinese_digits = '〇一二三四五六七八九'; // 中文小寫數字
var capital_chinese_digits = '零壹貮參肆伍陸㭍捌玖拾佰仟萬億兆'; // 中文大寫數字,應用侷限在金融,例如支票、匯款單、存款/提款單等
// 由阿拉伯數字轉換成小寫中文數字
var year = '106';
year.split('').map( function( item ) {
return small_chinese_digits.split('')[item];
}).join('');
// 回傳 "一〇五"