How To View Line Numbers In Eclipse on Mac OSX

There is nothing more frustrating, when trying to debug a compilation error in Eclipse, than not knowing what line number you’re looking at in your application code.

(Lets face it – we’ve all been there!)

 

Here’s how to turn it on in Eclipse, on a Mac:

Go to Eclipse (found on the Menu bar, on the top left of the screen) -> Preferences -> General -> Editors -> Text Editors -> Select the “Show line numbers” checkbox.

 

How To View Line Numbers In Eclipse on Mac OSX

Turning on Maintenance Mode for your Magento websites

 

Let’s face it – At some point in time, you’re going to have to perform some kind of maintenance on you Magento portal.

(Trust me – It’s not a question of if … Just when!)

 

This may be to perform tasks as simple as installing a new 3rd party plugin, to somewhat more complex and time consuming as performing a software upgrade, or any other reason your brilliant mind can come up with.

 

The last thing you want, when performing site maintenance, is for an “unaware” customer to be browser/transacting on your website.

( “Why!” you ask? Two Words … Customer Experience!! )

 

Given this background – the best thing to do, when performing maintenance activities on your Magento portal, is to “warn” your (potential) customers that your site is currently undergoing maintenance and may not be fully operational.

Thankfully, Magento supports the “Maintenance Mode” functionality, right out of the box, and here’s the simplest way to trigger it:

Step 1. Before you proceed any further – make sure you edit the file MAGENTO_ROOT_FOLDER/errors/default/503.phtml to contain the desired “Maintenance Mode” messaging that is compliant with your brand/service.

Step 2. If you want to access the Magento portal (i.e. the website front end or Admin back end) while performing your upgrade tasks – proceed to Steps 2. Else proceed to Step 3.

Step 2. Open the MAGENTO_ROOT_FOLDER/index.php file in edit mode using your favorite text editor (I recommend nano)

Step 2a. Enter the following text at the appropriate location (i.e. before the location of the code snippet outlned in Step 2b) of the MAGENTO_ROOT_FOLDER/index.php file:
$USER_IP = $_SERVER['REMOTE_ADDR'];

// Tip: If there are more than 1 IP addresses - enter all of them in the array declaration above

$IPS_ALLOWED_DURING_MAINTENANCE_MODE = array('ENTER_THE_PUBLIC_IP_ADDRESS_OF_THE_MACHINE_YOU_WILL_CONNECT_FROM');

Step 2b. Search for the text if (file_exists($maintenanceFile)) within MAGENTO_ROOT_FOLDER/index.php and replace it with if (file_exists($maintenanceFile) && !in_array($USER_IP, $IPS_ALLOWED_DURING_MAINTENANCE_MODE))

Step 2c. Save the changes made to the MAGENTO_ROOT_FOLDER/index.php file.

Step 3. Create a file named maintenance.flag under the MAGENTO_ROOT_FOLDER on your Magento installation server node(s).
Hint: The file doesn’t need to have any content inside.

Step 4. Clear Magento cache(s).
At this point, anyone accessing the website (i.e. except for users, connecting from machines with the IP specified in $IPS_ALLOWED_DURING_MAINTENANCE_MODE) will see the “Site Maintenance” messaging specified in Step 1.

Once you maintenance task(s) have been performed, execute the following steps below to restore the website to a “General Access” mode:

Step 1. Delete the file MAGENTO_ROOT_FOLDER/maintenance.flag.

Step 2. Clear Magento cache(s).

Step 3. Validate that you are now able to access the website from a machine/IP that’s not in the $IPS_ALLOWED_DURING_MAINTENANCE_MODE list.

Step 4. Enjoy a well deserved Beer (or four)

 
Good Luck!!  🙂

How To Log Debug Information Within Your Oracle OAF Applications

Here’s a handy guide on the API calls needed to log debug messages, from within the most commonly used Oracle OAF classes/objects in your project:

Application Module (*******AMImpl.java)
this.writeDiagnostics(this, "I am logging from the Application Module class", OAFwkConstants.STATEMENT);
OR
getOADBTransaction().writeDiagnostics(this, "I am logging from the Application Module class", OAFwkConstants.STATEMENT);

 

