Skip navigation
1 2 Previous Next

Mahmoud Rabie's Blog

17 posts

Goal

  • Architecting for DevOps by replacing large Monolithic Applications with Microservices.

 

Key-enabling technology

Docker containers

 

Services Orchestration

Swarm

 

Microservices Application Lab (using Swarm)

https://training.play-with-docker.com/swarm-stack-intro/

 

Reference

https://www.docker.com/solutions/microservices

Continuous Improvement is on of the core principles of DevOps

Screen Shot 2018-12-31 at 7.14.53 AM.png

 

What is DMAIC?

     Continuous improvement is to solve problems in order to:

  • deliver better value faster and cheaper to the customers,
  • bring more meaning to your work,
  • and/or leave a healthier environmental footprint.

     A well-known method to for structured problem solving to facilitate continuous improvement, is DMAIC.

 

DMAIC is an acronym that stands for Define, Measure, Analyze, Improve, and Control. It represents the five phases that make up the process:

Screen Shot 2018-12-31 at 7.10.23 AM.png

Reference

DASA DevOps Fundamentals

Prerequisites

Microsoft Windows [Version 10.0.17134.472]

 

Steps

(1) Download Office 365 Offline/Standalone installer O365HomePremRetail.img

(2) Mount the img

(3) Install from the file Office\Setup64

(4) Download and Install BIPublisherDesktop64

(5) Go to folder C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\DotNetInstallFiles

(6) Install TBAddInSetup64 into this location C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\TBAddInSetup64

(7) Word --> Options --> Manage COM Add-ins

(8) Activate Oracle BI Publisher Desktop

Goal

Developer (Dev) and DBA (Ops) together must build a new web application for the recently-acquired coffee shops chain

 

Preconditions

- Oracle DB 12c as JSON document store.

 

Why JSON?

JSON supported by all Oracle features

- Analytics

- Encryption

- In-Memory

- RAC

- Parallel SQL

 

How is JSON stored?

- No special data type for JSON. It can be VARCHAR2, BLOB or CLOB.

- Add CONSTRAINT checks could validate the input document.

SQL> CREATE TABLE orders(order_details BLOB  
                            CONSTRAINT is_json 
                                 CHECK (order_details IS JSON)      );

 

Native SQL support for JSON

Screen Shot 2018-12-28 at 1.21.53 PM.png

 

Reference

https://www.nloug.nl/downloads/ogh20170615_m._colgan.pdf

Prerequisites

- Remote Oracle Database + ORDS 17.3 or later

- ORDS instance having a connection pool configured for target database

 

The Basics

Execute any SQL through a REST Endpoint - e.g. "curl" utility

curl   -H    "Content-Type:application/json"
       -u    "SOCTT:TIGER"
       -d    '{"statementText":"select systimestamp as dt from dual"}'
       http://{ords-hostname}:{ords-port}/ords/{db-schema}/_/sql

 

And the response would be the following self-describing JSON

Screen Shot 2018-12-26 at 10.04.26 PM.png

 

Using Remote Database Connections

(1) Shared Components --> Data Sources --> REST Enabled SQL

( Name, End Point, Authentication)

(2) Use a REST Enabled SQL Service and therefore a remote Oracle database as the Data Source for Oracle APEX components like:

• Classic Reports, Interactive Reports

• Reflow Report, Toggle Columns Report

• Tree Region, JET Charts, CSS Calendar

• PL/SQL Process

Screen Shot 2018-12-27 at 8.55.02 AM.png

 

 

Using Custom PL/SQL Code

  • Access REST enabled SQL sources within custom PL/SQL Code:
    • Execute query and provide a "cursor" object APEX_EXEC.OPEN_REMOTESQL_QUERY
    • Execute a PL/SQL block anonymously APEX_EXEC.EXECUTE_REMOTE_SQL
  • Use REST Enabled SQL as a Plug-In developer:
    • "Region Source supports different Data Sources" Plugin Attribute
    • Use APEX_EXEC PL/SQL package in Plug-In code

 

Reference

https://www.oracle.com/technetwork/developer-tools/apex/overview/apex-181-new-features-otn-4491380.pdf

