JavaScript Functions

I sometimes try to remember basis of JavaScript Functions. So, I often exercise about it. I followed this link https://www.w3schools.com/js/js_function_definition.asp. I copied some important descriptions from that link. My aim is to follow this post when I need to remember again 🙂

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task.

A Function is much the same as a Procedure or a Subroutine, in other programming languages.

Why Functions?

You can reuse code: Define the code once, and use it many times.

You can use the same code many times with different arguments, to produce different results.

JavaScript Function Syntax

Function parameters are listed inside the parentheses () in the function definition.

Function arguments are the values received by the function when it is invoked.

Inside the function, the arguments (the parameters) behave as local variables.

Function Declaration (function statement)

function name(parameter1, parameter2, parameter3) {
  // code to be executed
}

Function Expression

The function below is actually an anonymous function (a function without a name).

Functions stored in variables do not need function names. They are always invoked (called) using the variable name.

var x = function (a, b) {return a * b};
var z = x(4, 3);

Function() Constructor

Functions can also be defined with a built-in JavaScript function constructor called Function().

var myFunction = new Function("a", "b", "return a * b");

var x = myFunction(4, 3);

Self-Invoking Function (Immediately Invokable Function Expression IIFE)

When functions are used only once, a common pattern is an IIFE (Immediately Invokable Function Expression).

You have to add parentheses around the function to indicate that it is a function expression:

The function below is actually an anonymous self-invoking function (function without name).

(function () {
  var x = "Hello!!";  // I will invoke myself
})();

Arrow Function

LoopBack 3 – Simple API with Oracle Example

Expose your Oracle Database as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/09/loopback-3-simple-api-example/

So if you want to start from beginning, read that one as well.

Follow this link https://kenanhancer.com/2019/09/12/mysql-docker-container-exercise/ to create a Oracle container 🙂

You can find LoopBack 3 project in the following repository. After clonning switch to oracle branch 🙂 or run the following command.

git checkout oracle

https://github.com/kenanhancer/loopback3-simple-api.git

Kubernetes configure kubectl to use multiple clusters

First of all, you need to have kubectl CLI in your host machine. So, follow the below steps.

Install with Chocolatey on Windows

choco install kubernetes-cli

Install with Homebrew on MacOS

brew install kubernetes-cli

Install with Kubernetes Official Documentation(with Curl)

Follow this link https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-macos

Test to ensure the version you installed

kubectl version

Checking kubectl config

When you run below command, you will see output as shown in the following screenshot. I didn’t configure yet so, it shows an empty config.

kubectl config view
Continue reading

Creating, Starting, Stopping, Packaging and Publishing a Vagrant Box

I use Vagrant for local development in order to build any development environment. For example, when I need a Kubernetes multi node cluster, I can demonstrate with Vagrant quickly(https://kenanhancer.com/2019/09/08/kubernetes-multi-node-cluster-with-one-updated-vagrant-file/). After I complete my exercise about any technology, I also publish to Vagrant Cloud so that it can be used later without wasting time. But, I am not using only Vagrant, there are different technologies and there are different CLI for them. So, if I don’t use one technology sometime, I can forget some important commands. That’s why, this post is important for me to remember Vagrant CLI 🙂

To read more information about Vagrant CLI https://www.vagrantup.com/docs/cli/ follow official link.

Continue reading

Oracle Docker Container Exercise

You can up and run Oracle Docker container in your local machine and later connect from sqlplus CLI to query your database.

Follow the following Oracle GitHub link for more details

https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance

After cloning Oracle docker-images repository from GitHub, run the following command in your terminal to build a Oracle Docker XE image.

docker build --force-rm=true --no-cache=true --shm-size=1G --build-arg DB_EDITION=xe -t oracle/database:18.4.0-xe -f Dockerfile.xe .

When build is done, run the following command to start a Oracle XE Database container.

docker run -d --name oracleXe --network=oracle_xe_network -p 1521:1521 -p 5500:5500 -e ORACLE_PWD="Pass_123456" oracle/database:18.4.0-xe

LoopBack 3 – Simple API with Redis Example

Expose your Redis NoSQL as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/13/loopback-3-simple-api-with-mysql-example/

So if you want to start from beginning, read that one as well.

You can find LoopBack 3 project in the following repository. After clonning switch to mongodb branch 🙂 or run the following command.

git checkout redis

https://github.com/kenanhancer/loopback3-simple-api.git

LoopBack 3 – Simple API with MongoDB Example

Expose your MongoDB NoSQL as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/13/loopback-3-simple-api-with-mysql-example/

So if you want to start from beginning, read that one as well.

Follow this link https://kenanhancer.com/2019/09/13/mongodb-docker-container-exercise/ to create a MySQL container 🙂

You can find LoopBack 3 project in the following repository. After clonning switch to mongodb branch 🙂 or run the following command.

git checkout mongodb

https://github.com/kenanhancer/loopback3-simple-api.git

LoopBack 3 – Simple API with MySQL Example

Expose your MySQL Database as a REST service with LoopBack 3 (Node.js Open API Framework)

This post is continuation of previous post https://kenanhancer.com/2019/09/09/loopback-3-simple-api-example/

So if you want to start from beginning, read that one as well.

Follow this link https://kenanhancer.com/2019/09/12/mysql-docker-container-exercise/ to create a MySQL container 🙂

LoopBack MySQL example will not start wihout running the following code in MySQL Database container. So, run the following command in it.

ALTER USER root IDENTIFIED WITH mysql_native_password BY 'password';

You can find LoopBack 3 project in the following repository. After clonning switch to mysql branch 🙂 or run the following command.

git checkout mysql

https://github.com/kenanhancer/loopback3-simple-api.git