網頁

2014年12月20日 星期六

Linux "2>&1 | tee build.log"

Last Update: 2014/12/20 16:21+08
Type: Note



make 2>&1 | tee build.log
不一定要是 make
是執行什麼東西就可以用

0: stdin, 1: stdout, 2: stderr
"2>&1": 將標準錯誤 重新定向到 標準輸出

"tee build.log": tee 將同時輸出到 控制台 和 build.log


C++ &(and) 與 const

Last Updat: 2014/12/20 15:03+08
Type: Note



測試 C++ 的 & 與 const

2014年12月19日 星期五

makefile .PHONY

Last Update: 2014/12/20 13:43+08
Type: Note



# makefile
gen:
 mkdir -p clean
clean:
 rm -rf clean
執行 "make gen ; make clean"
會生成 clean 的目錄, 但無法成功執行 clean 的命令
得到的錯誤訊息為 "make: `clean' is up to date."
因為 make 執行時, 會去搜尋該檔案或目錄是否存在
為了避免檔案目錄與命令的衝突 可以加下 .PHONY
# makefile
gen:
 mkdir -p clean

clean:
 rm -rf clean
.PHONY: clean
就可以成功執行了
像是宣告它是偽檔案/目錄的意思
也可以避免它花時間去搜尋



2014年12月13日 星期六

C++ vector - Pointer or Not

Last Update: 2014/12/13 20:13+08
Type: Note



Intro

當我們宣告一個 vector 時, 要用 Pointer 還是 不要用 比較好?
我覺得是要看個人使用習慣
雖然有人說用 new 出來的, 也就是用 Pointer 比較好
但其實只要瞭解它的運作, 別搞亂就可以了
需要注意的是 vector 在 超出它當前的容納量時, 會重新 宣告/要求 分配memory



2014年12月7日 星期日

C++ member declare has incomplete type

Last Update: 2014/12/08 13:42+08
Type: Note



class 宣告member時
若該member的型態並非指標
則該member的型態必需事先就定義完整
如下例, compile是會失敗的
class Personality;
class Human{
  Personality p;
}

class Personality{
  string name;
}
因為它必須先計算 Human class 的 memory 大小
但他卻還不知道 Personality class 的 size, 所以無從計算

如果改成指標型態 就沒有問題, 因為指標大小是固定的
class Personality;
class Human{
  Personality *p;
}

class Personality{
  string name;
}
在使用 include 時要注意這點
Java 和 C# 沒有這問題, 因為 class 都是以指標型態儲存



----------------------------------


實例上來看, 我們會像下面這樣宣告 形成不完全的型態
//Human.h
#ifndef HUMAN_H_
#define HUMAN_H_
#include "project.h"
class Human{
  Personality p;
}
#endif
//Personality.h
#ifndef PERSONALITY_H_
#define PERSONALITY_H_
#include "project.h"
class Personality{
  string name;
}
#endif
//project.h
#include "Human.h"
#include "Personality.h"
這就會導致上述提到的不完全型態
"#define PERSONALITY_H_" 後, 接著引入 project.h
此時的 Personality class 尚未宣告 or 尚未完成宣告
project.h 引入 Human.h
Human class 宣告, 但無法計算size, 因為 Personality class 未完成



2014年11月7日 星期五

Eclipse - CDT for C/C++

Last Update: 2014/11/09 14:23+08
Type: Note



Intro




Eclipse 安裝 CDT(C/C++ Development Tools)
Help
-> Instal New Software...
-> 選Eclipse版本 ex. Mars - http://download.eclipse.org/releases/mars
-> 勾選 Programming Language-> C/C++ Development Tools 和 C/C++ Development Tools SDK



2014年11月6日 星期四

Linux CentOS 零碎記事

Last Update: 2015/02/12 15:57+08
Type: Note



Install Package from *.rpm
rpm -Uhv xxx.rpm

Install SSH
yum -y install  openssh*
service sshd start
Install bison
yum install bison
service sshd start

Remmina遠端桌面 - 無法連接至RDP伺服器
rm -rf ~/.freedp



2014年10月27日 星期一

Verilog - UART Simple Send / Receive

Last Update: 2014/10/29 00:24+08
Type: Note



看到 embecosm/chiphack 寫的 UART transmit
使用 除頻器 和 Finite State Machine 完成 UART 的發送
很不錯的練習題

他的github裡有 uart.v
但主要部份沒填, 只有FSM的架構
圖層 1 Idle Send Start Bit Send Data Bit Send End Bit Key1 Press not last bit last data bit