Goal

MLE will be added to Oracle APEX upcoming releases. It contains the support of brilliant language Python. I will be ready to integrate my code once its ready!

 

Given:

- macOS High Sierra 10.13.6

- python3 Version

$ python3 --version
Python 3.7.1

 

- brew version

$ brew --version
Homebrew 1.8.6

 

Prerequisites

brew

brew install mpg321
brew install portaudio

 

pip3

pip3 install amp
pip3 install pyaudio
pip3 install pyspeech
pip3 install speechrecognition
pip3 install googletrans

 

ArToEnVoiceTranslator.py

#!/usr/bin/env python3

# Requires PyAudio and PySpeech.

import speech_recognition as sr

from time import ctime

import googletrans as gt

import time

import os

from gtts import gTTS

def speak(audioString,mylang):

print(audioString)

  tts = gTTS(text=audioString, lang=mylang)

  tts.save("audio.mp3")

  os.system("mpg321 audio.mp3")

def recordAudio():

# Record Audio

  r = sr.Recognizer()

with sr.Microphone() as source:

print()

  audio = r.listen(source)

# Speech recognition using Google Speech Recognition

  data = ""

try:

# Uses the default API key

# To use another API key: `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`

  data = r.recognize_google(audio ,language="ar-SA")

print("You said: " + data)

except sr.UnknownValueError:

print("***")

except sr.RequestError as e:

print("Could not request results from Google Speech Recognition service; {0}".format(e))

return data


def translateToEnglish(text):

if text != "":

  mygt = gt.Translator()

  translation = mygt.translate(text,dest='en')

  speak(translation.text,'en')

# initialization

time.sleep(1)

speak('السلام عليكم هذا مترجم للكلام من اللغة العربية إلى اللغة الانجليزية، رجاء تكلم بالكلمة العربية واصبر ليتم ترجمتها لك بالانجليزية','ar')

while 1:

  data = recordAudio()

  translateToEnglish(data)

 

 

Regards

Mahmoud

Goal:

OpenStack is the future of modern data centers. RDO is all-in-one implementation for beginners.

 

(1) /etc/environment

LANG=en_US.utf-8
LC_ALL=en_US.utf-8

 

(2) /etc/hosts

192.168.68.111    openstack01

 

(3) Disable WiFi adapter by renaming its ifcfg-.... file

 

(4) /etc/sysconfig/network-scripts/ifcfg-enp38s0

HWADDR=E4:11:5B:59:3D:61
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
NM_CONTROLLED=no
USERCTL=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp38s0
UUID=56b4291b-1032-48b3-b5e6-3b832cef7507
DEVICE=enp38s0
ONBOOT=yes
    IPADDR=192.168.68.111
        NETMASK=255.255.255.0
        GATEWAY=192.168.68.1
        DNS1=192.168.100.1
        DNS2=8.8.8.8

 

(5) Prerequisites

systemctl disable firewalld
systemctl stop firewalld
systemctl disable NetworkManager
systemctl stop NetworkManager
systemctl enable network
systemctl start network
yum install -y centos-release-openstack-rocky
yum-config-manager --enable openstack-rocky
yum update -y

 

(6) Install Packstack Installer

yum install -y openstack-packstack

 

(7) Run Packstack to install OpenStack

packstack --allinone

 

Reference

https://www.rdoproject.org/install/packstack/

 

Next Step

https://www.oracle.com/technetwork/systems/hands-on-labs/hol-openstack-linux-ovm-2399741.html

Goal:

A frequently-required function for Arabic accountants who are using Oracle database-based applications.

 

Here is the function for numbers less than 99999

 

CREATE OR replace FUNCTION Writenuminarabicwords (totnetget IN NUMBER)
RETURN VARCHAR2 
IS 
  strnum            VARCHAR2(10); 
  numinarabic       VARCHAR2(100); 
  a7ad              VARCHAR2(1); 
  a7adarabic        VARCHAR2(50); 
  asharat           VARCHAR2(1); 
  asharatarabic     VARCHAR2(50); 
  me2at             VARCHAR2(1); 
  me2atarabic       VARCHAR2(50); 
  alaaf             VARCHAR2(1); 
  alaafarabic       VARCHAR2(50); 
  asharatolof       VARCHAR2(1); 
  asharatolofarabic VARCHAR2(50); 
  me2atolof         VARCHAR2(1); 
  me2atolofarabic   VARCHAR2(50); 
  malayeen          VARCHAR2(1); 
  malayeenarabic    VARCHAR2(50); 
  numlength         NUMBER; 
