String Ordered Permutation Algorithm Problem

String Permutation Problem

The algorithm problem goes something like this:

If you are given a character and its possible substitution set, then write a function that would print all the permutation of its characters.


Given word “java”

Substitution Set =>
j [“J”, “7”]
a [“@”, “J”, “9”]
v [“V”, “^”]

Based on this, the possible permutations could be: J@V@, 7JV9..

Here is my approach using java

package com.gullele;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

 * @author
public class PassPermutation {
	 * Holds the result of the permutation
	private List result;
	 * @param args
	public static void main(String[] args) {
		PassPermutation word = new PassPermutation();
		List words = word.wordToListMapper("java");
		word.permuteIt("", words, 0);
		for (String str : word.result) {
	 * Recursive function to handle the permutation.
	 * @param words
	private void permuteIt(String part, List words, int index) {
		int size = words.size();
		if (index == size-1) {
			String word = words.get(words.size()-1);
			for (int i=0 ; i < word.length() ; i++) {
				this.result.add(part + word.charAt(i));
		} else {
			String word = words.get(index);
			for (int j=0 ; j < word.length() ; j++) {
				part += word.charAt(j);
				permuteIt(part, words, index);
				part = part.substring(0, part.length()-1);
	private void initializeResult() {
		this.result = new ArrayList();
	 * A word to its combination mapping
	 * @param word
	 * @return
	private List wordToListMapper(String word) {

		Map mapper = this.dictionary();
		List mapped = new ArrayList();
		for (Character c:word.toCharArray()) {
			if (mapper.containsKey(c)) {
		return mapped;
	 * A mapping dictionary.
	 * @return
	private Map dictionary() {
		Map mapper = new HashMap();
		mapper.put('j', "J7");
		mapper.put('a', "@J9");
		mapper.put('v', "v^");
		return mapper;

setting JAVA_HOME on mac osx

How to set JAVA_HOME ON MAC OSX computer

Setting java_home as environment variable might be almost required especially when you use frameworks. Frameworks like axis2 web server and others. Also some code editors require that too.

What is environment variable

Those are variables that would allow you to execute command line actions from any directory, basically from everywhere.

The simplest example is using java -version. In this case, if you don’t have explicit environment variable on where to look for, it requires you to either be in the java folder or to fully list the whole path till bin folder.

Setting JAVA_HOME in mac osx

The first part is to make sure you have java installed in your machine.

java -version

If this is giving you an output with the version, then it means java is installed, otherwise, you should first install it.

The following task will be to find out where the binary files are located.

Click the apple icon on the left top corner of your mac and select system preferences..

system preference

system preference

And from there click Java and you will get the path information from there.

Once you got where the java is located, usually on /Library/Java/JavaVirtualMachines/jdk1.***/Contents/Home

Open the bash properties file

vi ~/.bash_profile

And add the java path here

export JAVA_HOME=export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

The above would be what it would look like fro jkd 1.8 on my El Capitan macbook pro.

react-native application has not been registered

react-native application has not been registered command error

Playing with react for the mobile development and getting this error?

There are a number of reasons for this to happen.

the name of the react-native class is not matching

Give attention to the line you have something like this

AppRegistry.registerComponent('YOUR-COMPONENT', () => YOUR-COMPONENT);

The name of the component you will be referring as ‘YOUR-COMPONENT’ should align with the main class you refer.

Other instance of node or the react-native app might be running

If other instance of the node process is running make sure to kill it and have clear for the current application you are working on.

ps aux | grep react-native 

Kill the processes that you see on the ps and start the application again.

To kill the process just use kill
Then do the react-native run-ios

hello world weblogic – hello world tutorial on weblogic

hello world weblogic app server

There are lots of application servers for java and oracle weblogic is one of them. As of this writing the current and latest weblogic server is 12c

I will show a simple hello world tutorial on weblogic. The tutorial is for beginners of weblogic server.

This hello world weblogic tutorial assumes you have java skill already.

Installing weblogic server

First thing first, lets install and configure weblogic server

Go here and download the one which says Quick Installer for Mac OSX, Windows and Linux (209 MB). It will give you a zip file.

Unzip the file to get fmw_12.

Run the jar file as
java -Xmx1024m -jar fmw_12.
And follow the wizard – stay tuned it might take a while

Upon completion, you will get a folder wls12212

Get inside wls12212 folder and issue the following command to configure domain

$ bash oracle_common/common/bin/

The above command will trigger wizard to follow. Just pick the default values. There is a part where you will be asked for username and password as well.

To start the server run the following
bash user_projects/domains/base_domain/

And try to access the server through http://localhost:7001/console

Yaay.. you got your weblogic server up and running.


web logic server

Now you can deploy any web applications to the server

On the left pane of the console, you will see deploy link and clicking on that should give you a tool to locate and deploy your war files or folders. If you have simple hello world web app war file upload it there.

You can get sample hello world war file from here

Download the above war file and go to deployments->configuration and click on install.

On the path, locate the downloaded war file and click next next.

Once it is loaded, access the file by going to

Simple Servlet example without eclipse

Simple servlet example – how to create servlet without eclipse

These days we are all surrounded by heavy frameworks that make life easier for us. Like maven, spring and hibernate and more. But how can we create a simple servlet website without the need of all those.

The main idea of servlet lies around very simple and intuitive files and structures. Knowing those only is good enough to built a good web app and that is what I will be showing here.

The main parts of the java web app are the following.

1. The Servlet – the java class that is handling the POST and GET http verbs
2. the deployment descriptor – web.xml. File telling how the webapp should be interacted like the url pattern
3. Servlet jar file – This is the jar handling the magic of interaction with the web for the servlet.

Structure of the webapp

Consuming SOAP tutorial – Using java eclipse

Consuming SOAP tutorial from java step by step

SOAP, Simple Object Access Protocol, is older and still usable protocol for exchanging messages between systems.

Since soap is xml based, it is language and operating system independent. You can publish a soap service through your wsdl using Java on Linux and you can consume it through PHP application running on windows.

These days, SOAP is a bit lagging behind RESTful services which are rather more of architectural approaches than being protocol by themselves.

This is a tutorial showing how to consume an existing SOAP service using java language.

For this example, I will use a WSDL published on

In this one, I use already established wsdl for weather related tasks.

Eclipse has a nice tool to make life easier to consume SOAP related messages and I will show you here step by step.

Consuming SOAP tutorial step by step

1. Go ahead and create a new dynamic java project on your Eclipse

dynamic java project

java project

dynamic web project

dynamic web project

Continue reading Consuming SOAP tutorial – Using java eclipse

sftp connection

connect to sftp from php

connecting sftp using php

What is SFTP
When to use SFTP
Automating SFTP
What to consider when automating
SFTP download using php code
SFTP upload using php code
List all files on SFTP Server

What is SFTP

SFTP, Secure File Transfer Protocol, is more applicable these days where cyber security is at its peak. Whenever possible, one has to use SFTP as the communications are encrypted.

Most of tools that are used for FTP like filezilla allows using SFTP with minor adjustment. SFTP has to be supported by the server that is providing the FTP server and usually uses different port than that of the FTP.

SFTP is pretty much like FTP as far the connection and usage is concerned. It has just another layer of security to make it more secure while uploading and downloading the file.

Basic server address, username, password and port are still necessary to connect and interact with SFTP server.
Continue reading connect to sftp from php

jQuery Select Option from Json

jQuery select option population using json as data source

jQuery select option tutorial will show how you can glue together the following terms together

  • select box
  • JSON
  • jQuery
  • *Javascript

* You might ask isn’t jQuery javascript? Yes indeed you are right, but jQuery is a framework making javascript programming a lot easier.

When I say plain javascript, or as some are calling it old school javascript, I meant to use the same task without using jQuery.

What select box is and types of select box options

Select box is one of the most used HTML element along with text input, radio option and the like.

Select box will allow you to provide dropdown options where you can select one or more items from it. You can make the select box to allow multiple selection using multiple attribute

Continue reading jQuery Select Option from Json

Passing composite object parameter to jersey in Restful Java web

How to pass complex object parameter to jersey

In this tutorial, I will try to show how to pass composite object as a parameter to jersey’s endpoint java application.

It seems like you are working on RESTful API based java application. In that case, chances are high that you are working with jersey.

If you are not familiar with jersey, jersey is an implementation of JAX-RS APIs. Hence, it is a seamless framework by which API based java projects can be implemented.

As of this writing, the current version of jersey is 2.23.
Continue reading Passing composite object parameter to jersey in Restful Java web