Tuesday, June 15, 2010

Import/Export BLOB data type correctly in MySQL database

MySQLDump is one of the built-in tools which is useful enough for data import/export on daily operation. To deal with complex data types like Binary or BLOB, it is good to export them in HEX code in order to avoid any invalid character set issue or corrupted data during data import.

MySQL manual has already mentioned about this:

--hex-blob

Dump binary columns using hexadecimal notation (for example, 'abc' becomes 0x616263). The affected data types are BINARY, VARBINARY, the BLOB types, and BIT.


Thursday, June 10, 2010

Gnome Network Manager - A must read note

When trying to figure what's happening for my NetworkManager settings being in-consistent with the settings in original interface control file /etc/network/interfaces, I found this note:

Why won't Network Manager manage my Networks?

If your network connection is listed in /etc/network/interfaces, it is unavailable to NetworkManager with it's default setup (read this to see how to change it to manage these connections: http://wiki.debian.org/NetworkManager ). The best option for a standard setup is to open the file using

sudo gedit /etc/network/interfaces 
and comment out (ie put a # in front of) or delete every line in the /etc/network/interfaces file except the two with lo in them- they read

auto lo
iface lo inet loopback

Things are you really want to manage static IP yourself. Then you add new line in /etc/network/interfaces, remember, but not in Network Manager. Any non-dhcp (static) interface in /etc/network/interfaces will not be governed by NetworkManager. Then you may ignore the alert icon on NetworkManager even if you have connection access to the outside with your static interface settings.

Fix MAC address to eth0 mapping issue on Debian based Guest VM

When using VMware server/ESXi in production environment, new MAC address is allocated to a new VM being added. Same situation happens on the same VM if it is configured to have new network adaptor. A different MAC address is allocated to that network adaptor and it never duplicates. Debian based Linux will automatically map this new MAC address to a different network interface, i.e., eth? (where ? is always greater than 0) In this case, it will never map back to original network interface, say, eth0.

Now check the file "/etc/network/interfaces", the content should be:



Assuming you always have one network adaptor installed on your system and that one is expected to be eth0:

To make sure new adaptor's MAC address being mapped to eth0 network interface, there is a file that raises such interest:
"70-persistent-net.rules"

I don't know what's 70 means but it always appears when you have network adaptor installed on your system.

Try issue following command to locate this file in your linux environment:


This file is created by udev service at startup where auto detection of network adaptor takes place. New content will be added to the bottom of the file automatically. It determines the output results you could find by issuing ifconfig command.



In this case, eth2 is active, not for eth0.


Basically, the file "70-persistent-net.rules" contains all the detected PCI devices and then do the mapping with them. Here is a typical one:



Well, obviously you will find it useful to have a look at the NAME key paire whereas eth0 is specified. Meanwhile, assigned MAC address (either physical or virtual one) is shown after ATTR{address}.

This kind of settings will be accumulated along the time when new network adaptors are added or MAC address is changed. New string with NAME="eth?" will be added to the end of the file so we can tell from the aforementioned file that the MAC address has been changed twice and finally eth2 becomes the current active network interface.

If you want to force new MAC address being mapped to eth0 network interface, you can delete this file, namely "70-persistent-net.rules", with the following command:



Then modify the content in "/etc/network/interfaces" to substitute eth2 with eth0:



After system reboot, you will find a brand-new "70-persistent-net.rules" file reappearing in the directory but the content will be:



Now, the network adaptor is mapped to eth0 again.

For the administrative point of view in VMware environment, it is not a good practice to manually reset network interface mapping like this. That would be good if we can automate it. Here is how:

  • locate directory "/etc/init.d"
  • pick one of networking related script like "/etc/init.d/networking" and edit it
  • locate stop) section within script file "/etc/init.d/networking"
  • add the following line towards the end of the section (right before double semi-colon ;;):
  • save it
  • If you find a symbolic link linked to this script file within /etc/rc0.d/ directory, then it means it will run stop) section of "/etc/init.d/networking" during system shutdown process, i.e., deleting "70-persistent-net.rules" automatically. If not, you may need to create a symbolic link yourself within /etc/rc0.d/ directory. The command would be like this:
$ sudo ln -s /etc/init.d/networking /etc/rc0.d/networking


Now, everything is ready. Try reboot the system to let things happen.

Whenever MAC address is going to be changed at next bootup, the problematic "70-persistent-net.rules" file would have been deleted first during shutdown period. Then a new "70-persistent-net.rules" file will be created with the correct mapping of MAC address to eth0 again at next startup. It makes sure new MAC address is always mapped to eth0 adaptor, with the basic assumption that there is only one network interface card installed on the system.

Tuesday, April 6, 2010

Apache 403 forbidden for image files


I think it’s such a wired thing that it’s actually related to permission issue. The working solution can be found in http://ubuntuforums.org/archive/index.php/t-763605.html .
What you could do is:

Duplicate a folder and then reset all file permissions required. Everything works FINE AGAIN!

Friday, March 12, 2010

File encryption on Linux

AESPIPE is a package for convenient pipeline encryption tool via command line. 

