This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Create the MongoDB collection and an expiring index on a field named "expiresAt". | |
| * | |
| * db.createCollection('locks'); | |
| * db.locks.createIndex( { "expiresAt": 1 }, { expireAfterSeconds: 0 } ) | |
| **/ | |
| async function acquireLock(name, ttlSeconds) { | |
| const collection = await db.collection('locks'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function acquireLock(name) { | |
| // Open connection to database | |
| const collection = await db.collection('locks'); | |
| try { | |
| // Insert an entry to the database, using the _id field, which already has a unique key constraint | |
| await collection.insertOne({ _id: name }); | |
| // No exception was thrown, so we successfully acquired a lock | |
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function (user, context, callback) { | |
| const axios = require('axios'); | |
| const isSocial = context.connectionStrategy === context.connection; | |
| // if it is the first login (hence the `signup`) and it is a social login | |
| if (context.stats.loginsCount === 1 && isSocial) { | |
| let loginMethod = ''; | |
| const connectionName = user.identities[0].provider.toLowerCase(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Create a new trigger | |
| CREATE OR REPLACE FUNCTION public.notify_parqet_api_signup() | |
| RETURNS TRIGGER AS $$ | |
| DECLARE | |
| parqet_user_id varchar; | |
| social_provider_id varchar; | |
| BEGIN | |
| -- Extract ID from social provider, can be null | |
| social_provider_id := NEW.raw_user_meta_data->>'provider_id'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doYourStuff() { | |
| const yourString = "foobar" | |
| const uniqueString = findUniqueString(yourString) | |
| // continue with your logic with unique string | |
| } | |
| function findUniqueString(baseString) { | |
| let uniqueString = baseString | |
| // number of iterations should be super small, probably unnecessary to have a max threshold |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { join } from "path"; | |
| export default function () { | |
| const { nuxt } = this | |
| // Make sure components is enabled | |
| if (!nuxt.options.components) { | |
| throw new Error('please set `components: true` inside `nuxt.config` and ensure using `nuxt >= 2.13.0`') | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| ... | |
| "logo": { | |
| "light": "/<repo-name>/logo-light.svg", | |
| "dark": "/<repo-name>/logo-dark.svg" | |
| }, | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default theme({ | |
| // ... | |
| router: { | |
| base: '/<repo-name>/' | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: docs | |
| # define the trigger | |
| on: [push, pull_request] | |
| jobs: | |
| docs: | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| # We used "docs" as directory name for our documentation, we will be referencing this later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| Issuer, | |
| generators, | |
| Client, | |
| TokenSet, | |
| CallbackParamsType, | |
| } from "openid-client"; | |
| const http = require('http'); | |
| const issuer = await Issuer.discover('https://cognito-idp.eu-central-1.amazonaws.com/eu-central-1_VqitD3cvk/.well-known/openid-configuration') |