Skip to content

Instantly share code, notes, and snippets.

Avatar

Salipro Pham salipro4ever

View GitHub Profile
@salipro4ever
salipro4ever / gitlab-ci-error-reinitialized.md
Created Jul 14, 2020
[ERROR] fatal: git fetch-pack: expected shallow list
View gitlab-ci-error-reinitialized.md

CAUSE:

Start by checking installed version of git on your CentOS 7 server. This version dont support "git fetch-pack"

$ git --version
git version 1.8.3.1

FIXED:

sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm

View gitlab-ci-note.md

Linux:

yes | php artisan key:generate

if ! grep -qc "^APP_KEY=.*$" .env; then php artisan key:generate; fi

View composer-error-ssl.md
[Composer\Downloader\TransportException]                                                                                                
  The "https://repo.packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:  
  error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed                                                       
  Failed to enable crypto                                                                                                                 
  failed to open stream: operation failed

=>

@salipro4ever
salipro4ever / .httpd
Created Nov 12, 2019
Gzip & Cache on Apache24
View .httpd
# Gzip
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
View hide-admin-wp.md
// Remove Administrator role from roles list
add_action( 'editable_roles' , 'hide_adminstrator_editable_roles' );
function hide_adminstrator_editable_roles( $roles ){
    if ( isset( $roles['administrator'] ) && !current_user_can('level_10') ){
        unset( $roles['administrator'] );
    }
    return $roles;
}
@salipro4ever
salipro4ever / batch-image-download.md
Created Sep 21, 2019
Download all image url from string
View batch-image-download.md
    $string = file_get_contents(config_path('mapplic.json'));

        $pattern = '~(http:|https:)\/\/[^/\s]+\/\S+\.(jpe?g|png)~i';

        $m = preg_match_all($pattern,$string,$matches);

        print_r($matches[0]);

        foreach ($matches[0] as $i => $url){
@salipro4ever
salipro4ever / subdomain-laravel.md
Created May 6, 2019
subdomain map to subdirectory route in existing Laravel
View subdomain-laravel.md

I serve multiple subdomains with Laravel with this code here:

RouteServiceProvider.php

  protected function mapSubdomainRoutes()
  {
    Route::group([
      'namespace' => $this->namespace,
      'domain' => '{subdomain}.affekt.de',
    ], function () {
@salipro4ever
salipro4ever / paginate-laravel-collection.php
Created Dec 8, 2018
You can add this method as Collection method in AppServiceProvider. just add this in boot method.
View paginate-laravel-collection.php
if (!Collection::hasMacro('AppServiceProvider')) {
Collection::macro('paginate',
function ($perPage = 15, $page = null, $options = []) {
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
return (new LengthAwarePaginator(
$this->forPage($page, $perPage), $this->count(), $perPage, $page, $options))
->withPath('');
});
}
@salipro4ever
salipro4ever / paginate.php
Created Dec 8, 2018 — forked from ctf0/paginate.php
Laravel Paginate Collection or Array
View paginate.php
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
*
* @return LengthAwarePaginator
*/
You can’t perform that action at this time.