可以思考一下除頻器的運作, 填上適當的counter數
還有 UART 10-bit 一組, start-bit=0 + 8-bit data + end-bit=1

這是改完 測試通過的檔案 DE0_NANO_UART_Send.v


接著做 Receive: DE0_NANO_UART.v
PC端 C#測試代碼: DE0_NANO_UART.cs



2014年10月25日 星期六

OpenRISC with DE0-Nano

Last Update: 2014/10/29 00:24+08
Type: Note



---Intro---


把 OpenRISC 燒進 DE0-Nano 執行嵌入式的 Linux 系統

Environment & Requirement:
VMWare
Ubuntu 12.04.2 Desktop i386
FPGA板 - DE0-Nano
USB to UART (FTDI接腳, ex. UB-391 記得裝驅動)


2014年10月20日 星期一

OpenRISC with DE0-Nano - kevinmehall version

Last Update: 2014/10/17 01:11+08
Type: Note



---Intro---


把 OpenRISC 燒進 DE0-Nano 執行嵌入式的 Linux 系統

Environment & Requirement:
VMWare
Ubuntu 12.04.2 Desktop i386
FPGA板 - DE0-Nano
USB to UART (FTDI接腳)

個人建議 看 這篇 官方版本的


2014年10月11日 星期六

Hello! DE0 Nano (Altera FPGA)

Last Update: 2014/10/12 15:20+08
Type: Note



---Intro---


因為要學著用 OpenRISC
所以買了官方推薦的 FPGA: Terasic DE0 Nano
畢竟是練習用的 所以買個比較便宜的
真心建議要玩FPGA就直接買個板子吧!
讀萬卷書 不如行萬里路~ 比較有感覺

Content
  • 開個箱文唄
  • Installation & Driver & Test
  • My First FPGA


2014年10月9日 星期四

Linux CentOS 網路設定

Last Update: 2014/10/09 16:36+08
Type: Note


網路設定 - 固定IP

CentOS
http://yenpai.idis.com.tw/archives/240-%E6%95%99%E5%AD%B8-centos-6-3-%E5%AE%89%E8%A3%9D-2%E7%B6%B2%E8%B7%AF%E8%A8%AD%E5%AE%9A%E7%AF%87
(P.S. 有空再整理)



Troubleshooting


修改 /etc/resolv.conf 無效
請修改 /etc/sysconfig/network-scripts/ifcfg-eth0
ex:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
NETMASK=255.255.255.0
IPADDR=xxx.xxx.xxx.xxx
GATEWAY=xxx.xxx.xxx.xxx
DNS1=8.8.8.8
DNS2=168.95.1.1
記得重啟 service network restart



如果要生成device的uuid
uuidgen eth0

C++ Split

Last Update: 2014/10/09 16:35+08
Type: Note


用 stringstream by 特定字元切割 ex: ':'
  std::ifstream infile("file.txt");
  if (!infile.is_open()) 
   return;
  
  std::string line;
  while (std::getline(infile, line)) {
   std::stringstream ss(line);
   std::string key, val;
   std::getline(ss, key, ':');
   std::getline(ss, val, ':');
用 istringstream by token (空白) 切割
  while (std::getline(infile, line)) {
   std::string key, val;

   istringstream iss(line);
   std::vector<std::string> tokens;
   copy(std::istream_iterator<std::string>(iss),
     std::istream_iterator<std::string>(),
     back_inserter<vector<std::string> >(tokens));
   if (tokens.size() != 2)
    continue;
   key = tokens[0];
   val = tokens[1];



C++ Interface Destructor

Last Update: 2014/10/09 16:32+08
Type: Note


即使是 interface 也需要有解構子
class IAnimal
{
  virtual void walk()=0;
  virtual ~IAnimal(){}
};
如果你這樣用
IAnimal* animal = new Lion();
delete animal;
這個 interface 是不知道 Lion 的解構子



Drag and Drop Files into a C# application

  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
      this.AllowDrop = true;
      this.DragEnter += new DragEventHandler(Form1_DragEnter);
      this.DragDrop += new DragEventHandler(Form1_DragDrop);
    }

    void Form1_DragEnter(object sender, DragEventArgs e) {
      if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
    }

    void Form1_DragDrop(object sender, DragEventArgs e) {
      string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
      foreach (string file in files) Console.WriteLine(file);
    }
  }

2014年7月21日 星期一

Linux gcc g++

Last Update: 2014/06/28 18:36+08
Type: Note


