Skip to content

Instantly share code, notes, and snippets.

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
$ 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
@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
$ createdb demo
@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;
// ...
// If you want to support verify you can add implements
class User extends Authenticatable
{
use Notifiable;
use SoftDeletes;
// ...
@andyyou
andyyou / Markdium-Hack.php
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
use App\Http\Controllers\Auth\LoginController;
Route::get('/login/{provider}', [LoginController::class, 'redirectToProvider'])
->name('social.login');
Route::get('/login/{provider}/callback', [LoginController::class, 'handleProviderCallback'])
->name('social.callback');
@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
$ laravel new demo
@andyyou
andyyou / Markdium-Hack.php
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('FACEBOOK_CALLBACK_URL'),
'scopes' => ['email', 'public_profile'],
@andyyou
andyyou / Markdium-Shell.sh
Created October 23, 2020 06:01
Markdium-Laravel 8 - Integrate Jetstream + Socialite in 30 mins
$ php artisan migrate
@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
// app/Actions/Fortify/UpdateUserProfileInformaiton.php
['required', 'email', 'max:255', 'unique:users,email,NULL,id,deleted_at,NULL'],
// ...
])->validateWithBag('updateProfileInformation');
// ...
}
// ...
}