Skip to content

Instantly share code, notes, and snippets.

View xiaoyu2er's full-sized avatar
🚗

Yanqi Zong xiaoyu2er

🚗
  • Los Angeles, CA, USA
  • 11:11 (UTC -07:00)
View GitHub Profile
@KeKs0r
KeKs0r / get-jwt.ts
Created January 24, 2023 14:11
Get JWT Token from service account for GCP (to use Google Api in cloudflare workers)
import { subtle } from 'crypto'
import { Base64 } from 'js-base64'
type ServiceAccount = {
private_key_id: string
private_key: string
client_email: string
}
@markelliot
markelliot / getGoogleAuthToken.js
Last active March 20, 2025 19:22
Converts Google service user OAuth2 credentials into an access token in Cloudflare-compatible JS
/**
* Get a Google auth token given service user credentials. This function
* is a very slightly modified version of the one found at
* https://community.cloudflare.com/t/example-google-oauth-2-0-for-service-accounts-using-cf-worker/258220
*
* @param {string} user the service user identity, typically of the
* form [user]@[project].iam.gserviceaccount.com
* @param {string} key the private key corresponding to user
* @param {string} scope the scopes to request for this token, a
* listing of available scopes is provided at
function interceptNetworkRequests(ee) {
const open = XMLHttpRequest.prototype.open;
const send = XMLHttpRequest.prototype.send;
const isRegularXHR = open.toString().indexOf('native code') !== -1;
// don't hijack if already hijacked - this will mess up with frameworks like Angular with zones
// we work if we load first there which we can.
if (isRegularXHR) {
@bcnzer
bcnzer / worker.js
Created October 15, 2018 09:31
Cloudflare Worker that uses Workers KV to get Authorization data. All authentication and authorization is done on the edge
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))
})
/**
* Entry point of the worker
*/
async function handleRequest(event) {
try {
// Get the JWT
@gwuhaolin
gwuhaolin / 前端异常监控.md
Last active August 20, 2020 12:13
前端异常监控

前端异常监控

为什么需要前端异常监控

如今Web庞大复杂应用场景广泛,再加上各种浏览器造成的环境差异,很难保证我们的页面呈现给每个用户时都是正常的。稳定和准确是每个产品的基础,对于用户直接交互的页面更加显得重要。我们不能等到用户投诉后才知道出现问题,而是应该主动监控尽快暴露出异常。

前端有哪些异常

  • 静态资源加载异常
    • 网络环境恶劣
    • 运营商劫持
    • 文件丢失
@dwayne
dwayne / 01-intro.md
Last active September 5, 2024 13:47
My notes from the book "ng-book: The Complete Book on AngularJS by Ari Lerner".

Introduction

Author: Ari Lerner.

AngularJS offers a single framework that can be used to build dynamic, client-centric applications. It provides:

  • Module support
  • DOM manipulation
  • Animations
  • Templating