Thursday, September 17, 2009

How to install Equation in Microsoft Office 2003

To resolve this problem, use Maintenance mode to install the Equation Editor to your computer's hard disk with the Run from My Computer mode.

To Install Equation Editor in Microsoft Office 2000, follow these steps:
  1. Quit all programs that are open.
  2. Click Start, point to Settings, and then click Control Panel.
  3. In Control Panel, double-click Add/Remove Programs.
  4. In the Add/Remove Programs Properties dialog box, click your Microsoft Office 2000 installation, and then click Change.
  5. In the Microsoft Office 2000 Maintenance Mode dialog box, click Add or Remove Features.
  6. In the features tree, click the plus sign (+) next to Office Tools.
  7. Click the arrow next to Equation Editor.
  8. Click Run all from My Computer.
  9. Click Update Now.

Tuesday, June 16, 2009

Convert an array to collection

import java.util.Arrays;
import java.util.List;
import java.util.Iterator;

public class ArraysExample
{
public static void main(String[] args)
{
String[] array = {"Happy", "New", "Year", "2006"};
List list = Arrays.asList(array);

Iterator iterator = list.iterator();
while (iterator.hasNext())
{
System.out.println((String) iterator.next());
}
}
}

The result of our code is:

Happy
New
Year
2006

ref: http://www.kodejava.org/examples/25.html

Thursday, June 11, 2009

How do I add AdSense to my google site?

Now, ... Google Site has new Gadget for AdSense. So, ... anyone can add your own adsense if you have existing adsense's account

If you want to add Google AdSense to your site, just follow these steps:

  1. Click the More actions drop-down menu, and select Manage site.
  2. Click Monetize on the left side of the page.
  3. Click the Monetize this site button.
  4. Create a new AdSense account or use an existing account. Follow the instructions, depending on the radio button you select.

Once you've enabled AdSense, go to any of your site's pages, click Insert, and select AdSense to insert ads within your page. You can also choose to have ads displayed in your global sidebar.

AdSense can appear at the side bar by using edit side bar and page content by using insert.

Have a fun ^^"

ref: https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=48182

Tuesday, June 9, 2009

Get number of rows in resultset

You can extract the data from the resultset from the top and rs.last() will move you to the end of the resultset.

Then, the method rs.getRow() get the row number of the last row and also shows you the number of rows in the table.

For example:

public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = getConnection();
String query = "select [table_field] from [table_name]";
stmt = conn.createStatement();

rs = stmt.executeQuery(query);
while (rs.next()) {
String id = rs.getString(1);
}
rs.last();
int rowCount = rs.getRow();
System.out.println("Number of Rows=" + rowCount);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (SQLException e) {}
}


ref: http://www.roseindia.net/java/java-get-example/number-rows-resul.shtml

Thursday, June 4, 2009

java BigDecimal problem

BigDecimal v = new BigDecimal(0.12d);
System.out.println(v);

result: 0.11999999999999999555910790149937383830547332763671875

Because ::: In Java API

public BigDecimal(double val)

Translates a double into a BigDecimal. The scale of the BigDecimal is the smallest value such that (10scale * val) is an integer.

Note: the results of this constructor can be somewhat unpredictable.

---

But ...


BigDecimal v = new BigDecimal("0.12");
System.out.println(v);

result: 0.12

Because:

The (String) constructor, on the other hand, is perfectly predictable: new BigDecimal(".1") is exactly equal to .1, as one would expect. Therefore, it is generally recommended that the (String) constructor be used in preference to this one.

ref: http://www.narisa.com/forums/index.php?showtopic=12589&st=15