CO11N --time ticket
CO15 -- for order
CO14 -- display
This man is too old to remember everything in his brain. Right now, he needs a place to write down what he has studied.
2013年8月29日 星期四
2013年8月21日 星期三
Perl Mail::Sendmail 傳送 utf8字元
http://www.geego.com.tw/technical-discussion-forum/tech-tips-sendmail-sending-utf8-characters-%E5%82%B3%E9%80%81-%E5%AD%97%E5%85%83-%E7%B7%A8%E7%A2%BC
Perl Mail::Sendmail 傳送 utf8字元
作者:Ben哥|發布日期:2012/03/23
當看到錯誤訊息Wide character in subroutine entry at /usr/share/perl5/Mail/Sendmail.pm line 237.
原因可能為使用perl的Mail::Sendmail模組寄送中文時會出現的問題,請使用 use Encode把內容編碼後, 再寄信時把信件表頭中加入 Content-type = ‘text/plain; charset="utf-8″‘ 即可
程式範例:
#!/usr/bin/perl
use Mail::Sendmail;
use utf8;
use Encode;
$email = ‘perl.mail::sendmail@geego.com.tw’;
$course = “test course";
my $message = “這是一封用來測試perl的Mail::Sendmail模組可否成功寄送utf8字元.\n";
$message = encode( “utf8″, $message );
my %mail = ( To => “$email",
From => ‘GeeGo Customer Service<customers@geego.com.tw>’,
‘Content-type’ => ‘text/plain; charset="utf-8″‘,
Subject => “Perl’s Mail::Sendmail sending text body with utf8 encoding",
Message => “$message" );
sendmail(%mail) or die $Mail::Sendmail::error;
當看到錯誤訊息Wide character in subroutine entry at /usr/share/perl5/Mail/Sendmail.pm line 237.
原因可能為使用perl的Mail::Sendmail模組寄送中文時會出現的問題,請使用 use Encode把內容編碼後, 再寄信時把信件表頭中加入 Content-type = ‘text/plain; charset="utf-8″‘ 即可
程式範例:
#!/usr/bin/perl
use Mail::Sendmail;
use utf8;
use Encode;
$email = ‘perl.mail::sendmail@geego.com.tw’;
$course = “test course";
my $message = “這是一封用來測試perl的Mail::Sendmail模組可否成功寄送utf8字元.\n";
$message = encode( “utf8″, $message );
my %mail = ( To => “$email",
From => ‘GeeGo Customer Service<customers@geego.com.tw>’,
‘Content-type’ => ‘text/plain; charset="utf-8″‘,
Subject => “Perl’s Mail::Sendmail sending text body with utf8 encoding",
Message => “$message" );
sendmail(%mail) or die $Mail::Sendmail::error;
2013年8月16日 星期五
Mail::Box
http://search.cpan.org/~markov/Mail-Box/
http://quark.humbug.org.au/publications/perl/perlmailbox.html
Perl provides a number of interfaces to mailbox folders of which Mail::Box is but one. This article will cover the basic use of it and show how to open a mailbox folder, be it a flat file or over POP or IMAP, and how to manipulate the messages inside.
Modules
First you need to import the required modules - in most cases this will be sufficient:use Mail::Box::Manager;
Opening Mailboxes
This section will cover how to open mailboxes of 3 different formats - mbox, POP and IMAP.Mbox Format
To open a mbox folder, simply do the following:my $mailspool = "/var/spool/mail/username"; my $mgr = Mail::Box::Manager->new; my $folder = $mgr->open(folder => $mailspool);
POP3
There are two ways to open a POP folder, as follows:my $url = 'pop3://user:password@pop.example.com' my $pop = Mail::Box::POP3->new($url); my $mgr = Mail::Box::Manager->new; my $pop = $mgr->open(type => 'pop3', username => 'myname', password => 'mypassword', server_name => 'pop.example.com');
IMAP4
IMAP folders are opened similarly to POP, as follows:my $imap = Mail::Box::IMAP4->new(username => 'myname', password => 'mypassword', server_name => 'imap.example.com'); my $url = 'imap4://user:password@imap.example.com'); my $mgr = Mail::Box::Manager->new; my $imap = $mgr->open($url);
Manipulating Folders
To find out the name of the folder you're accessing, simple do the following:$name = $folder->name;To check the number of messages in the folder, just:
my $emails = $folder->messages;To loop over each message simply call the messages subroutine in array context, like so:
foreach $msg ($folder->messages) { # all messages # Do something with $msg }To extract basic information from a message, such as subject, to, from and the body, simply use the following:
my $subject = $msg->subject; my @to = $msg->to; my $from = $msg->sender->address; my $body = $msg->decoded;The array returned from the to subroutine consists of Mail::Address objects. To pull the actual address out of it, something like the similar will do:
foreach $to (@to) { print "to = ".$to->format."\n"; }
Conclusion
As you can see, Mail::Box provides a very simple interface for pulling out basic information from a mailbox. You can do much more than is shown here, for more information see the perldoc for Mail::Box, Mail::Box-Overview and Mail::Box-Cookbook.IMAP command
[dwmgr@misdwp01 ~]$ telnet mail1.xxx 143
Trying xxx.xxx.xxx.xxx...
Connected to mail1.xxx.
Escape character is '^]'.
* OK The Microsoft Exchange IMAP4 service is ready.
Trying xxx.xxx.xxx.xxx...
Connected to xxx.xxx.xxx.xxx.
Escape character is '^]'.
* OK The Microsoft Exchange IMAP4 service is ready.
A login xxx@xxx.xxx xxx
A OK LOGIN completed.
B select INBOX
* 0 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UIDVALIDITY 66390] UIDVALIDITY value
* OK [UIDNEXT 896] The next unique identifier value
B OK [READ-WRITE] SELECT completed.
C logout
* BYE Microsoft Exchange Server 2010 IMAP4 server signing off.
C OK LOGOUT completed.
Connection closed by foreign host.
Trying xxx.xxx.xxx.xxx...
Connected to mail1.xxx.
Escape character is '^]'.
* OK The Microsoft Exchange IMAP4 service is ready.
Trying xxx.xxx.xxx.xxx...
Connected to xxx.xxx.xxx.xxx.
Escape character is '^]'.
* OK The Microsoft Exchange IMAP4 service is ready.
A login xxx@xxx.xxx xxx
A OK LOGIN completed.
B select INBOX
* 0 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UIDVALIDITY 66390] UIDVALIDITY value
* OK [UIDNEXT 896] The next unique identifier value
B OK [READ-WRITE] SELECT completed.
C logout
* BYE Microsoft Exchange Server 2010 IMAP4 server signing off.
C OK LOGOUT completed.
Connection closed by foreign host.
2013年8月14日 星期三
如何利用CSS & JavaScript 做出 tree狀menu and 自動變換圖案而且有層次
ReportCenter.html
有 z-index,而且圖案在最下面,所以menu tree可以不被蓋住
---------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>報表中心</title><link rel="StyleSheet" href="dtree.css" type="text/css" />
<link rel="StyleSheet" href="ReportCenter.css" type="text/css" />
<script type="text/javascript" src="dtree.js"></script>
<script type="text/javascript" src="ReportCenter.js"></script>
</head>
<body onLoad="LoadFunctions()">
<div class="dtree" style = "float: left; width: 15%; height=700; z-index: 2; position: absolute; left:0; top:0 ">
<p><a href="javascript: d.openAll();">全部展開</a> | <a href="javascript: d.closeAll();">close all</a></p>
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'報表中心');
d.add(1,0,'經營管理','');
d.add(2,0,'行政管理','');
d.add(3,1,'1-1 銷售分析管理報表','http://misdb01/ReportServer/Pages/ReportViewer.aspx?%2fasp%2fASP+by+Product&rs:Command=Render');
d.add(4,2,'2-1 刷卡紀錄明細表','http://misdb01/ReportServer/Pages/ReportViewer.aspx?%2f%E5%88%B7%E5%8D%A1%E7%B4%80%E9%8C%84%2f%E5%88%B7%E5%8D%A1%E7%B4%80%E9%8C%84%E6%98%8E%E7%B4%B0%E8%A1%A8&rs:Command=Render');
d.add(5,2,'2-2 查號台','http://misdb01/ReportServer/Pages/ReportViewer.aspx?%2f%E6%9F%A5%E8%99%9F%E5%8F%B0%2f%E6%9F%A5%E8%99%9F%E5%8F%B0%E6%98%8E%E7%B4%B0%E8%B3%87%E6%96%99&rs:Command=Render');
/*
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
*/
document.write(d);
//-->
</script>
</div>
<div style="float: right; width:85% height=700; z-index: 1; position: absolute; left:100px; top:50px">
<img name=as width=100% height=700 src="index_photos_01.jpg" />
</div>
<!--
<p><a href="mailto:ty.ruan@bigsun-energy.com">©2002-2003 xx光電</a></p>
-->
</body></html>
#########################################################################
ReportCenter.css (其實這個用不到)
---------------------------------------------------------------------------------------------------------------------------------
.container {
overflow: hidden;
}
.right {
float: right;
width: 100px;
}
.left {
float: left;
width: 100px;
}
.middle {
margin: 0 100px;
}
#########################################################################
dtree.js
--------------------------------------------------------------------------------------------------------------------------------- /*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr? |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/
// Node object
function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : 'img/base.gif',
folder : 'img/folder.gif',
folderOpen : 'img/folderopen.gif',
node : 'img/page.gif',
empty : 'img/empty.gif',
line : 'img/line.gif',
join : 'img/join.gif',
joinBottom : 'img/joinbottom.gif',
plus : 'img/plus.gif',
plusBottom : 'img/plusbottom.gif',
minus : 'img/minus.gif',
minusBottom : 'img/minusbottom.gif',
nlPlus : 'img/nolines_plus.gif',
nlMinus : 'img/nolines_minus.gif'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};
// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};
// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};
// Highlights the selected node
dTree.prototype.s = function(id) {
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
};
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};
// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};
// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Closes all children of a node
dTree.prototype.closeAllChildren = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom) {
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
};
// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};
// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};
// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
};
// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id) {
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
};
// If Push and pop is not implemented by the browser
if (!Array.prototype.push) {
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
};
if (!Array.prototype.pop) {
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
};
#########################################################################
ReportCenter.js
--------------------------------------------------------------------------------------------------------------------------------- var b_delay = 3000;
var bannerID; var b = 0;
var b_links = new Array();
var b_imgs = new Array();
function LoadB_Imgs(b,img_file){
b_image = new Image();
b_image.src = img_file;
b_imgs[b] = b_image.src;
}
LoadB_Imgs(0,"index_photos_01.jpg");
LoadB_Imgs(1,"index_photos_02.jpg");
LoadB_Imgs(2,"index_photos_03.jpg");
function RotateBanner() {
document.as.src = b_imgs[b];
if (b >= 2) {
b = 0;
}
else {
b++;
}
bannerID=setTimeout("RotateBanner()",b_delay);
}
function LoadFunctions() {
RotateBanner();
}
CSS : background 用法
<body style="
background-image: url(index_photos_01.jpg);
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% 50%;
">
background-image: url(index_photos_01.jpg); 指定圖片路徑
background-repeat: no-repeat; 不要重複圖片
background-attachment:fixed; 和下面background-position搭配決定位置
background-position:50% 50%; 50 50 代表中間
background-image: url(index_photos_01.jpg);
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% 50%;
">
background-image: url(index_photos_01.jpg); 指定圖片路徑
background-repeat: no-repeat; 不要重複圖片
background-attachment:fixed; 和下面background-position搭配決定位置
background-position:50% 50%; 50 50 代表中間
-moz-background-size:auto; /*for Firefox*/
-webkit-background-size:auto; /*for Google Chrome、Safari*/
-o-background-size:auto; /*for Opera*/
background-size:auto; /*for IE*/
- 預設值為auto,即背景圖片原始長寬。
- length指定圖片具體大小的數值,不允許負值。
- percentage以背景圖所在元素的百分比指定背景圖大小,不允許負值。
- length與percentage可設定2數值,也可只設定1個數值,當只設定一個數值,另一個數值(高)預設值為auto,此時高度以背景圖原始寬高比例,自動縮放。
- cover主要用於背景圖小於所在的內容,而背景圖又不適合使用repeat,此時就可以採用cover的方式,使背景圖放大至內容的大小,但此方法容易使背景圖因放大而失真。
- contain與cover正好相反,主要用於背景圖大於所在內容,但卻需要將背景圖完整呈現,此時就可採用contain的方式,使背景圖縮小至內容的大小。
2013年8月12日 星期一
類似 connect by + dual,得到許多日期的方法
Declare @start int, @end int
Select @start=1, @end=1000;
With cte( Number ) as
(
Select @start as Number
union all
Select Number + 1
from cte
where Number < @end
)
Select getdate()+number*-1,
datename(weekday,getdate()+number*-1),
datepart(weekday,getdate()+number*-1)
From cte Option (MaxRecursion 1000)
Declare @start datetime, @end datetime
Select @start='2013-08-01', @end='2013-08-13';
With cte( dt ) as
(
Select @start as dt
union all
Select dt+1
from cte
where dt+1 < @end
)
Select dt,datename(weekday,dt),datepart(weekday,dt)
From cte
hinet的帳號用FET3.5G無綫網卡 設定
請按下列設定:
pop3:msa.hinet.net (按自己hinet pop3設定)
smtp:smtp.fetnet.net
使用者名稱和密碼,輸入hinet的資料。
接下來要進入"其他設定"的外寄伺服器,勾選"smtp需要驗證",
輸入fetnet的使用者名稱和密碼, 這樣就搞定了。
帳號是遠傳手機門號
密碼需要到遠傳網站 加入會員,用會員那組密碼才能寄出去
2013年8月7日 星期三
將 excel 文件傳輸至 server 端,再 poi 解析導入 table 中
http://forum.flowring.com/post/view?bid=34&id=12246&sty=3&age=0&tpg=1&ppg=1#12246
//上傳按鈕觸發事件 Form.openUploadFileWin("D:\\AgentflowShare\\", "strExcelName"); //導入按鈕觸發事件 //採用 POI? 取 Excel 工作薄 var workbook = new Packages.org.apache.poi.hssf.usermodel.HSSFWorkbook(new Packages.java.io.FileInputStream("D:\\AgentflowShare\\" + strFileName)); var sheet = workbook.getSheet(workbook.getSheetName(0));//獲取 EXCEL 工作薄 var rows = sheet.getPhysicalNumberOfRows();//獲取行數 if (rows > 0) { sheet.getMargin(sheet.TopMargin); for (var r = 1; r < rows; r++) { //首行取出標題欄 var row = sheet.getRow(r); //獲得單行 if (row != null) { var cells = row.getLastCellNum();//?得列? for (var c = 0; c < cells; c++) { row.getCell(c); var cell = row.getCell(c);//獲得單列 cmpExcelTable.setValueAt(cell, r - 1, c);//插入數據 } } } }
agentflow 應用程式中上載下載檔案 example
http://forum.flowring.com/post/view?bid=33&id=1135&sty=3&keywords=%E6%AA%94%E6%A1%88
/*********************************************************/
// 範例:應用程式中上載下載檔案。
// 說明:在應用程式中,使用API來執行上載和下載檔案功能。
// 設定:使用Form.openUploadFileWin()和Form.downloadFileCustom()。
// 適用版本:(只適用於JSP表單) Agentflow V2.0或以上版本
/*********************************************************/
在表單的openFormAction中加入以下code:
在[上載檔案]按鈕的actionPerformed中加入以下code:
在[下載檔案]按鈕的actionPerformed中加入以下code:
/*********************************************************/
// 範例:應用程式中上載下載檔案。
// 說明:在應用程式中,使用API來執行上載和下載檔案功能。
// 設定:使用Form.openUploadFileWin()和Form.downloadFileCustom()。
// 適用版本:(只適用於JSP表單) Agentflow V2.0或以上版本
/*********************************************************/
在表單的openFormAction中加入以下code:
{ALL: var file = new Packages.java.io.File("C:/formFile").listFiles(); //抓取特定目錄下所有檔案名稱 var table = Form.getComponent("tspFile"); for(var r = 0; r < Packages.java.lang.reflect.Array.getLength(file); r++){ var fileName = new Packages.java.lang.String(file[r]); table.setValueAt(fileName.substring(12), r, 0); //把檔案名稱加入表格中 } }
在[上載檔案]按鈕的actionPerformed中加入以下code:
var fileTable = Form.getComponent("tspFile"); var row = fileTable.getRowCount(); Form.openUploadFileWin("C:\\formFile\\", "tspFile", row, 0); //上載指定檔案並把檔案名稱加入表格中
在[下載檔案]按鈕的actionPerformed中加入以下code:
var row = Form.getComponent("tspFile").getSelectedRow();
Form.downloadFileCustom("C:\\formFile\\", "tspFile", row, 0); //下載表格中選取的檔案到指定位置

2013年8月6日 星期二
T-SQL : 將換行符號置換
select crt_date,cus_num,ctt_date,ctt_type,ctt_aact,ctt_invr,
cus_will,
replace(replace(ctt_cont,char(10),' '),char(13),' ') ctt_cont
from contact_record
簡論毛利率
http://www.wretch.cc/blog/nemochan/67577
Philip A. Fisher在其價值投資的經典著作"非常潛力股"(Common Stock & Uncommon Profit)中提及產品、研發以及銷售能力是衡量一家公司是否具有投資價值的三大指標(當然還有其他指標如管理階層的誠信和能力等等)。惟該如何判定公司的產品在市場上是否有競爭力,個人認為毛利率是很有代表性的參考指標...
結論:
1. 毛利率15%以及40%是公司賺哪種錢(管理財、技術財、創新財)的參考指標
2. 毛利率高低無絕對好壞,需視其趨勢變動以及總銷貨毛利增減來決定
3. 完整的毛利率分析需同時考量銷貨收入以及銷貨成本的變動
4. 財報上的數字僅為參考指標,要知道公司產品有無競爭力最簡單的方法是去問該行業的人
以下分段討論
1. 毛利率15%以及40%是公司賺哪種錢(管理財、技術財、創新財)的參考指標
經過大學時代修財報分析的磨鍊、事務所階段查帳時對上市櫃公司帳務的了解、 投信階段每天聽基金經理人和研究員報告市場和產業,以及企金一年多實際走訪許多企業主和財務長的訪談,在去年(2006)時對突然有所領悟,只要是"製造 業"(服務業或加工業不論),不管是哪種產業,都可以用簡單的15%和40%的分水嶺來判斷其產品競爭力以及營運模式。
毛利率在15%以內的公司,可以簡單歸類為賺取管理財。這種類型公司因產品的差異化不大,技術層次和進入門檻不高,故毛利相對偏低,要賺錢就是靠管理能力和經濟規模。最好的例子就是台灣的PC或是面板零組件業,其毛利大多僅約10%,甚至NB產業只有5%的水準。
這種產業因其附加價值為組裝的技術,零件成本佔總銷貨成本高達八九成,故營收很容易就有數十億甚至百億的規模,但銷貨毛利相對於營收就顯得很可憐。惟雖毛 利偏低,因多屬訂單生產,沒有產品做了之後賣不掉的風險,故仍有其獲利空間,但須靠相當之經濟規模來分攤其管理成本和高的產能利用率來分攤其折舊。
毛利率在15%-40%的公司,除了管理財外,還多賺了技術財。這種類型公司一般而言產品有一定程度的差異性,且製造加工過程需要有獨到的技術,可能是在台中接觸的高科技公司不多的緣故,反而覺得傳產在這方面的公司好像比較多一些。
以這兩年紅到連高盛都入主的和大工業(1536)來說,雖屬傳統的金屬加工業,惟靠其數十年累積下來精密加工的能力,終於成功的在2003打入美國汽車 OE市場,大單進來的同時仍能享有三成的毛利殊屬不易(在此先不論該公司最近官司纏身的負面訊息)。另外我的投資路系列提到的車王電子(1533)也是很 好的例子,靠其微機電整合、電源 管理和累積二十年的模具造成的進入障礙就讓公司立於不敗之地,毛利也都能突破三成。近期進場的億豐也是傳統到不行的塑膠射出產業,但靠其獨家的一條鞭整合 生產能力(或可說是獨特的Business Model,但還不及其後提到的創新Business Model),毛利也是超過三成的水準。
補充說明,能賺技術財的公司不像只賺管理財的要靠把營收做大來賺錢,這種類型的公司營收幾十億就算該產業中Level 1的Player,就算是億豐這種已經做到世界級的百葉窗門大廠營收也超過百億沒多少。但因毛利率高過只賺管理財的公司甚多,單純比較銷貨毛利不見得會低 於營收數倍於這類公司的管理財公司。
毛利率超過40%的公司,除了管理財和技術財外,個人認為還多賺了創新財。這類公司一般來講都以其獨特創新的營運模式創造出驚人的高毛利。以台股而言,最 好的例子就是台積電,張先生以其獨特先進的晶圓代工思維造就了今天的台積電,就是Business Model創新的最好典範。另外台中健身器材大廠喬山也是很好的例子,利用其優越的管理能力和在中國的低成本製造優勢,同時又能打造自有品牌享有較高的毛 利,整個微笑曲線都整合在其價值鍊中,不也是另一種Business Model的創新嗎?
2. 毛利率好壞,需視其趨勢變動以及總銷貨毛利增減來決定
毛利率的好壞,除了觀察趨勢變動外,另還需要考量總銷貨毛利的增減變動。簡單可以分成四種類型。
其一,毛利率上升,總銷貨毛利增加,這是最好的情形,代表公司業務擴張的同時仍能享有更高的毛利,對這種公司要給他拍拍手。
其二,毛利率上升,總銷貨毛利減少,這種狀況比較少見,有的話一般是見於轉型期的公司,公司放棄低毛利的產品轉型做別的,但新的產品或訂單一下子跟不上來就會造成這種情形,當然從壞的角度來看也有可能是公司的低價產品面臨競爭賣不出去所致。
其三,毛利率下跌,總銷貨毛利增加,這是成長期企業步入成熟期最常碰到的情形,利潤高的市場或單子做完了之後,如果還要繼續長大就只能將就著有賺頭的單子 就做了,也有可能是公司進入新市場或新產品線策略性的低價競爭來拉抬與對手的差距,但一般這是公司方面官方的漂亮話而已。
其四,毛利率下跌,總銷貨毛利減少,這是最慘的情形,代表公司所在的行業面臨強烈的競爭,且公司的競爭優勢在逐步流失。且這種情況下若銷貨收入還在成長代 表公司流血搶單,營收成長只是好看而已(我的投資路系列提到的華宇可以參考),當然如果毛利下跌且營收衰退的話就很糟糕了,公司在快速的走向衰亡。
3. 完整的毛利率分析需同時考量銷貨收入以及銷貨成本的變動
除了走勢和總銷貨毛利之外,要預測企業的毛利率以作為投資價值判定的基礎,還須參酌銷貨收入以及銷貨成本的走勢。
銷貨收入而言,企業會在年報揭露銷貨的產品比重%、銷售地區%和主要客戶銷售%,配合深入的了解企業產品銷售所屬的產業和市場,相對的比較其成長有沒有超過整理產業或該地區平均,就可以知道企業的表現是優於平均水準還是不及格。(補充說明若變動超過20%,年報的最後會有會計師查核說明簡單帶過變動的原因也可以參考)
這個方法困難的是目前很多上市櫃公司資訊揭露得很不透明,且台灣很多企業的產品線很多元,不容易分析其整個產品組合,AND大多數時候要找出其銷售地區或產品的相對比較指標也不是那麼容易的事情,SO絕大多數時候只能大概憑感覺或和同業比較來判斷表現是否超水準。
銷貨成本而言,年報的財務報表中會有一份銷貨成本明細表,認真的去讀這份報表可以發覺很多資訊。(同樣若變動超過20%,年報最後面會有會計師查核說明帶過變動原因)
舉個例子而言,台灣最大的汽車輪圈製造廠源恆工業這兩年因其主要原料鋁的價格狂飆造成其相當程度的虧損。認真去讀他的報表就可以知道,由於其為資本密集產 業,技術門檻不高,屬於前面分類中賺管理財的公司,正常的情形企業的銷貨收入若為100塊,銷貨成本會佔到90塊,扣掉管銷後可以賺個兩三塊錢。但問題就 出在他的90塊銷貨成本中,直接原料佔了70,直接人工佔了10,折舊又佔了10。這種經營模式在金屬價格穩定的時候沒太大的問題,但偏偏前兩年鋁價狂 飆,又接的是國際大廠的單,成本轉嫁會有遞延的情形,兩相因素之下就造成大虧的情形。
相反的例子,同樣是金屬加工業,以前面提到的和大為例,銷貨收入100,銷貨成本只佔65,65中原料只佔25,人工佔30,折舊佔10。這樣的經營模式 讓他縱然在鋼價飆漲的這兩三年,銷貨成本只稍微拉升一點到接近70,這就是賺技術財不同於賺管理財的地方。(或許會有人說不能拿作輪圈的源恆跟作齒輪的和 大相比,但就算拿同樣做輪圈的巧新科技來相比,源恆依然吃虧在其只賺管理財的經營模式。補充說明巧新因為才剛公開,對外資訊較少,只有公開資訊觀測站可以 下載其資料)
以上這些資訊都可以從銷貨成本明細表中挖出來,只要用心去讀報表,再與產業和大環境的總經趨勢結合,要能夠精準預測公司未來短期內的損益情形真的不難。
4. 財報上的數字僅為參考指標,要知道公司產品有無競爭力最簡單的方法是去問該行業的人
說了那麼一長篇,都是純粹的紙上用兵。
我覺得從毛利率的觀點做出發只是簡單篩選出可能的投資標的的第一步,找出看起來產品有競爭力的公司後再來就是實際的去了解是不是像是報表看起來這樣。這時 候我建議最快最有效的方法就是去問該業內的人,畢竟每個產業有其獨特的遊戲規則,隔行如隔山,太細微的技術性的東西不是我們這種門外漢能懂的,但是最起碼 產業的遊戲規則要花時間去了解,這樣才能判斷目標公司的Business Model是不是真的能賺錢。而這也是Fisher在非常潛力股中最為推崇的"閒聊法"。
毛利率的分析只是個開頭,當然毛利率越高代表其產品越有競爭力,也能賺到更高一層的財富,但是哪種股票有其投資價值我覺得還必須考量不同的產業特性或是 Business Model而定,只賺管理財的公司中也有像鴻海這麼勇的,惟相較而言個人會比較推崇和偏好有能力賺取技術財和創新財的公司。
補充說明以下幾點。
原本打算結合OEM、ODM和OBM等不同生產模式,再配合產業生命週期這些因素加起來一起寫,但這樣主題會變得太大,也遠超過筆者能夠駕馭和組織,所以還是簡單分類三種財就好。
文中提及企業的毛利率都是以合併報表為準。15%和40%也非絕對的判斷標準,個人心中的尺其實際上是15-20%和40-50%。
DRAM產業不適用。
這兩年賺飽飽的鋼鐵類股原則上應屬賺管理財,這兩年多賺的部分應歸屬於機會財,這是原物料產業獨有的特性,但機會財有賺有賠。
僅是自己從少少的經驗中歸納出來的心得,相信市場中會有很多的例外情形,只能說這是我的判斷方法,怎麼用或能不能用就見仁見智。
以上
機會財、管理財、創意財、政策財
http://david888.com/david/2011/03/772/
其實這四種分類方法,是各說各話的,搜尋了網路上幾個關鍵字後,有人說三種、有人說四種。但不管怎麼分類,我相信總是脫離不了這四種大綱。
- 機會財:抓到時代的趨勢,社會的需求,靠著供需法則,攀住抓緊所賺到的財富
- 管理財:快速反應市場,積極回應,穩健管控,不該花的不花,不該浪費的省下,靠著強大的「管理」自律,省下就是賺到。
- 創意財:新發明,新創意,新產品,改良品,獨家。
- 政策財:因為政府或國際商貿組織法規的變化,需求量突然變多,或靠關係取得的獨家或少數絕對權力能賺的財富。
機會財: 能掌握到的公司多,但能持續賺機會財的時間短
管理財: 能掌握到的公司多,能持續賺管理財的時間長
創意財: 可遇不可求,縱然有專利或其他方式保護,但只要有利可圖,同業的取代品也會在很短時間誕生。
政策財: 可遇不可求
雖然這看起來是公司的財富取得分類法,
但個人的財富也可以這樣演繹。天下道理殊途同歸。
2013年8月5日 星期一
SQL Server CONVERT() Function
http://www.w3schools.com/sql/func_convert.asp
SQL Server Date Functions
The CONVERT() function can be used to display date/time data in different formats.
The table below represent the style values for datetime or smalldatetime
conversion to character data:
The result would look something like this:
SQL Server Date Functions
*************************************************************************************************************
select convert(char(7),employee_hire_date,111)
from hrms_employee
2006/06
2006/06
SQL Server CONVERT() Function

Definition and Usage
The CONVERT() function is a general function that converts an expression of one data type to another.The CONVERT() function can be used to display date/time data in different formats.
Syntax
CONVERT(data_type(length),expression,style)
Value | Description |
---|---|
data_type(length) | Specifies the target data type (with an optional length) |
expression | Specifies the value to be converted |
style | Specifies the output format for the date/time |
Value (century yy) |
Value (century yyyy) |
Input/Output | Standard |
---|---|---|---|
- | 0 or 100 | mon dd yyyy hh:miAM (or PM) | Default |
1 | 101 | mm/dd/yy | USA |
2 | 102 | yy.mm.dd | ANSI |
3 | 103 | dd/mm/yy | British/French |
4 | 104 | dd.mm.yy | German |
5 | 105 | dd-mm-yy | Italian |
6 | 106 | dd mon yy | |
7 | 107 | Mon dd, yy | |
8 | 108 | hh:mm:ss | |
- | 9 or 109 | mon dd yyyy hh:mi:ss:mmmAM (or PM) | Default+millisec |
10 | 110 | mm-dd-yy | USA |
11 | 111 | yy/mm/dd | Japan |
12 | 112 | yymmdd | ISO |
- | 13 or 113 | dd mon yyyy hh:mi:ss:mmm (24h) | |
14 | 114 | hh:mi:ss:mmm (24h) | |
- | 20 or 120 | yyyy-mm-dd hh:mi:ss (24h) | |
- | 21 or 121 | yyyy-mm-dd hh:mi:ss.mmm (24h) | |
- | 126 | yyyy-mm-ddThh:mi:ss.mmm (no spaces) | ISO8601 |
- | 130 | dd mon yyyy hh:mi:ss:mmmAM | Hijiri |
- | 131 | dd/mm/yy hh:mi:ss:mmmAM | Hijiri |
Example
The following script uses the CONVERT() function to display different formats. We will use the GETDATE() function to get the current date/time:
CONVERT(VARCHAR(19),GETDATE())
CONVERT(VARCHAR(10),GETDATE(),10)
CONVERT(VARCHAR(10),GETDATE(),110)
CONVERT(VARCHAR(11),GETDATE(),6)
CONVERT(VARCHAR(11),GETDATE(),106)
CONVERT(VARCHAR(24),GETDATE(),113)
CONVERT(VARCHAR(10),GETDATE(),10)
CONVERT(VARCHAR(10),GETDATE(),110)
CONVERT(VARCHAR(11),GETDATE(),6)
CONVERT(VARCHAR(11),GETDATE(),106)
CONVERT(VARCHAR(24),GETDATE(),113)
Nov 04 2011 11:45 PM
11-04-11
11-04-2011
04 Nov 11
04 Nov 2011
04 Nov 2011 11:45:34:243
11-04-11
11-04-2011
04 Nov 11
04 Nov 2011
04 Nov 2011 11:45:34:243

*************************************************************************************************************
select convert(char(7),employee_hire_date,111)
from hrms_employee
2006/06
2006/06
create table as select
select * into [bigsun_human].[dbo].[hrms_department]
from [mishr].[28318416].[dbo].[hrms_department]
from [mishr].[28318416].[dbo].[hrms_department]
fnFormatDate
MS SQL Server 的T-SQL 真的不好用,連TO_CHAR都沒有。
我自己寫了一個function,供MS SQL Server使用
用法
select dbo.fnFormatDate(getdate(),'yyyymmddHHMISS')
----------------------------------------------------------------------------------------------------------------------------------
drop FUNCTION dbo.fnFormatDate
CREATE FUNCTION dbo.fnFormatDate (@Datetime DATETIME, @FormatMask VARCHAR(32))
RETURNS VARCHAR(32)
AS
BEGIN
DECLARE @StringDate VARCHAR(32)
SET @StringDate = @FormatMask
IF (CHARINDEX ('HH',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'HH',
DATENAME(HH, @Datetime))
IF (CHARINDEX ('MI',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'MI',
DATENAME(MI, @Datetime))
IF (CHARINDEX ('SS',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'SS',
DATENAME(SS, @Datetime))
IF (CHARINDEX ('YYYY',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'YYYY',
DATENAME(YY, @Datetime))
IF (CHARINDEX ('YY',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'YY',
RIGHT(DATENAME(YY, @Datetime),2))
IF (CHARINDEX ('Month',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'Month',
DATENAME(MM, @Datetime))
IF (CHARINDEX ('MON',@StringDate COLLATE SQL_Latin1_General_CP1_CS_AS)>0)
SET @StringDate = REPLACE(@StringDate, 'MON',
LEFT(UPPER(DATENAME(MM, @Datetime)),3))
IF (CHARINDEX ('Mon',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'Mon',
LEFT(DATENAME(MM, @Datetime),3))
IF (CHARINDEX ('MM',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'MM',
RIGHT('0'+CONVERT(VARCHAR,DATEPART(MM, @Datetime)),2))
IF (CHARINDEX ('M',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'M',
CONVERT(VARCHAR,DATEPART(MM, @Datetime)))
IF (CHARINDEX ('DD',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'DD',
RIGHT('0'+DATENAME(DD, @Datetime),2))
IF (CHARINDEX ('D',@StringDate) > 0)
SET @StringDate = REPLACE(@StringDate, 'D',
DATENAME(DD, @Datetime))
RETURN @StringDate
END