BEGIN 
    strnum := To_char(totnetget); 

    -- check a7ad digit 
    a7ad := Substr(strnum, Length(strnum), 1); 

    IF a7ad != '0' THEN 
      IF a7ad = '1' THEN 
        a7adarabic := 'واحد'; 
      ELSIF a7ad = '2' THEN 
        a7adarabic := 'اثنان'; 
      ELSIF a7ad = '3' THEN 
        a7adarabic := 'ثلاثة'; 
      ELSIF a7ad = '4' THEN 
        a7adarabic := 'أربعة'; 
      ELSIF a7ad = '5' THEN 
        a7adarabic := 'خمسة'; 
      ELSIF a7ad = '6' THEN 
        a7adarabic := 'ستة'; 
      ELSIF a7ad = '7' THEN 
        a7adarabic := 'سبعة'; 
      ELSIF a7ad = '8' THEN 
        a7adarabic := 'ثمانية'; 
      ELSIF a7ad = '9' THEN 
        a7adarabic := 'تسعة'; 
      END IF; 

      numinarabic := a7adarabic; 
    END IF; 

    -- check asharat digit 
    IF( Length(strnum) > 1 ) THEN 
      asharat := Substr(strnum, Length(strnum) - 1, 1); 

      IF asharat != '0' THEN 
        IF asharat = '1' THEN 
          IF( a7ad = '0' ) THEN 
            asharatarabic := 'عشرة'; 
          ELSE 
            IF a7ad = '1' THEN 
              asharatarabic := 'احد عشر'; 
            ELSIF a7ad = '2' THEN 
              asharatarabic := 'اثنا عشر'; 
            ELSIF a7ad = '3' THEN 
              asharatarabic := 'ثلاثة عشر'; 
            ELSIF a7ad = '4' THEN 
              asharatarabic := 'أربعة عشر'; 
            ELSIF a7ad = '5' THEN 
              asharatarabic := 'خمسة عشر'; 
            ELSIF a7ad = '6' THEN 
              asharatarabic := 'ستة عشر'; 
            ELSIF a7ad = '7' THEN 
              asharatarabic := 'سبعة عشر'; 
            ELSIF a7ad = '8' THEN 
              asharatarabic := 'ثمانية عشر'; 
            ELSIF a7ad = '9' THEN 
              asharatarabic := 'تسعة عشر'; 
            END IF; 
          END IF; 
        ELSIF asharat = '2' THEN 
          asharatarabic := 'عشرون'; 
        ELSIF asharat = '3' THEN 
          asharatarabic := 'ثلاثون'; 
        ELSIF asharat = '4' THEN 
          asharatarabic := 'أربعون'; 
        ELSIF asharat = '5' THEN 
          asharatarabic := 'خمسون'; 
        ELSIF asharat = '6' THEN 
          asharatarabic := 'ستون'; 
        ELSIF asharat = '7' THEN 
          asharatarabic := 'سبعون'; 
        ELSIF asharat = '8' THEN 
          asharatarabic := 'ثمانون'; 
        ELSIF asharat = '9' THEN 
          asharatarabic := 'تسعون'; 
        END IF; 
      ELSE 
        asharatarabic := a7adarabic; 
      END IF; 

      IF( a7ad != '0' 
          AND asharat != '1' ) THEN 
        numinarabic := a7adarabic 
                       || ' و ' 
                       || asharatarabic; 
      ELSE 
        numinarabic := asharatarabic; 
      END IF; 
    END IF; 

    -- check me2at digit 
    IF( Length(strnum) > 2 ) THEN 
      me2at := Substr(strnum, Length(strnum) - 2, 1); 

      IF me2at != '0' THEN 
        IF me2at = '1' THEN 
          me2atarabic := 'مائة'; 
        ELSIF me2at = '2' THEN 
          me2atarabic := 'مائتان'; 
        ELSIF me2at = '3' THEN 
          me2atarabic := 'ثلاثمائة'; 
        ELSIF me2at = '4' THEN 
          me2atarabic := 'أربعمائة'; 
        ELSIF me2at = '5' THEN 
          me2atarabic := 'خمسمائة'; 
        ELSIF me2at = '6' THEN 
          me2atarabic := 'ستمائة'; 
        ELSIF me2at = '7' THEN 
          me2atarabic := 'سبعمائة'; 
        ELSIF me2at = '8' THEN 
          me2atarabic := 'ثمانمائة'; 
        ELSIF me2at = '9' THEN 
          me2atarabic := 'تسعمائة'; 
        END IF; 
      ELSE 
        me2atarabic := asharatarabic; 
      END IF; 

      IF( a7ad != '0' 
           OR asharat != '0' ) THEN 
        numinarabic := me2atarabic 
                       || ' و ' 
                       || Writenuminarabicwords(To_number(Substr(strnum,
                                                          Length(strnum)
                                                          - 1, 2))); 
      ELSE 
        numinarabic := me2atarabic; 
      END IF; 
    END IF; 

    -- alaaf digit 
    IF( Length(strnum) > 3 ) THEN 
      alaaf := Substr(strnum, Length(strnum) - 3, 1); 

      IF alaaf != '0' THEN 
        IF alaaf = '1' THEN 
          alaafarabic := 'ألف'; 
        ELSIF alaaf = '2' THEN 
          alaafarabic := 'ألفان'; 
        ELSIF alaaf = '3' THEN 
          alaafarabic := 'ثلاثة الاف'; 
        ELSIF alaaf = '4' THEN 
          alaafarabic := 'أربعة الاف'; 
        ELSIF alaaf = '5' THEN 
          alaafarabic := 'خمسة الاف'; 
        ELSIF alaaf = '6' THEN 
          alaafarabic := 'ستة الاف'; 
        ELSIF alaaf = '7' THEN 
          alaafarabic := 'سبعة الاف'; 
        ELSIF alaaf = '8' THEN 
          alaafarabic := 'ثمانية الاف'; 
        ELSIF alaaf = '9' THEN 
          alaafarabic := 'تسعة الاف'; 
        END IF; 
      ELSE 
        alaafarabic := me2atarabic; 
      END IF; 

      IF( a7ad != '0' 
           OR asharat != '0' 
           OR me2at != '0' ) THEN 
        numinarabic := alaafarabic 
                       || ' و ' 
                       || Writenuminarabicwords(To_number(Substr(strnum,
                                                          Length(strnum)
                                                          - 2, 3))); 
      ELSE 
        numinarabic := alaafarabic; 
      END IF; 
    END IF; 

    -- asharatolof digit 
    IF( Length(strnum) > 4 ) THEN 
      asharatolof := Substr(strnum, Length(strnum) - 4, 1); 

      IF asharatolof != '0' THEN 
        IF asharatolof = '1' THEN 
          asharatolofarabic := 'عشرة آلاف'; 
        ELSIF asharatolof = '2' THEN 
          asharatolofarabic := 'عشرون ألفا'; 
        ELSIF asharatolof = '3' THEN 
          asharatolofarabic := 'ثلاثون ألفا'; 
        ELSIF asharatolof = '4' THEN 
          asharatolofarabic := 'أربعون ألفا'; 
        ELSIF asharatolof = '5' THEN 
          asharatolofarabic := 'خمسون ألفا'; 
        ELSIF asharatolof = '6' THEN 
          asharatolofarabic := 'ستون ألفا'; 
        ELSIF asharatolof = '7' THEN 
          asharatolofarabic := 'سبعون ألفا'; 
        ELSIF asharatolof = '8' THEN 
          asharatolofarabic := 'ثمانون ألفا'; 
        ELSIF asharatolof = '9' THEN 
          asharatolofarabic := 'تسعون ألفا'; 
        END IF; 
      ELSE 
        asharatolofarabic := alaafarabic; 
      END IF; 

      IF( a7ad != '0' 
           OR asharat != '0' 
           OR me2at != '0' 
           OR alaaf != '0' ) THEN 
        numinarabic := Writenuminarabicwords(To_number(Substr(strnum, Length(
                                                       strnum) 
                                                                      - 4, 2)))
                       || CASE 
                            WHEN ( asharatolof = '1' 
                                   AND alaaf = '0' ) THEN ' آلاف ' 
                            ELSE ' ألف ' 
                          END 
                       || CASE 
                            WHEN ( a7ad != '0' 
                                    OR asharat != '0' 
                                    OR me2at != '0' ) THEN ' و ' 
                          END 
                       || Writenuminarabicwords(To_number(Substr(strnum,
                                                          Length(strnum)
                                                          - 2, 3))); 
      ELSE 
        numinarabic := asharatolofarabic; 
      END IF; 
    END IF; 

    -- me2atolof digit 
    IF( Length(strnum) > 5 ) THEN 
      me2atolof := Substr(strnum, Length(strnum) - 5, 1); 

      IF me2atolof != '0' THEN 
        IF me2atolof = '1' THEN 
          me2atolofarabic := 'مائة ألف'; 
        ELSIF me2atolof = '2' THEN 
          me2atolofarabic := 'مائتا ألف'; 
        ELSIF me2atolof = '3' THEN 
          me2atolofarabic := 'ثلاثمائة ألف'; 
        ELSIF me2atolof = '4' THEN 
          me2atolofarabic := 'أربعمائة ألف'; 
        ELSIF me2atolof = '5' THEN 
          me2atolofarabic := 'خمسمائة ألف'; 
        ELSIF me2atolof = '6' THEN 
          me2atolofarabic := 'ستمائة ألف'; 
        ELSIF me2atolof = '7' THEN 
          me2atolofarabic := 'سبعمائة ألف'; 
        ELSIF me2atolof = '8' THEN 
          me2atolofarabic := 'ثمانمائة ألف'; 
        ELSIF me2atolof = '9' THEN 
          me2atolofarabic := 'تسعمائة ألف'; 
        END IF; 
      ELSE 
        me2atolofarabic := asharatolofarabic; 
      END IF; 

      IF( a7ad != '0' 
           OR asharat != '0' 
           OR me2at != '0' 
           OR alaaf != '0' 
           OR asharatolof != '0' ) THEN 
        numinarabic := Writenuminarabicwords(To_number(Substr(strnum, Length(
                                                       strnum) 
                                                                      - 5, 3)))
                       || ' ألفا و ' 
                       || Writenuminarabicwords(To_number(Substr(strnum,
                                                          Length(strnum)
                                                          - 2, 3))); 
      ELSE 
        numinarabic := me2atolofarabic; 
      END IF; 
    END IF; 

    -- more than 999999 is not available in this version 
    IF( Length(strnum) > 6 ) THEN 
      numinarabic := strnum; 
    END IF; 

    RETURN numinarabic; 
