Saturday, June 25, 2016

How to set up Icons that displays differently amid iOS and Android devices


Hello folks,

We've already mentioned how great and powerful Ionic framework is. But it has several useful functions such as ionic.Platform.isAndroid(), ionic.Platform.isIOS(),  and ionic.Platform.isWindowsPhone()
that might be extremely helpful to you use within your code to detect which icon to use. That's a great feature that we can not skip and the reason why I've created this article just for that.

An example of this is:

var iconThiagoLeoncio;

if (ionic.Platform.isAndroid()) {
  iconThiagoLeoncio = 'ion-android-arrow-back';
} else if (ionic.Platform.isIOS()) {
  iconThiagoLeoncio = 'ion-ios-arrow-back';
} else {
  iconThiagoLeoncio = 'ion-android-arrow-back';
}


In practice, I am going to to do a simpler check. If it is Android, use the Android icon, otherwise use IOS. This won’t work as neatly if you want to specify ionic.Platform.isWindowsPhone() ,
 however so far Ionicons have no Windows Phone specific icons so I am using Android icons as standard coding project:


var iconThiagoLeoncio = ionic.Platform.isIOS() ? 'ion-ios-arrow-back' : 'ion-android-arrow-back';


When this is in objects by itself, I am going to use regularly, I am turning the object into a directive which contains this logic specifically.
For example, a custom back button (replace starter with the global app name you use for your modules in such):

angular.module('starter.directives', [])
    .directive('backbutton', [function () {
        return {
            restrict: 'E',
            replace: true,
            scope: false,
            template: '<button class="button icon button-clear"></button>',

            compile: function (element, attrs) {
                var iconThiagoLeoncio = ionic.Platform.isIOS() ? 'ion-ios-arrow-back' : 'ion-android-arrow-back';
                angular.element(element[0]).addClass(iconThiagoLeoncio);
            }
        };
    }])


This code above creates the the element below:


<backbutton ng-click="goBack()"></backbutton>

With that in mind and in your code you can reuse across many different apps and we can keep this in sych(updated) with any new changes in your location.

Very important to mention in here:
There is a back button element in Ionic, however we are creating our own simpler version for some situations, for example a custom modal windows in your project.
Keep in mind this great example just works for any other button and icons you might want to use as well.

Another IONIC article on my blog:  Ionic How to get started with Ionic

happy coding,
Thiago Leoncio

Saturday, June 18, 2016

Error Oracle Database 12c installation for IAM Oracle


Hello my friends,


If you run into the error "error invoking target irman ioracle of makefile" while trying to install Oracle Database, and the log shows a missing ljavavm12 library, you might need to copy the java library like so:



cp /opt/oracle/product/12.1.0/dbhome_2/javavm/jdk/jdk6/lib/libjavavm12.a /opt/oracle/product/12.1.0/dbhome_2/lib/


I hope it helps,
Thiago Guimaraes

Saturday, June 4, 2016

How to get details from current machine in java using JNA(Java Native Access)

hello Folks,

[Java - Coding time]


  • How to get details from current machine in java.

More about JNA:

Java Native Access (JNA)

To use Windows and the domain controller for authentication, we can use native Windows APIs. To call those APIs in Java, we can use the Java Native Access (JNA) library, which you can find on GitHub at https://github.com/twall/jna and on Maven central:

[Libs]


[Source Code]


/**
 *
 */
package thiago.leoncio;

import java.net.UnknownHostException;
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.Advapi32Util.Account;

/**
 * @author THiago
 * @Date 06/04/2016
 * @Description: How to get details from current machine.
 * @libs for JNA(jna.jar;jna-min.jar;jna-platform.jar)
 */
public class MachineDetails {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

System.getProperty("user.name"); //platform independent
java.net.InetAddress localMachine = null;
try {
localMachine = java.net.InetAddress.getLocalHost();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Hostname of local machine: " + localMachine.getHostName());
System.out.println("UserName logged on your machine:" +System.getProperty("user.name"));
System.out.println("=========== Java Native Access (JNA) details ===========");
for(Account account: Advapi32Util.getCurrentUserGroups()){
       System.out.println(account.fqn);
    }

}

}




[Output]:
Hostname of local machine: TLEONCIO_LAPTOP
UserName logged on your machine: tleo73638
=========== Java Native Access (JNA) details ===========
WST\domain users
Everyone
BUILTIN\Administrators
BUILTIN\Users
NT AUTHORITY\INTERACTIVE
CONSOLE LOGON
NT AUTHORITY\Authenticated Users
NT AUTHORITY\This Organization
..

Please, see this JNA and Waffle article also:  http://phonecoding.com/2016/10/how-to-use-waffle-library-for-jna-java.html



happy coding,
--Thiago