Categories
Technical

Good Practice Programming with David Raleche

Categories
Laravel

Install Laravel Nova

1 - composer create-project --prefer-dist laravel/laravel admin "5.8.*"


2 - add/update in composer.json the following item
"repositories": [
     {
         "type": "composer",
         "url": "https://nova.laravel.com"
     }
 ],

Next, you may add laravel/nova to your list of required packages in your composer.json file:

"require": {
     "php": "^7.1.3",
     "fideloper/proxy": "^4.0",
     "laravel/framework": "5.8.*",
     "laravel/nova": "~2.0"
 },
3 - php artisan nova:install
4 - php artisan migrate
5- Authorizing Nova in non-local Environment
/**
 Register the Nova gate.
 *
 This gate determines who can access Nova in non-local environments.
 *
 @return void
 */
 protected function gate()
 {
 Gate::define('viewNova', function ($user) {
     return in_array($user->email, [
         '[email protected]',
     ]);
 });
 } 
#6 - Deploy with credentials
composer config http-basic.nova.laravel.com [email protected] mxxxxxxxxxxxxxxxxg
Categories
Git

Git got to a particular hash version

Use git checkout <sha1> to check out a particular commit.

Categories
PHPUnit

phpUnit Debug Technics Guzzle

$body = json_decode($response->getBody());

 fwrite(STDERR, json_encode($json));
 fwrite(STDERR, $body->message);
 public function testSuccesssfulJobCancel()
{

    $this->postOrderSuccesful();

    $headers = [
        'Authorization' => QATemplate::$deleteKey,
    ];
    $url = '/v1/jobId/M111111123-001';

    $response = QATemplate::$http->request(
        'DELETE',
        $url,
        [
            'verify' =>false,
            'http_errors' => false,
            'headers' =>$headers
        ]
    );

    $body = json_decode($response->getBody());

    fwrite(STDERR, json_encode($json));
    fwrite(STDERR, $body->message);


    $this->assertEquals(200, $response->getStatusCode());
    $this->assertContains("Success Job Deleted", $body->message);
}

Categories
Technical

New Keyboard Das X50Q Soft Tactile

Enjoying my new Keyboard ! Volume control is awesome !

Categories
Git

How to easily copy one git branch to another local branch ?

git checkout local-branch-i-want-to-revert
git reset --hard origin/branch-i-want-to-copy
Categories
General

DBeaver Configuration : Postgres and MacOs

1 . Install postgres

2. Find path to pg_dump

/Applications/Postgres.app/Contents/Versions/latest/bin

3. configure client (Dbeaver)

to add hidden files -> command + shift + G

paste /Applications/Postgres.app/Contents/Versions/latest/bin

and select the folder

4. Voila !

Categories
Laravel

How to Laravel Nova? Postgres

Create Resource

 php artisan nova:resource DirectMailing

Create Model

 php artisan make:model DirectMailing -m

Postgres

How to deal multiple schema ?

Connection variable is critical

protected $connection = 'pgsql-api';

How to deal with Schema and uuids ?

file location : app/LoyaltyLevels.php

class LoyaltyLevels extends Model
{
    //
    protected $connection = 'pgsql-api';
    protected $table = 'api.loyalty_levels';
    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'loyalty_level_uuid';
    protected $keyType = 'string';
}

File location app/Nova/LoyaltyLevels.php

 public function fields(Request $request)
    {
        return [
            Text::make('loyalty_level')->sortable(),
            Text::make('loyalty_level_description')->sortable(),
        ];
    }
Categories
Technical

SSL ImportError: No module named cryptography

Problem – Let’s Encrypt

[[email protected] ec2-user]# /usr/local/bin/certbot-auto --no-bootstrap
 Creating virtual environment…
 Installing Python packages…
 Installation succeeded.
 Traceback (most recent call last):
   File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in 
     from certbot.main import main
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 2, in 
     from certbot._internal import main as internal_main
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/_internal/main.py", line 10, in 
     import josepy as jose
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/init.py", line 41, in 
     from josepy.interfaces import JSONDeSerializable
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 7, in 
     from josepy import errors, util
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 7, in 
     import OpenSSL
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/init.py", line 8, in 
     from OpenSSL import crypto, SSL
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 12, in 
     from cryptography import x509
 ImportError: No module named cryptography

Solution

rm -rf /opt/eff.org/*
pip install -U certbot
certbot renew --debug
 certbot
Categories
Technical

How to Compress files tar bz2 ?

Compress bz2

tar -cjvf archive.tar.bz2 stuff

Decompress bz2

tar -jxvf filename.tbz2