Skip to content

Instantly share code, notes, and snippets.

View dmandrade's full-sized avatar
🎯
Focusing

Danilo Andrade dmandrade

🎯
Focusing
View GitHub Profile
@dmandrade
dmandrade / jetstream-confirm-2fa.patch
Last active February 27, 2022 06:40
Add views to confirm 2FA enable using TOTP code
Add 2FA enable confirmation using TOTP code
@package laravel/jetstream
--- src/Http/Livewire/TwoFactorAuthenticationForm.php
+++ src/Http/Livewire/TwoFactorAuthenticationForm.php
@@ -3,8 +3,9 @@
namespace Laravel\Jetstream\Http\Livewire;
use Illuminate\Support\Facades\Auth;
@dmandrade
dmandrade / fortify-confirm-2fa.patch
Created June 2, 2021 14:22
Adds option to confirm activation of 2FA
Adds option to confirm activation of 2FA
@package laravel/fortify
--- /dev/null
+++ database/migrations/2021_06_01_145800_add_two_factor_confirmed_column_to_users_table.php
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
@dmandrade
dmandrade / laravel-impersonate.patch
Created June 2, 2021 01:01
Add password hash in session to fix leave impersonate in Jetstream/Fortify
Add password hash in session to fix leave impersonate in Laravel 8 with jetstream
@package lab404/laravel-impersonate
--- src/Guard/SessionGuard.php
+++ src/Guard/SessionGuard.php
@@ -16,7 +16,9 @@ class SessionGuard extends BaseSessionGuard
public function quietLogin(Authenticatable $user)
{
$this->updateSession($user->getAuthIdentifier());
@dmandrade
dmandrade / gist:0b6067cdc75345a9b3c095285e931825
Last active September 26, 2019 23:11
CLI util commands
# Resize images in folder
$ npm install sharp-cli
$ find . -name '*.jpg' | gawk -F'.jpg' '{ printf "sharp -i \"%s\" -o ./%s-thumb.jpg resize 321 485\n", $0, $1 }' | bash
# Rename folder image in sequential order
$ find . -name '*.jpg' | gawk 'BEGIN{ a=1 }{ printf "mv \"%s\" %d.jpg\n", $0, a++ }' | bash
@dmandrade
dmandrade / gist:e76a2da8da8a325f3ab9e275da15d5d9
Last active May 2, 2024 23:27
React Native build unsigned apk without development server
# create assets folder in the current project
$ mkdir android/app/src/main/assets
# create bundle script
$ react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
# execute command to run android to create debug apk
$ react-native run-android
# change to android folder
@dmandrade
dmandrade / cpfValidator.php
Last active April 29, 2020 15:27
validar cpf
<?php
function validaCpf($cpf) {
$cpf = preg_replace("/\D+/", "", $cpf);
if(strlen($cpf) < 11 || count(array_count_values(str_split($cpf))) === 1) {
return false;
}
for ($t = 9; $t < 11; $t++) {
for ($dv = 0, $c = 0; $c < $t; $c++) {
$dv += $cpf[$c] * (($t + 1) - $c);
}
@dmandrade
dmandrade / gist:fbc7f9e3effbf0fe1589b7d96e2d3ba4
Created December 21, 2017 17:39
List recently installed package-names in one line
This results in a single line of package names that can be easily added to a sudo apt-get purge command.
cat /var/log/dpkg.log |awk '/ install / {printf "%s ",$4 }'
#!/usr/bin/env bash
set -e
{
cat <<-'EOH'
# This file lists all individuals having contributed content to the repository.
EOH
echo
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
} > authors.md