EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

Two dimensional Array unique


$goods = [
  1 => [
    'id' => 12,
    'price' => 77,
  ],
  2 => [
    'id' => 43,
    'price' => 855,
  ],
  4 => [
    'id' => 34,
    'price' => 1,
  ],
];

$goods_unique_ids_keys = array_keys(array_unique(array_column($goods, 'id')));
$goods_filter_datas = array_filter($goods, fn($key) => in_array($key, $goods_unique_ids_keys), ARRAY_FILTER_USE_KEY);
        

Livewire form and outside form with button action maybe different your think

In liveiwre word some button action and alpine @click action be clicked, livewire 3 update (ajax) is different your think. Component

    public $test_input=1;

    public function tt()
    {
        info('tt');
        info($this->test_input);
    }
blade

        <div class="row row-cols-1 row-cols-md-3 g-4" x-data>
            <form wire:submit="tt">
                <input type="text" wire:model='test_input'>
                <button type="submit">form type=submit</button> {{-- // update (ajax) --}}
                <button type="button">form type=button</button> {{-- // No update (ajax) --}}

                <button wire:click='tt; $wire.test_input=3;'>form wire:click</button> {{-- // update (ajax) and run twice --}}
                <button @click='$wire.tt; $wire.test_input=3;'>form @click</button> {{-- // update (ajax) and run twice --}}
            </form>

            <button type="submit">out form type=submit</button> {{-- // No update (ajax) --}}
            <button type="button">out form type=button</button> {{-- // No update (ajax) --}}

            <button wire:click='tt; $wire.test_input=3;'>out form wire:click</button> {{-- // update (ajax)  --}}
            <button @click='$wire.tt; $wire.test_input=3;'>out form @click</button> {{-- // update (ajax)  --}}
        </div>
So be careful and try to understand
1. what time public variable have value or be set value
2. run twice, not run one.

[轉] Powershell Script for Sending Email via Remote SMTP

https://tecadmin.net/powershell-sending-email-via-smtp/

# Define the sender, recipient, subject, and body of the email
$From = "sender@example.com"
$To = "recipient@example.com"
$Subject = "Test Email"
$Body = "This is a test email sent via remote SMTP using PowerShell."
 
# Define the SMTP server details
$SMTPServer = "smtp.example.com"
$SMTPPort = 587
$SMTPUsername = "username"
$SMTPPassword = "password"
 
# Create a new email object
$Email = New-Object System.Net.Mail.MailMessage
$Email.From = $From
$Email.To.Add($To)
$Email.Subject = $Subject
$Email.Body = $Body
# Uncomment below to send HTML formatted email
#$Email.IsBodyHTML = $true
 
# Create an SMTP client object and send the email
$SMTPClient = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$SMTPClient.EnableSsl = $true
 
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($SMTPUsername, $SMTPPassword)
$SMTPClient.Send($Email)
 
# Output a message indicating that the email was sent successfully
Write-Host "Email sent successfully to $($Email.To.ToString())"

gitlab runner 【x509: certificate relies on legacy Common Name field, use SANs instead】 And 【x509: certificate signed by unknown authority】

https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28841

【x509: certificate relies on legacy Common Name field, use SANs instead】

1. Change all example.com for your domain

openssl genrsa -out ca.key 2048

openssl req -new -x509 -days 365 -key ca.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=Acme Root CA" -out ca.crt

openssl req -newkey rsa:2048 -nodes -keyout example.com.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=*.example.com" -out example.com.csr

openssl x509 -req -extfile <(printf "subjectAltName=DNS:example.com,DNS:www.example.com") -days 365 -in example.com.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out example.com.crt

2. Put crt and key to gitlab ssl. Stop gitlab. Start gitlab.

Check gitlab have new DNS

openssl s_client -connect example.com:443 /dev/null | openssl x509 -noout -text | grep DNS:
3. if have 【x509: certificate signed by unknown authority】


gitlab-runner register --tls-ca-file="Use just create crt file"

laravel socialite line How to

Thank

https://medium.com/laravel-news/adding-auth-providers-to-laravel-socialite-ca0335929e42

This have problems https://socialiteproviders.com/Line/

1.


composer require socialiteproviders/line

2. create app/Providers/LineProvider.php

https://github.com/SocialiteProviders/Line/blob/master/Provider.php


namespace App\Providers;

use GuzzleHttp\RequestOptions;
use Laravel\Socialite\Two\InvalidStateException;
use \SocialiteProviders\Manager\OAuth2\AbstractProvider;
use \SocialiteProviders\Manager\OAuth2\User;

class LineProvider extends AbstractProvider
{
    public const IDENTIFIER = 'LINE';

    /**
     * The separating character for the requested scopes.
     *
     * @var string
     */
    protected $scopeSeparator = ' ';

    /**
     * The scopes being requested.
     *
     * @var array
     */
    protected $scopes = [
        'openid',
        'profile',
        'email',
    ];

    /**
     * Get the authentication URL for the provider.
     *
     * @param  string  $state
     * @return string
     */
    protected function getAuthUrl($state)
    {
        return $this->buildAuthUrlFromBase(
            'https://access.line.me/oauth2/v2.1/authorize',
            $state
        );
    }

    /**
     * Get the token URL for the provider.
     *
     * @return string
     */
    protected function getTokenUrl()
    {
        return 'https://api.line.me/oauth2/v2.1/token';
    }

    /**
     * Get the raw user for the given access token.
     *
     * @param  string  $token
     * @return array
     */
    protected function getUserByToken($token)
    {
        $response = $this->getHttpClient()->get(
            'https://api.line.me/v2/profile',
            [
                RequestOptions::HEADERS => [
                    'Authorization' => 'Bearer '.$token,
                ],
            ]
        );

        return json_decode((string) $response->getBody(), true);
    }

    /**
     * Map the raw user array to a Socialite User instance.
     *
     * @param  array  $user
     * @return \Laravel\Socialite\User
     */
    protected function mapUserToObject(array $user)
    {
        return (new User())->setRaw($user)->map([
            'id'       => $user['userId'] ?? $user['sub'] ?? null,
            'nickname' => null,
            'name'     => $user['displayName'] ?? $user['name'] ?? null,
            'avatar'   => $user['pictureUrl'] ?? $user['picture'] ?? null,
            'email'    => $user['email'] ?? null,
        ]);
    }

    // /**
    //  * Get the POST fields for the token request.
    //  *
    //  * @param string $code
    //  *
    //  * @return array
    //  */
    // protected function getTokenFields($code)
    // {
    //     return array_merge(parent::getTokenFields($code), [
    //         'grant_type' => 'authorization_code',
    //     ]);
    // }

    /**
     * @return \SocialiteProviders\Manager\OAuth2\User
     */
    public function user()
    {
        if ($this->hasInvalidState()) {
            throw new InvalidStateException();
        }

        $response = $this->getAccessTokenResponse($this->getCode());

        if ($jwt = $response['id_token'] ?? null) {
            $bodyb64 = explode('.', $jwt)[1];
            $user = $this->mapUserToObject(json_decode(base64_decode(strtr($bodyb64, '-_', '+/')), true));
        } else {
            $user = $this->mapUserToObject($this->getUserByToken(
                $token = $this->parseAccessToken($response)
            ));
        }

        $this->credentialsResponseBody = $response;

        if ($user instanceof User) {
            $user->setAccessTokenResponseBody($this->credentialsResponseBody);
        }

        return $user->setToken($this->parseAccessToken($response))
            ->setRefreshToken($this->parseRefreshToken($response))
            ->setExpiresIn($this->parseExpiresIn($response));
    }
}

3. edit app/Providers/AppServiceProvider.php


namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        $this->bootLineSocialite();
    }

    public function bootLineSocialite(): void
    {
        // // laravel Socialite 和 Socialite Line 有問題,就是 在初始載入不了
        // // 看Socialite Line 作者還有在3星期前維謢,所以就不知道怎麼回事
        // // https://medium.com/laravel-news/adding-auth-providers-to-laravel-socialite-ca0335929e42
        $socialite = $this->app->make('Laravel\Socialite\Contracts\Factory');

        $socialite->extend(
            'line',
            function ($app) use ($socialite) {
                $config = config('services.line');

                // https://github.com/SocialiteProviders/Line/blob/master/Provider.php
                return $socialite->buildProvider(LineProvider::class, $config); // \SocialiteProviders\Line\Provider::class
            }
        );
    }
}

4. routes/web.php


Route::get('/auth/redirect', function () {
    return Socialite::driver('line')->redirect();
});

Route::get('/auth/callback', function () {
    $user = Socialite::driver('line')->user();

    dd($user);
});