Categories
Git

Tutorial – Submit large files in GIT

INSTALL LFS ON RHEL/CentOS

  1. Install git >= 1.8.2
    • Recommended method for RHEL/CentOS 5 and 7 (not 6!)
      1. Install the epel repo link (For CentOS it’s just sudo yum install epel-release)
      2. sudo yum install git
    • Recommended method for RHEL/CentOS 6
      1. Install the IUS Community repo. curl -s https://setup.ius.io/ | sudo bash or here
      2. sudo yum install git2u
    • You can also build git from source and install it. If you do that, you will need to either manually download the git-lfs rpm and install it with rpm -i --nodeps git-lfs*.rpm, or just use the Other instructions. The only other advanced way to fool yum is to create and install a fake/real git rpm to satisfy the git >= 1.8.2 requirement.
  2. To install the git-lfs repo, run curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash from here
  3. sudo yum install git-lfs
  4. git lfs install

Install software on your Macbook MAC

brew install git-lfs

List type files to be tracked

git lfs track "*.psd"

git add .gitattributes

Example

git add file.psd 

git commit -m "Add design file" 

git push origin master
Categories
Laravel

Tutorial – How to do a search form with laravel pagination bootstrap ?

Define routes at routes/web.php

//All certificates
Route::post('/search-certificates', 'CertificatesController@search' );
Route::get('/search-certificates', 'CertificatesController@search' );
or
Route::any('/search-certificates', 'CertificatesController@search' );

Define Controller function Search

public function search(Request $request){
    $searchString = $request->input('searchString');
    $searchCertificates = DB::table('NAMEOFYOURBABLE')
        ->where('BOROUGH', 'like', "%$searchString%" )
        ->orwhere('STREET', 'like', "%$searchString%" )
        ->orwhere('POSTCODE', 'like', "%$searchString%" )
        ->orderBy('POSTCODE', 'asc')
        ->orderBy('NUMBER', 'asc')
        ->orderBy('JOB_NUMBER', 'asc')
        ->paginate(20);

    $searchCertificates->appends(['searchString' => $searchString]);

    return view('search-certificates', ['searchCertificates' => $searchCertificates]);
}

Most important line on the code above is the one below because it will allow search pagination

    $searchCertificates->appends(['searchString' => $searchString]);

Define View Laravel Blade Page

Form

<form action="/search-certificates" method="POST" role="search">
    {{ csrf_field() }}
    <div class="input-group">
        <input type="text" class="form-control" name="searchString"
               placeholder="Search by Street or Postal Code " />
         <button type="submit" class="btn btn-primary">Submit</button>
    </div>
</form>

Grid/Table

<div class="row justify-content-center">
<table class="table table-striped">
<thead>
<tr>
<th>POSTCODE</th>
<th>ISSUE_TYPE</th>
<th>C_O_ISSUE_DATE</th>
<th>BOROUGH</th>
<th>NUMBER</th>
<th>STREET</th>
<th>Number of Units</th>
<th>NTA</th>
</tr>
</thead>
<tbody>
@foreach ($searchCertificates as $oneCertificate)
<tr>
<td>{{ $oneCertificate->POSTCODE }}</td>
<td>{{ $oneCertificate->ISSUE_TYPE }}</td>
<td>{{ $oneCertificate->C_O_ISSUE_DATE }}</td>
<td> {{ $oneCertificate->BOROUGH }}</td>
<td>{{ $oneCertificate->NUMBER }}</td>
<td>{{ $oneCertificate->STREET }}</td>
<td>{{ $oneCertificate->PR_DWELLING_UNIT }}</td>
<td>{{ $oneCertificate->NTA }}</td>
</tr>
@endforeach
</tbody>

Blade Pagination Link

{{ $searchCertificates->links( "pagination::bootstrap-4") }}
Categories
Laravel

Tutorial Install Oauth2 Server

Find below the steps to install an Oauth2 server with laravel Passport

Install the package

composer require laravel/passport
php artisan migrate
php artisan passport:install

Retrieve the keys from laravel passport

Personal access client created successfully.
 Client ID: 7
 Client secret: JfTAiRtvsdX2pZI1cBUShCrd2BU5pYYrX0lzHwRhBq
 Password grant client created successfully.
 Client ID: 8
 Client secret: Y3nUHg1xcaOPCsdsdsqbIjA3Ghj5CJnTf0pD1p3t2U5wN

Modify App\User.php file

<?php namespace App;
 use Laravel\Passport\HasApiTokens; 
use Illuminate\Notifications\Notifiable; 
use Illuminate\Foundation\Auth\User as Authenticatable; 

class User extends Authenticatable {    
 use HasApiTokens, Notifiable; 
}

Register the routes necessary to issue access tokens and revoke access tokens, clients, and personal access tokens:

<?php namespace App\Providers; 
use Laravel\Passport\Passport;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; 

class AuthServiceProvider extends ServiceProvider {  
   /**      
    * The policy mappings for the application.      
    *     
    * @var array      
    */     
     protected $policies = [  
       'App\Model' => 'App\Policies\ModelPolicy',   
      ];    
 /**      
   * Register any authentication / authorization services.      
   *
   * @return void     
   */  
   public function boot()     
   {
      $this->registerPolicies();   
      Passport::routes();    
   } 
}

Configure config/auth.php

'guards' => [     
         'web' => [         
                   'driver' => 'session',
                   'provider' => 'users',
           ],
         'api' => [         
                   'driver' => 'passport',
                   'provider' => 'users',    
                ],
 ],

SET TO GO, now get access token to proceed

Use the generated key in initial step called Password grant client

Categories
Server Token Web Server

Rest Client

Insomnia

Postman

Categories
Laravel

Tutorial – Laravel 6 – Create Login Page

composer require laravel/ui 
php artisan ui vue --auth 
npm install && npm run dev
php artisan migrate

See the routes created

php artisan route:list

Categories
Laravel

Tutorial Log Viewer – Laravel

Fantastic try to the log viewer of Laravel
https://github.com/ARCANEDEV/LogViewer

Edit .env

LOG_CHANNEL=daily

Composer install the package

composer require arcanedev/log-viewer

Publish the laravel package

php artisan log-viewer:publish

Verify installation

php artisan log-viewer:check

Enjoy programming !

Go to http://{your-project}/log-viewer

See Screenshots


Categories
Unix

How to find executable command in unix ?

Type the following :

whereis 
Categories
AWS REDIS Unix

How to install redis on AWS unix ec2 instance ?

 $ vi /etc/yum.repos.d/epel.repo

 [epel]
 name=Extra Packages for Enterprise Linux 6 - $basearch
 baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
 mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
 failovermethod=priority
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Step 2: Clean all yum repo and update repolist:

$ yum clean all
$ yum repolist

Step 3: Install Redis on the server by running command

$ yum install redis 

Step 4: Check redis status

service redis status

service redis start
service redis stop
service redis restart

Categories
Unix

How to find out Unix release version ?

cat /etc/*elease
Categories
Unix

How to fix CURL error setting certificate verify locations ?

error setting certificate verify locations:
CAfile: /usr/local/etc/openssl/cert.pem
CApath: /usr/local/etc/[email protected]/certs

To fix this issue find my solution below

ln -s  /usr/local/etc/openssl\@1.1 /usr/local/etc/openssl

Create a symbolic link toward the folder researched