---Ubuntu---------

lastest
sudo apt-get install g++

special version
sudo apt-get install g++-4.7


switch
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7

remove update-alternatives
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++



---CentOS---------

su root

yum install gcc-g++
若compile出現 cannot find -lm (或 -lxxx)
yum install glibc-static



Eclipse & PHP

Last Update: 2014/07/24 15:32+08



PDT install


Help > Install New Software
   > Work with: Kepler(your eclipse version) http://download.eclipse.org/xxxxxxxxx
   > Programming Language
     >勾選PHP Development Tool (PDT)
Next Next Next ...

P.S: Linux 可能要先download core: https://eclipse.org/pdt/#download



.buildpath

在新增PHP project時, 可以設定 src目錄
若發現沒有 auto complete 時
可以在 Project Build Path 重新設定 src目錄
另外也可以在專案目錄裡找到 .buildpath 的檔案, 去修改
<buildpath>
 <buildpathentry kind="src" path="war"/>
 <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>
auto complete 會用到的2個設定
src: 你自己寫的php code
con: PHP 的 Core API



Apache 虛擬目錄設定

Last Update: 2014/07/21 21:59+08
Type: Note



Alias /test "D:\Dev\test\eclipsews\test\war"
<Directory "D:\Dev\test\eclipsews\test\war">
 Options Indexes FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all
 DirectoryIndex index.html index.php
 Require all granted
</Directory>

Require all granted:
  xampp要加, 還不確定什麼時候狀況需要


2014年6月14日 星期六

GitHub & Eclipse

Last Update: 2014/05/25 13:48+08


Intro

用 Eclipse 與 GitHub 連結
Github的每個repository就是一個專案
雖有人提過可以用branch來做multi-projects
但還是別扭曲本意


2014年5月27日 星期二

C / C++ format string

Last Update: 2014/05/27 19:00+08
Type: Note



C sprintf - 使用時間當做範例
#include <time.h>

time_t timep;
struct tm *p;
time(&timep);
p=gmtime(&timep);

sprintf(fn, "t%02d%02d%02d", p->tm_hour, p->tm_min, p->tm_sec);


C++ ostringstream
#include <string>
#include <sstream>

int no = 12;
std::ostringstream oss;
oss << "data_" << no << ".text";
std::string str = oss.str();

printf("%s\n", str.c_str());



2014年4月19日 星期六

C++ vector 與 memory

Last Update: 2014/04/20 13:29+08


Intro

關於vector 與 memory 使用注意事項


2014年4月8日 星期二

gcc/g++ in Windows - MinGW & Cygwin

Last Update: 2014/04/09 09:35+08
Type: Note



---MinGW---

