0

Linux Backup / Clone Disk

I want to clone my entire disk to to new disk using Linux.
I just need to write a simple command using dd and specify if (input file / disk) and of (output file).

dd if=/dev/sda of=/dev/sdb
 
To get get the current progress of disk copy / cloning 
I need to know the process id of dd process. 
Using command belows I can get the process id.

ps aux | grep -i dd

To make the progress shown on the console I need to write the following command

kill -SIGUSR1 


Reference :

http://www.thegeekstuff.com/2010/10/dd-command-examples/
http://serverfault.com/questions/4906/using-dd-for-disk-cloning
0

Linux - Sync time using google web server

Reference : http://superuser.com/questions/307158/how-to-use-ntpdate-behind-a-proxy

I got problem to sync time on my Linux controllers using ntpdate because they are under proxies & firewall. I found a simple solution and it's using google web server time.
Execute this
sudo date -s "$(wget -S "http://www.google.com/" 2>&1 | grep -E '^[[:space:]]*[dD]ate:' | sed 's/^[[:space:]]*[dD]ate:[[:space:]]*//' | head -1l | awk '{print $1, $3, $2, $5 ,"GMT", $4 }' | sed 's/,//')"
if the timezone is not configured yet, simply run this command
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime 
or using wizard
dpkg-reconfigure tzdata
0

Skip MySQL temp table

I have a problem where MySQL has taken a long time to copy the data to a temporary table.
I found a solution at:

http://stackoverflow.com/questions/7532307/skip-copying-to-tmp-table-on-disk-mysql

But in this problem, I changed the / tmpfs to / dev / shm.
More information about the / dev / shm can be found here

http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html

Step I:

1. Change the configuration of MySQL to use / dev / shm as temp tables directory

2. Change tmp_table_size = 2K
0

C# textbox with double value filter

Simply handle KeyPress event. Allow copy, paste, cut and backspace too.

private void txtSpadRef_KeyPress(object sender, KeyPressEventArgs e)
{
  Double isNumber = 0;
  String s = e.KeyChar.ToString();
  int[] allowedChar = new int[] {3,8,22,24 };
  foreach (int i in allowedChar) { 
    if(e.KeyChar.Equals(Convert.ToChar(i))){
      return;
    }
  }

  if (s == "." && txtSpadRef.Text.IndexOf(".") < 0)
  {
    s += "0";
  }
  e.Handled = !Double.TryParse(s, out isNumber);
}



0

Row Locking With MySQL

Source : http://www.xpertdeveloper.com/2011/11/row-locking-with-mysql/

Steps:
  1. Start tarnsaction
  2. Lock the desired row by using normal select statement and add FOR UPDATE or LOCK IN SHARE MODE in the back.
  3. Update the row(s)
  4. Commit (update) / Rollback (revert)
    For example :
        SELECT * FROM table_name WHERE id=10 FOR UPDATE;
        SELECT * FROM table_name WHERE id=10 LOCK IN SHARE MODE;

Any lock placed with LOCK IN SHARE MODE will allow other transaction to read the locked row but it will not allow other transaction to update or delete the row.

Any lock placed with the FOR UPDATE will not allow other transactions to read, update or delete the row. Other transaction can read this rows only once first transaction get commit or rollback. 
0

MySQL Cache

Source : http://www.techiecorner.com/45/turn-on-mysql-query-cache-to-speed-up-mysql-query-performance/

It's a very simple.
Simply add to my.ini and restart MySQL service.
query-cache-type = 1          [0 (disable / off), 1 (enable / on) and 2 (on demand)]
query-cache-size = 20M     [the cache size)]

It will boost the performance. For me almost 5x faster.

:)
0

GWT - Add touch support to canvas

I have worked in the image viewer with support GWT scroll and touch.
The audience images using canvas + SVG transformation is detected so that the image can be panned and zoomed.No problems with scrolls, but I have a problem when showing images on smart phones.I have tried several other methods to handle events on canvas in GWT but failed.

Finally, I found an example of event handling in native JS and give a try. Luckyly it works.
I lost the URL of the referring page, but I'll try to find and update this post later.

The example :
I put all the event declaration in a function.
private native void attachTouch(JavaScriptObject ele) /*-{
    var ref = this;
    ele.ontouchstart = function(evt) {
      evt.preventDefault();
      var x2=-100;
      var y2=-100;
      if(evt.touches.length > 1){
        x2=evt.touches[1].pageX;
        y2=evt.touches[1].pageY;
      }
      ref.@net.vcari.webipc.client.graphics.ImageViewerSvgPanel::setInitialTouch(IIII)(evt.touches[0].pageX, evt.touches[0].pageY,x2,y2);
    }
    ele.ontouchmove = function(evt) {
      evt.preventDefault();
      var x2=-100;
      var y2=-100;
      if(evt.touches.length > 1){
        x2=evt.touches[1].pageX;
        y2=evt.touches[1].pageY;
      }
      ref.@net.vcari.webipc.client.graphics.ImageViewerSvgPanel::onTouchMove(IIII)(evt.touches[0].pageX, evt.touches[0].pageY,x2,y2);
    }
    ele.ontouchend = function(evt) {
      evt.preventDefault();
      ref.@net.vcari.webipc.client.graphics.ImageViewerSvgPanel::onEndTouch(II)(evt.pageX, evt.pageY);
    }
  }-*/;

Add touch events to the canvas:
attachTouch(canvas.getElement());

Yayy.....
 
Copyright © peyotest