Search Results


Friday, April 03, 2020

Fizzbuzz Program

Python 1
for num in range(1, 21):
    if num % 3 == 0 and num % 5 == 0:
        print('FizzBuzz')
    elif num % 3 == 0:
        print('Fizz')
    elif num % 5 == 0:
        print('Buzz')
    else:

        print(num)

Python2
for i in range(1, 21):
    print ("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i) )


Powershell
for ($i = 1; $i -lt 21; $i++) {
  $output = ""

  if ($i % 3 -eq 0) {
    $output += "Fizz"
  }

  if ($i % 5 -eq 0) {
    $output += "Buzz"
  }

  if ($output -eq "") {
    $output = $i
  }  Write-Output $output
}


Bash script
#!/bin/bash

x=1

while [ $x -le 21 ]
do
  if [[ 0 -eq "($x%15)" ]]
  then
    echo "fizz buzz"
  elif [[ 0 -eq "($x%5)" ]]
  then
    echo "buzz"
  elif [[ 0 -eq "($x%3)" ]]
  then
    echo "fizz"
   else
    echo "$x"
   fi   
  x=$(( $x + 1 ))
Done



Javascript
console.log("One Liner");
for (let i = 0i < 21; )
  console.log((++i % 3 ? "" : "fizz") + (i % 5 ? "" : "buzz") || i);
console.log("Simpler");

for (var i = 1i < 21i++) {
  if (i % 15 === 0console.log("FizzBuzz");
  else if (i % 3 === 0console.log("Fizz");
  else if (i % 5 === 0console.log("Buzz");
  else console.log(i);
}



Java
package client;

public class Fizzbuzz {
    public static void main(String[] args) {
        IntStream.range(1, 16)
.mapToObj(i -> {
if (i % 15 == 0)
return "FizzBuzz";
else if (i % 3 == 0)
return "Fizz";
else if (i % 5 == 0)
return "Buzz";
else
return "" + i;
}).forEach(System.out::println);
       }
   }
}

C
#include

int
main ()
{
  int i;

  for (i = 1; i < 21; i++)
    {
      if (i % 15 == 0)
        printf ("FizzBuzz");
      else if (i % 3 == 0)
        printf ("Fizz");
      else if (i % 5 == 0)
        printf ("Buzz");
      else
        printf ("%d", i);
      printf("\n");
    }

  return 0;
}

Go-Lang
package main

import (
    "fmt"
)

func main() {
  for i := 1; i < 21; i++ {
        if i%15 == 0 {
            fmt.Println("FizzBuzz")
        } else if i%3 == 0 {
            fmt.Println("Fizz")
        } else if i%5 == 0 {
            fmt.Println("Buzz")
        } else {
            fmt.Println(i)
        }
    }
}


PL/SQL
set serveroutput on;

declare
    i number := 0;
begin
    for i in 1..21
    loop
        if mod(i, 3) = 0 and mod(i, 5) = 0 then
            dbms_output.put_line('FizzBuzz');
        elsif mod(i, 3) = 0 then
            dbms_output.put_line('Fizz');
        elsif mod(i, 5) = 0 then
            dbms_output.put_line('Buzz');
        else
            dbms_output.put_line(to_char(i));
        end if;
    end loop;
end;
/


Oracle SQL
select rownum i,
       case
       when mod(rownum, 3) = 0 and mod(rownum, 5) = 0 then 'FizzBuzz'
       when mod(rownum, 3) = 0 then 'Fizz'
       when mod(rownum, 5) = 0 then 'Buzz'
       else to_char(rownum)
       end
from dual
connect by level < 21;

The Theory of Constraints

The Theory of Constraints is a methodology for identifying the most critical limiting factor that stands in the way of achieving a goal and then systematically improving that constraint until it is no longer the limiting factor. In manufacturing, the constraint is often referred to as a bottleneck.

The core concept of the Theory of Constraints is 
  • Every production system is composed set of chained events the led to the creation of finished goods or services.
  • The whole system is called Flow, the raw material goes in one end, and finished goods come from the other end.
  • The rate of Output of the Flow is directly proportional to the Output of the weakest link in the Flow. And the weakest link is called a bottleneck.
  • To improve capacity, we just have to improve the bottleneck. 
  • Its everyone's responsibility in the organization to swarm around and fix the bottleneck if it is stuck.
  • Any improvements not done at the bottleneck is just an illusion.


The Five Focusing Steps
The Theory of Constraints provides a specific methodology for identifying and eliminating constraints, referred to as the Five Focusing Steps. It is a cyclical process.

Identify
Identify the current constraint (the single part of the process that limits the rate at which the goal is achieved).

Exploit 
Make quick improvements to the throughput of the constraint using existing resources (i.e. make the most of what you have).

Subordinate 
Review all other activities in the process to ensure that they are aligned with and truly support the needs of the constraint.

Elevate 
If the constraint still exists (i.e. it has not moved), consider what further actions can be taken to eliminate it from being the constraint. Normally, actions are continued at this step until the constraint has been “broken” (until it has moved somewhere else). In some cases, capital investment may be required.

Repeat 
The Five Focusing Steps are a continuous improvement cycle. Therefore, once a constraint is resolved the next constraint should immediately be addressed. This step is a reminder to never become complacent – aggressively improve the current constraint…and then immediately move on to the next constraint.


Although this is created initially for the Manufacturing industry to manage production system, it could really be applied to anything.

The idea is to concentrate the core efforts on most pressing issues facing the organization.



Tuesday, November 29, 2016

Import certificates using keytool

Keytool


One of the import step to call an https webservice using java is to import the SSL certificates before initiating a call.

This example shows the certificates imports on a default weblogic certificates path. However this could be different on your weblogic server, so make sure the path is checked before installing the certificates.


cd /u01/app/oracle/products/jdk1.8.0_66/bin

Install
./keytool -import -keystore /u01/app/oracle/products/fmw1213/wlserver/server/lib/DemoTrust.jks -alias salesforcecom_test -storepass DemoTrustKeyStorePassPhrase -file ~/SalesforceCert.cer

Verify
keytool -list -keystore /u01/app/oracle/products/fmw1213/wlserver/server/lib/DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase -alias salesforcecom_test

Notepad++ plsql function list


Locate functionList.xml file on the Notepad++ install location.

Add association map

<association langID="17" id="sql_node"/>


And the following parser

<parser id="sql_node" displayName="SQL Node" commentExpr="((/\*.*?\*)/|(--.**$))">
    <function
            mainExpr="^[\s]{0,}(function|procedure|--[1-9])[\s]{1,}[\w_]{1,}">
            <functionName>
                  <nameExpr expr="^[\s]{0,}(function|procedure|--[1-9])[\s]{1,}\K[\w_]{1,}"/>
            </functionName>
    </function>
</parser>

And finally restart the Notepad++

Now enable View -- FunctionList

This should bring you list of all functions and procedures in the current sql or plsql file.

You can click on it to navigate to selected code block.

How to deploy XML publisher report to R12

XML Publisher deployment



To deploy concurrent program and request groups follow this link (FNDLOAD).

Deploy XMLP Entries

Following creates metadata for the XML publisher data definition and the associated template. This entries have to be created before uploading the actual files.

FNDLOAD apps/apps O Y DOWNLOAD  $XDO_TOP/patch/115/import/xdotmpl.lct XXC_CUSTOM_S.ldt XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME='XXC' DATA_SOURCE_CODE='XXC_CUSTOM' TMPL_APP_SHORT_NAME='XXC' TEMPLATE_CODE='XXC_CUSTOM'



FNDLOAD apps/apps O Y UPLOAD $XDO_TOP/patch/115/import/xdotmpl.lct CUSTOM.ldt


Deploy RTF


java oracle.apps.xdo.oa.util.XDOLoader \
UPLOAD -DB_USERNAME $APPS_UN \
-DB_PASSWORD $APPS_PW -JDBC_CONNECTION \
$DB_IP_ADDR:$DB_PORT_NO:$APPS_INS \
-LOB_TYPE TEMPLATE -LOB_CODE XXCUSTOM_CODE \
-APPS_SHORT_NAME $XXC -LANGUAGE 'en' \
-XDO_FILE_TYPE 'RTF' -FILE_CONTENT_TYPE 'application/rtf' \
-lct_FILE $XDO_TOP/patch/115/import/xdotmpl.lct \
-LOG_FILE LXXCUSTOM.log \
-FILE_NAME $LOAD_DIR/XXCUSTOM.rtf \
-CUSTOM_MODE FORCE


Deploy XLS



java oracle.apps.xdo.oa.util.XDOLoader \
UPLOAD \
-DB_USERNAME $APPS_UN \
-DB_PASSWORD $APPS_PW \
-JDBC_CONNECTION $DB_IP_ADDR:$DB_PORT_NO:$APPS_INS \
-LOB_TYPE TEMPLATE \
-APPS_SHORT_NAME $XXC \
-LOB_CODE XXCUSTOM_CODE \
-LANGUAGE en \
-TERRITORY 00 \
-NLS_LANG American_America.AL32UTF8 \
-XDO_FILE_TYPE XLS \
-FILE_CONTENT_TYPE application/rtf \
-FILE_NAME XXCUSTOM.xls \
-LOG_FILE L_XXCUSTOME.log     -CUSTOM_MODE FORCE


Deploy Data template



java oracle.apps.xdo.oa.util.XDOLoader \
UPLOAD \
-DB_USERNAME $APPS_UN \
-DB_PASSWORD $APPS_PW \
-JDBC_CONNECTION $DB_IP_ADDR:$DB_PORT_NO:$APPS_INS \
-LOB_TYPE DATA_TEMPLATE \
-APPS_SHORT_NAME $XXC \
-LOB_CODE XXCUSTOMER_CODE \
-LANGUAGE en \
-TERRITORY 00 \
-NLS_LANG American_America.AL32UTF8 \
-XDO_FILE_TYPE XML-DATA-TEMPLATE \
-FILE_CONTENT_TYPE text/xml \
-FILE_NAME XXCUSTOM.xml \
  -LOG_FILE L_XXCUSTOM.log       -CUSTOM_MODE FORCE



Friday, October 21, 2016

Bounce R12 apache server


Restart R12 apache server


Stop Server
sh $INST_TOP/admin/scripts/adoacorectl.sh stopall

Start Server
sh $INST_TOP/admin/scripts/adoacorectl.sh startall

Check Server status
sh $INST_TOP/admin/scripts/adoacorectl.sh status -l


Clear HTML cache :

# Stop the server
cd $ADMIN_SCRIPTS_HOME
./adopmnctl.sh stopall
./adoacorectl.sh status  -l  
cd $COMMON_TOP/_pages
# Here are the java classes to clear.
ls -l (Check the files)
rm *

# Compile the jsp files
cd $FND_TOP/patch/115/bin
ojspCompile.pl --compile --flush -p 10
cd $COMMON_TOP/_pages
ls -l (Check the files)

# Start the server again
cd $ADMIN_SCRIPTS_HOME
./adopmnctl.sh startall
./adoacorectl.sh status  -l

Thursday, September 29, 2016

Oracle apps R12: Useful profile option

Some useful R12 Profile Options


Output/Log Viewer

This option makes the concurrent program output to be opened in the internet explorer rather than form window.

Profile Option Name: Viewer: Text      
User: Value: browser


About this page: link

It enabled the "About this Page" link at the bottom of any OAF page. This link helps to find more information about the OA Framework page.

Profile Option Name: FND: Diagnostics 
User: Value: Yes


Forms Diagnostics

To get Diagnostics menu in forms use the following profile option

Profile Option Name: Hide Diagnostics menu entry
User Value: No

Profile Option Name: Utilities:Diagnostics
User Value: Yes


Session Timeout

This one lets the user stay logged-in longer.

Profile Option Name: ICX: Session Timeout
User Value (in Minutes): 180 


ICX: Limit time


This profile option defines the maximum connection time for a connection – regardless of user activity.
If 'ICX:Session Timeout' is set to NULL, then the session will last only as long as 'ICX: Limit Time', regardless of user activity.

Profile Option Name: ICX: Limit time
User Value (in Hours): 4



Wednesday, September 28, 2016

Jdeveloper Salesforce Adapter error

This version of the client is no longer supported


One fine day I opened the jdeveloper and added a new salesforce adapter component. I selected the wsdl and entered the username, password+security key and then "booom!!".

A nasty error message "This version of the client is no longer supported.".





What the heck is wrong with jdeveloper, you worked fine for years and why are you doing this now? grrr!!.

Would you ever give me a meaningful error message?!!

Solution


After a bit of research it is same problem we had with the server. Salesforce has disabled TLSv1.0 for all the SSL communications. (Find out more information about this here SalesForce TLS 1.0 has been disabled)

Luckily the solution is simple, just add  the following in your ../jdeveloper/jdev/bin/jdev.conf file:
AddVMOption -Dhttps.protocols=TLSv1.1 


And restart the Jdeveloper.

Note: This solution should work on both Jdev 12c and 11g

Tuesday, August 23, 2016

Automatic java mouse mover

There are many solutions to moving mouse automatically to keep the screen active in windows.

For java programmers, simple solution is to write a java program to move the mouse automatically.


package movemouse;

import java.awt.MouseInfo;
import java.awt.PointerInfo;
import java.awt.Robot;

import java.util.Random;

public class moveMouse {
    public moveMouse() {
        super();
    }

    public static final int WAIT = 60 * 1000; // SECONDS
    public static final int OFFSET = 3;

    public static void main(String... args) throws Exception {
        int x, y;
        Robot robot = new Robot();
        Random random = new Random();
        PointerInfo a;

        while (true) {

            a = MouseInfo.getPointerInfo();
            x = (int) a.getLocation().getX();
            y = (int) a.getLocation().getY();
            robot.mouseMove(+ OFFSET, y + OFFSET);
            Thread.sleep(WAIT);

            a = MouseInfo.getPointerInfo();
            x = (int) a.getLocation().getX();
            y = (int) a.getLocation().getY();
            robot.mouseMove(- OFFSET, y - OFFSET);
            Thread.sleep(WAIT);
        }
    }
}



Compile and Enjoy!

If you don't have jdk use this jar file (moused.jarred). Open the link and clikc on Download button to download the file and then rename it to jar. Use the following command to execute it.

java -jar moused.jar

Thursday, August 18, 2016

Some Useful FNDLOAD commands

Following are some of the useful commands to migrate WEBADI, Concurrent programs and request set link in EBS R12.

WEB ADI or Oracle Data Integrator


FNDLOAD apps/apps 0 Y DOWNLOAD $BNE_TOP/patch/115/import/bneintegrator.lct ldt_file_xintg.ldt BNE_INTEGRATORS INTEGRATOR_ASN="XXC" INTEGRATOR_CODE="TEST_XINTG"


FNDLOAD apps/apps 0 Y UPLOAD $BNE_TOP/patch/115/import/bneintegrator.lct ldt_file_xintg.ldt

Concurrent Programs


Concurrent program download also extracts the Executables and value sets along with it.

FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct $program.ldt PROGRAM APPLICATION_SHORT_NAME=XXA CONCURRENT_PROGRAM_NAME=$program


FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct XXtestfile.ldt WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


Request set and links


These commands will export both Request set and request set links.

FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct testfile.ldt REQ_SET_LINKS REQUEST_SET_NAME='XXTEST_REQ_SET'



FNDLOAD $APPS_UN/$APPS_PW 0 Y UPLOAD @FND:patch/115/import/afcprset.lct $LDT_DIR/testfile.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


FND Messages


Following command will download and load fnd messages.

FNDLOAD apps/$APPS_PW 0 Y DOWNLOAD $FND_TOP/patch/115/import/afmdmsg.lct messages_file.ldt FND_NEW_MESSAGES APPLICATION_SHORT_NAME="XXC" MESSAGE_NAME="MESSAGE_NAME"


FNDLOAD apps/$APPS_PW 0 Y UPLOAD $FND_TOP/patch/115/import/afmdmsg.lct XXC_UBM_HR_DEDUCTION_CODE_MISS.ldt WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE







Tuesday, June 28, 2016

SalesForce - TLS 1.0 has been disabled - Oracle SOA BPEL webservice

One fine day all of a sudden I started getting the following errors from all the web-services trying to connect to the SalesForce system.

Client received SOAP Fault from server : UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.

Ok, the SalesForce system was upgraded over the weekend. And one of the upgrades was to stop supporting TLS 1.0 and only support TLS 1.1 or higher version of SSL protocols.


Question:


How do we upgrade Oracle SOA web services to support TLS 1.1 or higher? 
Where does this  settings resides and how do we change it?

What a nightmare!

Luckily this is something that Java 7 supports, Phew! And it is just a matter of setting the system param

-Dhttps.protocols=TLSv1.1,TLSv1.2

or code as

System.setProperty("https.protocols", "TLSv1.1,TLSv1.2");

in your java program before calling the webservice.

How to change it in Oracle SOA?

  • Login to SOA server (windows/Unix)
  • Goto Domain home and then cd bin
  • vi setSOADomainEnv.sh
    • and past the following content at the end of the file
EXTRA_JAVA_PROPERTIES="${EXTRA_JAVA_PROPERTIES} -Dhttps.protocols=TLSv1.1,TLSv1.2"
export EXTRA_JAVA_PROPERTIES
  • Now bounce the SOA managed servers.
  • If you have a clustered server then remember to do it on all the nodes.
  • This solution works on Oracle SOA 12.1.3



Friday, May 06, 2016

Weblogic Tips

Some common weblogic tasks


Setting CLASSPATH


in Windows

Append the following lines to the file $DOMAIN_HOME/bin/setDomainEnv.cmd
CLASSPATH=%CLASSPATH%;%DOMAIN_HOME%/Properties


in Unix

Append the following lines to the file $DOMAIN_HOME/bin/setDomainEnv.sh
CLASSPATH="${CLASSPATH}${CLASSPATHSEP}${DOMAIN_HOME}/Properties"
export CLASSPATH


Normally files stored in the domain home could be accessed without having to set class path, this example is just for illustration.

Setting Boot.properties


You could set username and password in the properties files so that you dont have to enter weblogic credentials every time the server is started. It has to be done for every server

create a folder security under $domain_home/servers/AdminServer
create a new file boot.properties and enter the following

username=weblogic
password=welcome1

The clear text password will be automatically changed to encrypted one when the weblogic starts up for the first time


Script to Start and Stop servers


Startup Script

#!/bin/bash

cd /d01/fmw1213/oracle_common/common/bin

./wlst.sh<<ThisIsTheEnd
nmConnect('nodemanager','welcome1','wlHostname','5556','soa_domain','/u01/app/oracle/config/domains/soa_domain')
nmStart('AdminServer')

ThisIsTheEnd

exit 0


Shutdown Script

#!/bin/bash

cd /d01/fmw1213/oracle_common/common/bin

./wlst.sh<<ThisIsTheEnd
nmConnect('nodemanager','welcome1','wlHostname','5556','soa_domain','/u01/app/oracle/config/domains/soa_domain')
nmKill('AdminServer')

ThisIsTheEnd

exit 0




Script to Start and Stop NodeManager

Startup Script

#!/bin/bash

cd /d01/fmw1213/oracle_common/common/bin

./wlst.sh<<ThisIsTheEnd

startNodeManager(verbose='true',NodeManagerHome='/d01/fmw1213/config/domains/soa_domain/nodemanager',ListenPort='5556',ListenAddress='wlHostname')

ThisIsTheEnd

exit 0


Shutdown Script

#!/bin/bash

cd /d01/fmw1213/oracle_common/common/bin

./wlst.sh<<ThisIsTheEnd

nmConnect('nodemanager','welcome1','wlHostname','5556','soasit_domain','/d01/fmw1213/config/domains/soa_domain')
stopNodeManager()


ThisIsTheEnd

exit 0



Managing Log files


Refer this link


Decrypt Weblogic passwords


Refer this link


How to increase heap space and permgen space?


Refer this link




Wednesday, May 04, 2016

Testing network connectivity from Salesforce

One of the challenges with consuming the web-service from SalesForce is that lack of tools, like telnet and ping, to test the network connectivity.

But luckily we code execute anonymous code in SalesForce from Developer console. Here are the steps to test web-service from sales-force.

Register URL 


All the URLs must be registered in SalesForce remote site settings before being called by the code.

  • Go to Setup > Security Controls > Remote Site Settings
  • Click on New Remote Site, enter the following and click Save
    • Remote Site Name: XX_TEST
    • Remote Site URL: http://domainhost/
  • Click Save


SalesForce Test Code


  • Go to the Developer Console 
  • Navigate Debug > Open Execute Anonymous Window  (Ctrl + E)
  • Execute the following code
  • Logs should show up in the Query Results Window


String soapEndpoint = 'https://blabla/test';
String soapBody = 'soap envelope';

HttpRequest req = new HttpRequest();
Http http = new Http();
HttpResponse resp = new HttpResponse();
req.setEndpoint(soapEndpoint);

//add Request header
req.setMethod('POST');
req.setHeader('Content-type', 'text/xml; charset=utf-8');
req.setHeader('SOAPAction', 'namesspace for wsdl');
req.setBody(soapBody);
System.debug(soapBody);

// add the endpoint to the request
try {
System.debug('Sending request');
resp = http.send(req);
System.debug(resp.toString());
System.debug(resp.getBody());
}  catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
}

Friday, April 29, 2016

SOA Composite management commands

SOA Suite Utilities

These are some of the useful wlst commands to manage SOA composites. These are better alternatives to navigating the EM console for SOA management tasks.

Before executing these commands set the JAVA_HOME and path variables for wlst commands to work. If your using unix or linux then use linux syntax for setting path variable and java_home and then run wlst.sh under the same oracle path.

Open cmd and enter the following

  • set JAVA_HOME=C:\UBM\Programs\jdk1.7.0_79
  • set path=C:\UBM\Programs\jdk1.7.0_79\bin;C:\Oracle\Middleware12c\Oracle_Home\oracle_common\modules\org.apache.ant_1.9.2\bin;%PATH%
  • cd C:\Oracle\Middleware12c\Oracle_Home\soa\common\bin
  • ./wlst.sh or wlst.cmd

Starts SCA composite

sca_startComposite('hostname', '8001', 'weblogic', 'welcome1', 'TestSCAProcess', '1.0', partition='default')

Stops SCA composites

sca_stopComposite('hostname', '8001', 'weblogic', 'welcome1', 'TestSCAProcess', '1.0', partition='default')

Undeploy SCA composites

sca_undeployComposite("http://hostname:8001", "HelloWorld", "1.0", user="weblogic", password="welcome1",partition='myPartition')

Lists all SOA composites

sca_listDeployedComposites('hostname', '8001', 'weblogic', 'welcome1')

Assign Default composite

Sets a SOA composite application revision as the default version. This revision is instantiated when a new request comes in.
sca_assignDefaultComposite("hostname", "port", "weblogic", "welcome1","HelloWorld", "1.0", partition='myPartition')

Delete MDS files

# This command will delete all the files under /apps directory in mds.
connect('weblogic', 'welcome1', 't3://localhost:7101');
deleteMetadata(application='soa-infra',server='DefaultServer',docs='/apps/**');