Monday, 1 March 2021

Bitnami HTTPS Configuration

 bitnami@ip-172-26-44-221:/opt/bitnami$ sudo /opt/bitnami/bncert-tool
----------------------------------------------------------------------------
Welcome to the Bitnami HTTPS Configuration tool.

----------------------------------------------------------------------------
Domains

Please provide a valid space-separated list of domains for which you wish to
configure your web server.

Domain list []: dev.whyscience.com


The following domains were not included: www.dev.whyscience.com. 

Do you want to add them? [Y/n]: n



Warning: No www domains (e.g. www.example.com) or non-www domains (e.g.
www.example.com) have been provided, so the following redirections will be
disabled: non-www to www, www to non-www.
Press [Enter] to continue:
----------------------------------------------------------------------------
Enable/disable redirections

Please select the redirections you wish to enable or disable on your Bitnami
installation.



Enable HTTP to HTTPS redirection [Y/n]: Y


Changes to perform

The following changes will be performed to your Bitnami installation:

1. Stop web server
2. Configure web server to use a free Let's Encrypt certificate for the domains:                                                                                        
dev.whyscience.com
3. Configure a cron job to automatically renew the certificate each month
4. Configure web server name to: dev.whyscience.com
5. Enable HTTP to HTTPS redirection (example: redirect http://dev.whyscience.com                                                                                        
to https://dev.whyscience.com)
6. Start web server once all changes have been performed


Do you agree to these changes? [Y/n]: Y

----------------------------------------------------------------------------
Error: There has been an error.
Cannot bind to port 80 and/or 443. These ports are used for Let's Encrypt to
verify the domain DNS configuration. Please stop any services using those ports,                                                                                        
and ensure your system user has permissions to bind to them.
Press [Enter] to continue:

----------------------------------------------------------------------------

To solve this issue

Look for who is using the port 

bitnami@ip-172-26-44-221:/opt/bitnami$ sudo fuser 443/tcp
443/tcp:              3693  4811 12652 12900 13082

and then kill the process

bitnami@ip-172-26-44-221:/opt/bitnami$ sudo fuser -k 443/tcp
443/tcp:              3693  4811 12652 12900 13082


Now rerun you will not see anything

bitnami@ip-172-26-44-221:/opt/bitnami$ sudo fuser 443/tcp
bitnami@ip-172-26-44-221:/opt/bitnami$ sudo fuser -k 443/tcp

------------------------------------------------------------------------------

Then rerun the command

 bitnami@ip-172-26-44-221:/opt/bitnami$ sudo /opt/bitnami/bncert-tool

 

----------------------------------------------------------------------------
Performing changes to your installation

The Bitnami HTTPS Configuration Tool will perform any necessary actions to your
Bitnami installation. This may take some time, please be patient.

/Warning: Certificates may not renew automatically, due to a web server
configuration issue. For more information see:
https://docs.bitnami.com/general/how-to/understand-bncert/#certificates-not-renew
ed-automatically
Press [Enter] to continue:                                                                                                                                             ----------------------------------------------------------------------------
Some errors occurred


The configuration was applied, but some of the changes could not be applied.
Find the details below.

The configuration report is shown below.

Failed steps:
* Creating Let's Encrypt certificate: Automatic renewal not working

Find more details in the log file:
/tmp/bncert-202103020529.log

Now check the httpd.conf ; especially running port if it is not 80 and 443 then change.

Then rerun the command

 bitnami@ip-172-26-44-221:/opt/bitnami$ sudo /opt/bitnami/bncert-tool



Tuesday, 12 May 2020

top database ORM or query builder this order is on my performance

https://github.com/nette/database : https://doc.nette.org/en/3.0/database-explorer
https://github.com/izniburak/pdox
https://github.com/envms/fluentpdo

https://packagist.org/packages/illuminate/database
https://github.com/envms/fluentpdo
https://docs.opis.io/database/4.x/fields-selection.html

https://packagist.org/packages/mrjgreen/database
https://doc.nette.org/en/3.0/database-explorer


https://github.com/cakephp/database
https://nextras.org/orm/docs/3.1/entity
https://github.com/zetacomponents/Database/blob/master/docs/tutorial_example_08.php
https://packagist.org/packages/sofa/eloquence
https://docs.laminas.dev/laminas-db/adapter/
https://github.com/LinioIT/database
https://github.com/gsylvestre/php-models-generator
https://github.com/Luracast/Laravel-Database
https://github.com/spiral/orm
https://leanmapper.com/cs/quick-start/kapitola-5/
https://github.com/OpenBuildings/jam/blob/HEAD/guide/jam/getting-started.md
https://github.com/SergeyTsalkov/meekrodb
https://packagist.org/packages/joomla/database
https://github.com/top-think/think-orm
https://www.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/introduction.html
https://packagist.org/packages/ezsql/ezsql
https://github.com/kohana/database - old code

https://docs.opis.io/orm/1.x/quick-start.html - orm


https://github.com/FaaPz/PDO
https://github.com/envms/fluentpdo


annotation
https://nextras.org/orm/docs/3.1/entity

Friday, 24 April 2020

filter media stream

/**
    * filter media stream to reduce noise and more
    * if not filtered or have any problem then
    * return original stream itself
    *
    * @param stream    MediaStream   Source to Video tag
    * @return MediaStream
    */
    async function filterMediaStream(stream) {
      
      try {
        //filter media stream
        var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
        var source = audioCtx.createMediaStreamSource(stream);

        var delay = audioCtx.createDelay(1.5);

        // Create a biquadfilter
        var biquadFilter = audioCtx.createBiquadFilter();

        biquadFilter.Q.value = 8.5;
        biquadFilter.frequency.value = 550;//350 - default value
        biquadFilter.gain.value = 1;
        biquadFilter.type = 'bandpass';

        source.connect(biquadFilter);
        biquadFilter.connect(delay);
        delay.connect(audioCtx.destination);
        //assign user media          
        return await stream;
      } catch (error) {
        return null
        console.log('Error with media filtering: 'error.messageerror.name);
        //if u have problem with filtering media stream 
        //then return the original stream copy
      }
    }

Wednesday, 15 April 2020

error invalid_scope


 Check the
 
const OAUTH_SCOPES='openid profile offline_access user.read calendars.read';
 


http://localhost/wteam/?error=invalid_scope&error_description=The%20provided%20value%20for%20the%20input%20parameter%20%27scope%27%20is%20not%20valid.%20The%20scope%20%27OnlineMeetings.ReadWrite%27%20is%20not%20valid.&state=b26c7e96816d6a543452c52f4ef03d4e

GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem

1. https://curl.haxx.se/ca/cacert.pem

download cacert.pem file
 
2. php.ini

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo ="C:/wamp64/www/wteam/cacert.pem"

3. restart services : Done
 
( ! ) Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\wamp64\www\wteam\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 201
( ! ) GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\wamp64\www\wteam\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 201
Call Stack
#TimeMemoryFunctionLocation
10.0070367272{main}( )...\index.php:0
20.0595528752AuthController->callback( )...\index.php:86
30.0595529128League\OAuth2\Client\Provider\GenericProvider->getAccessToken( )...\index.php:70
40.0710609440League\OAuth2\Client\Provider\GenericProvider->getParsedResponse( )...\AbstractProvider.php:537
50.0710609440League\OAuth2\Client\Provider\GenericProvider->getResponse( )...\AbstractProvider.php:621
60.0710609440GuzzleHttp\Client->send( )...\AbstractProvider.php:608
70.4408647328GuzzleHttp\Promise\RejectedPromise->wait( )...\Client.php:130

Monday, 13 April 2020

Benchmark between Symfony HttpFoundation and Nette Http RequestFactory

<?php

require_once 'vendor/autoload.php';
$s = 0;
$n = 0;

$bench = new Ubench;
for ($i=0; $i < 10000; $i++) {
   
$bench->start();
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$bench->end();

// Get elapsed time and memory
$s += $bench->getTime(true); // elapsed microtime in float

$bench->start();
$request = new Nette\Http\RequestFactory;
$request->fromGlobals();
$bench->end();

$n += $bench->getTime(true); // elapsed microtime in float

}

echo "<br>Symfony average request: " . $s/10000 . '<br>';
echo "Nette average request: " . $n/10000;


Result: Average request Time

Welcome to the framework
Symfony average request : 0.0016007466554642
Nette average request: 0.0020953632354736

        "symfony/http-foundation":"5.0.7",

symfony/http-foundation is the clear winner


        "symfony/http-foundation":"5.0.7",

        "nette/http""^3.0"

Sunday, 12 April 2020

Benchmark between Symfony DependencyInjection ContainerBuilder AND League Container

<?php

require_once 'vendor/autoload.php';
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;


class Bar {}

class Foo
{
    public $bar;

    public function __construct(Bar $bar)
    {
        $this->bar = $bar;
    }
}

   
$bench = new Ubench;

$bench->start();


$container = new League\Container\Container;

$container->add(\Foo::class)->addArgument(\Bar::class);
$container->add(\Bar::class);

$foo = $container->get(\Foo::class);

var_dump($foo instanceof \Foo);      // true
var_dump($foo->bar instanceof \Bar); // true
$bench->end();
echo '<br>';
echo '<br>';
echo '<br>';
echo '<br>League';
// Get elapsed time and memory
echo  '<br>' . $bench->getTime() . '<br>'; // 156ms or 1.123s
echo $bench->getTime(true) . '<br>'; // elapsed microtime in float

echo $bench->getMemoryPeak() . 'Peak memory<br>';

echo $bench->getMemoryPeak(true) . '<br>'; // memory peak in bytes

// Returns the memory usage at the end mark
echo $bench->getMemoryUsage() . '<br>';


echo '<br>';
echo '<br>';
echo '<br>';
echo '<br>Symfony';
$bench->start();

$containerBuilder = new ContainerBuilder();
$containerBuilder
    ->register('bar', 'Bar');


$containerBuilder
    ->register('foo', 'Foo')
    ->addArgument(new Reference('bar'));

$foo = $containerBuilder->get('foo');

var_dump($foo instanceof \Foo);      // true
var_dump($foo->bar instanceof \Bar); // true
$bench->end();

// Get elapsed time and memory
echo  '<br>' . $bench->getTime() . '<br>'; // 156ms or 1.123s
echo $bench->getTime(true) . '<br>'; // elapsed microtime in float

echo $bench->getMemoryPeak() . 'Peak memory<br>';

echo $bench->getMemoryPeak(true) . '<br>'; // memory peak in bytes

// Returns the memory usage at the end mark
echo $bench->getMemoryUsage() . '<br>';

 Result:

League

C:\wamp64\www\mecrud\index1.php:33:boolean true
C:\wamp64\www\mecrud\index1.php:34:boolean true

6ms
0.0061249732971191
Peak memory : 2097152

Symfony

C:\wamp64\www\mecrud\index1.php:68:boolean true
C:\wamp64\www\mecrud\index1.php:69:boolean true

6ms
0.0063478946685791
Peak memory: 2097152



Composer require

 "require": {
        "php""^7.2.5",

        "league/container""^3.3",
        "symfony/dependency-injection""^5.0"
    },
    "require-dev": { 
        "devster/ubench""~2.0.0"
    },


Multiple run gives mixed result. I decided to use league (https://container.thephpleague.com/).