利用NPM快速建置Node.js網路應用框架

參考網址:臺灣大學計算機及資訊網路中心

-Linux系統(以Ubuntu為例)
1.使用app-get 來安裝,若是CentOS則用yum install
$ sudo apt-get install nodejs
$ sudo apt-get install npm


圖五 NPM安裝

2.Linux上node已被更名為nodejs,可用ln -s 指令來連結node為執行檔
$ sudo ln -s /usr/bin/nodejs /usr/local/bin/node
使用node -v 和npm -v 確認是否已安裝成功。
因為apt-get 安裝比較穩定版本,若要最新版本可自行抓原始碼來編譯。 https://github.com/joyent/node.git

Node.js 教程 http://www.runoob.com/nodejs/nodejs-tutorial.html

發表於 Linux系統, 程式設計 | 發表迴響

PhotoImpact x3 1試用版

參考網址:
校園文化網站課程 提供中文試用版下載點
b24338869

還在測試

cd C:\Program Files (x86)\Corel\Ulead PhotoImpact X3
rename Ulead.dat Ulead.dat_aa
mklink /j Ulead.dat D:\soft\Ulead.dat

需用管理者權限執行
本想把Ulead.dat目錄放在x:
可惜 /j 無法使用網路磁碟機
所以還是得把Ulead.dat目錄複製過來


刪除C:\Users\5A88\AppData\Roaming\Ulead Systems\Ulead PhotoImpact\13.0資料夾
重新執行photoImpact

試用結果:印章有問題

發表於 軟體使用 | 發表迴響

How to Open, Edit, and Convert XNB Files KODU檔案格式

參考網址:https://www.lifewire.com/xnb-file-2622568

by Tim Fisher

Updated October 30, 2018

A file with the XNB file extension is an XNA Game Studio Express XNA Framework Content Pipeline Binary file. It's used to save original game files into a proprietary format.

 

In English: an XNB file is usually a compressed file full of images that appear in a video game created with XNA Game Studio, but they may also contain additional game data like audio files.

Some software might refer to XNB files as compiled asset files.

Note: The XNB file extension looks an awful lot like XMB and might seem similar but XMB files are video game data files used in games like Age of Empires and X-Wing.

 

How to Open an XNB File

The real source of XNB files is Microsoft XNA Game Studio, a tool that works with Microsoft Visual Studio to help create video games for Microsoft Windows, Windows Phone, Xbox 360, and the (now defunct) Zune. This program, however, isn't a practical tool to extract images from XNB files.

Your best bet is a program called XNB Exporter, which is a portable (meaning no install is necessary) tool that extracts the PNG files from the compressed XNB file you're working with.

The easiest way to use this program is to copy the XNB file into the same folder as the program and then enter the file name of the XNB file without the file extension (e.g. file instead of file.xnb) in XNB Exporter, and then press Go for it!.

You might also be able to open and/or edit XNB files with the GameTools GXView tool.

Note: If you've installed GameTools but can't find GXView, you can open it directly from the installation folder, almost always here: C:\Program Files (x86)\GameTools\GXView.exe.

Tip: Some file types are text-only files and can be opened and viewed with any text editor, like Notepad in Windows, or a more advanced text editor from our Best Free Text Editors list. This isn't the case with any Game Studio XNB file, but if the one you have is a different format, this might be of some help.

If you do manage to get an XNB file opened with a text editor, but it's not entirely composed of text, there may be something within it that identifies the program used to create the file, which you then might be able to use to find a suitable program for opening it.

If the above tools don't open your XNB file, it's possible that yours has nothing to do with XNA Game Studio and isn't a plain text file, in which case it's an entirely different format instead. The best thing to do is to see what folder the XNB file is stored in, and see if that context can help you determine the program that's using it.

Note: If your file doesn't open as explained above, double-check that you're reading the file extension correctly. For example, even though XMB and XNK files resemble the XNB file extension, neither are the same as XMB and therefore don't open with the same programs.

 

How to Convert an XNB File

A regular file converter will not convert XNB files. The tools we already mentioned above are designed for getting image files out of an XNB file, which is probably what you're wanting to do.

However, you may also try TExtract, TerrariaXNB2PNG, or XnaConvert if the software from above doesn't help.

