Posts

Showing posts from 2016

2023-09-13, Wednesday, Cloudy

新工上遇上了挫折。寫好的東西達不到標準需要別人執手尾了。雖然同事說沒關係,但反應了自己的不足。有時反省自己為何做事總是不好,為何別人有留意或想到的事情自己總是忽略。現在覺得是自己天生的思考模式問題,可能看多少書都沒用。或者自己應該更適合做地盤呢類工作,而唔係IT。

Google Speech API with Cantonese

I am trying to convert some Cantonese audio clip into text with the Google Speech API. The example app on https://cloud.google.com/speech/docs/samples was good (I am using Java) and following the instruction I can get the example converting the sample clip into text. But than I get into trouble converting the Cantonese. Firstly, I can't get it converting Cantonese clip. It just returned blank result. I did two things to make it return some transcript. Setting the Language Code     RecognitionConfig config =         RecognitionConfig.newBuilder()             .setEncoding(AudioEncoding. LINEAR16 )             .setSampleRate( samplingRate ).setLanguageCode( "yue-Hant-HK" )             .build(); Using Audacity and record the clip with MONO channel, and export it as RAW type: File type: Other uncompressed files Header: RAW (header-less) Encoding: Signed 16-bit PCM And finally I got a response like below: INFO: Received response: results {  

Useful SSH usage

This post has a command that is useful about running SQL statement. https://gist.github.com/scy/6781836 The command is: mysql -e 'SHOW DATABASES;' -h 127.0.0.1 | ssh -L 3306:localhost:3306 remotehost cat This post is good too about ssh without password instead of using rsa key: http://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password ssh-keygen -t rsa -b 2048 ssh-copy-id id@server

no main manifest attribute in jar file

Recently I need to create a jar with ant so after a few search I found that I have to work with a manifest file. Everything seems fine and I can build my jar file with ant happily until I use the ant's manifest task to add manifest file into jar file and run with "java -jar xxx.jar", I always get an error:  no main manifest attribute in xxx.jar I was wondering why it doesn't work after I have follow the instructions here and using the examples there as reference.  After started things all over again with basic Java tutorial on Oracle's website, finally I figure it out. It was all about the manifest file the ant task genereted: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.7 Created-By: 1.8.0_91-b14 (Oracle Corporation) Built-By: Whelan Chan Name: common Main-Class: xxx.xxx.util.xxxRunner There are two EOL after the "Built-By" attribute and so all the attributes after it could not be recognized. After I removed the extra EOL: Manif
Somebody creates a 2D game engine... looks good, will check it out later. https://www.reddit.com/r/gamedev/comments/4veo6l/i_created_game_engine/

About learning regular expression

Useful regex test site for java: http://www.ocpsoft.org/tutorials/regular-expressions/java-visual-regex-tester/ http://java-regex-tester.appspot.com/ Very good site(non-java): http://regexr.com/ Very good learning site: http://www.regular-expressions.info/ http://www.bearcave.com/software/antlr/antlr_examples.html

Something about bit operation

One day I was thinking of how to handle an array of bits so I can use it to mark some information of another array. After checking below thread final I've made my own class to handle it. As I am not a very good coder I may have made careless mistake but still want to put it here for my future reference and whoever passes by here please do leave me some comment about it so I can improve myself. /**  * Create a simple class containing an array of bits.  *  * @author Whelan Chan  *  */ public class BitArray{     private long bitX64[] = null;     private final static int BIT_SIZE = 64;       public BitArray(int size) {         bitX64 = new long[size / BIT_SIZE + (size % BIT_SIZE == 0 ? 0 : 1)];     }     public boolean getBit(int pos) {         return ((bitX64[pos / BIT_SIZE] >> pos & 1l) == 1l);     }     public void setBit(int pos, boolean b) {         long b8 = bitX64[pos / BIT_SIZE];         long posBit = (long) (1l << (pos % BIT_SIZE));      

wsimport on jBoss 4.2.2

I was having problem with my webservice client generated by wsimport on jBoss 4.2.2. Finally with the help of my boss i fixed it and hopefully will help somebody encountered the same issue as me or myself in the future. I did not know what exactly was happening as seems the exception was suppressed and could not be seen in the catch cause. But fixing it I actually was just copying library into jboss-4.2.2GA\lib\endorsed. 1. Download JAX-WS 2.6 and copy below files: Gmbal-api-only.jar  Jaxb-api.jar  Jaxb-impl.jar  Jaxws-api.jar  Jaxws-rt.jar  Policy.jar  Stax-ex.jar  Streambuffer.jar into jboss-4.2.2GA\lib\endorsed. (Please refer to https://developer.jboss.org/thread/214201?tstart=0) 2. Copy below files: jboss-jaxrpc.jar  jboss-jaxws.jar  jboss-saaj.jar into jboss-4.2.2GA\lib\endorsed. (Please refer to http://leakfromjavaheap.blogspot.hk/2013/03/jboss-422-ga-to-jdk-7-or-jdk-6-migration.html) After copying the jars the client works but I am having: com.s

XA jdbc setup

http://blogs.msdn.com/b/dataaccesstechnologies/archive/2011/10/27/unable-to-do-remote-sql-stored-procedure-debugging-from-vs2010.aspx https://docs.oracle.com/cd/E26180_01/Service.94/ATGServiceInstallGuide/html/s0507enablingxadatasourcesonmssql01.html https://www.progress.com/jdbc/resources/tutorials/understanding-jta/distributed-transactions-and-the-transaction-manager