2012年11月27日 星期二

簡易PHP +Shell Programming環境 (eclipse+vrapper)

最近在找能夠幫助我維護php程式的環境,找到了這個版本的eclipse


能夠提供php簡易的錯誤parsing 功能,再加上


擁有快速的編輯介面 (仿vi)

最後安裝Shell Editor

ShellEd Wiki

將.vrapperrc檔案放置於

C:\Users\帳號名\

底下

內容設定可參考

2012年11月20日 星期二

[VAIO SZ58 WebCam Driver] Sony Visual Communication Camera VGP-VCC7 Win 7 64bit drivers


在SONY VAIO SZ58 上安裝Win 7 64-bit時,發生WebCam無法啟動,所以找了一下driver,終於找到合用的,如下



How to use:
1.) In device managerupdate the driver for the Sony Webcam, 'browse my computer...'. 
2.) Now select 'LET ME PICK FROM A LIST.....'.
3.) Click 'HAVE DISKand then browse to the path of the extracted zip file.
4.) 'Sony Visual Communication Camera VGP-VCC7is now selectedClick NEXT.
5.) Windows can't verify publisher.... who cares. 'INSTALL THIS DRIVER SOFTWAREANYWAY'
6.) Test in Skype

2012年11月5日 星期一

Linux vi 存檔錯誤

File-encodings setting (notice the plural) does not include utf-8, so Vim does not try to save it with that encoding. It probably either tries to save it using plain old ASCII encoding or something like latin1, which does not include this char and therefore conversion fails. 
You should fix your 'fencs' setting to something like ucs-bom,utf-8,default,latin1 or you can force Vim to save it in utf-8 encoding, by issuing :w ++enc=utf8 filename. (It might be, that this needs the +multi_byte feature, which is only enabled, when compiling at least a big version of Vim). 

簡單的說就是檔案含有UTF-8的內容,vim存檔時沒有使用UTF-8的encoding存檔所產生的錯誤。

解決方法只需在存檔時加入一個option即可,如下:

:w ++enc=utf8 FileName

2012年9月12日 星期三

System Update Error "Failed to fetch http://..."

當在做系統update時,出現無法Fetch....的錯誤訊息時,可嘗試下列commands


First confirm that you are able to browse other websites. 
Then, Run this commands:  sudo mv /var/lib/apt/lists{,bakjune4};
sudo mv /var/cache/apt/archives/partial{,bakjune4};
sudo apt-get update;
sudo apt-get upgrade;  


Linux Terminal 快捷鍵