Controller (*******CO.java)
pageContext.writeDiagnostics(this, "I am logging from the Controller class", OAFwkConstants.STATEMENT);

 

View Object (*******VOImpl.java)
this.writeDiagnostics(this, "I am logging from the View Object class", OAFwkConstants.STATEMENT);
OR
((OADBTransactionImpl)getDBTransaction()).writeDiagnostics(this, "I am logging from the View Object class", OAFwkConstants.STATEMENT);

 

View Row Object (*******VORowImpl.java)
((OAApplicationModuleImpl) getApplicationModule()).writeDiagnostics(this, "I am logging from the VOImpl class", OAFwkConstants.STATEMENT);

 

Entity Object (*******EOImpl.java)
getOADBTransaction().writeDiagnostics(this, "I am logging from the Entity Object class", OAFwkConstants.STATEMENT);

 

EntityExpert (*******EntityExpert.java)
getOADBTransaction().writeDiagnostics(this, "I am logging from the Entity Expert class", OAFwkConstants.STATEMENT);

 

You can replace OAFwkConstants.STATEMENT with any of the following log levels:

OAFwkConstants.UNEXPECTED
OAFwkConstants.ERROR
OAFwkConstants.EXCEPTION
OAFwkConstants.EVENT
OAFwkConstants.PROCEDURE
OAFwkConstants.STATEMENT

Log File Analysis Made Easy Using SED / HEAD / TAIL / GREP

For this blog post, I’ll be running my commands against DemoLogFile.log.

SED

  • If you want to look at the content on specific line numbers, in the file that you’re interested in, use the command below:

sed -n -e 100p -e 150p -e 187p ~/Documents/temp/DemoLogFile.log
sed -n -e 100p -e 150p -e 187p ~/Documents/temp/DemoLogFile.log

  • If you want to see all the content between between two line numbers, in the file that you’re interested in, use the command below:

sed -n 100,150p ~/Documents/temp/DemoLogFile.log
sed -n 100,150p ~/Documents/temp/DemoLogFile.log

HEAD

  • If you need to view the first N lines, of the file you’re interested in, use the command below:

head -n 50 ~/Documents/temp/DemoLogFile.log
head -n 50 ~/Documents/temp/DemoLogFile.log

TAIL

  • If you want to see the last N lines, of the file you’re interested in, use the command below:

tail -n 50 ~/Documents/temp/DemoLogFile.log
tail -n 50 ~/Documents/temp/DemoLogFile.log

  • If you want to see all content except the first N lines, of the file you’re interested in, use the command below:

tail -n +350 ~/Documents/temp/DemoLogFile.log
tail -n +350 ~/Documents/temp/DemoLogFile.log

  • If you want to view the last N lines – in REAL TIME – of the file you’re interested in, use the command below:

tail -50f ~/Documents/temp/DemoLogFile.log
tail -50f ~/Documents/temp/DemoLogFile.log

GREP

  • If you want to search for specific text or patterns, within the file you’re interested in, use the command below:

grep -ri "Line # 352" ~/Documents/temp/DemoLogFile.log
grep -ri “Line # 352” ~/Documents/temp/DemoLogFile.log

  • If you want to search for specific text or patterns and a few lines following the match, within the file you’re interested in, use the command below:

grep -ri -A 10 "Line # 352" ~/Documents/temp/DemoLogFile.log
grep -ri -A 10 “Line # 352” ~/Documents/temp/DemoLogFile.log

Solving the dreaded “FRM-92095: Oracle JInitiator version too low. Please install version 1.1.8.2 or higher” issue in Oracle EBS

I recently ran into the dreaded FRM-92095: Oracle JInitiator version too low. Please install version 1.1.8.2 or higher error when I opened up Oracle Forms, on a new (client) laptop.

FRM-92095_Error

So, I thought it make sense to create a post on how you can resolve this issue.

Long story short, essentially, you have two options:

