Wednesday, December 5, 2007

MySQL convert or cast int to string

Suppose you have a table with 2 columns one int and other varchar. Now if you want to update varchar fields in all the records with the int value, use this query :

update table_name set varchar_Field = CAST(int_Field AS CHAR);

If you want to some text in addition to the int field, then use :

update table_name set varchar_Field = CONCAT(CAST(int_Field AS CHAR), 'sampleText');

vi search and replace all

:%s /search_text/replace_text/g

If either of the search or replace texts has a forward-slash '/', use the backward-slash '\' to escape it.

Tuesday, November 13, 2007

Understanding Object wait()

The general rule of thumb to use the wait statement is as follows. This idiom addresses the issue of both missed notifications and early notifications.

synchronized(synclock) {
while (condition_does_not_hold) {
syncLock.wait();
}
// Perform action appropriate to condition
}
// Perform action that needs to be done outside the synchronized block

When wait is called on an Object's instance ...
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

Tuesday, November 6, 2007

Double-Checked Locking

Here is a very good article on Double-Checked Locking

I liked the 4th method a lot - On Demand Lazy Initialization. Using simple concepts and achieving solution to complex problem.

"Static classes are not initialized until needed and the initialization is guaranteed to be thread-safe."

Monday, November 5, 2007

Telugu font rendering in Ubuntu Feisty Fawn

Copy and Paste these commands and restart machine or XSession(Ctrl+Alt+Backspace)
  • sudo apt-get install ttf-telugu-fonts ttf-indic-fonts language-pack-te
  • wget http://abhiomkar.googlepages.com/lohit_te.ttf
  • sudo cp lohit_te.ttf /usr/share/fonts/truetype/ttf-telugu-fonts/
  • sudo fc-cache
This information is taken from Abhinay's Blog

Friday, October 19, 2007

Install of MySQL/PHPMyAdmin aka LAMP (Linux Apache MySQL PHP)

  • sudo apt-get install mysql-server
  • sudo apt-get install apache2
  • sudo apt-get install php5
  • sudo apt-get install php5-mysql
  • sudo apt-get install phpmyadmin

More information is available at the this link

Here is the link giving step by step instructions for getting mysql/apache/php and phpmyadmin working. Tells you how to set up mysql user too.

Wednesday, October 17, 2007

How to run pre-Vista programs in Compatibility Mode

The Windows Fanatics weblog details how to use Vista's Compatibility Mode to run apps that aren't quite Vista ready. Here's how:

1. Right click the executable and click the Properties option.
2. Select the Compatibility tab.
3. Select the Run This Program in Compatibility Mode option.
4. From the drop-down list, choose the operating system you ran before upgrading to Vista.
5. If necessary, select the option to run the program as an administration.
6. Click OK.

This post is contributed by baki. He can reached at bhanukiran.j@gmail.com