It's useful to have an instant encryption on the fly. Database backup would be one of the most important tasks carried out for daily operation. Encryption helps backup operator to secure the backup which can then be copied to anywhere for storage, without too much concern over the data privacy.

To backup mysql database with further encryption, we can type the following command:






Note: -P parameter would point to a key file which contains the password for encryption purposes. Of course, you'll need that when you want to decrypt the file again.

To retrieve the original backup file from the encrypted copy, we can type this:






Friday, February 5, 2010

Using Nautilus to browse networks

There was a famous error shown up while using Nautilus File Manager to browse Network:



Seems wired, especially when you are doing the same thing over a remote connection to your Ubuntu server.
After a research among the materials on the Internet, a solution is found without installing any other components as mentioned by the other gurus. Try this in the terminal:


gksu is the command to open GUI program in the terminal while & sign keeps this as a separate process after initialization.

dbus-launch does do the tricks, i.e. network browsing.

For detailed explanation, please read this:
http://linux.die.net/man/1/dbus-launch

Friday, December 11, 2009

Healthcare Identifiers

People actively involved in developing HL7 compliant applications may find some issues on duplicate records caused by typos or inaccurate information. All these problems go back to the software developers who seem to hold all the responsibilities of creating such dilemma. On the one hand, people who do the data entry should share part of responsibilities in making wrong records. On the other hand, The patients may also provide inaccurate information about their identities. Finally, all these errors could make the patients suffering when medical staff makes wrong decisions based on the incorrect information produced by the software during treatment.


Medicare number is not a good choice for patient identification. You may agree with that after you read this:


Why not use the Medicare number?
A Medicare number is not unique. Some people have more than one Medicare number because they are members of more than one family and may be on multiple cards. Also, not everyone who needs healthcare will have a Medicare number.


So what is individual healthcare identifier?
An IHI is a unique 16 digit number that will be allocated to each Australian resident and others seeking healthcare in Australia. Your IHI will be unique and only apply to you for use in health information records alongside your name and date of birth. No clinical information will be linked to your identifier. Healthcare providers and healthcare organisations will also have their own unique identifiers.


An unique identifier would really help ease the pain of the application developers in Australia. For successful e-health strategy, health institution will need to use HL7 for orchestration among the systems maintained by different vendors. Patient identification causes big trouble to the developers whereas most of them find their own ways to identify an unique patient's record. With both of healthcare identifier and HL7 protocol, various systems can really talk to each others with less errors than ever before.


An exposure draft of Healthcare Identifiers Bill has been released and is ready for public comment. This will help build the basic infrastructure of e-health communication protocol. Hopefully, we will see Healthcare Identifiers Service offered by Medicare by mid-year 2010.


http://www.health.gov.au/internet/main/publishing.nsf/Content/pacd-ehealth-consultation

Thursday, November 12, 2009

Must-have functions in clinical application

Doctors see clinical software as a tool to help them sort out lots of problems where a team of workers would achieve in the past. What functions of a killer application would be desired by GPs? I looked around and find a useful comment from an article online.

How family doctor can function without these features:

  • chronic prescription handling
  • drug interaction checking
  • drug information
  • patient information leaflets
  • printing useful patient data report
  • tracking of investigations
  • chronic disease management tools/searches
  • audit tools for doctors (i.e., to ensure they are doing what they think they are doing)
  • legible notes
  • comprehensive backup strategies
  • remote access from home
An open source tool like OSCAR seems to be popular among the GPs. That's good starting point to add and enhance such features for making doctors' life easier.



Thursday, September 24, 2009

Advanced PHP mail problem in Ubuntu

After a MTA like sendmail has been setup in Linux environment, PHP script for sending email seems not to work correctly. The symptom is so weird. Say, you sent out email successfully without any error message by using PHP. However, the email actually didn't reach the destination mailbox. The famous PHP manual did not show any light on what happened.

Assuming we are using SMTP server other than the sendmail agent to send out the email, sometimes we need to pass authentication details to make it work. However, PHP built-in mail() function is lack of authentication feature. This function works really well on Windows machine, supposing it is using SMTP server in local network.

For Linux, it is recommended to use PEAR project's Mail object as it has extra feature for passing authentication parameters to SMTP server. This is especially useful when the hosting machine is not in the local network of SMTP server. In this case, authentication is a must to send through emails successfully.

For the beginning of the PHP script, we'd better add this:



Then you may pupulate Mail::factory() object to send out the email content.

PHP4 or newer version has already integrated PEAR's Mail library in its package. If they don't, then you may add it yourself:



The beta 1.2.0b2 version of Mail works okay so I guess you may like it. Of course, you may install newer version as you like.

Then you may use Mail::factory() object for sending email using PHP script, surely with your SMTP username and password. This Mail object works even if you don't use authentication.

Nice to have a try;)

Tuesday, September 1, 2009

Remote Javascript function calls to close IE7 Window with PDF opened

When we let users open a PDF file from our web site, it seems we can't close that IE7 window by javascript once the PDF content is loaded. We want more interactive features at the client's IE7 browser, like closing window from Parent window's JS call.
The question is: How can we make Javascript function calls to remotely close an child IE7 Window with PDF opened?
Answer: HTML tag frameset can help us solve this problem. Take a look at this forum discussion for more ideas.