Skip to content

Instantly share code, notes, and snippets.

View letswritetw's full-sized avatar
🐱
Cat

Let's Write - August letswritetw

🐱
Cat
View GitHub Profile
@letswritetw
letswritetw / work.js
Created November 5, 2023 01:57
web-worker.js
// 引用 axios
importScripts('../dist/axios.min.js');
// 設定最大並行請求數限制
const MAX_CONCURRENT_REQUESTS = 5;
let activeRequests = 0;
let queue = [];
self.onmessage = e => {
@letswritetw
letswritetw / gitlab-imoprt.js
Last active August 18, 2023 14:17
gas-import-postman-collections
const gitLabToken = '請貼上 GitHub Access Token';
const postmanApiKey = '請貼上 Postman API Key';
// 以下請貼上要匯進 Postman Collection 的清單
const repoList = [
{
projectId: '48419806',
filePath: 'Postman_Collections/postman-backup-demo.json'
}
];
@letswritetw
letswritetw / github-imoprt.js
Last active August 18, 2023 14:18
gas-import-postman-collections
const postmanApiKey = '請貼上 Postman API Key';
const githubToken = '請貼上 GitHub Access Token';
const repoOwner = '請貼上 GitHub 帳號名稱';
// 以下請貼上要匯進 Postman Collection 的清單
const repoList = [
{
repoName: 'postman-backup-demo',
filePath: 'Postman Collections/postman-backup-demo.json'
}
@letswritetw
letswritetw / index.js
Created July 14, 2023 13:07
gas-backup-postman-collections
// 存進雲端
function saveJsonToDrive({ name, json }) {
const today = getToday({ divider: '-' });
const folderName = name; // 資料夾名稱
const time = new Date().getTime();
const fileName = `${time}_backup.json`; // 檔案名稱
// 取得「備份」資料夾
@letswritetw
letswritetw / nodejs-ftp-upload-node.js
Created November 25, 2021 14:39
nodejs-ftp-upload
const express = require('express');
const cors = require('cors');
const app = express();
const fileupload = require('express-fileupload');
app.use(fileupload(), cors())
const jsftp = require('jsftp');
const Ftp = new jsftp({
host: '這邊填FTP的主機',
@letswritetw
letswritetw / nodejs-ftp-upload-client.js
Created November 25, 2021 14:37
nodejs-ftp-upload
import 'idempotent-babel-polyfill';
// POST 給後端的 URL
const uploadUri = 'https://www.example.tw/uploadFileToFTP';
// 處理每一個 POST
function fileUploadHandler(file) {
return new Promise((resolve, reject) => {
let formData = new FormData();
formData.append('clientFile', file);
import { getAuth, getRedirectResult, GithubAuthProvider } from "firebase/auth";
const auth = getAuth();
const providerGithub = new GithubAuthProvider();
getRedirectResult(auth)
.then((result) => {
const credential = GithubAuthProvider.credentialFromResult(result);
if(credential) {
@letswritetw
letswritetw / firebase-auth-github-popup-v9.js
Created November 14, 2021 05:22
firebase-auth-github
import { getAuth, signInWithPopup, GithubAuthProvider } from "firebase/auth";
const auth = getAuth();
const providerGithub = new GithubAuthProvider();
signInWithPopup(auth, providerGithub)
.then((result) => {
const credential = GithubAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
@letswritetw
letswritetw / firebase-auth-fb-popup-v9.js
Created November 10, 2021 12:49
firebase-auth-google-fb
import { getAuth, signInWithPopup, FacebookAuthProvider } from "firebase/auth";
const auth = getAuth();
const providerFb = new FacebookAuthProvider();
signInWithPopup(auth, providerFb)
.then((result) => {
const credential = FacebookAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
const user = result.user;
@letswritetw
letswritetw / firebase-auth-google-redirect-v9.js
Created November 10, 2021 12:47
firebase-auth-google-fb
import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth";
const auth = getAuth();
const providerGoogle = new GoogleAuthProvider();
getRedirectResult(auth)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
const user = result.user;