Tuesday, January 12, 2016

Linux - sed to clean up "color codes" or escape sequence

If you see

drwxr-xr-x   23 abc xyz          4096 May 24  2011  [00;34m. [00m/
drwxrwsr-x    4 abc xyz          4096 May  3 01:14  [00;34m.. [00m/

in your directories, you could use the following to remove the color code.

sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"


1. http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed

Wednesday, December 16, 2015

WebSphere - Error 404: SRVE0190E: File not found: {0}

When you are accessing a URL from WebSphere Application Server and you encounter the following error

Error 404: SRVE0190E: File not found: {0}

this could means that your WebSphere Application Server is misconfigured.

This could happen if you are trying to access a URL which is actually a servlet mapping and the actual URL/resource does not actually exist.

To workaround this problem, set the following in your WebSphere Application Server



1. http://www-01.ibm.com/support/knowledgecenter/SS7JFU_7.0.0/com.ibm.websphere.express.doc/info/exp/ae/rweb_custom_props.html?cp=SS7JFU_7.0.0%2F1-15-5-9522.

2.  http://frightanic.com/software-development/solution-to-error-404-srve0190e-on-websphere-6-1/

Monday, November 23, 2015

Chrome - Multiple Chrome icon at the taskbar


When I am fixing my laptop, I messed up with the Chrome Person setting. 

Although Chrome shows only 1 users, it will pop up an addition icon at the task bar whenever I clicked on the pinned Chrome icon (see below)

The previous behavior is only one Chrome icon at the task bar (see below)


Remove "C:\Users\YOUR_USERNAME\AppData\Local\Google\Chrome\User Data" and restart Chrome will fix the issue.



Tuesday, October 13, 2015

Regex - Find line that contain certain words

When you are using text editor, such as Notepad++, which support regular expression search, to analyze log file, below are some regular expression that could be useful


... | ...      Means boolean Or. Example, apple | pear match apple or pear

(...)         Means grouping. Example, gr(a|e)y match gray or grey

?             Means there is zero or one of the preceding element. Example, colo?ur match color or colour

*             Means there is zero or more of the preceding element. Example, ab*c match ac, abc, abbc, etc..

+             Means there is one or more of the preceding element. Example, ab+c match abc, abbc, etc

^             Means match starting position of the line. Example, ^abc match abcxyz but not xyzabc

$             Means match ending position of the line. Example, abc$ match xyzabc but not abcxyz

.              Means match any single character. Example, .at match cat, hat, lat, etc....

\b            Means word boundary. It is typically used to avoid accidentally matching a word that appears inside some other word. For example, \bcat\b doesn't match catfish, but it matches cat regardless of what punctuation and whitespace surrounds it.


1. Match exact word in a line


The above match hello exactly. No character before or after.

2. Match zero or more occurrences of any character


The above match helloANYthinGworld as well as helloworld.

3. Find line containing a specific words.

^.*\b(Some Word)\b.*$

The above will search each line which contain Some Word

4. Find line containing any of the words


The above will search each line which contain apple or orange or pears or durian


1. http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm

Friday, September 25, 2015

Bluetooth - Setting up A2DP profile on Windows 7 (MacBook Pro with Bootcamp)

This may not be a new thing, but, this topic had gotten my attention for the past 3 days.

Why? Because, I had just bought a wireless bluetooth speaker and it does not work with Windows 7. Initially, I was totally baffled and asking myself... "Why does it work for my Android phone while it failed with Windows 7"

To be accurate, Windows 7 does pair with the bluetooth speaker but failed with multiple error messages: “Device driver software was not successfully installed. Bluetooth Peripheral Device. No driver found.”

After some research, I conclude that Windows 7 does not necessary come with A2DP profile which most of the mobile bluetooth speaker used. And now, the solution is in the general direction of updating the existing bluetooth driver.

Updating existing bluetooth driver would work if the bluetooth manufacturer of your machine provide an update. But for my setup, running Windows 7 within a MacBook Pro with Bootcamp, does not work that way.

I had tried the following and none of them work

1. Broadcom official updater - It does not recognize the built-in bluetooth device even though the underlying bluetooth is a Apple Broadcom Built-in Bluetooth

2. Updating Apple Broadcom Built-in Bluetooth - The same driver not found error persisted.

3. Installed the driver

  • a. Acer Atheros
  • b. Intel Bluetooth Suite
  • c. Anycom Bluetooth driver
  • d. Asus Bluetooth Suite

and some does fixed the driver not found error. However, no sound will ever be played by the speaker

So, the only workable solution for me is to install Toshiba Blueooth Stack. But, the downside is, for some unknown reason, Toshiba Bluetooth Stack only valid for 30 days for non-Toshiba machine and it does not seem to be purchasable. (My advice is find your own source)

Now comes the instruction to make Toshiba Bluetooth Stack work on a MacBook Pro Window 7 Machine

1. Download Toshiba Bluetooth Stack driver (Note: This is the official Toshiba driver version 8 which only valid for 30 days and this guide work for Toshiba driver version 9)

2. Install the Toshiba Bluetooth Stack. At some point, it will try to locate a compatible hardware, but, it will fail. Simple click cancel and complete the installation.

3. Find the bluetooth hardware id from Device Manager. It should be in a format of USB\VID_06AB&PID_1234

4. Copy C:\Program Files(x86)\Toshiba\Bluetooth Toshiba Stack\Drivers\tosrfusb\tosrfusb.inf to a temporary location. Usually, you are not allow to modify the contents of files located within C:\Program Files.

5. Open up tosrfusb.inf with a text editor

6. Locate and modify [Standard] and [Standard.NTamd64] section. The [Standard] section is for 32 bits system and [Standard.NTamd64] is for 64 bits system. You will need to assign a new item in these sections

For example, if the last entry (item 150) of the [Standard] section is %TosrfUsb.DevicDesc150%=TosrfUsb_Device, .....

I will add

%TosrfUsb.DeviceDesc160%=TosrfUsb_Device, USB\VID_06AB&PID_1234

after the last entry (item 150). 160 is a random choice as long as the number is not taken in the section.

Same goes to [Standard.NTamd64] sections

7. Locate and modify [Strings] section. Type in the following line after line
TosrfUsb.DeviceDesc150 = "xxxxxx"

TosrfUsb.DeviceDesc160 = "Apple Built-In Bluetooth Toshiba"

8. Copy tosrfusb.inf from temporary location back to C:\Program Files(x86)\Toshiba\Bluetooth Toshiba Stack\Drivers\tosrfusb\ (Note: you will require Administrator permission to perform this step)

9. Reboot the machine

10. After the machine had been reboot, goes to Device Manager and select Apple Broadcom Built-in Bluetooth to update the driver

In the Update Driver Software dialog, click Browser my computer for driver software

Then, click Let me pick from a list of device drivers on my computer

Then, click on Have Disk

Browse to C:\Program Files(x86)\Toshiba\Bluetooth Toshiba Stack\Drivers\tosrfusb and start the driver installation

You will be prompt about installing an unsigned driver. Accept it and proceed with the driver update.

11. After the driver update complete, you should be able to see Apple Built-In Bluetooth Toshiba in Device Manager

12. Now, you should be able to use Toshiba Bluetooth Manager located at the taskbar or Toshiba Add New Connection located at the start menu to add pair with your A2DP bluetooth speaker.

Thursday, August 20, 2015

JMS - Setting Up And Accessing A Remote Glassfish 4 and OpenMQ JMS Queue via ORB

This is a complete guide to setup JMS queue with Glassfish 4 and the setting required to access the JMS queue with a remote standalone client.

Download Glassfish

1. Download latest Glassfish at https://glassfish.java.net/download.html

2. Follow the instruction at the download page to install Glassfish 4. (Mainly unzip the package and run ./asadmin start-domain). To stop Glassfish server, you can run ./asadmin stop-domain

3. You may want to enable remote admin. Simply run ./asadmin enable-secure-admin

4. After installation, you can access the admin webpage with http://hostname:4848

Check ORB Configuration

Since we are using ORB (Object Request Broker) for remote JMS connectivity, we will take a look at the ORB setup in Glassfish 4.

1. Go to Configurations -> server-config -> ORB -> IIOP Listeners -> orb-listener-1

2. From the above screenshot, you can see that the default listening port is 3700 and we will need this port number for later configuration with JNDI properties.

3. We will be using the default setting of ORB configuration

Check JMS Host Configuration

Now, let's take a look at the JMS Host configuration. JMS host represents a Message Queue broker and I will be using Embedded type as JMS Service Type (MQ broker is co-located in the same JVM as the GlassFish server instance it services and the JMS service uses lazy initialization to start the broker when the first JMS operation is requested instead of immediately when the GlassFish instance is started)

1. Go to Configurations ->server-config -> Java Message Service

2. Note that the Default JMS Host is default_JMS_host. This is usually sufficient and the setting of default_JMS_host is as follow

3. In actual fact, this define the host and port of the Message Queue broker. The Host will be localhost because we are accessing the JMS queue via ORB. The Port is ${JMS_PROVIDER_PORT}. It is actually defined at System Properties (See Below) and the default value is 7676

4. We will be using the default setting for JMS Hosts configuration

Create JMS Physical Destinations

The Message Queue broker uses physical destination to route delivered message and deliver to consumer. We need to create at least 1 Physical Destination for our JMS queue.

1. Go to server (Admin Server) -> JMS Physical Destinations tab

2. Click New

3. Fill in the information (mostly default except Name and Type) and click save.

a. Name: A name which uniquely identify the physical destination
b. Type: As I am creating a Queue, the Physical Destination Type is javax.jms.Queue.

Create Connection Factories

We need a JMS connection factory that allow an application to create other JMS objects

1. Go to Resources -> JMS Resources -> Connection Factories

2. Click New

3. Fill in the information (mostly default except JNDI Name and Resource Type) and click save

a. JNDI Name: A name which uniquely identify the connection factory
b. Resource Type: As I am creating a Queue, the Resource Type is javax.jms.QueueConnectionFactory

Create a Destination Resources

We need a JMS destination resource to provide information about the actual physical destination information of the queue.

1. Go to Resources -> JMS Resources -> Destination Resources

2. Click New

3. Fill in the information (mostly default except JNDI Name, Physical Destination Name and Resource Type)

a. JNDI Name: A name which uniquely identify the destination resource
b: Physical Destination Name: Use the Physical Destination which we had created previously
c. Resource Type: As I am create a Queue, the Resource Type is javax.jms.Queue

Setting Up JNDI Properties for Remote Queue Access

The above should get your JMS Message Broker and Queue up and running. Definitely, you can use telnet to verify if the server/port is running

a. For ORB, use telnet hostname 3700
b. For JMS Message Broker, use telnet hostname 7676

Next, the following JNDI properties (put them into a jndi.properties file) will allow you to perform remote connection to the JMS queue

java.naming.factory.initial: com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs: com.sun.enterprise.naming
java.naming.factory.state: com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
org.omg.CORBA.ORBInitialHost={hostname or IP of your remote client}

You need to ensure the following jar files are included in the JAVA CLASSPATH

a. {Glassfish 4 installation Path}/mq/lib/jms.jar
b. {Glassfish 4 installation Path}/glassfish/lib/gf-client.jar

With the above, you can use your preferred programming language to write a standalone client (use the Connection Factory and Destination Resource JNDI Name which we had created as JNDI lookup) and connect to your JMS queue remotely.


1. Glassfish 4.0 Administration Guide

Sunday, July 5, 2015

Chrome Brower Goes Out Off Screen

If you Chrome goes "Off Screen", that is, out of the monitor screen and you have no way to drag it back by a mouse, you can try the following (From Sunny Balanga)
  1. Press Alt + Space: This opens the the “Window Menu.”
  2. Choose “move” either by clicking on the option if you can see the menu, or by hitting the “M” key.
  3. Hit one of the “arrow” keys, the one with a direction opposite to where your browser window has gone (mine went to the right, so I hit the “left arrow” key) enough times until you can see the enough of the browser to be able to drage it.
  4. Drag the browser to the desired position.
  5. Close the browser (this is important in order to ensure that this new position of the browser is saved and will be the position of the browser the next time you open it. Skipping this step means that the last saved position is “off screen”. Should the brower close improperly, it will re-open in the last saved position, that is “off screen” and this procedure will need to be repeated.)
  6. Re-open you browser and proceed normally.
The above is copied from http://www.sunnybalanga.com/2011/06/09/chrome-broweser-goes-off-screen-fixed-resolved/ and it works for me.