END; 

I hope it helps someone.

 

Regards

Mahmoud

Below is a high-level guide with some quick and dirty definitions to inform you as you start to transition your team.

https://www.dragonspears.com/blog/agile-project-using-scrum-methodology

Hello Everybody

 

The Disciplined Agile (DA) process decision framework provides light-weight guidance to help organizations streamline their processes in a context-sensitive manner, providing a solid foundation for business agility.

https://www.disciplinedagiledelivery.com/

 

I hope that helps someone

 

Regards

Mahmoud

Hello Everybody

 

Python is a powerful programming language. It is used extensively by giants such as Google.

 

You might need to run Python script from Web not from CLI as usual. You have to be aware of CGI-BIN importance.

 

Here are two short guides for running Python scripts with cPanel

https://forums.cpanel.net/threads/short-guide-to-running-python-scripts-with-cpanel.244361/

https://www.namecheap.com/support/knowledgebase/article.aspx/9587/29/how-to-run-python-scripts

 

In addition, here is a nice tutorial for building a basic RESTful API in Python

https://www.codementor.io/sagaragarwal94/building-a-basic-restful-api-in-python-58k02xsiq

 

I hope that helps someone

 

Regards

Mahmoud

Hello Everybody

 

Oracle ADF could use Oracle JET to implement CRUD operations on top of ADF BC.

 

