Skip to content

Instantly share code, notes, and snippets.

View vasco3's full-sized avatar

Gorka Cesium vasco3

View GitHub Profile
@kettanaito
kettanaito / README.md
Last active April 7, 2024 15:22
Chromium on Vercel (serveless)

Chromium on Vercel (serverless)

This is an up-to-date guide on running Chromium in Vercel serverless functions in 2022. What you will read below is the result of two days of research, debugging, 100+ failed deployments, and a little bit of stress.

Getting started

Step 1: Install dependencies

Use chrome-aws-lambda that comes with Chromium pre-configured to run in serverless, and puppeteer-core due to the smaller size of Chromium distributive.

@trungdq88
trungdq88 / paddle-revenue.js
Last active April 6, 2023 14:07
A scriptable's script to get Paddle revenue from multiple accounts using puppeteer.
/*
RUN THE SCRIPT BY YOURSELF:
- Run `node paddle-revenue.js` on your server and let it run 24/7.
- Access the API at http://your_server_ip:8175/ (JSON)
HOSTED VERSION:
If you don't want to run the script by your own, you can use the
hosted version. The price is $5 per month per Paddle account.
Here is how:
// https://twitter.com/reasonml/status/1238026671581622272?s=20
// https://gist.github.com/chenglou/b6cf738a5d7adbde2ee008eb93117b49
// This is a proper alternative to
// https://github.com/BuckleScript/bucklescript/blob/b9508105b1a35537bdea9a1fabd10f6c65f776b4/jscomp/bsb/templates/react-hooks/src/FetchedDogPictures/FetchedDogPictures.re#L14
// The one in that file uses Promise, but that's *wrong*.
// We only used promise as a demo of its API. We'll remove it soon.
// As you can see below, the pure XMLHttpRequest code is just as clean,
// less mysterious for all, more performant, extensible, and actually correct.
  1. Install these packages:
yarn install --dev @babel/core @babel/preset-env jest babel-jest
  1. Add babel.config.js (exactly babel.config.js, not .babelrc, not .babelrc.json etc):
module.exports = {

To add the snippets:

  1. Hit > shift + command + p and type snippets (or go look for 2.)
  2. Select Preferences: Open User Snippets
  3. Choose the language type for which you want to add the custom snippet (choosed all, for js/ts/fql files)
  4. Copy/Paste the snippets.json content in there

Currently covered:

  • q.Lambda
  • q.Let
  • q.Var
@ptpaterson
ptpaterson / nested-fql-manual.js
Last active December 26, 2021 15:09
Template for building deeply nested FQL queries for FaunaDB
const baseQuery = q.Paginate(q.Match(q.Index(indexName), terms));
// or
// const baseQuery = q.Paginate(q.Collection(collectionName))
const expandedQuery = q.Map(baseQuery, (ref) =>
q.Let(
{
instance: q.Get(q.Var('ref'))
},
{
// This is a proper alternative to
// https://github.com/BuckleScript/bucklescript/blob/b9508105b1a35537bdea9a1fabd10f6c65f776b4/jscomp/bsb/templates/react-hooks/src/FetchedDogPictures/FetchedDogPictures.re#L14
// The one in that file uses Promise, but that's *wrong*.
// We only used promise as a demo of its API. We'll remove it soon.
// As you can see below, the pure XMLHttpRequest code is just as clean,
// less mysterious for all, more performant, extensible, and actually correct.
// Ignore these externals for now. They're just for illustration
// purposes. I just copy pasted the Js code from
@colllin
colllin / Readme.md
Last active February 21, 2024 14:55
FaunaDB User Token Expiration (for ABAC)

Auth0 + FaunaDB ABAC integration: How to expire Fauna user secrets.

Fauna doesn't (yet?) provide guaranteed expiration/TTL for ABAC tokens, so we need to implement it ourselves if we care about it.

What's in the box?

3 javascript functions, each of which can be imported into your project or run from the command-line using node path/to/script.js arg1 arg2 ... argN:

  1. deploy-schema.js: a javascript function for creating supporting collections and indexes in your Fauna database.
@colllin
colllin / Readme.md
Last active August 11, 2020 03:03
Auth0 + FaunaDB integration strategy

Goal

Solutions

At the very least, we need two pieces of functionality:

  1. Create a user document in Fauna to represent each Auth0 user.
  2. Exchange an Auth0 JWT for a FaunaDB user secret.
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API