This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function csvToArray($filename = '', $delimiter = '\t') | |
{ | |
if (!file_exists($filename) || !is_readable($filename)) | |
return []; | |
$row = 0; | |
$fileContent = []; | |
if (($handle = fopen($filename, "r")) !== FALSE) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implementação de rotina de verificação da conta de e-mail: | |
- Criar migração do model User adicionando o campo: | |
$table->timestamp('email_verified_at')->nullable(); | |
- Implementar a interface MustVerifyEmail no model User; | |
- O Laravel já possui um listener chamado SendEmailVerificationNotification que é responsavel por enviar | |
o e-mail quando um usuario é registrado. Ele está relacionado ao evento Auth\Events\Registered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Custom password validation laravel 7: | |
For create a custom password rule for laravel you should run a command: php artisan make:rule PasswordRule. | |
The class will be created in App\Rules folder. Example: | |
<?php | |
namespace App\Rules; | |
use Illuminate\Contracts\Validation\Rule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Password reset laravel 7: | |
- Add the traits below in model User: | |
Illuminate\Notifications\Notifiable; | |
Illuminate\Contracts\Auth\CanResetPassword; | |
- Install laravel/ui that contains the migration of reset token table. Commands: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json.JSONException; | |
import org.json.JSONObject; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
import java.util.ArrayList; | |
import io.realm.RealmObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Snippet para o VS Code | |
- Dentro do VS Code tecle `Ctrl + Shift + P`, digite `snippet` e escolha a opção `Preferences: Configure User Snippets`; | |
- Clicar em New Global Snippets file... | |
- Digite um nome para o arquivo; | |
- Apagar o conteudo do arquivo e inserir o json abaixo: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Arredonda numero | |
* | |
* @param mValue - valor a ser arredondado | |
* @param precision - numero de casas decimais | |
* @param ceilOrFloor - true para mais, false para menos | |
**/ | |
public static double roundNumber(double mValue, int precision, boolean ceilOrFloor) { | |
double result = mValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double calcDistanceBetweenCoords(Double origLat, Double origLng, Double destLat, Double destLng) | |
{ | |
double result = 0; | |
if (origLat == null || origLng == null || destLat == null || destLng == null) { | |
return result; | |
} | |
// converte as coordenadas para radianos | |
origLat = Math.toRadians(origLat); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- CSS --> | |
<link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@2.3.3/dist/esri-leaflet-geocoder.css" | |
integrity="sha512-IM3Hs+feyi40yZhDH6kV8vQMg4Fh20s9OzInIIAc4nx7aMYMfo+IenRUekoYsHZqGkREUgx0VvlEsgm7nCDW9g==" | |
crossorigin=""> | |
<!-- JS --> | |
<script src="https://unpkg.com/esri-leaflet-geocoder@2.3.3/dist/esri-leaflet-geocoder.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import org.jetbrains.annotations.NotNull; | |
import java.io.IOException; | |
import java.util.concurrent.TimeUnit; | |
import okhttp3.Interceptor; | |
import okhttp3.OkHttpClient; |
NewerOlder