pikopong

it's all about knowledge

Archive for May, 2008

Reading MyKad using Visual Basic

with 19 comments

It seems that a lot of people asking how to read MyKad using Visual Basic, but since I don’t have the slightest idea on how to code in VB, I started to search around. To my surprise, Xenon (the one who reverse engineered MyKad to get the APDU) actually wrote a small application in VB to read MyKad. So, for those who can’t afford to buy SDK from commercial company, you can download the code here for FREE !

VB Application to read MyKad


View the discussion
Download the code

Written by amree

May 28th, 2008 at 12:32 am

Posted in programming

Tagged with , , ,

Hospital Universiti Sains Malaysia at WCIT 2008

with 2 comments

WCIT 2008

In case you didn’t know, HUSM stands for Hospital Universiti Sains Malaysia and I’m currently working there. Early this year, my head of the department got invited by MDeC to this event. The event took place at Kuala Lumpur Convention Center from 18/5/2008 to 22/5/2008. You can read all the information about WCIT here.

To my surprise, we were the only hospital that manage software development all by ourselves. Even though Hospital Universiti Kebangsaan Malaysia started developing their own, they still has to rely on vendors in terms of hardware and the database (they’re using Oracle). Other hospitals didn’t actually bring their own IT Department people, instead they sent their vendors. However, they’re some from Kementerian Kesihatan Malaysia who brought their own IT people even though the application they brought was coded by the vendor (the only difference is that they own the code, not the vendor).

The event was a really an eye opener for me. I saw lots of new technologies that has been integrated into our daily lives. It’s pretty cool to see the advancement of IT industries in Malaysia. I managed to meet some interesting developers, managers and others who has a lot of experience in the industry itself. Not to forget, I also managed to come close to our Prime Minister and also Yang di Pertuan Agong. It was almost as I could actually slap their back, but of course I didn’t do it, hey, I still love my job :)

However, I’m a little bit disappointed with the technology used. Lots of people/developers/vendors in the government still rely on non-open source software. Why should you pay when you can get it free? That’s what HUSM is trying to say in the event. We’ve developed our own software and save millions of ringgit, but of course, other managements don’t care, they think as long as they have the money, they’ll just spend it to the max. What they don’t realize is that some of the money that shouldn’t be spent in the first place could be used for other things. Now, imagine that mindset in each and every head of the department (including non-IT) in Malaysia. We could actually save billions and our IT people will gain knowledge more than ever.

I’m also surprised other IT Department didn’t bother to ask us much about the technologies that are being used in our applications. I mean, it’s not that weird if the end user didn’t ask what database that we use, but IT people ? Come on, it’s like a chef is not interested in asking about the recipe (ok, maybe a bad analogy there, but you should get my point).

Even though we just got small booth (read: very very small), I think we somehow manage to tell the people that HUSM is different. I’m looking forward to another event like this. Till then, enjoy the photos taken using Canon A710 at my Picasa Web Albums.

P/S: Thanks to MDeC for the invitation, we really appreciate it :)

Written by amree

May 25th, 2008 at 6:37 pm

Posted in husm

Tagged with , , ,

Printing to Zebra S4M Using Java and ZPL II

with 17 comments

Apparently there’re some codes scattered on the net telling people that you can print to a Zebra printer by sending ZPL II codes using PrintService. But the problem is, it’s not working, I don’t know why, maybe because of a different version of printer or model but I’m pretty sure the thing that came out from the printer is just ordinary text not barcode which is what the code was supposed to output.

New Version

Thanks to Oleg for pointing out on how to print using Zebra S4M connected either via USB or network.

The solution is pretty simple, all you have to do is do not install Zebra S4M as a Zebra S4M (sounds weird, I know), instead, just install it as a local raw printer (Linux) or generic text printer (Windows).

For CUPS user in Linux, this is the example for the correct configurations:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#/etc/cups/printers.conf
<Printer Zebra>
Info
Location
DeviceURI socket://10.1.1.5:9100
State Idle
StateTime 1223445299
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Option orientation-requested 3
</Printer>

You can always add the printer using the web interface, just make sure you choose the RAW as the Make/Manufacturer and Model/Driver.

For Windows user, please take a look at Oleg comment.