Here is a start of series

Andrejus Baranovskis Blog: Oracle JET CRUD - Search and Edit Form - Part I

 

I hope that helps someone.

 

Regards

Mahmoud

Hello Everybody

 

If you face INTERNAL SERVER ERROR and you did your best with DEBUG entries but with no result.

 

There is a big hope in ADVISOR.

 

Regards

Mahmoud

Hello Everybody

 

Based on this brilliant PHP class

https://www.phpclasses.org/package/5453-PHP-Validate-Saudi-resident-identifier-numbers.html

 

I searched the internet for PL/SQL code that achieves that but I didn't find. Here is another nice validator in multiple languages except PL/SQL.

https://github.com/alhazmy13/Saudi-ID-Validator

 

That is why I wrote, PL/SQL function to validate Saudi ID/Iqama/Residence number

CREATE OR REPLACE FUNCTION is_number (p_string IN VARCHAR2)
  RETURN INT
IS
  v_num NUMBER;
BEGIN
  v_num := TO_NUMBER(p_string);
  RETURN 1;
EXCEPTION
WHEN VALUE_ERROR THEN
  RETURN 0;
END is_number;
/

create or replace FUNCTION  "CHECKSTDID" (STDID in VARCHAR2) return number is  
  Result number; -- 1 --> Saudi , 2 --> Non-Saudi , 0 --> Invalid  
  ZF0dd  varchar2(100);  
  mysum    number := 0;  
  idtype varchar2(1);  
