Skip to content

Instantly share code, notes, and snippets.

@andyyou
andyyou / gke-gce-cloud-armor-lb.sh
Created February 10, 2023 07:19 — forked from pydevops/gke-gce-cloud-armor-lb.sh
Example Cloud Armor policies protecting Google HTTPS Global Load Balancer in front of GCE instance group and GKE cluster
#!/usr/bin/env bash
# REF: https://cloud.google.com/armor/docs/integrating-cloud-armor#with_ingress
# REF: https://cloud.google.com/armor/docs/configure-security-policies
# REF: https://cloud.google.com/iap/docs/load-balancer-howto
# REF: https://cloud.google.com/sdk/gcloud/reference/compute/url-maps/add-path-matcher
# REF: https://cloud.google.com/load-balancing/docs/https/setting-up-url-rewrite
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
@andyyou
andyyou / Markdium-Hack.php
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
// app/Actions/Fortify/CreateNewUser.php@create
// app/Actions/Fortify/UpdateUserProfileInformation.php@update
// unique rule
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,NULL,id,deleted_at,NULL'],
'password' => $this->passwordRules(),
])->validate();
@andyyou
andyyou / Markdium-Hack.php
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
// app/Actions/Fortify/CreateNewUser.php
['required', 'string', 'email', 'max:255', 'unique:users,email,NULL,id,deleted_at,NULL'],
// ...
])->validate();
return DB::transaction(function () use ($input) {
return tap(User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
@andyyou
andyyou / Markdium-Hack.php
Last active October 28, 2020 06:35
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
// ...
Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
return Inertia\Inertia::render('Dashboard');
})->name('dashboard');
@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
$ composer require laravel/socialite
# (opt) If you meet memory limit error, place `COMPOSER_MEMORY_LIMIT=-1` before command
# $ COMPOSER_MEMORY_LIMIT=-1 composer require laravel/socialite
@andyyou
andyyou / Markdium-Hack.php
Last active October 28, 2020 07:05
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
<div>
@php
$providers = [
'google' => [
'bgColor' => '#ec462f',
'icon' => 'fab fa-google',
],
'facebook' => [
'bgColor' => '#1877f2',
'icon' => 'fab fa-facebook-f',
@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
$ php artisan make:controller Auth/LoginController
@andyyou
andyyou / Markdium-Hack.php
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->dropUnique(['email']);
$table->string('password')->nullable()->change();
$table->json('social')->nullable();
$table->softDeletes();
$table->unique(['email', 'deleted_at']);
});
}
@andyyou
andyyou / Markdium-Hack.php
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
use Illuminate\Database\Eloquent\SoftDeletes;
use SoftDeletes;
protected $casts = [
'email_verified_at' => 'datetime',
'social' => 'array',
];
@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
# 1. Create project
$ laravel new demo
# 2. Install jetstream with teams
$ composer require laravel/jetstream
$ php artisan jetstream:install inertia --teams
$ npm install && npm run dev
# (opt) For customize template you should publish these views
$ php artisan vendor:publish --tag=jetstream-views