Test this Java code, it should print out a barcode:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.attribute.PrintServiceAttribute;
import javax.print.attribute.standard.PrinterName;
 
public class SimplePrint {
 
   public static void main(String[] args) {
 
       try {
 
           PrintService psZebra = null;
           String sPrinterName = null;
           PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
 
           for (int i = 0; i < services.length; i++) {
 
               PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class);
               sPrinterName = ((PrinterName) attr).getValue();
 
               if (sPrinterName.toLowerCase().indexOf("zebra") >= 0) {
                   psZebra = services[i];
                   break;
               }
           }
 
           if (psZebra == null) {
               System.out.println("Zebra printer is not found.");
               return;
           }
           DocPrintJob job = psZebra.createPrintJob();
 
           String s = "^XA^FO100,40^BY3^B3,,30^FD123ABC^XZ";
 
           byte[] by = s.getBytes();
           DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
           Doc doc = new SimpleDoc(by, flavor, null);
           job.print(doc, null);
 
       } catch (PrintException e) {
           e.printStackTrace();
       }      
   }
}

Old Version

So, I started looking around for other methods. I even tried posting on java’s forum and offered 10 duke points, but no one seems to answer my question. After googling around, I found out that I could upload a file containing the ZPL II to the printer, so, I tried and it did work. But another problem arise, Two people cannot ftp simultaneously due to the limited access set by the printer.

Printing using FTP (I’m using Apache Commons Net library)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.io.FileInputStream;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
 
public class FtpPrint {
 
   public static void main(String[] args) {
 
       try {
 
           FTPClient f = new FTPClient();            
 
           f.connect("10.1.127.3");
           f.login("anonymous", "");
           f.setFileType(FTP.ASCII_FILE_TYPE);                            
 
           FileInputStream in = new FileInputStream("/path/to/file");
           if (f.storeFile("filename", in)) {
               System.out.println("Upload ok");
           }                
 
           f.logout();
           f.disconnect();
 
       } catch (Exception e) {
           e.printStackTrace();
       }
   }
}

In the end I had to find another solution. After 3 days of searching the internet up and down, I found out that Zebra’s website offered a piece of code in Java to print using ZPL II using socket programming which automatically solve all of my problems, I was like, what the.. Note to myself, always search for the manufacturer site before googling around. However, a few modifications needed for the given code such as the printer port and the language sent. You can get the codes below:

Printing using socket (Got it from Zebra website)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.io.DataOutputStream;
import java.net.Socket;
 
public class SocketPrint {
 
   public static void main(String argv[]) throws Exception {
 
       for (int i = 0; i &lt; 10; i++) {
           Socket clientSocket = new Socket("10.1.127.3", 9100);
           DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
           outToServer.writeBytes("^XA^FO100,40^BY3^B3,,30^FD123ABC^XZ");
           clientSocket.close();
       }
   }
}

Download guide to ZPL II

Written by amree

May 11th, 2008 at 9:44 am

Posted in programming

Tagged with ,

List of TV Series You Must Watch

with 11 comments

Since I got nothing to do on this boring weekend, I decided to share with you people my favorite TV Series. So here goes the list with some information about it, oh, by the way, it may contain a little bit spoiler for those who haven’t watch it, but I’ll try my best to keep it to the minimum so that it won’t ruin your experience if you decided to watch it.

CSI: Las Vegas

You may ask, why not CSI Miami or CSI New York ? Simply because it’s the first and the leader, Gil Grissom. is actually a scientist (in the show, not in real life) which to me is so freaking cool. Compared to other CSIs, others are not scientist. But don’t get me wrong, I do like CSI Miami (due to the coolness of Lt. Horatio Caine), it’s just that I like Las Vegas more. Cases presented are much more mysterious, weird, and complicated than the others. Remember last season criminal, the Miniature Killer ? The one who killed people and then send a miniature model of the crime scene to the CSI team, totally wicked.

Desperate Housewives

I still remember the first time I heard about this TV Series, I was like, the only reason I would watch a TV Series displaying old housewives together is because Teri Hatcher is in it. I became one of her fan due to her act in Lois & Clark: The New Adventures of Superman. So, I decided to watch the first episode and then, I’m totally hooked to the TV Series not just because of Teri Hatcher anymore, but also because of Eva Longoria and of course, the storyline which is also interesting. Who would have guessed, a beautiful neighborhood got so many secrets hidden inside their houses and that’s what make Desperate Housewives so interesting.

