EExcel 丞燕快速查詢2

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

[轉]After 5 years, I'm out of the serverless compute cult

https://dev.to/brentmitchell/after-5-years-im-out-of-the-serverless-compute-cult-3f6d

I have been using serverless computing and storage for nearly five years and I'm finally tired of it. I do feel like it has become a cult. In a cult, brainwashing is done so gradually, people have no idea it is going on. I feel like this has happened across the board with so many developers; many don’t even realize they are clouded. In my case, I took the serverless marketing and hype hook, line, and sinker for the first half of my serverless journey. After working with several companies small and large, I have been continually disappointed as our projects grew. The fact is, serverless technology is amazingly simple to start, but becomes a bear as projects and teams accelerate. A serverless project typically includes a fully serverless stack which can include (using a non-exhaustive list of AWS services):


  1. API Gateway
  2. Cognito
  3. Lambda
  4. DynamoDB
  5. DAX
  6. SQS/SNS/EventBridge

Combining all of these into a serverless project become a huge nightmare for the following reasons.



Testing


All these solutions are proprietary to AWS. Sure, a lambda function is a pretty simple idea; it is simply a function that executes your code. The other services listed above have almost no other easy and testable solutions when integrated together. Serverless Application Model and Localstack have done some amazing work attempting to emulate these services. However, they usually only only cover basic use cases and an engineer ends up spending a chunk of time trying to mock or figure out a way to get their function to test locally. Or, they simply forget it and deploy it. Also, since these functions typically depend on other developer's functions or API Gateway, there tends to be 10 different ways to authorize their function. For example, someone might have an unauthorized API, one may use AWS credentials, another might use Cognito, and yet another uses an API key. All of these factors lead to an engineer having little to no confidence in their ability to test anything locally.


Account Chaos


Since engineers typically don't have a high confidence in their code locally they depend on testing their functions by deploying. This means possibly breaking their own code. As you can imagine, this breaks everyone else deploying and testing any code which relies on the now broken function. While there are a few solutions to this scenario, all are usually quite complex (i.e. using an AWS account per developer) and still cannot be tested locally with much confidence. Chaos engineering has a time and a place. This is not it.


Security


With all the possible permutations of deployments and account structures, security becomes a big problem. Good IAM practices are hard. Many engineers simply put a dynamodb:* for all resources in the account for a lambda function. (BTW this is not good). It becomes hard to manage all of these because developers can usually quite easily deploy and manage their own IAM roles and policies. And since it is hard to test locally, trying to fix serverless IAM issues requires deploying to AWS and testing (or breaking) in the environment.


Bad (Cult-like) Practices


No Fundamental Enforcement


