To disconnect project from SVN, right-click on the project and select Team->Disconnect.

/** * Show how to find the degree of a slope. * @author Xuan Ngo */ public class Trigonometry { public static void main(String[] args) { /** * All trigonometric functions in java.lang.Math return values in radians. * Therefore, you can use the Math.toDegrees() to convert to degree. * The inverse of sin, cosine and tangent are arcsine, arccosine and arctangent. */ double dSlope = 1; // 1=y/x=1/1 double dRadian = Math.atan(dSlope); double dDegree = Math.toDegrees(dRadian);
-- Check what indexes are already defined for a table. SHOW INDEX FROM tablename; -- Create the index. CREATE INDEX index_name ON tablename(col1, col2, ...);
CREATE TABLE new_table ENGINE=MEMORY AS SELECT * FROM old_table;
SELECT table_schema "Database Name" , sum( data_length + index_length ) / 1048576 AS "Database Size in MB" , sum( data_free )/ 1048576 AS "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema ;
Output:
+--------------------+---------------------+------------------+ | Database Name | Database Size in MB | Free Space in MB | +--------------------+---------------------+------------------+ | bt_96580 | 1.1242 | 0.0014 |
import java.awt.Toolkit; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import javax.imageio.ImageIO; /** * Take screenshots of the full screen. * @author Xuan Ngo */ public class PrintScreen { public static void main(String[] args) { // Print help how to use this application. if (args.length != 3) {
Using the object data type instead of its primitive counter part is very expensive. In fact, object data type is approximatively 43 times slower than its primitive counter part. However, I have to scale up to 1 billion iterations to see the difference.
/** * Performance of primitive data type vs object data type. * @author Xuan Ngo * */ public class PrimitiveVsObject { public static void main(String[] args) { long lStart = 0; long lEnd = 0; int lMaxSize = 1000000000; // 1 billion. // Primitive data type
When you use primitive data types(i.e int, double and float) with hibernate, you will not be able to convert them to null because Java doesn't allow them to be null. In order for these data types to be null, use their object counter part.(i.e Integer, Double, Float). However, it is very expensive to use the object data type. Therefore, use them only when needed.
/** * Add variable values in a string. * @author Xuan Ngo * */ public class ParamterizedString { public static void main(String[] args) { String[] aAnimals = new String[]{"horse", "lion", "zebra", "elephant"}; String s = String.format("The zoo contains: %s, %s, %s, %s.", aAnimals); System.out.println(s); // The zoo contains: horse, lion, zebra, elephant. } }
It is located at Window->Preferences->Java->Code Style->Formater.