Categories
General

How to resolve dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.5.0.dylib ?

Here are the following 2 commands to resolve issue

brew tap shivammathur/php
brew install shivammathur/php/[email protected]

Categories
General

What are Long and Short Polling in AWS SQS ?

Find below an amazing article about AWS SQS

https://laravel-news.com/amazon-sqs-tips?utm_medium=email&utm_campaign=You%20can%20now%20generate%20test%20files%20with%20Laravel%20make%20commands%20-%20382&utm_content=You%20can%20now%20generate%20test%20files%20with%20Laravel%20make%20commands%20-%20382+CID_d9fd547e177fba8f9a066975d2d06163&utm_source=email%20marketing&utm_term=Things%20I%20Didnt%20Know%20About%20SQS

Long and Short Polling

SQS’s API is all HTTP based. This means that when our queue workers poll SQS for a new job, it’s making an HTTP request to the SQS API.

By default, this does “short polling” – if no job is available when the HTTP request is made, SQS immediately returns an empty response.

Long polling allows you to keep an HTTP request open for a certain amount of time. While the HTTP request is open, SQS may send a job to the queue worker at any time.

Laravel doesn’t do any long polling, but there is something important to know here.

If you use the SQS queue driver, you may see that some jobs take a while to get processed – as if the queue worker can’t find a new job. This is related to how SQS is scaled within AWS.

Here’s the relevant thing to know, from the SQS docs:

With short polling, the ReceiveMessage request queries only a subset of the servers (based on a weighted random distribution) to find messages that are available to include in the response. Amazon SQS sends the response right away, even if the query found no messages.

With long polling, the ReceiveMessage request queries all of the servers for messages. Amazon SQS sends a response after it collects at least one available message, up to the maximum number of messages specified in the request. Amazon SQS sends an empty response only if the polling wait time expires.

It turns out that with long polling, we’re likely to get jobs more quickly as it polls all of the SQS servers that may contain our jobs!

However, Laravel doesn’t support long-polling out of the box. Luckily, we can do something about that. There’s a little note in the bottom of the docs linked above:

Short polling occurs when the WaitTimeSeconds parameter of a ReceiveMessage request is set to 0 in one of two ways:

  • The ReceiveMessage call sets WaitTimeSeconds to 0.
  • The ReceiveMessage call doesn’t set WaitTimeSeconds, but the queue attribute ReceiveMessageWaitTimeSeconds is set to 0.

https://laravel-news.com/amazon-sqs-tips?utm_medium=email&utm_campaign=You%20can%20now%20generate%20test%20files%20with%20Laravel%20make%20commands%20-%20382&utm_content=You%20can%20now%20generate%20test%20files%20with%20Laravel%20make%20commands%20-%20382+CID_d9fd547e177fba8f9a066975d2d06163&utm_source=email%20marketing&utm_term=Things%20I%20Didnt%20Know%20About%20SQS

Categories
General

How do we recognize a good programming ?

  • Readability
  • Time complexity
  • Space complexity
  • Reusability
  • Code coverage for deployment
Categories
General

How to onboard a developer in your team ?

Onboarding tools

1 – Assist them in having their work environment ready

#1 –  create a company email for new employee

#2 –   Provide a GIT repository account

#3 –  provide local development environment – Sandboxes account

#4 – provide Jira Account / access

#5 – provide Confluence account

#6 –  provide VPN access

#7 –  provide Chat/Slack access


2- Guideline Programming

3 – Recommendation for integrating  developers in the group

*  pull request / code review against programming guideline

*  write functional test on the latest/pending release

* write documentation phpdocs / swagger / add documentation

4 – Programming guideline

programmer guideline
programmer guideline

 Principles are guiding this methodology


- Readability
- Quality Assurance
- Logic
- Reusable code

 Readability


PSR-2 code styling
Function no longer than 50 lines
PHP doc Block
TypeHint your functions
More information:

For better code readability we suggest PSR-2 code styling to be applied. We consider a function bigger than 25 lines is not an efficient function. For engaging this methodology we recommend 50 lines maximum per function. DocBloc are essentials. Swagger in a case of API writing is essential to be present.
A developer should be able to explain his work easily and quickly and should use materials to do so

Quality Insurance


No PHP error message
No PHP Warning messages
No PHP Notices
No hardcore credentials
Unit Testing
Details:

When executing the code we expect the quality assurance team to verify that no PHP errors, warnings, notices are produced. We also expect the QA team to go throughout the code to verify that no hardcore credentials are present within the code. Unit Test writing should be edited by QA team preferably

Logic


DRY (do not repeat yourself)
KISS (Keep it Stupid Simple)
SOLID principles

 Reusable Code


Use PHP throw exception
Use Object oriented techniques
Use static function

Use PHP throw exception
Use Object oriented techniques
Use static function

Add the following your PHP too get rid of PHP notices, warnings

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

SWAN Profile

Smart

Work hard

Ambitious

Friendly

Categories
General

How to run a PHP interview in 30 min ?

GENERAL

Do you know what we are doing ?

Why are you leaving your current job ?

Are you looking for long term, short term role ?

What are you looking for to do in your next job ?
– technology ?
– role ?

Tell us about your latest project ?

Tell us about your experience of working in a group?

Could you tell us about a difficult project you had to resolve ?

Could you describe a time when you disagreed with your manager on how to accomplish something ?

Do you prefer working on your own or in a team ?

If you could change one thing about your personality, what would it be and why ?

PHP

