Tuesday, April 25, 2017

Java - iterate over a UTF-8 string

Either read the file as UTF-8 or convert it later.

public static void main(String[] args) throws Exception {

String path = "D:\\test.txt";
FileInputStream stream = new FileInputStream(new File(path));
BufferedReader br = new BufferedReader(new InputStreamReader(stream,"UTF-8"));
String str;
while ((str = br.readLine()) != null) {
for(int i = 0; i< str.length(); ++i) {


BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String str;
while ((str = br.readLine()) != null) {
byte[] ptext = str.getBytes(ISO_8859_1);
str = new String(ptext, UTF_8);
for(int i = 0; i< str.length(); ++i) {

Java get unicode point of a character

class Main {
  public static void main(String[] args) {
char ch = 'ö';
ch = 'म';


  private static String getUnicodePoint(char ch) {
      String hex = String.format("%04x", (int) ch);
       return hex;

Tuesday, April 11, 2017

outlook not starting

Start Outlook in safe mode to fix "Processing" screen

If Outlook stops responding at a screen that says "Processing," you can close Outlook, start it in safe mode, then close it and open it normally to fix the problem.

Close Outlook.

Launch Outlook in safe mode by choosing one of the following options.

In Windows 10, choose Start, type Outlook.exe /safe, and press Enter.

In Windows 7, choose Start, and in the Search programs and files box, type Outlook /safe, and then press Enter.

In Windows 8, on the Apps menu, choose Run, type Outlook /safe, and then choose OK.

Close Outlook, and then open it normally.

Monday, March 13, 2017

Andrew Ng machine learning

Gradient Descent vs Normal Equation
Normal equation good for smaller feature size

Normal Equation Noninvertibility
too many features (m <= n)
redundant features (linearly dependent)
pinv vs inv in Octave.
Normal equation - regularization makes X'X invertible even if it's not.

Sunday, March 5, 2017

Andrew ng clustering & PCA

randomly assign clusters
assign clusters to each instance
re compute clusters
example image compression - choose R,G,B as numerical features and
assign clusters to each point

example - data compression - reduce n-dimensions to K-dimensions
co variance matrix to capture non axis aligned features' variance(spread)
reconstruct original data by same matrix - U
eigen vectors
example - image compression - choose each pixel as feature - select K
most important ones

scatter3 in octave for 3D-visualization

andrew ng collaborative filtering

recommender systems - collaborative filtering

If you know weights for movie attributes, romance, action etc, you can
learn weights for user preferences.

If you know weights for user preferences, you can compute movie attributes.

If you don't know both, start with a guess for one and compute other.
then reverse. then reverse. until it converges.

But there is another efficient approach which can solve for both together.

Thursday, March 2, 2017

mysql : database size query

SELECT table_schema "DB Name", Round(Sum(data_length + index_length) /
1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP
BY table_schema;


table size query

SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "schema_name"

Blog Archive