Skip to content

Instantly share code, notes, and snippets.

View leaysgur's full-sized avatar
🏠
Active Weekdays 09-17 JST

Yuji Sugiura leaysgur

🏠
Active Weekdays 09-17 JST
View GitHub Profile
@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
@mannyyang
mannyyang / firebase-token.js
Last active March 14, 2022 07:42
firebase cloudflare
import { getTokenFromGCPServiceAccount } from '@sagi.io/workers-jwt'
/**
* Getting the access token to use in the header.
*/
// For example's sake, the file contents (modified) from the private key has been
// listed below, but the recommended way would be to use environment variables.
export async function getAccessToken() {
const jwtToken = await getTokenFromGCPServiceAccount({
@phistrom
phistrom / slack-verify.js
Last active September 22, 2023 19:34
Function to verify X-Slack-Signature header in a Cloudflare Worker
/* global SLACK_SIGNING_SECRET */
const SIGN_VERSION = 'v0' // per documentation, this is always "v0"
/**
* Verify that a request actually came from Slack using our Signing Secret
* and HMAC-SHA256.
*
* Based on code examples found in Cloudflare's documentation:
* https://developers.cloudflare.com/workers/examples/signing-requests
@myakura
myakura / 00-README-cds-2020.md
Last active January 29, 2021 12:50
Chrome Dev Summit 2020まわりの記事メモ

Chrome Dev Summit 2020まわりの記事メモ

はじめに

書いてる人:myakura (Masataka Yakura)

このgistにあるもの

Chrome Dev Summit 2020の前後でGoogleのひとが公開した記事を、やる気の続く限り読んで書いたメモ。
主にみているのは以下のサイト。

@threepointone
threepointone / durable-objects-001-fundamentals.md
Last active January 29, 2025 13:22
Notes on Durable Objects. Part 1 - Migrations.

Note: Since writing this, I've been pointed to some exciting new research/tooling called Project Cambria https://www.inkandswitch.com/cambria.html I'll likely have to rewrite this article taking that into account. Leaving this up for posterity's sake.


(This series isn't meant to be a primer/tutorial, though we might do something regarding it in the future. For official documentation and starters, see https://developers.cloudflare.com/workers/learning/using-durable-objects.

Further - these are my personal views; I expect to be wrong about a lot of them. Indeed, I'm not paying much attention to presenting these well at the moment, simply writing down thoughts. As such, expect these writeups to change often, particularly as the platform takes shape. I'm also mostly a front end guy, so don't get mad if I get it very wrong. Give me feedback! Always happy to learn and make changes.)

Durable Objects are a fascinating new storage primitive from cloudflare for their workers platform. There's a lot of 'cool'

@nfantone
nfantone / before-shutdown.js
Created September 23, 2020 13:00
Node.js graceful shutdown handler
'use strict';
/**
* @callback BeforeShutdownListener
* @param {string} [signalOrEvent] The exit signal or event name received on the process.
*/
/**
* System signals the app will listen to initiate shutdown.
* @const {string[]}

Preact: Progressive Hydration

Preact now supports seamless progressive hydration.

Any component can throw during hydration (or new tree creation like a route change!), and if a component somewhere higher in the tree catches that via componentDidCatch, hydration gets paused.

Re-rendering the tree (via setState, etc) simply resumes hydration where it left off.

@azu
azu / ua-client-hints.md
Last active July 13, 2021 07:33
User Agent client hintsのJavaScript APIとHTTP Header
/*
It's now a package. You can find it here:
https://github.com/joshnuss/svelte-local-storage-store
*/
// Svelte store backed by window.localStorage
// Persists store's data locally
@WebReflection
WebReflection / dom-libraries.md
Last active February 24, 2025 11:28
A recap of my FE / DOM related libraries

My FE/DOM Libraries

a gist to recap the current status, also available as library picker!

Minimalistic Libraries

do one thing only and do it well

  • µhtml (HTML/SVG auto-keyed and manual keyed render)
  • augmentor (hooks for anything)
  • wickedElements (custom elements without custom elements ... wait, what?)