begin  
      
    -- If non-numeric then invalid  
    If ( is_number(STDID)=0 ) THEN  
       Result := 0;
       return Result;  
    END If;  
      
    --If length does not equal 10 then invalid  
    If(LENGTH(STDID) != 10) THEN  
       Result := 0;  
       return Result;  
    END IF;  
      
    -- get type  
    idtype := substr(STDID,1,1);  
      
    -- ID TYPE should be one or 2 only  
    --If length does not equal 10 then invalid  
    If(idtype not in ('1','2')) THEN  
       Result := 0;  
       return Result;  
    END IF;  
      
    -- you must do mapping between PHP's substr and PL/SQL's substr  
    for i in 0..9  
    loop  
      if ( Mod(i ,2) = 0 )then  
          ZF0dd := LPad( TO_NUMBER(substr(STDID,i+1,1))*2 , 2, '0');  
          mysum := mysum + TO_NUMBER(substr(ZF0dd,1,1)) + TO_NUMBER(substr(ZF0dd,2,1));       
      else  
          mysum := mysum + TO_NUMBER(substr(STDID, i+1 , 1 ));               
      end if;  
    end loop;  
      
    -- find result  
    if Mod(mysum,10) != 0 then  
      Result := 0;  
    else  
       Result := TO_NUMBER(idtype);  
    end if;  
      
    return(Result);  
end;  

 

I hope that helps someone

 

Regards

Mahmoud

Goal:

Tracking of user activities by getting his/her IP is useful. However, it would be great if we find the location where he/she is coming from.

 

To get the IP of the client you could use this PL/SQL code

OWA_UTIL.get_cgi_env('X-Forwarded-For')

 

The Geolocation is not offered by any Oracle PL/SQL function. That's why we could use a nice free RESTful API to catch it. I wrote a function for that

create or replace FUNCTION  "GEOLOCATION" (p_ip in VARCHAR2) return CLOB is
    base_url varchar2(150);
    l_clob CLOB;
begin
    base_url := 'http://ip-api.com/json/' || p_ip;    
    
    /* RABIE: GET Request */
    l_clob := APEX_WEB_SERVICE.make_rest_request(
        p_url         => base_url,    
        p_http_method => 'GET'
    );
      
    /*RABIE: return value (TODO: should return the result from the server)*/
    return l_clob;
    
end;

 

I hope that helps someone

 

Regards

Mahmoud