Download
官網(http://www.mingw.org/)下載 MinGW installer

Install
選擇要安裝的資料夾(避免空白和符號)
在選擇 package 時, 將 [Basic Setup] 全部 mark 起來
> Apply Changes

Set Environment Variables
/bin 加入 環境變數中的 PATH

Eclipse > Project > 右鍵 Properties
> C/C++ General
> Paths and Symbols
> Include
> 在 GNU C Or GNU C++ 加入 <install dir>/include
> 在 Library Paths 加入 <install dir>/lib



---Cygwin---

Download
官網(http://cygwin.com/install.html)下載 Cygwin installer

Install
> 照指示安裝
    過程中有 Local Package Directory, 會把安裝檔載在這, 下次安裝就不用再次下載
> Select Packages 時, 搜尋 "gcc-g++"
     安裝 Devel 裡的
     cygwin32-gcc-g++: GCC for Cygwin 32 bit toolchain (C++)
     gcc-g++: GNU Compiler Collection (C++)
     [無效]cmake: Cross-platform makefile generation system
     make: The GNU version of the 'make' utility

Set Windows Environment Variables
新增 CYGWIN_HOME=<install dir>
PATH加入 %CYGWIN_HOME%/bin






2014年3月21日 星期五

OpenGL - Render Cube by Index Buffer

Last Update: 2014/03/21 17:28+08
Type: Note



glDrawArrays 僅是依 vertices 的順序繪
就是沒有 index buffer
要用 glDrawElements, 依 indecies 順序
std::vector vertices = std::vector(8);

PxVec3 geometry = PxVec3(2.0f,2.0f,2.0f);

vertices[0] = PxVec3(-geometry.x, geometry.y, geometry.z);//left-up-front
vertices[1] = PxVec3(geometry.x, geometry.y, geometry.z);//right-up-front
vertices[2] = PxVec3(-geometry.x, -geometry.y, geometry.z);//left-bottom-front
vertices[3] = PxVec3(geometry.x, -geometry.y, geometry.z);//right-bottom-front

vertices[4] = PxVec3(-geometry.x, geometry.y, -geometry.z);//left-up-back
vertices[5] = PxVec3(geometry.x, geometry.y, -geometry.z);//right-up-back
vertices[6] = PxVec3(-geometry.x, -geometry.y, -geometry.z);//left-bottom-back
vertices[7] = PxVec3(geometry.x, -geometry.y, -geometry.z);//right-bottom-back

unsigned int indecies[24] = {
 0,2,3,1,
 1,3,7,5,
 4,6,2,0,
 4,0,1,5,
 2,6,7,3,
 6,4,5,7
};

{
 /*Render*/
 glPointSize(5);
 glColor3f(1.0f,1.0f,1.0f);


 glEnableClientState(GL_VERTEX_ARRAY);

 glVertexPointer(3, GL_FLOAT, 0, &vertices[0].x);
 glDrawArrays(GL_POINTS, 0, vertices.size());

 GLuint indexBuffer;
 glGenBuffers(1, &indexBuffer);
 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
 glBufferData(GL_ELEMENT_ARRAY_BUFFER, 24 * sizeof(unsigned int) , indecies, GL_STATIC_DRAW);

 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
 glDrawElements(
  GL_QUADS,
  24,
  GL_UNSIGNED_INT,
  (void*)0);

 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 glDeleteBuffers(1, &indexBuffer);


 glDisableClientState(GL_VERTEX_ARRAY);

 glPointSize(1.0f);
}

OpenGL - Render Points with glDrawArray

Last Update: 2014/03/21 16:48+08
Type: Note



std::vector vertices = std::vector(8);

PxVec3 geometry = PxVec3(1.0f,1.0f,1.0f);

vertices[0] = PxVec3(-geometry.x, geometry.y, geometry.z);//left-up-front
vertices[1] = PxVec3(geometry.x, geometry.y, geometry.z);//right-up-front
vertices[2] = PxVec3(-geometry.x, -geometry.y, geometry.z);//left-bottom-front
vertices[3] = PxVec3(geometry.x, -geometry.y, geometry.z);//right-bottom-front

vertices[4] = PxVec3(-geometry.x, geometry.y, -geometry.z);//left-up-back
vertices[5] = PxVec3(geometry.x, geometry.y, -geometry.z);//right-up-back
vertices[6] = PxVec3(-geometry.x, -geometry.y, -geometry.z);//left-bottom-back
vertices[7] = PxVec3(geometry.x, -geometry.y, -geometry.z);//right-bottom-back


{/*Render*/
 glPointSize(5);
 glColor3f(1.0f,1.0f,1.0f);


 glEnableClientState(GL_VERTEX_ARRAY);

 glVertexPointer(3, GL_FLOAT, 0, &vertices[0].x);
 glDrawArrays(GL_POINTS, 0, vertices.size());

 glDisableClientState(GL_VERTEX_ARRAY);
 
 glPointSize(1.0f);
}

2014年3月20日 星期四

Google Project with SVN

Last Update: 2014/03/20 23:30+08
Type: Note (未完)


Apply for a new Google Project

(待續...)



TortoiseSVN


tortoisesvn 下載 SVN 工具
> 照指示安裝
> 建一個資料夾
> 點右鍵 [SVN Checkout...]
   > URL of repository: "https://<google project name>.googlecode.com/svn/trunk/"
   > Click OK
有更動要 Commit 的話
用 google account, 但密碼是用 google project專用的



Eclipse Install Subclipse


先到 subclipse.tigris.org 的 subclipse Download and Install 找你要的版本(for eclipse, e.q. http://subclipse.tigris.org/update_1.10.x) 並複製起來

在 Eclipse
> Help
> Install New Software ...
   > Work with: "http://subclipse.tigris.org/update_1.10.x" (剛才複製的網址)
   > 中間的核取清單 勾選 [Subclipse]
   > [Next]
   > 其餘用 default 到安裝完, 重啟



Eclipse connect to google project


從你的 Google Project 首頁 的頁籤中, 找到 Source
它會有個 Checkout 的連結 一般為 https://<google project name>.googlecode.com/svn/trunk/

在Eclipse
> Window
> Show View
> Other
> SVN/SVN Repositories (SVN檔案庫)
> OK
> 在新開啟的window(SVN檔案庫) 空白處按右鍵
   > 新增 > 檔案庫位置
   > Url: "https://<google project name>.googlecode.com/svn/trunk/"
   > Finish


---Share Project---
將Project更新上去

在Eclipse
> 在你的 Project 上, 點擊右鍵
> Team > Share Project ...
   > 選 [SVN]
   > Click [Next]
   > 使用現有檔案庫位置(剛剛新增的)
   > 接著照指示操作


---取回專案---
(待續...)



2014年3月2日 星期日

Naming Rule of Program

Last Update: 2014/03/03 14:12+08
Type: Note (未完)



大寫=Upper, 小寫=Lower
此篇未完成


C++
  • Namespaces are expected to be all lower case, this is borrowed form Java and C++
  • Functions within namespaces are expected to be lower case, with words connected by underscores. This is borrowed from traditional C programming conventions, as well as traditional Slick-C conventions. Couldn't borrow ideas from Java here...
  • Class names are mixed case and should start with an upper case letter. This is borrowed from Java and C#
  • Function names within classes are mixed case and should start out with a lower case letter. Again, borrowed from Java style
  • Class member variables should start with "m_" and can be mixed case
  • Static class member variables should start with "s_" and can be mixed case
  • Constants, such as enumerations, should be all upper case



Java
  • package(類似namespace) 全部字母為 Lower
  • function 第一個單字(word)的第一個字母為 Lower, 而後的單字開頭為 Upper
  • class 第一個字母為 Upper



VC++(MS)
  • namespace 第一個字母為 Upper
  • function ?
  • class 第一個字母為 Upper



C#(MS)
  • namespace 第一個字母為 Upper
  • function 第一個字母為 Upper, 而後的單字開頭為 Upper
  • class 第一個字母為 Upper



2014年2月12日 星期三

PHP - 用自己的/簡單的 SMTP 測試 Send EMail

Last Update: 2014/02/12 18:05+08
Type: Note



在 %php目錄/php.ini 裡
SMTP = msa.hinet.net ;hinet網路
;or SMTP = seed.net.tw ;seed網路

sendmail_from = admin@localhost



MySql 手動安裝 & phpmyadmin

Last Update: 2014/02/12 17:31+08



---Content---

下載好 MySQL (非*.msi) 版本後, 解壓縮
用 windows command (系統管理員身份), 並且到 MySQL目錄/bin 底下
執行 mysqld.exe --install
即可創建service
記得去啟動service才能用

此時的root並沒有密碼
有必要的話可以去修改
這邊我用 phpmyamdin 去管理 MySQL
phpmyadmin 只要下載解壓縮到 apache 底下的 htdocs 目錄就可以用了
但登入時預設是需要密碼的 可以到 /phpMyAdmin/config.inc.php 去修改設定檔
找到
$cfg['Servers'][$i]['AllowNoPassword'] = false;
改成
$cfg['Servers'][$i]['AllowNoPassword'] = true;
就可以用無密碼登入
進入後記得新增你要用的admin
每個帳號要新增2次, 一次選 [任意主機],一次選 [本地]





phpMyAdmin 太久沒操作 自動登出的問題

到 phpMyAdmin\libraries\config.default.php
$cfg['LoginCookieValidity'] = 1440;
把時間拉長即可, 單位是秒數





2014年2月2日 星期日

GAE Java - Parent / Child pair

Last Update: 2014/02/02 16:39+08
Type:Note

--- Intro ---

我們在 GAE Toturial 可以看到 Relastionship 的設置
Owned One/One, One/Many
Unowned One/One, One/Many, Many/Many

這篇要講在設計上, 用 One/Many
但使用上, 卻常常要從 child 去找 parent
例如, 一個網站上的一個使用者, 他可能擁有多個 email
該怎麼 declare entities


2014年2月1日 星期六

Linux Ubuntu 零碎記事

Last Update: 2016/2/10 22:54+08
Type: Note



Update All package
sudo apt-get update
sudo apt-get upgrade



Javascript - Other

Last Update: 2010/12/28 13:51+08


Javascript Other (雜項、未整理)
======================================================

Convert between Char and Integer:
var str = "abc";
alert(str.charAt(0) +" = " + str.charCodeAt(0));
alert(String.fromCharCode(99));



======================================================

Client Rectangle:
alert(document.getElementById("myDiv").getBoundingClientRect().left);
//return is [left, top, right, bottom, width, height]
//its native code, support IE, Chrome, FireFofx, Safari?, Opera?



======================================================



匯入多個 vcf 檔到gmail

Last Update: 2014/02/02 15:08+08
Type: Note


Windows Command - Copy 可以合拼多個檔案
用下述指令
command: copy /B *.vcf all_in_one.vcf
就會變成一個VCF了
但我們的VCF檔結尾可能會讓gmail的匯入功能誤判
所以讓每筆資料間隔個幾行比較安全
可以用 Notepad++ 置換 "BEGIN" -> "\n\nBEGIN" (regular expression)
再匯入到gmail即可



2014年1月31日 星期五

GAE Java - DatastoreService Set Parent-Child

Last Update: 2014/02/01 00:01+08
Type:Note

DatastoreService gaeDatastore = DatastoreServiceFactory.getDatastoreService();

Entity user = gaeDatastore.get(KeyFactory.stringToKey("aglzaG9wc21lbnVyEwsSBlNtVXNlchiAgICAgICoCgw"));
Entity userEMail = gaeDatastore.get(KeyFactory.stringToKey("aglzaG9wc21lbnVyGAsSC1NtVXNlckVNYWlsGICAgICAgKgJDA"));

userEMail.setProperty("relUser", user.getKey());
gaeDatastore.put(userEMail);

@SuppressWarnings("unchecked")
Collection emailList = (Collection) user
  .getProperty("relSetUserEMail");
if(emailList == null) emailList = new ArrayList();
emailList.add(userEMail.getKey());
user.setProperty("relSetUserEMail", emailList);
gaeDatastore.put(user);



GAE Java - DatastoreService Get All Kind

Last Update: 2014/01/31 23:58+08
Type: Note

DatastoreService gaeDatastore = DatastoreServiceFactory.getDatastoreService();

Query query = new Query(Entities.KIND_METADATA_KIND);
Iterable entityIterable = gaeDatastore.prepare(query).asIterable();
for(Entity entity : entityIterable) {
 System.out.println("Entity kind: " + entity.getKey().getName());
}



2014年1月4日 星期六

Linux vi & vim

Last Update: 2015/3/8 22:12+08
Type: Note



忘了從哪裡看到的...
複製-貼上
> 先將游標移到要開始的位置
> 按下"v",command 出現"VISUAL"
> 移動游標到要結束的位置,移動時可以看到有些字開始反白了,這就是選取的區域。
> 按下"d"作cut動作。 或是"y"作copy動作
> 可以看到反白不見,command的"VISUAL也不見了。
> 移動游標到目的位置
> 按下"p" 貼上


若不小心按到 Ctrl+s (中止終端機顯示)
可以按 Ctrl+q 恢復

Search
/search_text
vim
q = quit
w = write

:wq = 儲存離開



2014年1月2日 星期四

Unix & Linux 壓縮

Last Update: 2014/1/5 14:34+08
Type: Note



.tar
解壓:tar xvf FileName.tar
壓缩:tar cvf FileName.tar DirName
(注:tar是包裹(把多個檔案合成一個),不是壓缩!)
---------------------------------------------
.gz
解壓1:gunzip FileName.gz
解壓2:gzip -d FileName.gz
壓缩:gzip FileName
.tar.gz
解壓:tar zxvf FileName.tar.gz
解壓:tar zxvf FileName.tar.gz -C DirPath
壓缩:tar zcvf FileName.tar.gz DirPath
---------------------------------------------
.bz2
解壓1:bzip2 -d FileName.bz2
解壓2:bunzip2 FileName.bz2
壓缩: bzip2 -z FileName
.tar.bz2
解壓:tar jxvf FileName.tar.bz2
壓缩:tar jcvf FileName.tar.bz2 DirName
---------------------------------------------
.bz
解壓1:bzip2 -d FileName.bz
解壓2:bunzip2 FileName.bz
壓缩:未知
.tar.bz
解壓:tar jxvf FileName.tar.bz
壓缩:未知
---------------------------------------------
.Z
解壓:uncompress FileName.Z
壓缩:compress FileName
.tar.Z
解壓:tar Zxvf FileName.tar.Z
壓缩:tar Zcvf FileName.tar.Z DirName
---------------------------------------------
.tgz
解壓:tar zxvf FileName.tgz
壓缩:未知
.tar.tgz
解壓:tar zxvf FileName.tar.tgz
壓缩:tar zcvf FileName.tar.tgz FileName
---------------------------------------------
.zip
解壓:unzip FileName.zip
壓缩:zip FileName.zip DirName
---------------------------------------------
.rar
解壓:rar a FileName.rar
壓缩:rar e FileName.rar