2009年7月17日

Linux Console 解析度調整


以下轉貼自:

http://khwu.tw/node/25



修改開機管理程式設定值,使得Linux Console下 的解析度提高。 GRUB:


    vi /boot/grub/menu.lst

以我的menu.lst為例,在 kernel /boot/vmlinuz-2.6.18-1.2868.fc6 ro root=LABEL=/ rhgb quiet 行末加上 vga=xxx,其中xxx為下表所示的參數值。 修改後看起來像這樣


    kernel /boot/vmlinuz-2.6.18-1.2868.fc6 ro root=LABEL=/ rhgb quiet vga=792

存檔後重新啟動電腦,即可見到效果。 LILO:


    vi /etc/lilo.conf

直接找空位加入設定 vga=792,存檔後重新啟動電腦,即可見到效果。 對照表:


Colours   640x400 640x480 800x600 1024x768 1152x864 1280x1024
--------+----------------------------------------------------
4 bits | ? ? 770 ? ? ?
8 bits | 768 769 771 773 353 775
15 bits | ? 784 787 790 354 793
16 bits | ? 758 788 791 355 794
24 bits | ? 786 789 792 ? 795
32 bits | ? ? ? ? 356 ?
Colours 1600x1200
--------+---------
4 bits | ?
8 bits | 796
15 bits | 797
16 bits | 798
24 bits | 799
32 bits |

2009年7月16日

MySQL dump 匯入匯出範例

最近在處理很夭壽的爛攤子





雖然之前我也有參一咖





但很久以前就不想碰的東西竟然又回到我頭上....





真他媽的想罵髒話....(阿.....好像已經....= =)





