Skip to content

Instantly share code, notes, and snippets.

View marcusedu's full-sized avatar
🏠
Working from home

Marcus Duarte marcusedu

🏠
Working from home
View GitHub Profile
@marcusedu
marcusedu / Controller.php
Last active January 22, 2023 22:07
Controller base do laravel para aplicação de filtros e paginação
<?php
namespace App\Http\Controllers;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
@alexandreservian
alexandreservian / regex.md
Last active August 15, 2024 17:19
Metacaracteres Regex

Representantes

Meta Nome Função
. ponto um caractere qualquer
[] conjunto conjunto de caracteres permitidos
[^] conjunto negado conjunto de caracteres proibidos

Quantificadores

enum OrderType { asc, desc, sad }
String enumToString(dynamic enumValue) =>
enumValue.toString().replaceAll(RegExp(r"^.*?\."), "");
E stringToEnum<E>(List<E> values, String target, [E defaultIfNoMatch]) {
return values.firstWhere((enm) => enumToString(enm) == target,
orElse: () => defaultIfNoMatch);
}
@marcusedu
marcusedu / install_flutter_on_windows.bat
Last active October 17, 2020 13:46
Script que baixa e instala o chocolatey, dart-sdk, android studio e o git, depois clona o flutter na pasta src da raiz do disco e inicializa o Flutter doctor.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install dart-sdk androidstudio git
cd \
mkdir src
cd \src
git clone https://github.com/flutter/flutter.git
cd flutter
start bin/flutter.bat doctor
start flutter_console.bat
@echo off
@marcusedu
marcusedu / patterns.dart
Last active December 11, 2019 05:14
Expressões regulares de uso comum
final RegExp email = RegExp(
r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]"
r"{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a"
r"-zA-Z0-9])?)*$",
caseSensitive: false,
multiLine: false);
final RegExp mobileBrazilianPhone = RegExp(r"^\(?0?\d{2}\)? ?9 ?\d{4}-?\d{4}$",
caseSensitive: false, multiLine: false);
public class ExemploPaginacaoFirebaseDoUltimoParaOPrimeiro{
private DatabaseReference listaRef = FirebaseDatabase.getInstance().getReference("suaLista");
private int numItensPorPagina = 15;
private ArrayList<SeuItem> itens = new ArrayList();
private ChildEventListener meuChildEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
// Aqui ele registra a ultima key recebida e
// compara se a key atual é mais velha se for guardamos ela
if (ultimoItem == null)
@deividaspetraitis
deividaspetraitis / lumen-filesystem.md
Created October 19, 2017 09:36
Lumen flysystem ( filesystem ) integration

Lumen flysystem integration

By default lumen doesn't support laravel file system. In order to integrate to lumen we need follow these instructions:

  1. composer require league/flysystem
  2. Copy filesystems config file from Laravel ( https://github.com/laravel/laravel/blob/master/config/filesystems.php ) to your local Lumen installation document_root/config
  3. Bind filesystem to IoC for example in document_root/bootstrap/app.php by adding this code lines:

`` $app->singleton('filesystem', function ($app) {

@callmeloureiro
callmeloureiro / comoSerChatoNoWhatsapp.js
Last active September 23, 2024 19:29
Como fazer alguém te responder no whatsapp
/*
Hoje iremos MUDAR a vida da pessoa que não te responde no whatsappp...
Que tal enviar mensagens pra ela até obter uma resposta?!
Sensacional não acha?! Mas, somos devs, correto?! Então vamos automatizar esse paranauê!
Para utilizar:
- Abra o web.whatsapp.com;
- Selecione a conversa que você quer;
- Abra o console e cole o código que está no gist;
@noygal
noygal / Windows Subsystem for Linux version 1 and 2 (WSL) - node install guide.md
Last active October 16, 2024 01:06
Installing node via windows subsystem for linux

Windows 10 version 2004 - Installing Node.js on Windows Subsystem for Linux (WSL/WSL2)

UPDATE (Fall 2020): This gist is an updated version to the Windows 10 Fall Creators Update - Installing Node.js on Windows Subsystem for Linux (WSL) guide, I usually just keep here notes, configuration or short guides for personal use, it was nice to know it also helps other ppl, I hope this one too.

Windows updated windows subsystem for linux to version 2, as the F.A.Q stated you can still use WSL version 1 side by side with version 2. I'm not sure about existing WSL machines surviving the upgrade process, but as always backup and 🤞. NOTE: WSL version 1 is not replace/deprecated, and there ar

@fgilio
fgilio / axios-catch-error.js
Last active August 15, 2024 01:45
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