Skip to content

Instantly share code, notes, and snippets.

@salipro4ever
salipro4ever / sudo-gitlab-runner-command-not-found.md
Last active July 6, 2023 07:49
sudo: gitlab-runner: command not found
@salipro4ever
salipro4ever / .httpd
Created November 12, 2019 02:53
Gzip & Cache on Apache24
# 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
@salipro4ever
salipro4ever / hide-admin-wp.md
Last active November 25, 2021 02:39
WP Script
// 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 September 21, 2019 10:13
Download all image url from string
    $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 07:02
subdomain map to subdirectory route in existing Laravel

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 December 8, 2018 17:12
You can add this method as Collection method in AppServiceProvider. just add this in boot method.
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 December 8, 2018 17:10 — forked from ctf0/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
*
* @return LengthAwarePaginator
*/

pragmarx/version

https://github.com/antonioribeiro/version

This package is a Laravel (5.5+) utility which helps you keep and manage your application version, increment version numbers (major, minor, patch, build), and can also use your last commit hash as build number.

class ProjectController extends Controller
{
    /**
     * All of the current user's projects.
     */
    protected $projects;

    /**
 * Create a new controller instance.
@salipro4ever
salipro4ever / MyCheckClientCredentials.php
Created October 3, 2018 06:33
Get client from Client Credentials Grant - Laravel Passport
namespace App\Http\Middleware;
use Closure;
use Illuminate\Auth\AuthenticationException;
use League\OAuth2\Server\Exception\OAuthServerException;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Laravel\Passport\Http\Middleware\CheckClientCredentials;
class MyCheckClientCredentials extends CheckClientCredentials
{