中X學能力評量X標(這樣應該還是猜得出來吧





這鳥東西的資料量有夠大





應該說當初的規劃很鳥





早就被我料到的事情....= =





最後還是會掉到我頭上....





好了,不囉唆了= =





匯出範例:





mysqldump -u root -p DB_Name > C:\file.sql





mysqldump -u root -p DB_Name Table_Name > c:\file.sql





匯入範例:





mysql -u root -p DB_Name < C:\file.sql





匯出後只有122MB....不大啦~~





對一個施測對象是全國高中小學校學生系統來說





算還好啦,可是這只是預試....





重點在下下個月後.....OH!!!!!MY!!!!!天!!!!!!!!!





我有事,要先走

2009年7月11日

Linux 修改終端機介面 ls 的顯示顏色

以下轉貼至


http://blog.bestlong.idv.tw/2005/10/27/89





經常在 Linux shell 環境下使用 telnet, ssh …等等的終端機程式來連上主機作業的人。對於支援顏色顯示的使用者友善的方便功能,大大的提升可讀性。不過對預設的顏色想必每個人都會有不滿意的地方。以 ls 的顯示狀況來說,對目錄的深藍色在黑色背景下讀起來就相當的吃力。為了保護視力,當然就要調校一番。



先用 set 查了一下環境設定,知道設定的資料是在 /etc/DIR_COLORS.xterm 檔案中

用 vim 來編輯,修改其中 DIR 01;34 的 directory 項目設定。檔案中的注解有簡單的顏色說明,例如 01=bold 設為粗體,而 34=blue 是設為藍色。所以就依據個人喜好來選定顏色修改後存檔。然後重新連接就會看到改變後的效果。


如果不希望一個一個修改測試,可以用下面的一個 bash shell Script 來顯示以便挑選



#!/bin/bash

# Display ANSI colours.

#tiff 01;35

esc="\033["

echo -n " _ _ _ _ _40 _ _ _ 41_ _ _ _42 _ _ _ 43"

echo "_ _ _ 44_ _ _ _45 _ _ _ 46_ _ _ _47 _"

for fore in 30 31 32 33 34 35 36 37; do

line1="$fore  "

line2="    "

for back in 40 41 42 43 44 45 46 47; do

line1="${line1}${esc}${back};${fore}m Normal  ${esc}0m"

line2="${line2}${esc}${back};${fore};1m Bold    ${esc}0m"

done

echo -e "$line1\n$line2"

done



儲存成 display_ANSI_colors.sh 然後修改檔案屬性


$ chmod +x display_ANSI_colors.sh


執行檢視結果


$ ./display_ANSI_colors.sh


這樣是不是就方便許多。


以上的測試環境 Server 為 Linux Fedora Core 3 而 Client 為 WinXP 使用 PieTTY 連線。

2009年4月10日

【PHP+JS+Flash】檔案上傳的好幫手 - FancyUpload

官方網站:


http://digitarald.de/project/fancyupload/





這兩天使用時





突然發現會出現error





上官網看了一下





原來是Flash Player 10在搞鬼


(參考這篇:http://digitarald.de/journal/54706744/fancyupload-for-flash-10/





經過更新後又可以使用了





不過新版本好像有些許bug





就等待作者更新了

2009年3月28日

【PHP】filesize Fix 4Gb limit.

只能說被騙了~"~



還以為某檔案壞掉



檔案大小一直抓不正確



原來是php裡的filesize function 只支援到4 Gb.....





Fix 4Gb limit. ( Now limit 8 Gb ;))



<?php

   
function GetRealSize($file) {

       
// Return size in Mb

       
clearstatcache();

       
$INT = 4294967295;//2147483647+2147483647+1;

       
$size = filesize($file);

       
$fp = fopen($file, 'r');

       
fseek($fp, 0, SEEK_END);

        if (
ftell($fp)==0) $size += $INT;

       
fclose($file);

        if (
$size<0) $size += $INT;

        return
ceil($size/1024/1024);

    }

?>

【PHP】PHP 中的 unescape 函式

   function phpescape($str){

    
$sublen=strlen($str);

    
$reString="";

    
for ($i=0;$i<$sublen;$i++){

        
if(ord($str[$i])>=127){

            
$tmpString=bin2hex(iconv("utf-8","ucs-2",substr($str,$i,2)));    



            
if (!eregi("WIN",PHP_OS)){

                
$tmpString=substr($tmpString,2,2).substr($tmpString,0,2);

            }

            
$reString.="%u".$tmpString;

            
$i++;

        } 
else {

            
$reString.="%".dechex(ord($str[$i]));

        }

    }

    
return $reString;

}





function unescape($str) { 

         
$str = rawurldecode($str); 

         
preg_match_all("/%u.{4}|&#x.{4};|&#d+;|.+/U",$str,$r); 

         
$ar = $r[0]; 

         
foreach($ar as $k=>$v) { 

                  
if(substr($v,0,2== "%u"

                           
$ar[$k= iconv("UCS-2","utf-8",pack("H4",substr($v,-4))); 

                  
elseif(substr($v,0,3== "&#x"

                           
$ar[$k= iconv("UCS-2","utf-8",pack("H4",substr($v,3,-1))); 

                  
elseif(substr($v,0,2== "&#") { 

                           
$ar[$k= iconv("UCS-2","utf-8",pack("n",substr($v,2,-1))); 

                  } 

         } 

         
return join("",$ar); 









轉貼至:

http://www.phpchina.com/html/91/n-1091.html

2009年2月23日

【ExtJS】Grid 資料可用拖拉方式交換

var ddrow = new Ext.dd.DropTarget(Grid.getView().mainBody, {

            ddGroup : 'ddGroup',

            copy:false,

            notifyDrop : function(ddSource, e, data){

               

                var sm = Grid.getSelectionModel();

                var rows = sm.getSelections();

                var cindex = ddSource.getDragData(e).rowIndex;

                if (!this.copy){

                    for(i = 0; i < rows.length; i++) {

                        ds.remove(ds.getById(rows[i].id));

                    };

                };

                ds.insert(cindex,data.selections);

    

            }

});



grid 別忘了將 enableDragDrop設為true