» 2013 » March の記事

~ Clone OSX86 ~

connie 2013.03.31 | Mac OSX, osx86 | | No Comments

必需東西

  1. USB TO SATA case
  2. Carbon Copy Cloner (Mac Backup software
  3. Destination HDD 要有足夠位置放晒Source HDD 的資料
  4. Chameleon BootLoader

先到Application>ultilies>Disk ulitily Format 左HDD 先

去drive 既partition到,選擇1 partition Format "Mac OS Extended(journaled)

 Screen Shot 2013-04-01 at 8.28.28 PM

之後按option, 選擇GUID PARTITION TABLE完成按OK and APPLY

Screen Shot 2013-04-01 at 8.28.38 PM

FORMAT 後回到CCC , Select Source and destination , 打password , restore , 無乜特別野的

Screen Shot 2013-04-01 at 8.24.47 PM 

完成後,reboot , BIOS指返舊HDD boot 機,會入返去舊bootloader

入到去bootloader , 唔好boot 入舊HDD, boot 去新HDD

入到去OS後重新安裝Chameleon BootLoaderScreen Shot 2013-04-01 at 8.36.30 PM

之後boot機就成了: )

~ Mount A Network Share On Ubuntu ~

connie 2013.03.26 | ubuntu | | No Comments

先要安裝以下東東

apt-get install cifs-utils

安裝後要去新增一個directory for mount network drive

mkdir /media/share

之後手動試一下連接

mount.cifs //192.168.0.0/folder/  /media/share/ -o user=USERID,pass=PASSWORD

成功的話,將佢加去開機的指令

nano /etc/fstab

加入以下的東東

//192.168.0.0/folder/  /media/share/  cifs  username=USERID,password=PASSWORD  0  0

之後reboot , 看看mount 不mount 到了: )

~ crontab on ubuntu ~

connie 2013.03.25 | ubuntu | | No Comments

先寫好個shell script,並將佢set 做可以execute

chmod 755 filename

之後去

nano /etc/crontab

建議你先set 做一分鐘run一次,睇下run 唔run 到先

*/1  *   * * *  root    /home/user/sh/backup.sh
分 時 日 月 週 執行者身份  指令串

/ 代表毎隔幾耐run 一野,而 / 前需要有 * 的,上面的指令=一分鐘run 一次

如果想2月1日0:00 send email 請如下

0 0 1 2 * mail connie < /home/happy_birthday.txt

done : )

~ Socket Server and Client side in php ~

connie 2013.03.22 | php | | No Comments

首先要setup 好server side , 變更host and port

完成後要係putty 開啟server

php -q socket_server.php
<?php
//php -q socket_server.php
// 设置一些基本的变量
global $lat,$lnt;
$host = "192.168.0.1";
$port = 8888;
// 设置超时时间
set_time_limit(0);
// 创建一个Socket
$commonProtocol = getprotobyname("tcp");
$socket = socket_create(AF_INET, SOCK_STREAM, $commonProtocol);
 
//绑定Socket到端口
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
$ret = socket_listen($socket, 5);
if($ret){
    while (true){
        $spawn = socket_accept($socket) or die("Could not accept incoming connection\n");;
        echo("socket connected\n");
        if(!$spawn) break;
        $output = "Welcome to the PHP Test Server.....nice\n";
        socket_write($spawn, $output, strlen ($output)) or die("error\n");
        while($input = socket_read($spawn, 64)){
            echo($input);
        }
        echo("\n");
        socket_close($spawn);
    }
}
?>

Client Side

<?php
// 设置一些基本的变量
$host = "192.168.0.1";
$port = 8888;
// 设置超时时间
set_time_limit(0);
// 创建一个Socket
$commonProtocol = getprotobyname("tcp");
$socket = socket_create(AF_INET, SOCK_STREAM, $commonProtocol);
if(!$socket) echo "can't create socket";
//绑定Socket到端口
$result = socket_connect($socket, $host, $port) or die(socket_strerror());
if($result){
    $output="hello server!,connie";//lat:30.582029016593196;lnt:103.98662567138672
    socket_write($socket, $output, strlen ($output));
    $input = socket_read($socket, 1024);
    echo($input);
}
?>

之後係web browser 開client url , 便可以

~ add 7z compression with password for ubuntu ~

connie 2013.03.21 | ubuntu | | No Comments

先裝上7z on ubuntu

apt-get install p7zip-full

之後如果要加password 落過zip file 到可以用以下script

7z a -r -mhe=on -pmy_password output.7z a_directory
7z a -mhe=on -pmy_password output.7z a_file

 

~ Remove the Grub boot on Ubuntu ~

connie 2013.03.20 | ubuntu | | No Comments

當你的ubuntu server update 好多次之後,

就要開始清一清 Grub boot sector

唔係就會出現,以下error

/boot is using 91.2% of 227MB

先用以下cmd check 一check 現在用緊既kernels

uname -r

會出現以下的東東,不要remove 這個

3.2.0-39-generic

之後再list out all kernel which is stored in Grub boot

dpkg --list | grep linux-image

ubuntu_boot

remove uname -r 對下的kernels

sudo dpkg --purge linux-image-x.x.x.x-generic

完成後update

sudo update-grub2

 

| HOME |