Skip to content

Instantly share code, notes, and snippets.

View EduardoSP6's full-sized avatar

Eduardo P. Sales EduardoSP6

  • Maricá - RJ
  • 21:36 (UTC -03:00)
View GitHub Profile
@EduardoSP6
EduardoSP6 / android_adb_backup.md
Last active January 8, 2025 20:22
Como extrair backup dos dados de app do smartphone

Backup RealmDB Database Android

Este processo é útil para telefones que requerem permissões de acesso aos dados, apresentando o erro: error run-as: Could not set capabilities: Operation not permitted.

Obs.: Para funcionar a variavel do AndroidManifest [android:allowBackup] tem estar igual a true, habilitando backup do aplicativo.

1- Comando para efetuar o backup:

@EduardoSP6
EduardoSP6 / php_ignore_weekends.php
Last active January 8, 2025 20:21
PHP function to skip weekend days with Carbon
<?php
public function skipWeekend($dt) {
if ($dt->isWeekend()) {
$dw = $dt->dayOfWeek;
if ($dw == 6) {
return $dt->addDay(2);
} else if ($dw == 0) {
@EduardoSP6
EduardoSP6 / download_and_remove_img_ajax.md
Last active October 7, 2025 23:30
Download and remove images through Ajax

Exemplo de download imagens no Laravel + Blade e Ajax

View Blade (front-end):

Template: adminlte

@extends('layouts.adminlte')
@section('css')
    <!-- Pace style -->
    <link rel="stylesheet" href="/bower_components/AdminLTE/plugins/pace/pace.min.css">
@endsection            
@EduardoSP6
EduardoSP6 / custom_auth_user_by_passport.md
Last active October 7, 2025 23:35
Authenticate user by other fields through Laravel Passport

How to authenticate user by other fields in Laravel

Authenticate user by other model fields in Laravel 5.x API and Passport.

Model User:

<?php

class User extends Authenticatable implements Transformable
{
@EduardoSP6
EduardoSP6 / laravel_supervisor_config.md
Last active January 8, 2025 20:19
Configuração do Supervisor para gerenciar queue jobs do Laravel

Instalação e configuração do Supervisor para gerenciar os Jobs do Laravel no servidor linux.

1- Instalação:

sudo apt-get install supervisor

2- Acesse o diretório:

cd /etc/supervisor/conf.d

Instalação Wordpress via Easy Engine Digital Ocean

1- Criar usuario:

adduser nomedousuario

2- Adicionar ao grupo de administradores:

usermod -aG sudo nomedousuario
@EduardoSP6
EduardoSP6 / laravel_unique_validation_request.md
Last active January 8, 2025 20:15
Unique validation rule in Request - Laravel 5.4

Valid field serial_number from model Product as unique as an example;

Note if we are updating the record, and the value of record field is equals to value of request (received from form submit), it's necessary ignore because didn't have alterations in this field. Otherwise, it will validate as unique field.

class ProductRequest extends FormRequest 
{
    
    public function authorize()
@EduardoSP6
EduardoSP6 / drop_all_tables_from_database_mysql.txt
Last active April 17, 2019 18:04
How to drop all tables from Mysql Database
# select database
USE database_name;
# disable relationships
SET foreign_key_checks=off;
# this command will retreive the drop command for all tables from database. So just copy the result and execute
@EduardoSP6
EduardoSP6 / android_spinner_style.txt
Last active May 16, 2019 18:18
Android Spinner Style
1- Insert this code in styles.xml:
<style name="SpinnerStyle">
<item name="android:background">@drawable/spinner_style</item>
</style>
2- Create a new Vector Asset called ic_arrow_drop_down_black_18dp with size: 18x18dp.
3- Modify file /drawable/spinner_style.xml like:
@EduardoSP6
EduardoSP6 / download_file_from_s3.php
Last active January 8, 2025 20:01
Download file from Amazon S3 with PHP + Laravel
<?php
public function download($archive)
{
$s3Client = Storage::disk('s3');
$fileName = File::basename($archive->url);
$fullPath = env('AWS_PATH') . "imports/" . $fileName;
if ($s3Client->exists($fullPath)) {