Pages

Thursday, October 19, 2017

Why Does February Only Have 28 Days?


Top 7 Must Have WordPress Plugins - Killer!


Monday, July 7, 2014

Google Adsense

So I finally got my first payment from Google Adsense. Though it was only a few months back since my earnings skyrocketed (For 100K+ views!), it actually took me 5 years before reaching the threshold of $100.

Earn thru your blogs, check out: https://www.google.com/adsense

Friday, February 28, 2014

CS50x: Harvard's Introduction to Computer Science

Aspiring programmers, tech guys and tech gals, have you heard of Harvard College's CS50x course? If not, then let me share it to you. CS50x is an Introduction to Computer Science course offered by Harvard Extension School for FREE!

Thanks to the recent development of distance learning. Everything seems to be in place with Massive Open Online Course (MOOC). Platforms like of edX have been available to host University-courses online in a wide range of disciplines. People around the world can now access learning and can participate just by being online. I can see MOOC has a lot of potential especially for my countrymen here in the Philippines. But I'll say more about that in a separate post.

Back to CS50x, I'm enrolled! I was actually browsing the web and looking for some tech stuff when I saw it and caught my attention. Maybe you'll ask why I enrolled? ('Coz I'm a programmer for quite sometime now). Well, I took CS50 mainly because I want to fill in some gaps in my knowledge. And being enrolled for more than a month now is just awesome! I'm learning and enjoying a lot! Here's more about the course. According to Harvard:
An entry-level course taught by David J. Malan, CS50x teaches students how to think algorithmically and solve problems efficiently. Topics include abstraction, algorithms, data structures, encapsulation, resource management, security, software engineering, and web development. Languages include C, PHP, and JavaScript plus SQL, CSS, and HTML.

Moreover, CS50x is a self-paced online course. That means you can start anytime and finish everything within a year. Again, you have a year to submit the problem sets and projects (Demanding, but definitely doable as per CS50). And if you're serious and finish it with a passing grade, you'll get a certificate! The certificate will be issued by edX.

Interested? Check out CS50x: Introduction to Computer Science. I actually wrote this in my blog because I can't find any Filipinos (or there might be someone, sometwo, somethree out there too but we're very limited) actively taking this course. So its time to spread the word!

The semester (if that's what you want to call it) has just started - last January 2014. It will end on December 2014 so you still have plenty of time to catch up. Before you start, you can try the edX Demo first so you can familiarize yourself on how MOOC works. So there, I hope to see every aspiring dev gurus in the class!



 

Tuesday, January 28, 2014

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed in Tomcat

Last week, I encountered a very weird error in my Email service application. The error was like this:
javax.mail.MessagingException: IOException while sending message;
  nested exception is:
 javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
 boundary="----=_Part_0_29947292.1390460403892"
 at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:625)

The issue is being encountered when the application is deployed in a separate Tomcat instance (not in the main server). What's weird is when I deploy it in the main instance's webapps or via Eclipse. There's no problem.

So, seems like activation.jar (it is a shared lib folder named endorsed) wasn’t able to locate the mail.jar file because they’re not in the same level when they were loaded by Tomcat (you know instance issues and stuff).

1) activiation.jar (exists in the endorsed folder)
2) mail.jar (exists in the applications’ lib folder)

So the easiest way to resolve this is put the mail.jar in the endorsed folder too.

However, we are just sharing an environment from the main instance (which is being used by other applications). Hence, for our case we can't just put it there. :( So I really got annoyed with the issue because I can't see any workaround anymore but luckily, after hours of checking and debugging, I finally found a way to resolve it. :)

So to fix the issue programmatically, you can configure your application's mailcap registry through MailcapCommandMap. I put this few lines before sending the message and it worked!
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
        mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
        mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
        mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
        mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
        mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");

You can check more about MailcapCommandMap here.

Monday, January 27, 2014

Birthday Getaway!

I just turned 26 yesterday and guess what I did? I went to Baguio City for a day trip all by myself! Talk about making some from your bucket list come true, this is indeed an achievement. :)

Can't really tell all the specifics of my trip but one great thing I did, I went to the Cemetery of Negativism at Camp John Hay and buried all the ill feelings I have (I guess and hoped). I had fun indeed. SOOOO MUCH! :)

Anyway, here's a picture of me at one of the tomb where a negative feeling was buried. Had a long and steep walk before reaching the place so I got plenty of exercise on my birthday. Hah!

Friday, August 31, 2012

Sending a HTTP request in Java SE

Here's an example on how to send a HTTP request in Java SE using the HttpURLConnection class. Basically, the sample code below will allow you to send a POST method request with 2 parameters.

URL siteUrl = new URL("http://www.youractionurl.com");
HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);

DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content = "param1=1234&param2=user1234";
out.writeBytes(content);
out.flush();
out.close();

BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while(in.readLine() != null) {
         System.out.println(in.readLine());
    }
in.close();

The HttpURLConnection class extends the URLConnection superclass & supports HTTP-specific features to provide a communication link between application and URL. You can just check the Java SE API for more information. :)