Tuesday, September 3, 2013

Maximize an ImageView on Android

Problem
How to maximize an ImageView on Android while keeping the aspect ratio? There's a lot of combinations available on the Internet but the following code alone was able to solve my problem.

Solution
<ImageView android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:scaleType="fitCenter" />

Important Note
Make sure the ImageView is inside a LinearLayout for the android:layout_weight to work.

Source
Comment of Mohsen Afshin on stackoverflow.com

Wednesday, August 7, 2013

phpMyAdmin Installation on Ubuntu using Terminal

Had to install phpmyadmin on Ubuntu 12.04

Just used the following command:
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin


When asked to choose a Web server, I chose
[*] apache2


Clicked Enter when asked to create the database called dbconfig-common

Entered password for MySQL root, phpMyAdmin.

The installation completed but I was not able to open the link:
http://127.0.0.1/phpmyadmin/

Had to edit /etc/apache2/apache2.conf and added the following to the end of the file:
Include /etc/phpmyadmin/apache.conf


Restarted apache using
sudo /etc/init.d/apache2 restart


Finally, opened http://127.0.0.1/phpmyadmin/ again and it worked at last.

Friday, May 24, 2013

How to Display a JavaScript-like Alert in Java

Just put the following in your Java code:

javax.swing.JOptionPane.showMessageDialog(null, "Your message here");

Note:
Similar to JavaScript, your code will pause executing until you close the message dialog. So be careful when deploying your code for the client.

Thursday, May 2, 2013

OCJP Exam Tips I didn't find online


Just want to share my experience when I took the SCJP Exam years ago. Yep, OCJP was called that way back when Sun Microsystems was not yet acquired by Oracle.

After months of reviewing, thanks to God He allowed me to pass the exam with a score of 91%.

The duration of the exam is not a problem.
From my experience, the time allotted to take the exam is more than what is needed. You can actually double the number of questions on the exam so it will fit more to the exam duration. Here's why: During the exam, I actually used the time answering the questions and checking all the items all over again as if it was my first time. That is to include the time it took me to go to the restroom and also taking a glass of water outside the exam room. After I ended my exam, I still have fifteen minutes left unused.

Don't underestimate the ability of fresh eyes.
Do other things before rechecking your answers. I discovered many wrong answers when I rechecked my answers. That was, when I went to the restroom and had a drink of a glass of water. I'm sure I won't realize what's wrong with my answers if I continuously stared at my answers to each questions at that time.

Put your review book beside your bed
No superstition involved here. In this way you will cover more topics since you'll be reading it more often most likely before sleeping. Reviewing is also effective in making you sleepy. Your sleep will help you review and reviewing will help you sleep. And to you, both are beneficial :)

Reading an SCJP reviewer once is not enough
The reason is quite obvious here. Even with a year of experience in Java programming, it is not a reason that you already know all the topics covered in the exam. Take mock exams that measure your ability for each topic. After reading the book and taking exams, review topics you think you are not really familiar with yet. Then, code as necessary.


More tips when taking the exam:


Eat your meal two hours before the exam
When you eat your meal, your blood supply focuses on your stomach for about two hours during digestion. Your brain needs a lot of oxygen especially when taking the exam. Prevent your stomach from competing with the oxygen your brain needs.

Make an effective habit on your exam time
For sure you know the time of the day you will take the exam right? Why not answer mock exams on the days prior to your exam at the same time of the day of your exam. This will condition your body. The time you take the exam, your body already knows that you will be answering questions again.

Don't schedule your exam on an unholy hour
Perhaps you don't want to take your exam very early. Also, will not schedule it on a time of the day you usually feel sleepy.

Ask permission to God
Things happen if only God allowed it. Why not ask His permission. His decision determines if you'll pass or fail. But wait, just make sure you did your part - reviewed enough for the exam. Ask His protection on the day of your exam. Who knows you'll be sick by day you take it, or you'll be late because of the traffic, etc. It is good to rely to someone who controls everything. Make sure you ask it in Jesus' name. It's the only way you can connect with God.

Initially posted this entry on my multiply.com but multiply has closed my account already.

Sunday, April 28, 2013

Storage Failure - Facebook


Is Facebook running out of disk space?

I can't believe this. Just had trouble uploading images to Facebook this day. Creating an album and uploading the images give me the following error:


Facebook album storage failure error message


Trying to post a Facebook status with photo gives me a similar storage failure message:

Facebook status with image storage failure error message


Whew!
If you've also experienced the error. This is to say you are not alone. :)

Anyway, it is Facebook so let's expect it will be fixed soon by their talented developers.

Tuesday, March 26, 2013

jQuery Selector Using Data Attribute


<div id="divId" data-more-info="data value">
    Some div content
</div>


The div element above has two attributes declared. The first one is the id attribute and the second one is the data-more-info attribute.

1. The selector by id for the div above is pretty easy:
$("#divId")

2. Now, here's a way to select the div above using the second attribute data-more-info:
$("div[data-more-info='data value']")


The second query returns all div elements with 'data value' as value for its data-more-info attribute.

Wednesday, March 13, 2013

Oracle Webcenter Portal 11g Hands On Workshop


For reference, here's an outline for a training I will be attending to in the coming days.

Day 1


  • Introduction to WebCenter
  • ADF and JDeveloper as foundation for WebCenter Portal
  • Introduction to Data-binding Data Visualization Tool (DVT) in ADF
  • Lab exercise and discussion of Partner project requirements and goals
  • Java Server Faces and ADF architecture and its components
  • Building a web-based UI using JDeveloper and ADF
  • Lab exercise


Day 2


  • Building Page template and page layout,
  • Navigation and menu UI in WC Portal
  • Content Presenter (in WebCenter Portal) to Oracle WC Content
  • Lab exercise
  • ADF Bindings and Task-flow
  • Managing page and template during development and run-time
  • Lab exercise


Day 3


  • Portlet and web-clipping
  • WebCenter Portal Security
  • Integration with back-end services/systems
  • Managing run-time/design-time changes during SDLC
  • WebCenter Development Lifecycle

Installing rpm file in Ubuntu

Simple run the following command on your terminal:

sudo alien yourFileName.rpm

Then, double-click the generatd .deb file.


If alien is not yet installed, you will need to run the following command first:

sudo apt-get install alien dpkg-dev debhelper build-essential

Where is JDeveloper Installed in Ubuntu

Just installed Oracle JDeveloper but don't know where to locate the file to launch it?



Find it at the following path:
/home/<yourUsernameHere>/Oracle/Middleware/jdeveloper/jdev/bin/

Then, run the jedv or jdev.sh script to start launching the JDeveloper application.