Skip to content

Instantly share code, notes, and snippets.

@azole
azole / serverless.yml
Last active November 27, 2020 01:56
serverless.yml for Laravel8 + bref1.0 + redis extension
service: laravel
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: ap-northeast-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
runtime: provided.al2
@azole
azole / serverless.yml
Last active November 26, 2020 10:30
original serverless.yml
service: app
provider:
name: aws
region: ap-northeast-1 # 改成自己想要部署的 region
runtime: provided.al2
plugins:
- ./vendor/bref/bref
let doWorkPromise = function (job, timer, success) {
return new Promise((resolve, reject) => {
setTimeout(() => {
let dt = new Date();
if (success) {
// 成功
return resolve(`完成工作: ${job} at ${dt.toISOString()}`);
}
reject(`!!工作失敗: ${job} at ${dt.toISOString()}`);
}, timer);
<?php
// 0.0.0.0 表示監聽所有 IP 地址
$http = new Swoole\Http\Server('0.0.0.0', 9501);
$http->set([
// 可以 host static files
// 但不建議這樣做,靜態檔案還是讓 nginx 來
'enable_static_handler' => true,
// 'http_autoindex' => false,
@azole
azole / bash
Created November 16, 2021 05:38
Install drupal 8.9 with Nginx and php-fpm 7.4 in Ubuntu 20.04
sudo apt-get update
sudo apt-get install nginx -y
sudo apt-get install php7.4-fpm php7.4-cli php7.4-gd php7.4-mysql php7.4-xml php7.4-mbstring -y
# edit /etc/php/7.4/fpm/php.ini
sudo nano /etc/php/7.4/fpm/php.ini
# uncomment cgi.fix_pathinfo and set the value to "0"
sudo nano /etc/nginx/sites-available/default
# uncomment ~\.php section and modify as followed:
const fs = require('fs');
const writeFile = async (data, fileName) => {
// 你要寫的部分
return new Promise((resolve, reject) => {
fs.writeFile(fileName, data, (err) => {
if (err) {
reject(err);
}
resolve();
@azole
azole / hash-argon2.js
Created September 3, 2022 05:10
Hash-Test
const argon2 = require('argon2');
let plainPasswords = ['asdfwrwsdf', 'aserqwr&134sfasefr', 'asfw423d', 'asf8w4@w3423', 'qqsfw40#sjr#', 'PassW0rd', 'administartor'];
let len = plainPasswords.length;
let hashedPassword = [];
async function argon2Hash(count) {
console.time('argon2');
for (let i = 0; i < count; i++) {
const hash = await argon2.hash(plainPasswords[i % len], 10);

@azole 461 Followers 🕴 👉 Docker Container 基礎入門篇 1 👏 1883 👉 [WebConf2023] Docker 入門 101 👏 249 👉 從鐵人完賽到書籍書版 👏 140

@azole
azole / graylog.yaml
Last active June 25, 2024 07:58
to run graylog
services:
mongo:
image: mongo:6.0
container_name: mongo
networks:
- graylog
restart: unless-stopped
opensearch:
image: opensearchproject/opensearch:2.4.1
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
ports:
- "9090:9090"