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 / mfa_validator_input.dart
Last active February 27, 2024 20:24
A simple MFA Validator Input, with custom length code.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class MfaValidatorInput extends StatefulWidget {
const MfaValidatorInput({
super.key,
required this.length,
this.onCompleted,
this.onChanged,
this.focusNode,
<?php
namespace App\Console\Commands;
use Anik\Amqp\ConsumableMessage;
use Anik\Amqp\Exceptions\AmqpException;
use Anik\Amqp\Queues\Queue;
use Anik\Laravel\Amqp\Facades\Amqp;
use App\Models\Device;
use App\Models\DeviceVehicle;
@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;
// ==UserScript==
// @name Dias Atividade
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adiciona indicador de dias para conclusão da atividade
// @author Marcus Duarte<[email protected]>
// @match https://colaboraread.com.br/aluno/timeline/index/*
// @icon https://www.google.com/s2/favicons?domain=colaboraread.com.br
// @grant none
// ==/UserScript==
public function pegarValidadeDiaUtil($dias = 30, $finaisDeSemana = [0, 6]): Carbon
{
$agora = now();
$anoInicial = $agora->year;
$numFinaisDeSemanaParaPular = 0;
for ($i = 0; $i < $dias; $i++) {
$agora->addDays();
if (in_array($agora->weekday(), $finaisDeSemana)) {
$numFinaisDeSemanaParaPular++;
}
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 / CountryCodes.json
Last active July 1, 2019 15:59 — forked from anubhavshrimal/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
},
@marcusedu
marcusedu / app_switch.dart
Created February 21, 2019 17:15
Simples Switch com valores
import 'package:flutter/material.dart';
class AppSwitch extends StatefulWidget {
final String firstValue;
final String secondValue;
final String selectedValue;
final Null Function(String) onChange;
final Color selectedColor;
final Color unselectedColor;
final Color selectedTextColor;
@marcusedu
marcusedu / app_page_indicator.dart
Created February 19, 2019 00:07
Simple PageIndicator
import 'package:flutter/material.dart';
class AppPageIndicator extends StatefulWidget {
final PageController controller;
final int numItems;
final Color activeColor;
final Color inactiveColor;
final double dotSize;
final bool fillDots;
final EdgeInsets padding;
@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