Skip to content


Android speech recognition without network (CMUSphinx)

For doing accurate speech recognition on Android, Google’s speech recognizer, along with the android speech api is readily available. However, the problem is that this API require you to install the Google search on to the phone, and have a active data connection (speech database and the recognition is done in the backend).

There is an open source project called CMUSphinx, which has a mobile edition and has an Android demo. However most of the instructions found online on how to build didn’t really work very well for me. The next few posts are to document my step by step process for future use.

Posted in Java, Technology. Tagged with , , , .

Notepad automated time stamp logging

Can’t remember who/what told me this, but I just remembered it.

If you write .LOG in notepad as the first line, then everytime you open that text file with notepad it will automatically append a timestamp.

Not sure if this is going to be useful for anything, but meh, I will just put it here

Posted in Technology. Tagged with .

Using java.util.zip recursive zipping of directory and subdirectory

I have decided to start posting things on Java. And the first one is how to use java.util.zip to recursively zip a directory that contains:

  • File
  • Subdirectories
  • Empty subdirectories

The first two are straight forward, but the last one was a bit strange.

To add a file to zip (just an excerpt of code, may have missing try/except):

File f = new File("C:\\crx\\crx.zip");
ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(f));
String[] files = new String[] {"File1 (Full path)", "File2 (Full path)"};
String[] dirs = new String[] {"Full Path to directory 1","Full Path to directory 2"};
for(int i=0;i<files.length;i++) {
addFileToZip(files[i], zOut);
}

//now add all the directories
for(int i=0;i<dirs.length;i++) {
addDirectoryToZipRecursive(dirs[i], zOut);
}

zOut.flush();
zOut.close();

 

To add directories:

ZipEntry e = new ZipEntry(stripPath(path)+"/");
zip.putNextEntry(e);

To add files:

ZipEntry e = new ZipEntry(stripPath(f));
zip.putNextEntry(e);
FileInputStream in = new FileInputStream(f);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1)
zip.write(buffer, 0, bytesRead);
in.close();

Posted in Java. Tagged with , , .

htaccess and htpasswd

Have been using htaccess and htpasswd to protect my directories for a every long time, and after copy pasting the same stuff over and over many times, I have decided to add a post here so I can copy paste easier next time.

To password protect a directory:

vi .htaccess:

AuthUserFile /PATH TO PASSWORD FILE
AuthName "PHASER Password"
AuthType Basic

require valid-user

[Close vi]

htpasswd -cm [PATH TO PASSWORD FILE] [USERNAME]

[Enter password]

chmod 640 .htpasswd

chmod 644 .htaccess

Done!

Posted in Technology. Tagged with , .

Live Messenger hiding ads – Quick note

To remove ads from Live messenger 2011, http://apatch.org/

Posted in Technology. Tagged with , , .

Quick setup of LaTeX on Windows

First, I don’t really like LaTeX, feels funny writing code-like things and content at the same time.. Maybe I’m using it wrong lol

Anyway quick steps to setup LaTeX on Windows (7):

  1. http://miktex.org/
  2. http://www.xm1math.net/texmaker/
  3. Open this sample in Texmaker, and do Tools > Quick Build to test the installation
  4. If anything failed, you may need to check to see if miktex’s \bin is in path
  5. Also miktex may ask you to install extensions, allow

Posted in Technology. Tagged with , , , .

Almost 9 months later

Its almost a year at UCLA, and I’m almost seeing the end of my Masters! A few things I want to comment (rant) on, and some things I’d like grad school hopefuls reading this to know. *Note that if the only reason for you to apply to a US graduate school is to do a MS and find a job (and then stay in the US), this may not apply as much.

  • Be prepared, doesn’t matter how prepared you think you are about going to graduate school, doesn’t matter how prepared you think you will accept not being very good at it, think again. Triple whatever doubts  you may have, and see if you still want to do a PhD. It is that hard haha
  • There is no such thing as enough maths (I have zero maths prowess haha, literally 0…). But people can only be good at a couple of things right? You can’t be a programming master mind AND solve all these equations… (don’t tell me….)
  • Quarter system is relentless, and time flies by very fast. Drop a weekend and face the consequences. Homework, research assignments, random things that needs to be done rushes in like a torrent, lose footing at your own peril.
  • Most of the time the grades are lenient (thankfully)
  • Sleep time becomes nonexistent
  • Keep a good schedule (i.e. don’t do what I do: http://ucla.jamesyxu.com/?cat=13)
  • Just turn off once in a while, sit in bed all day and watch movies or something
  • A good advisor is very important. If you are self motivating (which I think describes a lot of western PhDs), then imho an easy going advisor who is there to help (not to slave drive) is very good. We put enough pressure on ourselves already, there is no point in having a slave driver whose only purpose is to muck up your planned schedule
  • Be flexible, do the things that takes the least amount of time first
  • Some things don’t need to be done NOW
  • Some things will be forgotten by others if you don’t do it NOW (so whether you want to do them if depends on how much free time there is)
  • There will be a lot of temptations to go back to work (or go to work) from the MSs graduating all the time

Right, end rant for now I guess…

Posted in Grad school. Tagged with , , .

Eclipse and Aptana

Accidentally installed Aptana plugin (when I was trying install PyDev lol). Now eclipse reports with a billion errors and warnings on startup. Tried uninstalling Aptana through the Eclipse update manager, but that didn’t seem to uninstall very cleanly.

To remove complete, I have found that by going to the plugins directory of eclipse, and just removing everything that has aptana in the name works (apart from the ones under pydev)

Posted in Technology. Tagged with , .

MercurialEclispe, clone a java project

Right, more issues.

Mercurial doesnt have a clone as Java project option (like SVN does), so to fix this:

  1. Clone a project
  2. Close Eclipse
  3. Edit the project’s .project file’s natures section
  4. Add <natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
  5. Add the java library:

Posted in Technology. Tagged with , , .

Eclipse Mercurial integration – failed to import extension mercurial_keyring

Installed MercurialEclispe, and had the following problem when trying to clone a repo:

failed to import extension mercurial_keyring

There are a number of solutions, such as installing the keyring module on the system’s python. However that gets you into a load of problems if you dont have the correct MSVC installed.

By far the easiest solution is to install TortoiseHG, and point the hg binary to C:\Program Files\TortoiseHg\hg.exe in the MecurialEclipse plugin preferences.

Posted in Technology. Tagged with , , .