0

GWT Property Grid Readonly

In my case I want to set the property grid to read only mode.
How I can do that?

  1. Readonly. Can't copy.

    Just add the editor event listener of the property panel, and on doBeforeEdit, set to always return false;
    LTCInfoGrid.addEditorGridListener(new EditorGridListenerAdapter(){
    @Override
    public boolean doBeforeEdit(GridPanel grid, Record record, String field, Object value, int rowIndex, int colIndex) {
    return super.doBeforeEdit(grid, record, field, value, rowIndex, colIndex);
    }
    )};

  2. Read only. Can copy & modified but reset the changes.

    Add the listener to editor listener, on doValidateEdit, set to always return false

    LTCInfoGrid.addEditorGridListener(new EditorGridListenerAdapter(){

    @Override
    public boolean doValidateEdit(GridPanel grid, Record record, String field, Object value, Object originalValue, int rowIndex, int colIndex) {
    return false;
    }
    });
0

SSH login without password

Source : http://linuxproblem.org/art_9.html
Note : Aku dah try. Jalan.

Your aim

You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):

a@A:~> ssh b@B mkdir -p .ssh

b@B's password:

Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:

From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B hostname
B
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:

* Put the public key in .ssh/authorized_keys2
* Change the permissions of .ssh to 700
* Change the permissions of .ssh/authorized_keys2 to 640
0

Web Auto Update (Linux + PHP)

In my project, the controller will be place at the remote site (like sabah & sawarak) and having sluggish internet connection. I need the controller to automatic update the firmware during the transfer.

How to do it?
  1. download the update script.

    wget http://192.168.0.8/ipvision-client/tools/autoupdate.php?id=IPV0001 -O autoupdate.sh

  2. Change the script file permission to allow execute.
    /bin/chmod 777 autoupdate.sh

  3. Execute the script

    bin/sh /tmp/autoupdate.sh

  4. update the status, so this operation not reoccur.

    wget http://192.168.0.8/ipvision-client/tools/autoupdate.php?id=IPV0001&action=done

  5. put the script on cron job.

0

Fileupload firmware update (linux + php)

I would like to perform the firmware update over file upload in my current project.
In my case I'm using Linux + PHP running on my vortex86SX controller.

How to do it ??

  1. Just pack all the updated files together and create a installation script (shell script) called installupdate.sh.
  2. Since shell script created is created on Windows, Linux is having problem to execute the script since it don't understand the additional trail ("\r") for new line. I use this command to remove the "\r" character.

    /bin/cat /tmp/installupdate/installupdate.sh | /bin/tr -d "\r" > /tmp/installupdate
  3. change permission of installation script to enable execute.
  4. run the installation script
  5. remove all the temporary files
Full code :
function installupdate(){
$uploadfile = '/tmp/installupdate.zip';
//phpinfo();
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile)) {
$cmd='/bin/mkdir /tmp/installupdate
/bin/unzip -o /tmp/installupdate.zip -d /tmp/installupdate
cd /tmp/installupdate/
/bin/cat /tmp/installupdate/installupdate.sh | /bin/tr -d "\r" > /tmp/installupdate/installupdate.sh
/bin/chmod 777 /tmp/installupdate/installupdate.sh
/bin/sh /tmp/installupdate/installupdate.sh
/bin/rm /tmp/installupdate.zip
/bin/rm /tmp/installupdate -r
'
;
echo "File is valid, and was successfully uploaded.\n";
system("$cmd");
} else {
echo "Possible file upload attack!\n";
}
}
0

GWT-Ext & PHP , Glassfish & Apache

Berikut cara macam mana nak guna GWT-Ext dalam Galssfish dan data dalam Apache-PHP.

1. Install Quercus. Ni carik post aku sebelum ni.
2. Create gateway script dalam glassfish (php-Quercus). Nama fail sebaiknya sama dengan nama fail dalam apache (php).

Fail scriptnya adalah seperti di bawah. Support untuk GET, POST & SESSION.


// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://localhost/adapt-gwt/index.php");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);

// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>
0

Install quercus -100% Java implementation of the PHP

Berikut adalah cara-cara untuk install quercus.

1. Download fail .war dari web http://quercus.caucho.com/
2. Deploy fail .war dalam glassfish.
3. Extract fail .war dan copy semua fail .jar dalam folder /WEBINF/lib/ ke folder GLASSFISH_HOME/domains/domain/lib.
4. Tambah servlet & mapping dalam web.xml


<servlet>

<servlet-name>Quercus Servlet</servlet-name>

<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Quercus Servlet</servlet-name>

<url-pattern>*.php</url-pattern>

</servlet-mapping>



6. create fail index.php dan deploy.
7. Try access fail php dari web browser.
0

GWT-Ext dengan PHP

Oleh kerana aplikasi GWT-Ext perlu menggunakan JAVA, agak susah untuk menggunakan data dari domain yang berlainan. Contohnya :

GWT -Glassfish guna port 16476.
PHP-Apache guna port 80.

Terdapat 2 cara untuk menggunakan php.
1. Install quercus -100% Java implementation of the PHP dan guna quercus ni saja.
2. Install quercus -100% Java implementation of the PHP dan guna PHP pada apache web server pada port 80. Kena pakai CURL.
 
Copyright © peyotest