2016年4月17日 星期日

VARRAY Example 01


/*
  Demo the varray.
  
*/

-- create a varray with the maximum size 6.
create or replace type options_type as varray(6) of varchar2(30);
/

-- create a table with varray
-- You don't have to create another table to store the varray. 
create table questions(q_id number, options options_type);

-- insert values
insert into questions values(1, options_type('Option A', 'Option B', 'Option C',
'Option D'));
commit;

select * from questions;

-- Use PL/SQL codes to insert values to questions table.
set serveroutput on
declare
 options questions.options%type;
begin
  options := options_type('A', 'B', 'C', 'D', 'E', 'F');
  -- Insert a new question.
  insert into questions values (2, options);
  
  -- Print out the rows in the Question table
  for question in (select * from questions) loop
    dbms_output.put(question.q_id || ' ');
 -- Print out the options in a question.
    for i in 1..question.options.count loop
        dbms_output.put(question.options(i) || ' ');
    end loop;
    dbms_output.put_line(' ');
  end loop;
end;
/
rollback;

2016年4月16日 星期六

PL/SQL Reference

Handling Exceptions

Oracle 11g Database error messages
ORA-00984 : 若在 SQL Statement 中使用了 SQLCODE 及 SQLERRM 這兩個 functions, 會產生編譯錯誤,之後再產生 OAR-00984 例外。

Handling PL/SQL Errors from Oracle PL/SQL Language Reference


Date functions
Trunc(Date): 對日期的不同單位, 如年、月、日, 進行捨去與進位. 預設為捨入到最近的一天。

2016年3月26日 星期六

JSF References

JavaServer Faces References


General



Converters and Validators

About Standard JSF Converters (Oracle.com): Provide the various converter and their full class name.

DateTime Converter

Date Format Pattern Syntax
Time Zone and Locale List

Validators

另一個方法, 只需使用  
ResourceBundle bundle = ResourceBundle.getBundle("resources.msgs"); 
即可。

Immediate attribute for UICommand and UIInput components

Tips

Reset the form

How do I reset input fields after a validation failure? by John Yeary
介紹 f:ajax 中的 resetValues 屬性及 f:resetValues 標籤的使用。

在JSF 2.2 後, 提供了 f:resetValues 標籤,放在 h:command 元件中。Example:


HTML5 and JSF

Others

Useful posters of the GoF patterns

2016年3月2日 星期三

data.frame 中的 row 及 column 操作, 使用 dplyr 套件


Row Operations

Filtering and slicing rows

slice()
filter()

Sorting rows

arrange()

Select distinct rows

distinct()

Column Operations

Column Selecting and rename

select()

Add new column

mutate()

Column-wise descriptive statistics

summarise()
注意 column name 的英文大小寫有別

 #對 iris 中的萼片長度計算平均值及變異數  
 data("iris")  
 summarise(iris, mean.SL=mean(Sepal.Length), sd.SL = sd(Sepal.Length))  

結果:


Group-wise + Column-wise descriptive statistics

group_by() + summarise()
使用 group_by() 會產生另外一個 data.frame, 其中會包含 grouping 的資訊. 
這個分群後的 data.frame 進到 summarise() 函數時, summarise()會看到 data.frame 中的分群資訊, 自動會去計算分群後 各 column 的統計量. 使用 str() 可以看到 data.frame 中的分群資訊。

範例:
 # 對 iris 以 species 欄位進行分群, 再計算每群的萼片長度計算平均值及變異數  
 iris.grouped <- group_by(iris, Species)  
 summarise(iris.grouped, count=n(), mean.SL=mean(Sepal.Length), sd.SL=sd(Sepal.Length))  

結果:

參考資料:

Jaynal Abedin and Kishor Kumar Das, Data Manipulation with R, 2nd, Packt Publising, 2015

2016年2月25日 星期四

Wordpress 參考資料

架站-新手

  1. Alannah Moore 著、Muki Wu 譯, WordPress 七天速成班-打造吸睛的風格化網站與部落格 (Create Your Own Website Using WordPress in a Weekend)
  2. Pseric, WordPress Plugins 百大外掛精選, 博碩, 2014
  3. 直接使用 wordpress 架站 https://zh-tw.wordpress.com/
  4. Wordpress 新手  (codex.wordpress.org)