Gossip Girl

I didn’t pay much attention at all when this TV Series was launched. I did read about its review on how Kristen Bell from Veronica Mars narrates the show as the “Gossip Girl” herself, the story which is somehow almost similar to The O.C (my favorite too). One day, my friend recommended me to watch it, so, I thought since I don’t have any teen drama to watch at that moment, I decided to give it a try, of course, I got hooked up to this one too. The first thing I noticed is one of the actor, the beautiful Leighton Meester which appeared before in House as one of her patient that fall in love with House just because she got disease that can fool her emotion. She definitely act very well for her character as a classy, beautiful, manipulative and rich. But, it’s not just about her, others act very well too.

Heroes

I don’t think I need to introduce this one, one of the most popular TV Series at the moment. Even though, it’s more like The 4400, only it’s so much better. This show got everything, flying, mind reading, bending space and time, invisible, fast healing, nuclear bomb, you just name it. My favorite character is definitely Peter Petrelli, the one who can absorb any abilities, that ability is just so freaking cool.

House M.D

I never like E.R much, House is the only medical show that interests me specifically because it deals with weird deseases and solve it like it’s a puzzle. Even though my friends from medical departments said that House is a stupid show since it shows how the doctor do all the work, from MRI, to X-Ray, to Lab Testing and others which is totally a lie since no doctors can do all that stuff alone. But, who cares ? I’m so glad I’m not in the medical field, coz, if I do, I won’t be able to enjoy this show. The most interesting part of this show is not about the medical itself, it’s about Dr House himself. The way he talks is just way too cool. I definitely like the way he being sarcastic to others around him. I also learned about a few weird deseases after watching this one.

Jericho

The storyline is indeed interesting. Some people said the show became worse at the end of Season 1. But seriously, you people just hold on and watch till the end of this TV Series. The ending is so well done that I felt I don’t care anymore if this show discontinued, simply because it has been ended very well. This is one of the show when it was cancelled, people got angry and started to send tons of nuts to the tv station just to show how many people are supporting this show.

Kyle XY

This is only show for people who likes to science fiction series. But of course, if you watch this series just because of the ‘cute’ main actor, Kyle himself, or maybe the heroin, the beautiful Amanda, I won’t blame you. The story got better when Kyle’s secret being exposed one by one. This is more like Heroes except there’s only one Hero where he can perform multiple extraordinary capabilities due to his powerful mind.

Lost

I seriously don’t understand why people would watch a TV Series displaying a bunch of people living on a remote island. I mean, what story could they possibly make ? So, I tried the first episode, oh my, I was so wrong about this one. The mystery about the island itself is enough to get me hooked. But if you don’t like waiting for the answer of everything happening on that island, you should just skip this one. It’s a very torturing moment waiting for the answer :(

Prison Break

The first season of this show is definitely the best. I was so addicted to this show, just to know what will happen in the next episode. Of course this is an interesting show, put a genius in a prison and watch him escape, that’s just so insanely cool. But it got worse in the second season, however, the third season became better, but still can’t beat the first season. By the way, every time I recommend Prison Break to anyone I know, they all seems can’t get enough of it, so, maybe you should try it if you just heard about this one for the first time :)

Smallville

Who don’t like Superman ? If you like Superman, you’ll definitely like this one, at least for a while. Getting a little boring from time to time due to the storyline. The only reason I’m still watching this one is because the current season likes to talks about the Superman’s secret. Thank god the heroin is in the coma right now (in the show), if not, this one will suck more.

Supernatural

Put ghosts, funny and cool guys, hot girls crying for help and black magic into a story, you got a good TV Series. Supernatural is more like a Ghostbusters except that it’s better and most of the ghosts are based on the real one from around the world. It’s always cool to watch Dean and Sam do some hocus pocus to destroy the ghosts, which usually boils to the same thing, either cremated the dead body or recite some weird words.

I guess that’s all, so, what about you, tell me a little bit your favorite show in the comment section, thanks !

Written by amree

May 8th, 2008 at 12:08 am

Posted in vids

Tagged with