Without help from frameworks, DRY (Don't Repeat Yourself), KISS (Keep It Simple Stupid) and other essential programming paradigms are simply ignored. In a perfect world, a team would reject PR's that do not abide by these basic principles. However, with the huge push for the cloud over the past several years, many junior developers have had the freedom to do what they want in the serverless space because of its ease of use; resulting in developers enmasse adopting something that doesn’t increase the health of the developer ecosystem as a whole. AWS gives you a knife by providing such an easy way to deploy code on the internet. Please don't hurt yourself with it.


Copy and Paste Culture


Most teams end up copying code to the new microservices and proliferating it across many services. I have seen teams with hundreds and even thousands of functions with nearly every function being different. This culture has gotten out of hand and now teams are stuck with these functions. Another symptom of this is not taking the time to provide a proper DNS.

DNS Migration Failures

Developers take the generic API Gateway generated DNS name (abcd1234.amazonaws.com) and litter their code with it. There will come a time when the teams want to put a real DNS in front of it and now you're faced with locating the 200 different spots it was used to change it. And, it's not as easy as a Find/Replace. Searching like this can become a problem when you have a mix of hard-coded strings, parameterized/concatenated strings, and environment variables everywhere that DNS name lies. Oh and telemetry? Yeah that's nowhere to be found.


Microservice Hell


This isn't a post about microservices. However, as teams and developers can decide and add whatever they want into their YAML files for deployment, you end up with hundreds of dependent services and hundreds of repositories. Many have different approaches and/or have different CI/CD workflows. Also, I've found that repository structures begin widely diverging. Any perceived cost savings has now been moved to managing all of these deployments and repositories. Here are a few examples of how developers choose to break up their serverless functions by Git repositories:

  1. Use a monolith for all their API's.
  2. Separate each API Gateway or queue processors
  3. Separate "domain" (i.e. /customers or /invoices)
  4. Separate by endpoint (I have seen developers break out a repository for POST:/customers while maintaining a separate one for GET:/customers/:id and so on…).

Many times, developers switch between different styles and structures daily. This becomes a nightmare not only for day-to-day development, but also for any developer getting to a quick-understanding of how the code deploys and what dependencies it has or impacts.


API Responses


The serverless cult has been active long enough now that many newer engineers entering the field don't seem to even know about the basics of HTTP responses. Now there are many veteran developers lacking this knowledge. While this is not strictly a serverless problem, I never have experienced this much abuse outside of serverless. I've seen endpoints returning 200, 400, 500 like normal. Yet another set of endpoints return all 2xx responses, with a payload like:

{
  "status": "ERROR",
  "reason": "malformed input"
}

Then, another set of endpoints implement inconsistent response patterns dependent on some permutation of query parameters. For example:
Query 1:
/customers?firstName=John

[{
  "accountId": "1234",
  "firstName": "John",
  "lastName": "Newman"
}]

Query 2:
/customers?lastName=Newman

{
  "accountId": "1234",
  "firstName": "John",
  "lastName": "Newman"
}

Inventing New Problems

As mentioned previously, initially deploying these types of services are easy. The reality is there are new problems with these kind of serverless structures that don't typically occur in server-backed services:

  1. Cold starts - many engineers don't care too much about this. But they suddenly start caring when Function A calls Function B which calls Function C and so on. Without some voodoo warm-up scripting solution, paying for provisioned concurrency, or ignoring it, you may be out of luck.
  2. In the past five years, prior to our work on our flooring installation marketplace, the teams I have been a part of have always chased the latest features because we had been doing workarounds like FIFO queues, state machines, provisioned concurrency, etc. As teams chase the latest features released by AWS (or your cloud provider of choice), things then become even harder to test and maintain since SAM or Localstack don't match these features for some time.
  3. Some awful custom eventing solution because… serverless. Engineers think simply putting an API Gateway in front of EventBridge will solve all their eventing problems. What about retries? What about duplicate events? What about replaying events? Schema enforcement? Where does the data land? How do I get the data? These are all questions that have to be answered or documented in a custom fashion. Ok, EventBridge supports a few of these things in some form but it does leave engineers chasing the latest features, waiting for these to become available. However, outside of the serverless cult, these issues can be solved with KafkaNATS, or other technologies. Use the right tool.
  4. When it’s not okay to talk about the advantages and disadvantages of serverless with other engineers without fear of reprisal, it might be a cult. Many of these engineers say Lambda is the only way to deploy anymore. There isn't much thought to offline solutions when things need to be run onsite or separated from the cloud. For some companies this can be a fine approach. However, many medium to large organizations have (potentially) offline computing needs outside of the cloud. Lambda cannot provide a sensitive, remote pressure device real-time updates in the event of an internet outage in the middle of Canada during winter.

So, how do I get out of the cult?


In this article, I didn’t plan to address the many options you have to extricate yourself from the grips of mindless serverless abuse. If you're interested, please leave a comment and I will write a follow-up on the different solutions and alternatives to serverless I’ve found as well as some tips to incrementally shift back to a normal life. What I did want to do here was to express the pains I have experienced with serverless technologies over the past couple years now that I have helped architect more traditional VM and container-based tech stacks. I felt compelled to ensure individuals, teams, and organizations know what serverless can really mean for long-term sustainability in an environment.


What does serverless do well?


Deployment and scaling. That's really it for most organizations. For a lot of these organizations, it's hard to find the time, people, and money to figure out how to automatically provision new VM's, get access to a K8S cluster, etc. My challenge to you is to first fix your deployment and scaling problems internally before thinking about serverless compute.



Conclusion

Serverless is one of the hottest new cloud trends. However, I have found it leads to more harm than good in the long run. While I understand some of the problems listed above are not unique to serverless, they are much more prolific; leading engineers to spend most of their time with YAML configuration or troubleshooting function execution rather than crafting business logic. What I find odd is the lack of complaints from the community. If I’m alone in my assessment, I’d love to hear from you in the comments below. I’ve spent a significant amount of time over the last few years working to undo my own serverless mistakes as well as those made by other developers. Maybe I’m the one who has been brainwashed? Time will tell.

jenkins withCredentials sshUserPrivateKey

https://codeleading.com/article/11015806881/

Remeber sshCommand remote, remote infos have identityFile
identityFile need be at insdie identity

Don't understand identity be keep. Only can be used inside identity

def getRemoteHost(ip, user) {
    def remote = [:]
    remote.name = ip
    remote.host = ip
    remote.user = user
    remote.identityFile = identity
    remote.port = 22
    remote.allowAnyHosts = true

    return remote
}

pipeline {
    agent any

    environment {
        ssh_ip = 'ooo.xxx.ooo.xxx'
        ssh_user = 'ubuntu'
        ssh_jenkins_key_uid = 'oooooooo-xxxx-xxxx-xxxx-oooooooooooo'
        
        // SSH_CREDS = credentials('oooooooo-xxxx-xxxx-xxxx-oooooooooooo')
    }
    
    stages {
        stage('ssh Command'){
            steps {
                withCredentials([sshUserPrivateKey(credentialsId: "${ssh_jenkins_key_uid}", keyFileVariable: 'identity')]) {
                    sshCommand remote: getRemoteHost(ssh_ip, ssh_user), command: "whoami"  //在远程服务器执行echo命令
                }
                
            }
        }
        
        
    }
}

def runCommand(cmd) {
    def remote = [:]
    remote.name = "${ssh_ip}"
    remote.host = "${ssh_ip}"
    remote.user = "${ssh_user}"
    // remote.identityFile = identity
    remote.port = 22
    remote.allowAnyHosts = true
    
    withCredentials([sshUserPrivateKey(
        credentialsId: "${ssh_jenkins_key_uid}", 
        keyFileVariable: 'identity')]) 
    {
        remote.identityFile = identity
        sshCommand remote: remote, command: cmd
    }
}

pipeline {
    agent any

    environment {
        ssh_ip = 'ooo.xxx.ooo.xxx'
        ssh_user = 'ubuntu'
        ssh_jenkins_key_uid = 'oooooooo-xxxx-xxxx-xxxx-oooooooooooo'
        
        // SSH_CREDS = credentials('oooooooo-xxxx-xxxx-xxxx-oooooooooooo')
    }
    
    stages {
        stage('ssh Command') {
            steps {
                echo 'whoami start...'
                runCommand('whoami') 
                echo 'whoami success'
    		}
        }
    }
}

model y 車機掛幾次

保养花费差7倍?特斯拉Model Y蔚来EC6《真十万公里长测》报告 7 Times in Maintenance costs? Tesla Model Y vs NIO EC6 Test

https://youtu.be/UrCEOMQPRzk?t=1052

17:32

laravel schedule cron docker dockerfile docker-compose

cron

php laravel UI Boostrap jetstream docker-compose

laravel_docker

dokcer-compose.yml

  cron:
    build: ./infra/docker/cron
    env_file: ./env.mariadb.local.env
    stop_signal: SIGTERM
    depends_on:
      - app
    volumes:
      - ./backend:/work/backend
Dockerfile

FROM php:8.0.11-fpm-buster
LABEL maintainer="ucan-lab "
#SHELL ["/bin/bash", "-oeux", "pipefail", "-c"]

# timezone environment
ENV TZ=Asia/Taipei \
  # locale
  LANG=en_US.UTF-8 \
  LANGUAGE=en_US:UTF-8 \
  LC_ALL=en_US.UTF-8 \
  # Laravel environment
  APP_SERVICES_CACHE=/tmp/cache/services.php \
  APP_PACKAGES_CACHE=/tmp/cache/packages.php \
  APP_CONFIG_CACHE=/tmp/cache/config.php \
  APP_ROUTES_CACHE=/tmp/cache/routes.php \
  APP_EVENTS_CACHE=/tmp/cache/events.php \
  VIEW_COMPILED_PATH=/tmp/cache/views \
  # SESSION_DRIVER=cookie \
  LOG_CHANNEL=stderr \
  DB_CONNECTION=mysql \
  DB_PORT=3306 

RUN apt-get update
RUN apt-get -y install locales libicu-dev libzip-dev htop cron nano
RUN apt-get -y install default-mysql-client

RUN locale-gen en_US.UTF-8 && localedef -f UTF-8 -i en_US en_US.UTF-8
RUN docker-php-ext-install intl pdo_mysql zip bcmath exif

RUN apt-get clean && rm -rf /var/lib/apt/lists/* 

# 自訂
RUN mkdir -p /tmp/cache
WORKDIR /work/backend


# 這行超級重要 把初始環境的變數寫死
RUN printenv > /etc/environment

# 把log 輸出到 docker 上
RUN ln -sf /proc/1/fd/1 /var/log/laravel-scheduler.log


#ADD crontab /var/spool/cron/crontabs/root
#RUN chown root:crontab /var/spool/cron/crontabs/root
#RUN chmod 0600 /var/spool/cron/crontabs/root

#RUN crontab -l | { cat; echo "* * * * * . /usr/local/bin/php /work/backend/artisan config:cache && php artisan schedule:run >> /var/log/cron.log 2>&1"; } | crontab -
#RUN crontab -l | { cat; echo "* * * * * date >> /var/log/cron.log"; } | crontab -
#RUN crontab -l | { cat; echo "* * * * * echo hello > /proc/1/fd/1 2>/proc/1/fd/2"; } | crontab -


COPY crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN crontab /etc/cron.d/crontab

CMD bash -c "/usr/local/bin/php /work/backend/artisan config:cache && cron -f"
cron

# 這行可有可無 主要是 dockerfile printenv 那行最重要 #!/usr/bin/env bash
# 這行可有可無 SHELL=/bin/bash
PATH=/usr/bin:/usr/local/bin:$PATH
* * * * * cd /work/backend && php artisan schedule:run >> /var/log/cron.log 2>&1
#* * * * * cd /work/backend && php artisan schedule:run >> /var/log/cron.log 2>&1 && echo schedule > /proc/1/fd/1 2>/proc/1/fd/2
#* * * * * date >> /var/log/cron.log
#* * * * * echo hello > /proc/1/fd/1 2>/proc/1/fd/2
#要多一行
app/Console/Kernel.php

protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();

        $fileCronLog = '/var/log/laravel-scheduler.log';  // dockerfile RUN ln -sf /proc/1/fd/1 /var/log/laravel-scheduler.log

        // cron('* * 26 * *')
        $schedule->command('your command')->timezone(config('app.timezone'))->everyMinute()->onOneServer()  
            ->before(function () {
                Log::info("Schedule your command before!");
            })
            ->after(function () {
                Log::info("Schedule your command after!");
            })
            ->onSuccess(function (Stringable $output) {
                Log::info("Schedule your command onSuccess!");
            })
            ->onFailure(function (Stringable $output) {
                Log::error("Schedule your command onFailure!");
            })
            ->appendOutputTo($fileCronLog);

【事實釐清】媒體報導「歐盟主要成員國近日同意將核能納入『綠色轉型』,成為解決碳排放的一環;希望各國利用核能,趕在2050年前實現碳中和」?

【事實釐清】媒體報導「歐盟主要成員國近日同意將核能納入『綠色轉型』,成為解決碳排放的一環;希望各國利用核能,趕在2050年前實現碳中和」?

https://tfc-taiwan.org.tw/articles/2192 

黃其君


✔正常查核程序:
優先翻閱一手資料,若不懂則請教專家
✖ TFC 台灣事實查核中心:
請教(有偏見)專家,也無對專家言論做查對

然後第一個說核能列入歐盟綠色轉型的不是台灣報導也不是哪個擁核媒體平台,是世界最大的媒體通訊社,美聯社以《EU leaders include nuclear energy in green transition》為標題報導歐盟高峰會結論,然後有紐約時報、日本時報等轉載刊登,到台灣因為翻譯就變成歐盟將核能納入綠色轉型。不懂台灣反核怎麼一直說別人世界最大平台假消息呢?

▉美聯社
https://reurl.cc/5gmyV6

范建德老師以2020/01/10的法案文字來認定歐盟要非核,但1/10有好多版本討論,法案文字都不是最終版,反核的還是綠黨提的...裏頭還要求2030歐盟要非核無煤阿...所以最後全部被刪光光也不意外。

▉法案文字
2020/01/15(無反核定案版)
https://reurl.cc/RdNl3Z
2020/01/10(無反核草案)
https://reurl.cc/4gx79v
2020/01/10(反核草案)
https://reurl.cc/Gk1R2v

而台大風險中心趙研究員真的讓你看看什麼叫超譯...

歐盟的技術文件裡提到核能在低碳能源中的重要腳色顯而易見,但確實在風險管理例如核廢料上難以將do no harm排除,很重要的一點,他有表明是因為現階段尚無啟用的核發電燃料的深層處置設施,所以無實例可以做評估。該報告也會在近一步針對核能做詳細討論。

並非像趙研究員說的什麼沒有解方或要隔絕數百萬年...可以不要自己腦補嗎?明明裏投也跟你說有解法了...

▉報告這邊看
https://reurl.cc/9zlYz8

Regarding the long-term management of High-Level Waste (HLW), there is an international consensus that a safe, long-term technical solution is needed to solve the present unsustainable situation. A combination of temporary storage plus permanent disposal in geological formation is the most promising, with some countries are leading the way in implementing those solutions. Yet nowhere in the world has a viable, safe and long-term underground repository been established. It was therefore infeasible for the TEG to undertake a robust DNSH assessment as no permanent, operational disposal site for HLW exists yet from which long-term empirical, in-situ data and evidence to inform such an evaluation for nuclear energy.

Given these limitations, it was not possible for TEG, nor its members, to conclude that the nuclear energy value chain does not cause significant harm to other environmental objectives on the time scales in question. The TEG has not therefore recommended the inclusion of nuclear energy in the Taxonomy at this stage. Further, the TEG recommends that more extensive technical work is undertaken on the DNSH aspects of nuclear energy in future and by a group with in-depth technical expertise on nuclear life cycle technologies and the existing and potential environmental impacts across all objectives.

https://hugo-m9c19ra1o-sueboy.vercel.app/

[轉]PHP 8.2 Remove libmysql mysqli

https://m.facebook.com/story.php?story_fbid=10216824504164331&id=1815507975

《 PHP RFC: Remove support for libmysql from mysqli 》

» https://wiki.php.net/rfc/mysqli_support_for_libmysql

PHP 核心開發團隊投票通過移除 mysqli 的 libmysql 支援,將於 PHP 8.2 正式生效。這項討論從農曆年前關注到年後,最終於 2022/2/5 全數投票通過。

對於一般 PHP 開發者是好事,不用再考慮 MySQL 是選擇 libmysql 還是 mysqlnd;面試時也減少面試官詢問兩者差異的比較 (不過現在很多面試官也不知道了)。

如果想瞭解 libmysql / mysqlnd 的優缺點,官方 RFC 也貼心地條列整理了。不過 RFC 裡沒提關於「License (授權)」的考量,特別在商業上。這也是 PHP 與 Python 及 Ruby 等社群有著不太一樣的生態考量。

Python 要連結 MySQL,通常選用 MySQL Connector 或 MySQLdb,但這兩者底層都依賴 libmysqlclient (MySQL C Library),而 libmysqlclient 的授權 [1] 主要採用 GPL-2.0,進而連帶影響了整體產品/專案的授權。

Ruby 要連結 MySQL,通常選用 mysql2,而其底層同樣依賴 libmysqlclient,有著同樣的潛在商業問題。

更重要的是 libmysqlclient 背後的公司是 Oracle。

但為什麼 PHP mysqlnd 沒有此問題?因為 mysqlnd 不依賴 libmysqlclient 而採用純 PHP extension 開發,授權採用 PHP License,在商業上避免了許多不必要的麻煩。

Python 其實也有不依賴 libmysqlclient 的 PyMySQL [2],Ruby 則有 mysql-rb [3],但效能大多不如 libmysqlclient 的實現。不像 PHP mysqlnd 在效能上大多勝於或接近 libmysql。

當然,Python 或 Ruby 若要不犧牲效能繼續採用 MySQLdb 或 mysql2,也是有替代方案的。

[1] https://dev.mysql.com/downloads/c-api/

[2] https://github.com/PyMySQL/PyMySQL

[3] https://github.com/kirs/mysql-rb

==========

https://hugo-kuh8tm78y-sueboy.vercel.app/

vendure GraphQL Login

https://demo.vendure.io/shop-api

union ..........

Need use ... on


mutation {
  authenticate(
    input: {
      native: { username: "test@vendure.io", password: "test" }
    }
    rememberMe: true
  ) {
    ... on CurrentUser {
      id
      identifier
      channels {
        id
        token
        code
        permissions 
      }
    }
    ... on InvalidCredentialsError {
      message
    }
  }
}

aws ecr new account docker push policy

1. IAM User -> New User -> Demo_ECR

Add Permissions policies 新增許可

a. 直接連接現有政策 AmazonEC2ContainerRegistryPowerUser

b. 建立policies -> Demo_ECR https://docs.aws.amazon.com/AmazonECR/latest/userguide/security-iam-awsmanpol.html

2. install aws cli tools windows

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html

3. aws ecr repositories -> private -> create repository

input demo

Keep ooxxooxxooxxooxx.dkr.ecr.ap-northeast-1.amazonaws.com/demo

save

4. aws cli login powershell windows

aws configure

go back IAM, show Demo_ECR -> 安全登入資料 security login

run 建立存取金鑰 create Access Key

copy new Access Key ID and AWS Secret Access Key

back aws configure. Input Access Key ID, Secret Access Key, ap-northeast-1 and Enter

5. docker login

aws ecr get-login-password --region ap-northeast-1

copy return Text like: eyJwYXlsb2FkIjoieE9hcWgzYmdPOXpN...............

6. docker image craete

First check your docker image: docker image ls

REPOSITORY = Image Name.

Tag is import.

Example "demo" is my image that want to send to aws repository.

docker tag "your image name":"your image" tag "aws repository URI"

docker tag demo:latest ooxxooxxooxxooxx.dkr.ecr.ap-northeast-1.amazonaws.com/demo

check "docker image ls" again

Now you can see new repository: ooxxooxxooxxooxx.dkr.ecr.ap-northeast-1.amazonaws.com/demo

7. docker image push

docker push ooxxooxxooxxooxx.dkr.ecr.ap-northeast-1.amazonaws.com/demo

Finish.

ERROR

Q: error parsing HTTP 403 response body: unexpected end of JSON input: ""

A: When you step 3. Image scan settings:get error If you check true. You can change false then push success.

A. other way.

https://github.com/aws/aws-toolkit-azure-devops/issues/311

https://stackoverflow.com/questions/34423873/docker-push-to-aws-ecr-private-repo-failing-with-malformed-json

go back step 1. change policy.

livewire checkbox

php

public $check_items;

public function mount()
{
   $this->check_items = collect(["png" => true, "scs" => true, "scz" => false, "xml" => true, "pdf" => false, ]);
}

blade

@forelse($check_items as $index => $item)
  
@empty
@endforelse

Expected response code 250 but got an empty response laravel 8

https://blog.trippyboy.com/2021/laravel/laravel-expected-response-code-250-but-got-an-empty-response/


./config/mail.php

'local_domain' => env('MAIL_HOST'),


'default' => env('MAIL_MAILER', 'smtp'),
'mailers' => [
    'smtp' => [
        'transport' => 'smtp',
        'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
        'port' => env('MAIL_PORT', 587),
        'encryption' => env('MAIL_ENCRYPTION', 'tls'),
        'username' => env('MAIL_USERNAME'),
        'password' => env('MAIL_PASSWORD'),
        'timeout' => null,
        'auth_mode' => null,
        'local_domain' => env('MAIL_HOST'),
],

laravel rules validate multiple row for other column

Multiple parts (id, name, finish, finish_noe)

finish = 2 is Job OK


protected $rules = [
    'parts.*.finish_note' => ['required_if:parts.*.finish,2'],
]

firebase deploy use rastasheep/ubuntu-sshd


docker run -d -P -p 9005:9005 -p 2222:22 -v C:\Users\user\Downloads\ooxxooxx\public_html:/project --name test_sshd rastasheep/ubuntu-sshd:18.04 

> apt update
> apt install curl
> curl -sL https://deb.nodesource.com/setup_16.x | bash -
> apt-get install -y nodejs

> npm install -g firebase-tools
> cd /project
> firebase login
> firebase deploy

程式設計師是如何神不知鬼不覺的弄丟銀行1分錢的?

https://kknews.cc/zh-tw/finance/zpxln2q.html

[開發經驗分享][JavaScript]浮點數運算出現一堆小數位數

https://dotblogs.com.tw/WillianHsiaoDotNetBLog/2020/01/15/JavascriptFloatCaculateBug?fbclid=IwAR0SnYG7FnesbfENWCsOT_ceGxqab6Q1dksJ3qIr-pe65m55wNBlWLc0Ns0

精確的浮點數運算 ?

https://medium.com/pyladies-taiwan/%E7%B2%BE%E7%A2%BA%E7%9A%84%E6%B5%AE%E9%BB%9E%E6%95%B8%E9%81%8B%E7%AE%97-28d34e652e51

疫苗

【開放CALLIN】🐶高端「真的」超級安全!?世界最大三期人體試驗場?論實證醫學重要性! ft. 台灣白色巨砲鄭醫師|歷史哥Talk 110.8.27

35分開始

文件有等級表 1最高,5最低,5:是專家學者意見




July 21, 2021

https://www.nejm.org/doi/full/10.1056/NEJMoa2108891?query=featured_coronavirus

Table 2




AZ疫苗致死風險就是比較高!簡單的邏輯教您科學思考!|歷史哥短篇




50分




林全 東洋 16:40

https://youtu.be/STBO88yaRI8?t=1000






兴疫苗如何?有效性与安全性不如辉瑞,阿斯利康,强生的疫苗? 于博士在德国




COVID-19疫苗統計資料

https://www.cdc.gov.tw/Category/Page/9jFXNbCe-sFK9EImRRi2Og




迷思?!

英 登記打疫苗,官方的

https://www.nhs.uk/conditions/coronavirus-covid-19/coronavirus-vaccination/book-coronavirus-vaccination/

If you're under 40, you'll only be shown appointments for the Pfizer/BioNTech or Moderna vaccines. If you're 40 or over, you'll be asked if you're pregnant to make sure you're only shown appointments for these vaccines.




澳洲

https://www.health.gov.au/initiatives-and-programs/covid-19-vaccines/learn-about-covid-19-vaccines/about-the-astrazeneca-covid-19-vaccine The Australian Technical Advisory Group on Immunisation (ATAGI) recommends the COVID-19 vaccine by Pfizer (Comirnaty) is preferred in adults aged under 60 years. In people 60 years and over, ATAGI continue to advise that the benefits of vaccination with the AstraZeneca vaccine outweigh the risks associated with vaccination. This recommendation is based on:

the increasing risk of severe outcomes from COVID-19 in older adults (and hence a higher benefit from vaccination), and the increased risk of thrombosis with thrombocytopenia following AstraZeneca vaccine in those under 60 years. There appears to be a small risk of TTS in people 60 years and over, but this risk appears to be lower than in younger people. Cases overseas have been reported at all ages.

1) 輝瑞/BNT一劑:52%。

2) 莫德納一劑:69.5%。

3) #AZ一劑: 76%!!




https://youtu.be/S2QChiAocmc?t=41 40 秒

鄭運鵬:拿第二期、第三期試驗當作疫苗的條件,這是沒有必要的,只要有緊急授權就好。


https://youtu.be/BvH46GLx7xg?t=3494

完全不推國產疫苗


Fosun Pharma will commercialize the COVID-19 vaccine in Greater China upon regulatory approval, including mainland China, Hong Kong, Macau and Taiwan.

https://biontech.de/covid-19




柯P怨疫苗預約系統來不及做好 唐鳳聲明回擊

https://tw.news.yahoo.com/%E6%9F%AFp%E6%80%A8%E7%96%AB%E8%8B%97%E9%A0%90%E7%B4%84%E7%B3%BB%E7%B5%B1%E4%BE%86%E4%B8%8D%E5%8F%8A%E5%81%9A%E5%A5%BD-%E5%94%90%E9%B3%B3%E8%81%B2%E6%98%8E%E5%9B%9E%E6%93%8A-002907650.html

回覆台北市的內容意旨僅有,「這批日本124萬劑AZ疫苗,不會使用疫苗預約系統」等語,與柯文哲所謂「疫苗預約系統來不及做好」的說法不符


不認同二期解盲就使用 中研院研究技師:應加入英國株病毒數據

https://udn.com/news/story/122190/5525521

中研院研究技師詹家琮說明,高端疫苗臨床二期解盲會過是合理的,但這是使用原始病毒株的數據,就二期來說也是OK的,但不適合直接通過食藥署EUA給人使用;如果不做三期臨床試驗,二期解盲的血清中和效力試驗一定要加上變異病毒株的實驗數據。

詹家琮解釋,三期臨床試驗要檢驗的是,疫苗接種者在他們生活的環境中,感染病毒的機率與病理表現,也就是當時當地人們正遭遇的病毒,感染後是否有保護力;因此,若要以二期試驗取代三期臨床試驗,應當以疫苗接種者之後會遭遇到的病毒來做試驗,否則數據就會失真而不可信。

詹家琮表示,若國產疫苗企圖以增加二期臨床試驗人數達到數千人,來彌補或是取代三期臨床試驗,是不得已接受的現實,但只要沒有做英國或印度的變異病毒株的實驗數據,就緊急給國人使用,他絕對無法認同。





兩樣情!香港BNT疫苗打不完 趙少康呼籲開放台人接種

https://www.bcc.com.tw/newsView.6307210

香港政府預訂了750萬劑輝瑞BNT(港稱復必泰疫苗),根據港府5月25日的說明,輝瑞BNT已到貨200多萬劑,至今庫存約84萬劑,使用期限在8月中屆滿。





陳弘美老師表示:

不要拿中文的思維來想日文 。不能單取一個單字、要看前面的整個文脈 引導的順向。

並且日文不 一定要用像中、英文 般的明顯字眼、"只" 不一定要用のみ、だけ 表達、有太多太多表達的方法、就看前面文脈的 整個趨向。

同學們來學習一下。

要注意到、 這裡是前面有很長的、 雄厚的理論在説明台灣將有 非常充分的量、甚至到2000萬劑、 相較下100萬劑是非常少量、 所以用"只"是完全合乎文脈 的邏輯。

https://youtu.be/iotqkCOd1cE?t=6060






越南苦于疫苗到货率低,洽谈代工俄罗斯疫苗

https://baijiahao.baidu.com/s?id=1702095458974636136

1. 找更多來源:俄羅期,批准中国国药集团(Sinopharm)疫苗

2. 代工生產 洽谈代工生产俄国疫苗,促进磋商传讯核糖核酸(mRNA)技术转移

3. 越南一方面也自己研发疫苗,越南国产的COVID-19 疫苗Nanocovax从8日开始第三期人体临床试验,希望明年能够供货

4. 6月初鼓励所有地方、企业和单位参与寻找疫苗货源,并列出36家符合进口疫苗资格的企业




【BOSS工作室 中天#LIVE】黃義霖批疫苗政策根本有問題 6/28也無法解封三級 來聽黃義霖醫師解析 @中天新聞 20210609

https://youtu.be/NXwPjlEUO2o?t=251




據我們的認知,七月以後,台灣國內的疫苗生產機制就會逐漸完備,而眼前台灣有緊急的需求。

蔡英文:預計在7月底可以供應第一波的國產疫苗 6分46秒

0513總統府記者會 蔡英文發表談話

https://youtu.be/09OKKtsfbPo?t=405




到底是誰說了台灣只需要一百萬劑疫苗?震怒的蘇貞昌請千萬不要罰日本自民黨參議員佐藤正久三百萬! 1分06秒

https://youtu.be/EdhoEFbghGI?t=66

而台灣製的疫苗也從七月份起兩家公司準備一次1000萬劑




1100317社會福利及衛生環境委員會-「我國新冠肺炎(COVID-19)+疫苗整備情形+」書面報告.pdf

https://www.mohw.gov.tw/dl-67845-a6b3cffc-8fb0-4bf7-ab1b-fc32052f3ea5.html




======

【宅卡啦影片】民進黨如何讓台灣防疫,一步一步走向如此崩潰與失敗的境地!看看他們做了什麼蠢事!

https://www.youtube.com/watch?v=EDMuZIM9yPQ




兩岸觀策/自由民主掛嘴邊 責任政治甩一邊

https://udn.com/news/story/7331/5478399

最近與台灣同步發生疫情的安徽六安、遼寧營口,三月底的雲南瑞麗及自去年以來多地爆發的疫情,每一地的衛生健康委官員、醫療院所到上級的市長、書記,他們轄內一旦發生群聚性疫情,就被記警告、免職、撤職,下台官員多到不知凡幾。




次氯酸水

https://zhuanlan.zhihu.com/p/346244002

https://alexshr1.pixnet.net/blog/post/402297314

https://www.tma.tw/ltk/109630508.pdf

https://www.youtube.com/watch?v=rRfmAMG5JBo

CHIH-SHENG LIN 1 年前 水神次氯酸水自製機,4萬元,是電解 稀釋鹽酸.弱酸性,效果當然最好, Baby Smile 家用機,電解食鹽水,較安全方便,只是製出的含鈉離子,呈弱鹼性, 但是比漂白水稀釋好很多

2NaCl+2H2O—>H2+Cl2+2NaOH, 然後應該是Cl2+2NaOH—>NaClO+NaCl+H2O吧。沒有形成次氯酸,大部分轉化成次氯酸鈉。也就是漂白水

終於懂了

那這樣不要買

便宜的生產器都是 次氯酸 + 次氯酸納 混在一起,而且現在賣的人怕被告,也是把公式弄出來

而水神債用電解的方式出來的純 次氯酸水 這個就是100% 沒問題,只是濃度問題

另外理解一件事,純次氯酸保存的問題,所以產品沒辨法賣太貴,要正常價,多銷,免得時間到了,還沒賣完

試紙...是試 氯 ppm ,不是試 ph




http://www.snb.co.jp/ics/2020/07/17/hclo/

https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/syoudoku_00001.html

https://www.nite.go.jp/information/koronataisaku20200522.html

06/26
https://www.nite.go.jp/information/osirase20200626.html

https://prtimes.jp/main/html/rd/p/000000003.000056737.html

https://www.nite.go.jp/data/000111312.pdf

選擇權 損益 怎麼計算?

https://futuresonline.blog/2020/12/02/op-buyer/

原來有 當日沖銷 持有到結算

docker-compose env_file

ERROR: Couldn't find env file:

Try to use one line.


env_file:
  - ./env.mariadb.local.env


env_file: ./env.mariadb.local.env

Laravel dotenv Kernel multile

Http/Kernel.php

.env .env-local.env .env-staging.env .env-production.env


class Kernel extends HttpKernel
{
    public function __construct(Application $app, Router $router)
    {
        parent::__construct($app, $router);
        
        $environmentPath = __DIR__.'/../../';

        $dotenv = Dotenv::createUnsafeImmutable($environmentPath, '.env'); // getenv not thread safe
        $dotenv->safeLoad(); //this is important
        
        $dotenv = Dotenv::createUnsafeImmutable($environmentPath, '.env.'.getenv('APP_ENV').'.env'); // getenv not thread safe
        $dotenv->safeLoad(); //this is important
    }

.env

APP_ENV=local

LOG_CHANNEL=stack

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.local.env

APP_NAME=OOXX_Local
APP_KEY=base64:NDvP.........g=
APP_DEBUG=true
APP_URL=http://localhost

QUERY_DETECTOR_ENABLED=true

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_NOTIFY=true
MAIL_MAILER=smtp
MAIL_HOST=smtp.ooxx.org
MAIL_PORT=587
MAIL_USERNAME=ooxx@ooxx.com
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=ooxx01@ooxx.com
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_BUCKETTEST=

.env.local.env

APP_NAME=OOXX_Local
APP_KEY=base64:NDvP.........g=
APP_DEBUG=false
APP_URL=http://staging.ooxx.com

QUERY_DETECTOR_ENABLED=false

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_NOTIFY=true
MAIL_MAILER=smtp
MAIL_HOST=smtp.ooxx.org
MAIL_PORT=587
MAIL_USERNAME=ooxx@ooxx.com
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=ooxx01@ooxx.com
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_BUCKETTEST=

視訊壓縮 intel amd

https://g.nga.cn/read.php?tid=20089658&rand=857

Amd VCE balance qc:25-26

Intel QSV balance qc:25

laravel ->paginate need becareful

When you use some model ->paginate

Get Illuminate\Pagination\LengthAwarePaginator But Value Don't Back To Variable.


$orders->paginate(10)


$orders = $orders->paginate(10)


So

$this->orders->paginate(10)


$this->oorders = $this->oorders->paginate(10)

買螢幕

https://monitor.buyerguide.info/

livewire public variable eloquent for security column

Get livewire public variable

Front web Try to get public $order

document.addEventListener('livewire:load', function () {
  console.log(@this.order);
Get empty Array

livewire window.livewire.find eloquent collection

https://github.com/livewire/livewire/issues/1641?fbclid=IwAR0uHylkj-1vg8p5jUoBgPYfuAYsWnBhgp6EK2bJcBce8ze-tdtAa8ElLNY#issuecomment-736146468

Eloquent Collection data won't be made available to the front end unless you have the collection properties specified in the $rules array as the contents are models, so the same conditions apply to it as apply to just a single model property. This is for security reasons so the whole collection and all properties aren't just sent to the front end.

See the example here of binding to an eloquent collection https://laravel-livewire.com/docs/2.x/properties......

But a standard collection (not eloquent) will work but only with primitive data types. If any models are added to the collection or any php objects (not eloquent models), they will be serialised into an array.

So eloquent use for public variable is OK.

======

Other way use makeHidden()

HP inkTank 115

https://www.mobile01.com/topicdetail.php?f=498&t=6030155#80825509


這台常常打折賣1990...

相片用三個彩色混出黑色的機種,沒有經過調色印照片都不佳

輸出前先用影像軟體調整曝光+25;飽和度+50

再選擇用相片紙輸出

如果輸出時選擇一般紙張,則會用四個顏色去印不會有問題

如果還會有灰濛濛的感覺

那就是你用的影印紙太爛了

livewire locale lang

middleware

routes/web.php

Route::group(['prefix' => 'member', 'as' => 'member.', 'middleware' => ['auth', 'setLocale:zh-tw']], function () {
    Route::get('/', App\Http\Livewire\MemberList::class);
});

app/Http/Middleware/SetLocale.php.php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class SetLocale
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next, string $lang)
    {
        app()->setLocale($lang);
        
        return $next($request);
    }
}

laravel 8 catch 419 redirect back

https://stackoverflow.com/questions/29115184/laravel-catch-tokenmismatchexception/29116516

At last 1 and 2.

APP\Exceptions\Handler.php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
// use Illuminate\Session\TokenMismatchException;
use \Symfony\Component\HttpKernel\Exception\HttpException;
class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        //
        $this->renderable(function (HttpException $e, $request) {
            if ($e->getStatusCode() == 419) {
                return redirect('/login');
                // session erros Can not use ->with('419error','Your session expired due to inactivity. Please login again.')
            }
        });
    }
}

tampermonkey biggo 文字過瀘

tampermonkey biggo 文字過瀘

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        <$URL$>
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// @grant        GM_addStyle
// @include      /biggo.com.tw
// ==/UserScript==

var $ = window.jQuery;

(function() {
    'use strict';

    // Your code here...
    // if(badDivs) {
    //    badDivs.parent().hide();
    //    badDivs.hide();
    // }

    var ds = $('.list-product-name.line-clamp-2 > a');
    let filter_arr = [
        '體感',
        '手把', '遊戲手把', '手柄', '矽膠', '橡膠', '按鈕', '桿帽',
        '帽蓋', '蓋套', '保護套', '把蓋',
        '電池', '插頭', '端口', '耳機插孔插座', '觸發器', '觸發', '折疊', '支架',
        '集線器', '下載版', '美國代購', '簡易支架底座', '一起玩', '直立架',
        '回收', '攜碼', '維修', 'Dock', '螺絲刀', '保護', '電源線', '充電', '皮膚', '面板', '按鍵條',
        '插孔', '塵套', '耳機', '方向盤', '光纖', '收納架', '冷卻器', '防塵', '貼紙', '序號', '貼膜',
        '雙肩包', '鐵盒', '中文', '傳感器', '收納包', '溫控風扇',
    ];

    ds.each((t, v) => {
        //console.log($(v).text(), $(v).text().includes(filter_arr));

        filter_arr.forEach((item) => {
            $(v).text().includes(item) ? $(v).parent().parent().parent().parent().parent().parent().remove() : '';
        });

        // $(v).css('background-color', 'red');
    });
})();

$(document).ready(function() {

});

Batocera xbox 360 手把

Batocera 支援 wireless xbox 手把,但要先裝 usb xbox wireless controller

https://wiki.batocera.org/kit_to_get_a_batocera

實際可以影片

https://youtu.be/-52SfcluhKA?t=36

https://youtu.be/goJjTF1t2lA?t=61

如果可以的話,xbox 360的副廠手把就非常便宜了

另一個是買 xbox one 新的 wireless controller,雖然 Batocera 有支援,但xbox one 的 controller 只支援 xobx one 手把

360 controller 只支援 360 手把

https://gaming.stackexchange.com/questions/143500/is-the-xbox-one-controller-compatible-with-xbox-360

模擬器 emulator

天馬 Pegasus pegasus-frontend.org

retroArch https://www.retroarch.com/

CoinOPS Next https://www.arcadepunks.com/coinops-arcade-front-end-for-pc/

batocera

小雞模擬器 https://www.xiaoji001.com/

wiki

https://emulation.gametechwiki.com/index.php/Comparison_of_Emulator_Frontends

Rom

https://www.reddit.com/r/Roms/comments/gar3bc/roms_megathread_30_ybin_edition/

serveless aws gcp speed

This problem, let me think my stupid manager and Smart Information Security Consultant before company.

Information Security Consultant Say GCP is very safe... Ya safe so customer lose.

html5 jquery bootstrap modal load No Jquery

Usually use jquery load url


https://stackoverflow.com/questions/34503683/jquery-to-open-bootstrap-v3-modal-of-remote-url


Only use html5



https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
https://stackoverflow.com/questions/17636528/how-do-i-load-an-html-page-in-a-div-using-javascript



    <a href="url ooxxooxx" data-toggle="modal" data-target="#myModal" onclick="myModal(this)">
      click me
    </a>

    <div id="part3dviewModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                </div>
                <div class="modal-body">
                    <p>Loading...</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        function myModal(o){
            p = document.querySelector("#myModal .modal-body");
            p.innerHTML = '<object type="text/html" data="' + o.href + '" ></object>';
        }
    </script>

laravel controller use class but no pass class ?

https://www.youtube.com/watch?v=ShrS3HXwzPg

class PostController extends Controller
{
  public function update(Post $post,
before

class PostController extends Controller
{
  public function update($post_id,
    $post = Post::findOrFail($post_id);

And many more things.

file_put_contents failed to open stream: Permission denied /tmp/cache/views/


php artisan view:clear
https://laracasts.com/discuss/channels/laravel/permission-denied-on-storageframeworkviews https://laravel.io/forum/07-06-2016-session-permissions-issue https://laracasts.com/discuss/channels/general-discussion/laravel-framework-file-permission-security

laravel livewire file update Real-Time File Validation mutile files

 https://laravel-news.com/livewire-file-upload


Real-Time File Validation

use Livewire\Component;
use Livewire\WithFileUploads;

class Show extends Component
{
    use WithFileUploads;
    
    public $files = [];
    
    
    public function updatedFiles() // 即時檢查檔案格式
    {
        $this->validate([
            'files.*' => 'image|max:1024', // 1MB Max
        ]);
    }
    
    public function store()
    {
        $filenames = collect($this->photos)->map->store('photos');
        'files' => $filenames->implode(','),
updatedFiles() is Hook into the “updated”

updatedPhoto  public $Photo
updatedPhotos public $photos = []
updatedFile   public $file
updatedFiles  public $files = []

laravel livewire Name problem

Use - and lowwercase

App/Http/Livewire/Order/DropdownMaterial.php

class DropdownMaterial extends Component
{

resources/views/livewire/order/create.blade.php

@livewire('order.dropdown-material', ['post' => $order_material_id])

Laravel livewire have Big Problem!

When juse livewire at blade.php

Must have Div At first.




<div style="text-align: center">
    <button wire:click="increment">+</button>
    <h1>{{ $count }}</h1>
</div>


<div>

<button wire:click="increment">+</button>
    <h1>{{ $count }}</h1>
    
<button class="btn btn-success btn-block" wire:click="create">
            {{ trans('global.add') }} {{ trans('cruds.order.title_singular') }}
        </button>   
</div>

laravel livewire namespace

App/Http/Livewire/Orders.php

namespace App\Http\Livewire;

use Gate;
use Livewire\Component;
use Symfony\Component\HttpFoundation\Response;

class Orders extends Component
{
    public function render()
    {
        abort_if(Gate::denies('order_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');
        
        return view('livewire.order');
    }
}
resources/views/livewire/order.blade.php

@extends('layouts.app')
@section('content')
    @livewire('order.show')
@endsection
App/Http/Livewire/Order/Show.php

    namespace App\Http\Livewire\Order;

    public function render()
    {
        abort_if(Gate::denies('order_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');
        
        $this->orders = Order::all();
        // Order::where('owner_id', auth()->id())->get(); // 只能看自己

        return view('livewire.order.show');
    }
resources/views/livewire/order/show.blade.php

{{ virables }}

laravel eloquent orm

 [one to one]


Table: User, Phone

Model: User

Relation: return $this->hasOne('App\Phone');


Talbe Phone need have user_id. Auto use User id -> Phone user_id




Table: User, Phone

Model: Phone

Relaion: return $this->belongsTo('App\User');


Table Phone need have user_id. Auto use User id -> User user_id




[one to many]


Table: Post, Comment

Model: Post

Relation: return $this->hasMany('App\Comment');


Table Comment need have post_id. Auto use Post id -> Comment post_id




Table: Post, Comment

Model: Comment

Relaion: return $this->belongsTo('App\Post');


Table Comment need have post_id. Auto Post id -> Comment post_id




[Many To Many]


Table: User, Role, Role_User

 Table Role_User must have user_id, role_id

Model: User


way1:

Relaion: return $this->belongsToMany('App\Role', 'role_user');


way2:

Relaion: return $this->belongsToMany('App\Role');

Must database/migrations defined talbe class like "CreateRoleUserPivotTable"













livewire laravel route problem!

larvel 8 remove Providers/RouteServiceProvider.php namespace. Maybe you add back again.



        protected $namespace = 'App\Http\Controllers';
...

        $this->routes(function () {
            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));
        });

Add backup namespace then get problem for livewire. Every route just use App\Http|controllers ooxxooxxooxx.

OLD Way


web.php

Route::resource('users', 'UsersController');
Route::delete('users/destroy', 'UsersController@massDestroy');

Get Error
Route::resource('orders', 'livewire.order');
Route::resource('orders', 'livewire@order');
Route::view('orders', [\App\Http\Livewire\Order::class, 'render']);

Maybe Way


web.php

Route::view('orders', 'livewire.order');

Files:
\app\Http\Livewire\Order.php inside use return view('livewire.order');
\resources\views\livewire\order.blade.php 

Get Error
Undefined variable: orders  or other ooxxooxx 
Alwasy get this Error. 

web.php

Route::get('/admin/orders', [\App\Http\Livewire\Order::class, 'render']);

Files:
\app\Http\Livewire\Order.php  
And use
return <<<'blade'
blade;

Get plain text @foreach($orders as o$key -> $permission 
Same Error.
Beacuse view run first. Only create view then @livewire('')

example:
order and orderlist

order view for fist(main) load page. orderlist be loaded by order view. order view have @livewire('orderlist').

https://stackoverflow.com/questions/64038485/laravel-livewire-components-or-controllers

or just remove namespace


Route::get('/admin/orders', \App\Http\Livewire\Order::class);

Don't add namespace in app/Http/livewire/ any file. Always get errors.

php auth role is_admin isAdmin or .... check role admin

User model getIsAdminAttribute()

https://www.youtube.com/watch?v=j97iBwTPlNE

https://stackoverflow.com/questions/58889575/laravel-5-8-authuser-is-not-using-user-model



public function getIsAdminAttribute()
{
   return (bool) $this->admin;
}

Auth::user()->isAdmin or auth()->user()->isAdmin

https://laracasts.com/discuss/channels/code-review/how-to-check-user-role-after-login


namespace App;

use App\Role;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    public function getIsAdminAttribute()
    {
        return $this->roles->pluck( 'name' )->contains( 'admin' );
    }

    public function roles()
    {
        // you will need a role model
        // Role::class is equivalent to string 'App\Role'
        return $this->belongsToMany( Role::class, 'users_role' );
    }
}
LoginController

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
use Input;
use Validator;
use Redirect;

class LoginController extends Controller
{
    //
    
    public function login_post( Request $request )
    {
        $data = Input::except( array( '_token' ) );

        // var_dump($data);

        $rule = array(
            'email'    => 'required|email',
            'password' => 'required',
        );

        $validator = Validator::make( $data, $rule );

        if ($validator->fails()) {
            // should do something
        } else {
            // no need to populate $data again with the same values
            // $data = Input::except( array( '_token' ) );
            
            if (Auth::attempt( $data )) {
                // here i want to check logged in user role
                $user = Auth::user();
                
                if ($user->roles->pluck( 'name' )->contains( 'admin' )) {
                    return Redirect::to( '/admin-dashboard' );
                }
                
                return Redirect::to( '/dashboard' );
            }
        }
    }
}

https://laravel.tw/docs/5.2/eloquent-serialization#appending-values-to-json

https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/111359/

方法簽名為getXXXAttribute
get XXX Attribute So XXX => IsAdmin

    public function getIsAdminAttribute()
    {
        return $this->roles()->where('id', 1)->exists();
    }

https://stackoverflow.com/questions/44017571/pass-current-eloquent-into-getxattribute-in-model


public function getIsAdminAttribute()
{   
   return Admin::where('user_id', $this->id)->count() > 0;
}

Error Running: npm install vue-template-compiler --save-dev --production=false

 Error 


  Additional dependencies must be installed. This will only take a moment.
  
  Running: npm install vue-template-compiler --save-dev --production=false
  


https://qiita.com/ucan-lab/items/f5bcdfceecffb9def4c5


Use yarn, Not npm


yarn add vue-template-compiler --dev --production=false
yarn run dev

[轉] Laravel Livewire vs Vue vs jQuery: Simple Example

 https://www.youtube.com/watch?v=o0HoP7WzRf0

php laravel UI Boostrap jetstream docker-compose

目錄裡面對應的檔案要先修改

=== 設定修改

[docker-compose]
 docker-compose.yml ./backend 在執行docker-compose目錄下建立backend目錄,或者是移動位置
db-store 使用的是 volumes


[mysql]
 infra/docker/mysql/Dockerfile
mysql user password root 等等自行變更,變更後要記得修改 infra/docker/php/Dockerfile

 infra/docker/mysql/my.cnf
collation_server = utf8mb4_unicode_ci


[php]
 infra/docker/php/Dockerfile 如果上面mysql設定有變更,記得這裡也要跟著變更
ENV TZ=Asia/Taipei
LANGUAGE=en_US:UTF-8


 infra/docker/php/php.ini
mbstring.language = zh-tw

[nginx]
 infra/docker/nginx/Dockerfile
ENV TZ=UTC+8



=== 指令開始執行

docker-compose up -d
  
docker-compose exec app composer create-project --prefer-dist laravel/laravel .

== jetstream Livewire !Now No Use


docker-compose exec app composer require laravel/jetstream
docker-compose exec app php artisan jetstream:install livewire  --teams
docker-compose exec app php artisan migrate

docker-compose exec web yarn install
docker-compose exec web yarn dev

== jetstream end

== Laravel UI Bootstrap Auth *more easy


docker-compose exec app composer require laravel/ui
docker-compose exec app php artisan ui bootstrap --auth
[ docker-compose exec app php artisan migrate ]

docker-compose exec web yarn install
docker-compose exec web yarn run dev

[ docker-compose exec web yarn add vue-template-compiler --dev --production=false ]

== Laravel UI Bootstrap end


docker-compose exec app composer require doctrine/dbal
docker-compose exec app composer require --dev barryvdh/laravel-ide-helper
docker-compose exec app composer require --dev beyondcode/laravel-dump-server
docker-compose exec app composer require --dev barryvdh/laravel-debugbar
docker-compose exec app composer require --dev roave/security-advisories:dev-master
docker-compose exec app php artisan vendor:publish --provider="BeyondCode\DumpServer\DumpServerServiceProvider"
docker-compose exec app php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"

=== remove all


docker-compose down --rmi all --volumes
docker-compose down --volumes

.參考:

https://github.com/ucan-lab/docker-laravel
https://github.com/ucan-lab/docker-laravel/blob/master/Makefile
https://qiita.com/ucan-lab/items/7824d1293fef4698c212

blade @can @cannot

https://laravel.com/docs/8.x/authorization#via-blade-templates


https://laravel.com/docs/8.x/authorization


The gate methods for authorizing abilities (allows, denies, check, any, none, authorize, can, cannot) and the authorization Blade directives (@can, @cannot, @canany) can receive an array as the second argument. These array elements are passed as parameters to gate, and can be used for additional context when making authorization decisions

flutter release apk

 1. pubspec.yqml

version1.1.1+3

2. local.properties

flutter.versionName=1.1.1
flutter.versionCode=3

Issue like this: 

這個 APK 已由擁有更高版本代碼的一或多個 APK 完全覆蓋,因此不會提供給任何使用者。從您的版本移除這個 APK,或查看版本中所有 APK 的指定目標和版本代碼。

Remove just create version in play store console. Create new version again. Maybe success.

噴墨

https://www.mobile01.com/topicdetail.php?f=498&t=5762149&p=2&p=2#72736497

我不是業代 也不需要幫hp打廣告 個人目前有
Brother MFC L2740dw 黑白雷射事務機
Canon CP910 相印機
HP IA 2020hc 噴墨

都用了超過三年以上 也都沒發生過問題 很合乎我的要求
之前買過7、8台噴墨
都是因爲印量不大 最後噴嘴乾掉壞掉
試過各種網路方法 都不好 無效
也曾請友人從美國帶正 附廠hp墨水 很多次(一個墨匣印不到200張 在台灣一個要快一千塊)
Epson canon Lexmark hp 都買過用過賣過丟過
只有這次這台hp 令我感到意外 用過非常滿意 有時一個月沒印 也不塞
因為用的少 第一瓶原廠附的墨水還在用 (要確認是用 HP 46 墨水匣 其他型號不清楚)
反正信不信看各人
我只是把好東西和網友分享 (印表機1990+墨水匣350 印 1500 彩色750張 不阻塞 我認爲合乎我的需要 事實上也是第一台令我滿意的噴墨印表機)


 (要確認是用 HP 46 墨水匣


重點是要找用"同墨匣 HP46" 的印表機 如HP 4729hc


如果印量不大的話 (一年幾百到1000張)
推薦 使用 HP46 墨匣的噴墨印表機 ( 就算噴頭出問題換掉也不心疼)
個人是使用已停產的 IA 2020hc 雖然很少用 (這是個人多年來唯一滿意的噴墨印表機, 3年多前隨機附的墨匣還沒換過) 噴頭沒塞過 列印效果不錯 重點是墨匣不到400元 可印 1500張 (彩色750張)

博奕代工

 這份報導,還是沒有寫出真正的情況,也是把事情混在一起談,因為並不是每一個進去博奕工作的工程師能了解大部份的情況

她碰到的根本是洗錢中心,不是博奕代工 內容中又把博奕代工和洗錢中心混在一起來談 區分三個角度 1. 線上博奕 2. 博奕代工 3. 洗錢 1. 線上博奕 對我們工程師來的角度來談,在國外“維運“,在合法的地方“維運“就是合法,大公司分工非常細和明確的,工程師只會負責開發遊戲,不負責“維運“ 大公司對於“風控“非常嚴格,一來怕內賊,二來怕一鍋踹,怎麼會混在一起 中小公司才有可能混在一起,也才有可能在一個地方“維運“ 2. 博奕代工 對我們工程師來的角度來談,代工就是幫忙寫遊戲系統、程式,這肯定100%不犯法,大公司會非常嚴格執行這個做法,建立一間公司,主力就是遊戲開發,開發遊戲,賣給台灣公司、外國公司都是合法的 就算是做實體機台(台灣有名就那家),賣給國外一樣合法 中小公司的代工理論上都就是上面所述,實際上會做到1. 的情況,那就會出現同樣問題“維運“,那“維運“到底合不合法,後面討論 3. 洗錢 癈話,一定違法,一定會出問題 “維運“這塊工作內,會有一定違法的兩個點:金流、客服,工程師的“維運“就妙在這裡,不是工程師的人做“維運“,那就要看你是做什麼了,這很清楚了吧! 內文中的點: 1. 拿現金 大公司是不會拿現金給你的,一定會匯給你,而且還會給你保足額的勞健保,該給你的一定給你 中小公司正常也不會拿現金給你的,那什麼時候拿現金,要避稅,可能是公司避,可能是你自己要避稅,都不是這些,那就是現金太多,應該就懂了吧! 2. 看到荷官…… 訓練的話應該是沒問題,實際被運用在台灣內的某角落才算違法吧! 3. 看到桌子…… 這是開發系統一定會需要的,實際被運用在台灣內的某角落才算違法吧! 4. 工作要上繳存簿,這不用想就知道這間公司是不正常的吧!不管是不是博奕,這年代還有人相信要上繳存簿?! 5. 跟政府談? 文內跟政府單位談線上博奕,這思序不清吧!國內連實體博奕都沒有,這些工作都是對國外,就算是出國轉回給內銷用,本質還是國外,國內那管得著,要談的是國外 日本、新加坡之類 6. 中國要求菲律賓停止“新“牌照發放,舊的能用,更好用,更貴,菲律賓不是笨蛋 7. 大量台灣人材... ... 大陸人材更多吧 8. 避免大量年輕人成為洗錢人頭戶,這跟博奕有個鬼關係,意思是沒博奕就沒有洗錢人頭戶?! 都混在一起談,詐騙就不用洗錢人頭戶?!犯毒就不用洗錢人頭戶?!

GCP logging winston LoggingWinston severity

If you want to control severity at LoggingWinston.

https://stackoverflow.com/questions/58055551/structured-logs-in-google-cloud-run-not-being-parsed-using-winston-for-logging


const winston = require('winston');
const useFormat = winston.format.combine(
  winston.format((info, opts) => {
    let level = info.level.toUpperCase();
      if(level === 'VERBOSE') {
        level = 'DEBUG';
      }

      info['severity'] = level;
      delete info.level;
      return info;
  })(),
  winston.format.json());
const { LoggingWinston } = require('@google-cloud/logging-winston');
const loggingWinston = new LoggingWinston();
const logger = winston.createLogger({
  level: 'debug',
  format: useFormat,
  transports: [
    new winston.transports.Console(),
    loggingWinston
  ]
});

gcloud tools docker

gcloud tools docker

Create directory "gcloud" at `pwd` first.

1. normal cli command


docker run -it -e CLOUDSDK_CONFIG=/config/mygcloud -v `pwd`/gcloud:/config/mygcloud -v `pwd`/gcloud/certs:/certs gcr.io/google.com/cloudsdktool/cloud-sdk
2. Put Projects


docker run -it -e CLOUDSDK_CONFIG=/config/mygcloud \
-v `pwd`/gcloud:/config/mygcloud \
-v `pwd`/gcloud/certs:/certs \
-v `pwd`/Documents/Projects:/home \
gcr.io/google.com/cloudsdktool/cloud-sdk

Firebase deploy default vpcConnector vpc-Connector gcloud vpc

oooxxxoooxxx: vpc Connector name
aaabbbaaabbb: your firebase project

Firebase deploy default  vpcConnector vpc-Connector
node_modules\firebase-tools\lib\gcp\cloudfunctions.js
  _createFunction
   
 const data  ADD
    vpcConnector: 'oooxxxoooxxx',




Failed


gcloud VPC

VPC_CONNECTOR=dosportsapi-redis01
projects/aaabbbaaabbb/locations/us-central1/connectors/oooxxxoooxxx

gcloud beta functions deploy api \
--runtime nodejs10 \
--trigger-http \
--region us-central1 \
--vpc-connector $VPC_CONNECTOR \
--egress-settings private-ranges-only \
--memory 2048MB 

javascript How does the double exclamation (!!) work in javascript?


https://stackoverflow.com/questions/29312123/how-does-the-double-exclamation-work-in-javascript

 value   !value !!value
 false truefalse 
 truefalse  true
 nulltrue false 
 undefinedtrue false 
 0true false 
 -0true false 
 1falsetrue 
 -5false true 
 NaNtrue false 
 ''true false 
 'hello'true false 

aws FortiGate VM public / private vm Can't OutGoing. SG need setting correct.

1. aws https://www.fortinet.com/content/dam/fortinet/assets/solutions/aws/FortiGate-AWS-Engineering-Reference-Document-Q4-2015.pdf 

2. https://geekdudes.wordpress.com/2018/07/18/install-fortigate-amazon-ec2-instance/ 
3. https://geekdudes.wordpress.com/2018/08/19/creating-static-route-in-aws-ec2-fortigate-instance/ 


Many documents forget SG(security group) 

1. FortiGate VM SG need Inbound rules:
All traffic All All 10.0.0.0/16

2. Private VM SG need  Inbound rules:
All traffic All All 10.0.0.0/16

Setting finish.

First fortigate cmd:
execute ping Private VM private ip. Need success.

Second in private vm cmd:
ping FortiGate Lan ip. Need success. Don't forgate Check "Ping" option.
ping 10.0.1.1. Need success.

Now 
ping 8.8.8.8  Must success.

=============

FortiGate 6.x 

Network/Interfaces
port 1 (alias: WAN) 10.0.0.xxx  "Role" Not Import.
port 2 (alias: LAN)  10.0.1.xxx  "Role" Not Import. And "Retrieve default gateway from server"Not Import. Need Check "Ping" option.

Static Routes
Subnet  0.0.0.0./0.0.0.0  
Gateway Address 10.0.0.1
port1 Wan
......... follow Link 2.3.

Firwall Polic
Best Import is port2(Lan) -> port1(Wan)

node.js express.js sequelize redis cache

http://liu-xin.me/2017/03/24/%E8%AE%A9%E5%86%99%E5%85%A5%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E6%95%B0%E6%8D%AE%E8%87%AA%E5%8A%A8%E5%86%99%E5%85%A5%E7%BC%93%E5%AD%98/

const to = require('await-to-js').default;
const Redis = require('ioredis');
const redis = new Redis(ooxxooxx);

function Cache() {}
Cache.get = async function(key) {
  const [err, res] = await to(redis.get(key));
  if (err) {console.error('REDIS::Cache::get]', err); return null;}
  return JSON.parse(res);
};

Cache.set = async function(key, value) {
  value = JSON.stringify(value);
  const [err] = await to(redis.set(key, value));
  if (err) {console.error('REDIS::Cache::set]', err); }
};


//
// sequelize.query
//
async function CacheSequelizeQuery(sequelize, sql, params, redisKey) {
  const cacheData = await Cache.get(redisKey);
  if (cacheData) return cacheData; // not empty return cache data

  const [err, lists] = await to(sequelize.query(sql, params));
  if (err) throw err;

  if (lists) await Cache.set(redisKey, lists); // not empty set cache data
  return lists;
}


//
// findOneCache
//
Sequelize.Model.findOneCache = async function() {
  let redisKey;
  for (const parms of Object.values(arguments)) {
    if (parms.where) redisKey = [this.name, JSON.stringify(parms.where)].join(':');
  }
  const cacheValue = await Cache.get(redisKey);
  if (cacheValue) return JSON.parse(cacheValue);

  const result = await Sequelize.Model.findOne.apply(this, arguments);
  Cache.set(redisKey, JSON.stringify(result));
  return result;
};

node.js redis special delete del

https://github.com/luin/ioredis

const Redis = require('ioredis');
const redis = new Redis();

const delScript = `
  local all_keys = {};
  local keys = {};
  local done = false;
  local cursor = "0"
  repeat
      local result = redis.call("SCAN", cursor, "match", KEYS[1], "count", KEYS[2])
      cursor = result[1];
      keys = result[2];
      for i, key in ipairs(keys) do
          all_keys[#all_keys+1] = key;
      end
      if cursor == "0" then
          done = true;
      end
  until done
  for i, key in ipairs(all_keys) do
      redis.call("DEL", key);
  end
  return true;
`;

redis.defineCommand('del', {
  numberOfKeys: 2,
  lua: delScript
});

redis.del('login:202007*', 10000, function(error, result) {
  console.log('error: ', error);
  console.log('result: ', result);
});

javascript functions parm default value

https://stackoverflow.com/questions/6600868/set-default-value-of-javascript-object-attributes

// default num: 0, unit: 'pics'
function items(op) {
  const { num, unit } = Object.assign({}, { num: 0, unit: 'pics'}, op);
}

mysql virtual colume alert


ALTER TABLE `user` 
  ADD `last name` VARCHAR(50)
   AS (
        case `name`
        when admin then 0
        else CONCAT(`name`, 'user')
         end
      ) 
  ;