(a) Door # 1
Uninstall JDK/JRE 7x and install JDK/JRE 6x.
P.S: This not my favorite solution.

(b) Door # 2
Add a Environment Variable called JAVA_TOOL_OPTIONS and assign the value -Djava.vendor=”Sun Microsystems Inc.” to it.

Window 7 Users:
(Windows Key > Right click on My Computer > Properties > Advanced System Settings > Environment Variables > Add either a User or System attribute > Click on the New button > Enter “JAVA_TOOL_OPTIONS” under Parameter Name and -Djava.vendor=”Sun Microsystems Inc.” under Parameter Values)

Hint: If you define a System attribute, you will need to reboot your computer. If you set a User attribute you will only need to close and re-open your browser

FRM-92095_Windows7

For OS X Users:
Add -Djava.vendor=”Sun Microsystems Inc.” as a Runtime Parameter for your installed JRE.
(Apple Icon > System Preferences > Java > Click on the Java tab > Click on the View button > Enter the value -Djava.vendor=”Sun Microsystems Inc.” under the Runtime Parameter field)

FRM-92095_OSX

 

And you’re back in business!!

Create BAT/EXE like scripts on OS X

If you’ve ever wanted to create a bat/exe like script – i.e something that you can simply double-click to make it run – on a Mac, here’s how you go about it:

  • Create the file with a “.command” extension.

For example, create a file “ListAllFiles.command” with the following content:

  • Ensure the file has executable privileges.

For example, you would run the following command to make ListAllFiles.command (created above) executable

 

Navigate to the folder containing the ListAllFiles.command file and double-click it … Voila … You’re in business!

How To Access System Files And Folders On A Rooted Android Phone

If you need to access any system files or folders (E.g: /cache/) on your rooted Android phone, here’s how to go about it:

  • Connect your Android phone to your computer/mac.
  • To find your device id, open up a terminal window and type in the following command:

  • To connect to the Android device/simulator of your interest, type in the following command:

  • To access system files and folders, you will need to have superuser/root permissions. Type the following command below to achieve this:

  • Assuming your phone is rooted, and that you have a super user access management tool app installed on your phone/emulator – at this point, you will be prompted to Approve ADB Shell’s superuser access request. You should say Yes.

  • If Superuser access was approved, you will notice that you’re now logged in as ROOT on your console. You should be able to access the requisite system files or folders via the console now.

  • If Superuser access was denied, you will receive an “opendir failed, Permission denied” error when trying to system files or folders:

 

EBS Password Reset Script

Ever been unable to get into your Oracle EBS instance because you forgot your password and/or your password expired?

Don’t worry … This simple SQL script will help you reset your password:

 

 

 

 

User Input Validation In Android

Typically, in an Android application, data validation is done on “form submission” – as seen in the demo below:


Unable to display content. Adobe Flash is required.

This is usually done via an onClick button event binding that gets triggered when the submit button is pressed.

A better alternative is to run validations when the user moves from one field to the next, as shown in the demo below:


Unable to display content. Adobe Flash is required.

Take a look at the registerUserNameOnFocusChangeListener() and registerPasswordOnFocusChangeListener() methods, in the source code below, to get a better understanding on how we can leverage OnFocusChangeListener bindings to achieve this.

How To Bulk Download Course Content From Coursera.org

Step 1) Login to Coursera and navigate to the course you’re interested in:

Step 2) Navigate to the Video Lectures section of the course:

Step 3) Open the JavaScript console window in your browser.

Step 4) Run the JS snippets below to bulk download the desired course content/files:
Tip: You will need to disable any active pop-up blockers on your browser.

To Download Video (MP4)
$(‘a[title*=”Video”]’).each(function(){window.open($(this).attr(‘href’));});

Download Subtitles (SRT/TXT)
$(‘a[title*=”Subtitles”]’).each(function(){window.open($(this).attr(‘href’));});

Download Slides (PDF/PPT)
$( “a[data-link-type*=’lecture_slides’]” ).each(function(){window.open($(this).attr(‘href’));});