XNB to WAV lets you copy out the WAV sound file from an XNB file. If you want the WAV file to be in some other sound format like MP3, you can use a free audio converter.

發表於 Windows系統, 程式設計, 軟體使用 | 發表迴響

html5 drag拖放實現兩個div互換

參考網址:https://github.com/sunshine940326/drag

<!DOCTYPE html>
<!DOCTYPE HTML>
<html>
<head>
    <style type="text/css">
        #div1
        {float:left; width:100px; height:35px; margin:10px;padding:10px;border:1px solid #aaaaaa;}
        #div2
        {float:left; width:200px; height:135px; margin:10px;padding:10px;border:1px solid #aaaaaa;}

    </style>
    <script type="text/javascript">
        function allowDrop(ev)
        {
            ev.preventDefault();
        }

        var srcdiv = null;
        function drag(ev,divdom)
        {
            srcdiv=divdom;
            ev.dataTransfer.setData("text/html",divdom.innerHTML);
        }

        function drop(ev,divdom)
        {
            ev.preventDefault();
            if(srcdiv != divdom){
                srcdiv.innerHTML = divdom.innerHTML;
                divdom.innerHTML=ev.dataTransfer.getData("text/html");
            }
        }
    </script>
</head>
<body>

<div id="div1" ondrop="drop(event,this)" ondragover="allowDrop(event)" draggable="true" ondragstart="drag(event, this)">
    <p>ni hao!</p>
</div>
<div id="div2" ondrop="drop(event,this)" ondragover="allowDrop(event)" draggable="true" ondragstart="drag(event, this)">
    <p>Hello world!</p>
</div>

</body>
</html>

 

發表於 程式設計 | 發表迴響

將網頁(HTML)內容轉貼到 Word 的分頁控制

參考網址:Tsung's Blog
 

想要將 網頁(HTML) 的內容, 直接貼到 Word 上, 然後希望可以控制 Word 分頁(做報告方便), 要使用哪個 HTML Tag 呢?

懶得看下述作法的, 可以直接使用結論, 就是下述 Tag.

View Raw Code?

  1. <br style="page-break-before:always;">

找 Word 分頁用的 HTML Tag 或參數的方法

  1. 於 Word 檔 Ctrl + Enter (產生分頁)
  2. 另存 HTML
  3. 再去開啟 HTML, 然後分別摘除嘗試即可.
  4. 註: CSS 的分頁屬性有這幾個: page-break-after、page-break-before、page-break-inside, 也可以考慮嘗試看看

註: 使用 <p>、<div>… 加上這 style 都不行, 一定要 <br> 才可以.

用相同的方法可以找出控制頁面邊界的CSS
 

<style media="print" type="text/css">
<!--
 /* Page Definitions */
 @page WordSection1
	{size:595.3pt 841.9pt;
	margin:1.0cm 1.0cm 1.0cm 1.0cm;
	layout-grid:18.0pt;}
div.WordSection1
	{page:WordSection1;}
-->
</style>

記得把class套用上去
 

<div class=WordSection1>	
	{{ include file= $content_file  }} 
</div>

同場加映:關於 @media print 的二三事..
 

列印模式下的頁面配置( @page ):

@page 是列印模式下對頁面配置的特殊屬性,主要可設定頁面的 size, margin , orphans 和 widow。

  • size 可直接指定寬度與高度(搭配單位 mm 或 cm 皆可)、或是通用尺寸( A4、A5.. ),此外可設定頁面的呈現方向( portrait / landscape )
  • margin 就是一般頁面的邊距(常用 word 的人應該不陌生 😀 )
  • orphans 和 widow 這印刷術語取名滿妙.., orphans 是指頁面最後一個段落的行數、widow 則是頁面第一個段落的行數,初始值都是2,表示限制頁面頂部及底部的段落不能只顯示一行就被分頁。
@page{
  size: A4 portrait;
  margin: 0.5cm;
  orphans:4;
  widows:2;
}

 

元素分頁的斷點設定:

元素後要被分頁嗎? page-break-after : auto | always | avoid | left | right
元素前要被分頁嗎? page-break-before : auto | always | avoid | left | right
元素本身要被分頁嗎? page-break-inside : auto | avoid
這三個屬性超重要!!!網頁內容無法預估長度的情況下,很難完美的呈現頁面布局,盡可能做到的就是避免顯示的元素被分頁切割。

h1, h2, h3, h4, h5, h6 {
  page-break-after:avoid;
  page-break-inside:avoid
}
h1+p, h2+p, h3+p {
  page-break-before: avoid;
}
a {
  page-break-inside:avoid
}
img{
  page-break-after: avoid;
  page-break-inside: avoid;
}
table, blockquote{
  page-break-inside: avoid;
}
ul, ol, dl {
  page-break-before:avoid;
}
/* 如架構本身用一組一組的 DIV 包住,也可強制設定每組 DIV 會各自切成一頁 */
div.pageBlock{
  page-break-before: always;
}

雖然無法讓想要的內容全部塞在同一頁,但利用 page-break 至少可以限制分頁的斷點判斷~整體閱讀起來也比較舒服了!!

發表於 程式設計 | 發表迴響

瀏覽器預覽列印-比較chrome70.0.3538.77及firefox63.0.3

在chrome中預覽列印遇到大檔時,速度會變得很慢,甚至當機。
找來firefox測試,同樣的網頁,預覽速度很正常。

筆記一下firefox預覽列印的方式
firefox必需點選右上角的列印按鈕才會進入列印預覽模式。
另一個找到預覽列印的方法是按Alt鍵,上方會出現工具列,再從檔案功能中下拉,就可以找到預覽列印了。
還有個方法就是安裝Print Preview Button這個外掛,就會在右上角出現預覽列印按鈕。

chrome預覽列印時可以選擇不同紙張大小,firefox則不行。firefox的預覽列印顯然弱了點。
firefox不同紙張的變通方式,用縮放模擬。(B4–>A4 為81%)

 

 

發表於 Windows系統 | 發表迴響

rsync + ssh 使用不同 port 執行

參考網址:Tsung's Blog
 

rsync + ssh 使用不同 port 的話, 需要加上 -e "ssh -p port_number", ex: 假設遠端的 ssh 機器是用 1234 port, 指令會如下述:

  • rsync -e "ssh -p 1234" -avz –bwlimit=3000 REMOTE_HOST:data_path .

另一種使用 –rsh='ssh -pPORT_NUMBER', 如下述範例:

  • rsync –rsh='ssh -p1234' -avz –bwlimit=3000 REMOTE_HOST:data_path .

另外一個是透過 .ssh/config, 做 ssh 遠端機器的相關設定, 如下述範例:

  1. vim .ssh/config
    Host REMOTE_HOST # 這個可以寫簡寫, 但是下面 rsync 的REMOTE_HOST 需與此一致.
    HostName REMOTE_HOST
    User YOUR_USERNAME
    Port 1234
    IdentityFile /home/YOUR_USERNAME/.ssh/id_rsa # 如果有在寫, 沒有這行可跳過不寫
  2. rsync -avz –bwlimit=3000 REMOTE_HOST:data_path . # 這邊就可以直接 rsync 即可.

 

發表於 Linux系統 | 發表迴響

SSH 免密碼登入

參考網址:dywang

  1. 在定時備份或批次遠端處理,往往需要免密碼登入遠端主機工作。為達此目的,首先必須在 client 端產生一組 key,包含公開金鑰(Public Key)與私密金鑰(Private Key),將公鑰送到要登入的主機,相互對應做免密碼的登入。key 的產生:

     

    [root@kvm8 ~]# ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    c3:e9:25:65:00:c8:65:cb:e8:fe:4e:7e:ce:06:a4:9d root@kvm8.deyu.wang
    The key's randomart image is:
    +--[ RSA 2048]----+
    |   . o+..        |
    |    o+ . .       |
    |    . o   o      |
    |   .  .. +       |
    |    .+ .S .      |
    |   .. E. +       |
    |    . ...        |
    |     + .o        |
    |     .++o        |
    +-----------------+
    
  2. 將公開金鑰放到要登入的主機

     

    [root@kvm8 ~]# scp .ssh/id_rsa.pub kvm7.deyu.wang:.ssh/
    The authenticity of host 'kvm7.deyu.wang (192.168.122.7)' can't be established.
    RSA key fingerprint is 33:76:31:62:25:dd:eb:a6:1f:5a:54:10:b8:25:c3:66.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'kvm7.deyu.wang,192.168.122.7' (RSA) to the list of known hosts.
    root@kvm7.deyu.wang's password: 
    id_rsa.pub                                    100%  401     0.4KB/s   00:00  
    
  3. ssh 登入欲免密碼登入的主機,這時還是要密碼。

     

    [root@kvm8 ~]# ssh kvm7.deyu.wang
    root@kvm7.deyu.wang's password: 
    Last login: Tue Feb  4 19:31:13 2014 from 192.168.122.1
    
  4. 系統預設處理放置公鑰的檔案為 authorized_keys,所以必須把剛剛傳送過來的公鑰累加到這個檔案中:

     

    [root@kvm7 ~]# cat .ssh/id_rsa.pub >> .ssh/authorized_keys
    
  5. 特別注意目錄 .ssh 及檔案 authorized_keys 的權限,若群組或其他人的權限過大,除了安全性有問題外,也有可能因 ssh 判斷要對應的金鑰不安全,而無法對應,也就是不能免密碼登入。

     

    [root@kvm7 ~]# chmod 700 .ssh/
    [root@kvm7 ~]# chmod 644 .ssh/authorized_keys 
    [root@kvm7 ~]# ll -d .ssh 
    drwx------. 2 root root 4096 Feb  4 19:36 .ssh
    [root@kvm7 ~]# ll .ssh/authorized_keys 
    -rw-r--r--. 1 root root 401 Feb  4 19:36 .ssh/authorized_keys
    
  6. 退出 kvm7.deyu.wang 回到 kvm8.deyu.wang。

     

    [root@kvm7 ~]# exit
    logout
    Connection to kvm7.deyu.wang closed.
    
  7. 再次登入 kvm7.deyu.wang 已不需要密碼。

     

    [root@kvm8 ~]# ssh kvm7.deyu.wang
    Last login: Tue Feb  4 19:32:57 2014 from 192.168.122.1

實作對應(含不同的ssh port)
 

ssh-keygen #passphrase直接按enter
scp -P xxxx .ssh/id_rsa.pub 120.116.xx.xxx:.ssh/
ssh -p xxxx 120.116.xx.xxx
cat .ssh/id_rsa.pub >> .ssh/authorized_keys
chmod 700 .ssh/
chmod 644 .ssh/authorized_keys
exit #退出遠端主機
ssh -p xxxx 120.116.xx.xxx #已不需密碼 

 

發表於 Linux系統 | 發表迴響

ajax入門

參考網址:中興大學資管系

jquery

發表於 程式設計 | 發表迴響

拖曳排序

參考網址:

MIS腳印 JavaScript 表格拖放排序 AJAX 資料庫 for PHP 
在FireFox中會有問題,解決方法:
參考網址:Mozilla    Drag and Drop: Copy and Move elements with DataTransfer
javascript中加入function dragstart_handler(ev) 
另外在被拖曳的元素上除了draggable="true"還需加上ondragstart="dragstart_handler(event);"
不加ondragstart在firefox中無法拖曳。
例<tr class="data" draggable="true" ondragstart="dragstart_handler(event);">
目前還有一個問題未解決??(107.11.106更新,關掉手勢擴展就解決了。)
在firefox中拖曳太遠會開啟一個新視窗https://www.google.com/webhp

function dragstart_handler(ev) {
 console.log("dragStart");
 // Change the source element's background color to signify drag has started
//// ev.currentTarget.style.border = "dashed";
 // Add the id of the drag source element to the drag data payload so
 // it is available when the drop event is fired
ev.dataTransfer.setData("text", ev.target.id);
 // Tell the browser both copy and move are possible
ev.effectAllowed = "copyMove";
}

 

107.11.10更新:
firefox 下使用html5拖拽会自动打开新标签的解决办法 (這個方法無效)

另一篇文章:
使用draggable拖动一个图片时,火狐上总会新开一个窗口 (BINGO)
是不是安装了手势操作扩展?拖拽时会在新标签页中打开页面,在工具—附加组件里查看下已经安装的扩展。

 

CSDN h5拖拽在兼容火狐与IE的实现需要注意的事

發表於 程式設計 | 發表迴響