Paste copied Text : [Shift] + [Insert]
Stop : [Ctrl] + [C]
Paste High Lighted Text : [Middle button]
Create New Terminal Tab : [Ctrl] + [T]
Switch Terminal Tabs : [Alt] + [#(Number)]
Close Current Terminal Tab : [Ctrl] + [Shift] + [W]

待續...

2012年7月3日 星期二

使用Eclipse+Vim 做為Python 的 IDE

最近開始使用Python練習寫一些程式,蒐集了一下資訊,網友建議使用eclipse,再加上個人比較偏好使用vim,所以找了下方法,大致分為兩種。
基本上安裝好下面的軟體即可! 注意Eclipse的版本有限定是v.3.7

Python v.3
Eclipse v.3.7 (要安裝Pydev,並設定Python interpreter)
gvim v.7
Eclim v.1.76

此方式是把vim 內嵌在eclipse裡,好處是vim的所有功能皆有,但跟eclipse本身介面會有點切割。如eclipse的快捷鍵必須要在滑鼠的focus不在vim視窗裡才有效、eclipse的auto-completion的功能失效、vim編輯完一定要存檔,eclipse自動存檔的功能無效等等。


基於以上理由,所以我選擇第二種方式


2.
第二種方式沒有限定版本,我只列出我安裝的版本,需要的軟體如下


Python v.3.2
Eclipse 4.2

接著安裝Eclipse plugins
在 Help -> Install New Software... -> Work with: 欄位加入要安裝的plugin address


  • Pydev,並設定Python interpreter,預設路徑是"C:\Python32"
http://pydev.org/updates


  • Vrapper,仿vim的plugin

http://vrapper.sourceforge.net/update-site/stable


  • ColorScheme,能夠把editor設成vim的配色

http://eclipse-color-theme.github.com/update

設定好效果如下



如此設定的好處是保有vim editor的操作,也同時擁有eclipse的auto completion的功能。只是會犧牲掉vim一些特有的功能,但對我來說影響不大。

2012年5月23日 星期三

使用WireShark 抓取SOAP封包

Filter輸入ip.addr==A&&ip.addr==B
A:為你Client之IP
B:為你Server之IP

會filter出Client與Server間的封包,大部分為SOAP。選擇其一封包並於其上按右鍵,選擇 "Follow TCP Stream",此時就會跳出一個視窗,show出所有的封包內容,就可以一次看到所有SOAP的XML資料。

Done

Linux環境下 console模式下抓封包



我的使用方式,開兩個terminals,一個執行
$ tcpdump -i eth0 -w abc.cap

另一個執行
$ tcpdump -r abc.cap 

使用tcpdump指令3個會用到的options


Ex.抓封包存入abc.cap檔案
$ tcpdump -i eth0 -w abc.cap 

Ex. 抓封包,分割每個儲存的封包(size 1500bytes)
$ tcpdump -i eth0 -s 1500 -w a.cap 

Ex. 讀封包
$ tcpdump -r abc.cap 

p.s. 必須使用root權限

2012年5月22日 星期二

[SOAP] No address associated with

PHP SOAP在Load wsdl時發生的錯誤
Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: No address associated with 
相關討論串Non-SOAP bindingBug#50443

解決方法為移除無Address的port之Binding,如下紅色部分。

Example:


  
    https://services.contentdirect.tv/v3.0/SubscriberService.svc"/>
  
  



2012年5月18日 星期五

VAIO 顯卡更新成官網最新driver方法

最近想要把我的VAIO sz58的顯示卡驅動程式更新到最新時,發現nVidia官方driver無法安裝,所以google了一下解決方法



依照以下步驟:
1. 下載對應到官方網站最新nVidia驅動程式版本,先執行一次,他會把安裝軟體解壓縮到C槽。
2. 到下面路徑找到兩個檔案 nvaa.inf, nvac.inf (版本號296.10會不一定會一樣)

C:\NVIDIA\DisplayDriver\296.10\WinVista_Win7\International\Display.Driver\

3. 修改裡面的內容 (記得先備份),每個檔案有3個sections要改,有兩個是緊接著[Manufacturer]這個section之後的兩個sections,另一個是[Strings]這個section,要加的內容都加在所屬section的最後面。 (紅色字體為要加的內容)

另外特別注意的是"PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D" 此為你的顯卡硬體裝置ID,可在Device manager裡查看,如下圖



nvaa.inf
...

[Manufacturer]
%NVIDIA_A% = NVIDIA_SetA_Devices,NTx86.6.0,NTx86.6.1

[NVIDIA_SetA_Devices.NTx86.6.0]

%NVIDIA_DEV.0407.0770.152D% = Section001, PCI\VEN_10DE&DEV_0407&SUBSYS_0770152D 
%NVIDIA_DEV.0407.1515.1043% = Section001, PCI\VEN_10DE&DEV_0407&SUBSYS_15151043 
...
%NVIDIA_DEV.0427.01% = Section001, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D


[NVIDIA_SetA_Devices.NTx86.6.1]
%NVIDIA_DEV.0407.0770.152D% = Section002, PCI\VEN_10DE&DEV_0407&SUBSYS_0770152D 
%NVIDIA_DEV.0407.1515.1043% = Section002, PCI\VEN_10DE&DEV_0407&SUBSYS_15151043 
...
%NVIDIA_DEV.0427.01% = Section002, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D


[Strings]
DiskID1 = "NVIDIA Windows Vista / Windows 7 (32 bit) Driver Library Installation Disk 1"
NVIDIA = "NVIDIA"
NVIDIA_A = "NVIDIA"
NVIDIA_DEV.0407.0770.152D = "NVIDIA GeForce 8600M GT"
NVIDIA_DEV.0407.1515.1043 = "NVIDIA GeForce 8600M GT "
...
NVIDIA_DEV.0427.01 = "NVIDIA GeForce 8400M GS"

nvac.inf
...


[Manufacturer]
%NVIDIA_A% = NVIDIA_SetA_Devices,NTx86.6.0,NTx86.6.1

[NVIDIA_SetA_Devices.NTx86.6.0]
%NVIDIA_DEV.0405.011D.1025% = Section001, PCI\VEN_10DE&DEV_0405&SUBSYS_011D1025 
%NVIDIA_DEV.0405.011E.1025% = Section001, PCI\VEN_10DE&DEV_0405&SUBSYS_011E1025 
...
%NVIDIA_DEV.0427.01% = Section001, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D

[NVIDIA_SetA_Devices.NTx86.6.1]
%NVIDIA_DEV.0405.011D.1025% = Section002, PCI\VEN_10DE&DEV_0405&SUBSYS_011D1025 
%NVIDIA_DEV.0405.011E.1025% = Section002, PCI\VEN_10DE&DEV_0405&SUBSYS_011E1025 
...
%NVIDIA_DEV.0427.01% = Section002, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D

[Strings]
DiskID1 = "NVIDIA Windows Vista / Windows 7 (32 bit) Driver Library Installation Disk 1"
NVIDIA = "NVIDIA"
NVIDIA_A = "NVIDIA"
NVIDIA_DEV.0405.011D.1025 = "NVIDIA GeForce 9500M GS"
NVIDIA_DEV.0405.011E.1025 = "NVIDIA GeForce 9500M GS "
...
NVIDIA_DEV.0427.01 = "NVIDIA GeForce 8400M GS"

4. 修改完後,存檔,重新執行setup.exe,此執行檔會在下面這個目錄
C:\NVIDIA\DisplayDriver\296.10\WinVista_Win7\International
5. 重開機

Done

2012年4月6日 星期五

PHP SOAP (WSDL)

最近在接觸WSDL時,碰到了一些NameSpace設定上的問題,在此memo設定方式。

WSDL file的一段

< element name='funcA' >
  < complexType >
    < sequence >
      < element name='param1' type='abc:elementA' >
      < element name='param2' type='abc:elementB' >
    < /sequence >
  < /complexType >
< /element >

< complexType name=' elementA' >
  < sequence >
    < element name='AA' type='xsd:string'>
  < /sequence > 
< /complexType >

< complexType name=' elementB' >
  < sequence >
    < element name='abc:elementBB' type='abc:BB' >
  < /sequence > 
< /complexType >

< complexType name=' elementBB' >
  < sequence >
    < element name='BBB' type='xsd:int' >
  < /sequence > 
< /complexType >

如上為一段WSDL中一段function call內容的定義,funcA有一個Complex Type的 input 參數,包著一個 sequence,裡面有兩個elements。此兩個 elements皆為自定義 variable。必須指定其所給的NameSpace (abc)。

所以就會成為以下設定
$params = array('param1'=>new SoapVar(array("AA"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc'), 'param2'=>new SoapVar(array( "elementBB"=>new SoapVar(array("BBB"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementBB', 'abc') ), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc'));

首先,先分開來看,先看怎麼定義第一個element 'param1'
new SoapVar(array("AA"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc')

再來是第二個element 'param2'
new SoapVar(array( "elementBB"=>new SoapVar(array("BBB"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementBB', 'abc') ), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc')

上面黃色部分是BB底下又包了一層complex type 'elementBBB',先不看這部分的話 其實是跟 'param1'是一樣的

最後把上面兩個elements用Array合起來,並給予name index,即完成!

如果有name沒設,或NameSpace沒設,有些server會認不出來而產生error。


2012年3月15日 星期四

Linux ~/.vimrc 設定

原文網址

在 Terminal中輸入
gvim ~/.vimrc
可設定以下內容 (以下是我個人的設定)

syntax on                           " 語法上色顯示
set ai              "自動縮排
set tabstop=2        " 設定縮排寬度 = 2
set softtabstop=2    " tab 的字元數
set shiftwidth=2           
set ruler            " 顯示右下角設定值
set ic               " 設定搜尋忽略大小寫
set ru               " 第幾行第幾個字
set hlsearc          " 設定高亮度顯示搜尋結果
set incsearch        " 在關鍵字還沒完全輸入完畢前就顯示結果
set smartindent
set history=100      " 保留 100 個使用過的指令

set nocp



colorscheme torte 

2012年3月14日 星期三

Linux File Time (atime, ctime, mtime)

st_atime
           Time when file data was last accessed. Changed by  the
           following   functions:   creat(),   mknod(),   pipe(),
           utime(2), and read(2).

st_mtime
           Time when data was last modified. Changed by the  fol-
           lowing  functions:  creat(), mknod(), pipe(), utime(),
           and write(2).

st_ctime
           Time when file status was last changed. Changed by the
           following   functions:   chmod(),   chown(),  creat(),
           link(2),  mknod(),  pipe(),  unlink(2),  utime(),  and
           write().


指令可使用
stat -c %x filename
stat -c %y filename
stat -c %z filename
或者
ls -lu  filename
ls -l    filename
ls -lc  filename


-lu    show access time and sort by name
-l     show modified time and sort by name
-lc   show ctime and sort by name

%x   Time of last access
%y   Time of last modification
%z   Time of last change

2012年3月12日 星期一

簡易 Linux FTP upload shell

簡易的FTP 檔案上傳Shell script


於Terminal中,輸入
gvim ftpUpload.sh
並輸入下列內容於此檔案
#!/bin/bash
echo file(s) upload $*;
ftp -v -i -n FTP位址 << FTPIT
user 帳戶 密碼
bin
cd /切換至要放上傳檔案的目錄
mput $*
quit
FTPIT
exit 0
存檔離開,並改變此檔案的屬性
chmod 755 ftpUpload.sh
最後,執行
./ftpUpload.sh file1.txt file2.doc file3.mov

p.s. 後面帶的參數即為要傳送的檔案名,而$*則為儲存所有arg的變數(以空格區隔)

Gvim plugin安裝於Ubuntu



以下內容出自上面原文,我再加上修改後,可於Ubuntu上安裝成功

註解程式快捷鍵plugin

於Terminal中輸入下列指令
sudo apt-get install vim-addon-manager vim-scripts
vim-addons install enhanced-commentify
即可
於Gvim中,將游標移至想要註解的那一行後按下
\+x
若要往下一行繼續註解,則按下
\+c

2012年3月6日 星期二

Ubuntu Wifi Hotspot不斷連線 斷線

在Ubuntu 11.10的版本,建立Hotspot後會不停的斷線與連線問題,嘗試了很多解法後,下面方法可以workable !
原文連結--> Cannot make Wi-Fi hotspot

1. go to System settings > Network > Wireless > Use as hotspot > Configure (or 'Edit connections' under your connections > Edit the hotspot connection)
2. Switch to IPv6 Settings tab > Set Method to 'Ignore' and confirm/save
3. in terminal (Ctrl + Alt + T) run the following command to kill all dnsmasq processes: sudo killall dnsmasq
4. go to System settings > Network > Wireless > Use as hotspot

How to dump SOAP FAULT in PHP

當SOAP function有exception發生時,可使用var_dump去顯示error msg


try
{
    throw new 
SoapFault('code''string''actor''detail''name''header');
}
catch( Exception $ex )
{
    
var_dump($ex->faultcode$ex->faultstring$ex->faultactor$ex->detail$ex->_name$ex->headerfault);
    // or
    var_dump($ex);
}
?>

搜尋此網誌