What IDE are you using for programming ?

What command do you use to find out the php version ?

What is the purpose of @ in PHP ?

Can you list different types of error in PHP ?

What is composer ?

What is type hinting ?

Can you list a PHP convention standard

What is an interface in PHP

What is the latest version released PHP ?

LOGIC

How would you handle PHP upgrade ?

What steps would you take before creating an api ?

ARCHITECTURE

API can you list different api protocols ?

SQL

What SQL client are you using ?

What keyword do you use to analyze a query ?

EXPLAIN

How many types of normalization exists ?

What is MYSQL comment for creating a new record ?

JAVASCRIPT

What is nodeJS ?

Have you used any JS framework ?

What is hoisting variable ?

What are the different types of Javascript variables ?

UNIX 

What is the Pipe command pipe doing in UNIX ?

What is VI ?

What is NGINX ?

FINAL

What are your hobbies outside of work ?

Categories
General

How to Fibonacci iteratively ?

Using Iteration


 public static int fibonacciLoop(int nthNumber) {
        //use loop
        int previouspreviousNumber, previousNumber = 0, currentNumber = 1;

        for (int i = 1; i < nthNumber ; i++) {

            previouspreviousNumber = previousNumber;

            previousNumber = currentNumber;

            currentNumber = previouspreviousNumber + previousNumber;

        }
        return currentNumber;
    }
Categories
General

What are the basics programming concepts to know ?

Categories
General

How to write Basic algorithms such as BFS and DFS in php ?

Find basic algorithms in the link here

https://github.com/davidraleche/Basic-Algorythm

DFS – Depth First Search

<?php

class Node{

  public $children = array();
  public $name = '';
  
  public function __construct(string $nameNode){
    $this->name = $nameNode;
  }
  
  public function isLinked(Node $node):bool{
    foreach($this->children as $c){
      if($c->name === $node->name){
        return true;
      }
    }
    return false;
  }

  public function linkTo(Node $node):Node{
    //Todo  verify if already linked
    $this->children[] = $node;
    
    return $node;
  }
  
  public function notVisitedArray(array $visitedArray):array{
    $notVisited = array();
    foreach($this->children as $c){
      if(!in_array($c->name,$visitedArray)){
        $notVisited[] = $c;
      }
    }
    return $notVisited;
  }
}

$node1 = new Node('1');
$node2 = new Node('2');
$node3 = new Node('3');
$node4 = new Node('4');

$node1->linkTo($node2);
$node1->linkTo($node3);
$node3->linkTo($node4);

//print_r($node1);
//$r = $node1->notVisitedArray(array('1'));
 // print_r($r);
//var_dump($node1);

dfs($node1);

function dfs(Node $node, 
             string $path = '',
             array $visited = array()): void{

  $visited[] = $node->name;
  $notVisited = $node->notVisitedArray($visited);
  if(sizeOf($notVisited) === 0){
    echo 'path: '.$path.'->'."$node->name"."\n\r";  
    return ;
  }
  foreach($notVisited as $key => $n){
    dfs($n, $path.'->'.$node->name, $visited);
  }
}

BFS – Breadth First Search


<?php


$graph = [
    'A' => ['B', 'C'],
    'B' => ['A', 'D'],
    'D' => ['B'],
    'C' => ['A',],
];

//bfs($graph, 'A', 'D'); // true
//bfs($graph, 'A', 'G'); // false
print_r(bfs_path($graph, 'A', 'D')); // ['A', 'B', 'D']


function bfs_path($graph, $start, $end) {
    $queue = new SplQueue();
    # Enqueue the path
    $queue->enqueue([$start]);
    $visited = [$start];
    while ($queue->count() > 0) {
        $path = $queue->dequeue();
        # Get the last node on the path
        # so we can check if we're at the end
        $node = $path[sizeof($path) - 1];
        
        if ($node === $end) {
            return $path;
        }
        foreach ($graph[$node] as $neighbour) {
            if (!in_array($neighbour, $visited)) {
                $visited[] = $neighbour;
                # Build new path appending the neighbour then and enqueue it
                $new_path = $path;
                $new_path[] = $neighbour;
                $queue->enqueue($new_path);
            }
        };
    }
    return false;
}
Categories
General

How to renew PAF of a NCOA ?

When hitting the following endpoint https://ws.satorisoftware.com/Architect/US/Move/MoveService.asmx?wsdl

If you have the following error :

 </SOAP-ENV:Envelope>HTTP/1.1 500 Internal Server Error

 <faultstring>Error 0x800404B4: Your Processing Acknowledgement Form (PAF) expired on 09/11/2021.  You must file a new form with your NcoaLink vendor before processing can continue.</faultstring> 

please do the following

If you look in  C:\Program Files (x86)\Satori Software\BCC Architect\Developer Center (United States)\Sample Code\move\NETClasses\csharp\Move_CSharp\bin\Release
 
If you click on Run Move Update, the Move Agent Wizard will pop up, and here is where you can renew your PAF.
Categories
General

What restful api method would be appropriate for an upsert ?

Create/Update endpoint in a restful api

The PUT API methodology should be appropriate for an upsert

According to the HTTP specification:

The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI.

I therefore think that the use of PUT for an insert or update is perfectly legitimate, provided that in both cases the URI is known in advance. If you’re using the key as part of the URI (as k1 in http://www.somewhere.com/resources/k1) this should be the case. To be ideally RESTful, however, a GET to the same URL should also allow you to download the resource.