網站維護


  1. 安裝 plugin 時不使用  FTP  (http://stackoverflow.com/questions/640409/can-i-install-update-wordpress-plugins-without-providing-ftp-access)



WP 網站功能擴充

頁面編輯 Live Composer Page Builder plug-in 
  1. 一般介紹
  2. Live Composer: How to add blog posts carousel (Youtube)
  3. Live Composer: Post Template (livecomposerplugin.com)
  4. Live Composer 試玩區
  5. 說明文件
  6. Image 元素的 Lightbox 功能,讓你點選圖片後,以 Overlay 的方式顯示圖片。(https://livecomposer.help/article/204-how-to-open-an-image-in-a-lightbox)
電子商務 WooCommerce
社群分享 Super Socializer 
流量追蹤碼埋設 Tracking Code Manager by IntellyWP
圖片尺寸最佳化 EWWW Image Optimizer

網站設計&規劃

一般規劃

  1. Ethan Watrall , Jeff Siarto 著、莊惠淳 譯, 深入淺出網站設計 (Head First Web Design)

HTML/CSS/JavaScript

  1. Elisabeth Robson, Eric Freeman 著、莊惠淳 譯, 深入淺出 HTML and CSS(第二版) (Head First HTML and CSS, 2/e). [書籍介紹]
  2. Eric T. Freeman, Elisabeth Robson 著、蔣大偉 譯, 深入淺出 JavaScript 程式設計 (Head First JavaScript Programming) [書籍介紹]

Mockups

  1. 9 Excellent Tools for Design Mockups
  2. Balsamiq Mockups: Desktop and online mock-up.
  3. Moqups.com : Online mock-up.
  4. Responsive Design with Mockups (balsamiq.com)

Style Guide

  1. Web Style Guide from Western University (pdf) 
  2. Page Structure and Site Design  (Excerpted from Web Style Guide)

網站易用性設計

  1. Janice (Ginny) Redish, Letting Go of the Words, Second Edition: Writing Web Content that Works (Interactive Technologies) 
  2. Steve Krug 著、胡為君 譯, 如何設計好網站 (Don't Make Me Think: A Common Sense Approach to Web Usability, 2/e)
  3. Steve Krug 著、陳亦苓 譯,深度測試-提高網站效益 (ROCKET SURGERY MADE EASY: The Do-It-Yourself Guide to Finding and Fixing Usability Problems) (DIY 一次搞定網站易用性問題), 上奇資訊
  4. UX Design: An Introduction with Scout Stevenson (youtube, 58:06)
  5. Example Usability Test with a Paper Prototype (youtube)
  6. Usability.gov (提倡網站易用性的組織)
  7. Garrett, Jesse James (2010). The Elements of User Experience: User-Centered Design for the Web and Beyond. New Riders Press. ISBN 978-0321683687. 
  8. Jeff Johnson, 2014. Designing with the Mind in Mind: Simple Guide to Understanding User Interface Design Guidelines, 2nd edition, Morgan Kaufmann.

Color Palettes

  1. Color Palettes Color Schemes (www.color-hex.com): 利用 keyword 找到 color palette.
  2. Adobe Color CC
  3. Color Palette FX: 上傳圖片產生圖片的 color palette. 

CSS

Word to html: 想把 Word 的內容變成網頁, 但是直接 copy & paste 又太多的奇怪 html code, 可以試試此網址的方案。轉出文字後,圖片還是要手動貼. 

2016年2月10日 星期三

Nested Blocks in PL/SQL

PL/SQL 中提供 Nested Blocks 的功能, 其目的為:
* Use to handle exception locally (Codes from Tony Andrews):
begin
   for emp_rec in (select * from emp) loop
      begin
         my_proc (emp_rec);
      exception
         when some_exception then
            log_error('Failed to process employee '||emp_rec.empno);
      end;
   end loop;
end;
* Declare local variables that have limited scopes (Codes from Tony Andrews);
declare
    l_var1 integer;
    -- lots of variables
begin
   -- lots of lines of code
   ...
   for emp_rec in (select * from emp) loop
      declare
         l_localvar integer := 0;
      begin
         -- Use l_localvar
         ...
      end
   end loop;

end;

Reference:
When should I nest PL/SQL BEGIN…END blocks? (http://stackoverflow.com/questions/2334659/when-should-i-nest-pl-sql-begin-end-blocks)