Skip to content

Instantly share code, notes, and snippets.

@Bulletninja
Bulletninja / Readme.md
Created May 26, 2020 — forked from colllin/Readme.md
Auth0 + FaunaDB integration strategy
View Readme.md

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.
@Bulletninja
Bulletninja / Readme.md
Created May 26, 2020 — forked from colllin/Readme.md
FaunaDB User Token Expiration (for ABAC)
View Readme.md

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.
@Bulletninja
Bulletninja / useFieldArray.js
Created May 17, 2020 — forked from joshsalverda/useFieldArray.js
Custom useFieldArray hook for formik using immutability-helper
View useFieldArray.js
import {useCallback, useRef, useEffect} from 'react'
import {useField, useFormikContext} from 'formik'
import update from 'immutability-helper'
const useFieldArray = props => {
const [field, meta] = useField(props)
const fieldArray = useRef(field.value)
const {setFieldValue} = useFormikContext()
useEffect(() => {
View js_programming_patterns.js
// one loop multiple checks (can be turned into a builder of other datastructure
const exampleValues = [2, 15, 8, 23, 1, 32];
const [truthyValues, falseyValues] = exampleValues.reduce((arrays, exampleValue) => {
if (exampleValue > 10) {
arrays[0].push(exampleValue);
return arrays;
}
arrays[1].push(exampleValue);
View run_async_threaded
def run_async(f, lock=None):
import weakref
from threading import Thread
def args_wrapper(*args, **kwargs):
class FunctionRunner(Thread):
def run(self):
if lock is not None: lock.acquire()
try:
self.result = f(*args, **kwargs)
finally:
View gist:6daca6bd5cfe58c9c6fed5340a5f0de0
var Twit = require("twit");
var Bot = new Twit({
consumer_key: "", //tu consumer key
consumer_secret: "", // tu consumer secret
access_token: "", //tu acess token
access_token_secret: "" //tu access token secret
});
Bot.post('statuses/update', {status: "Hola desde node con twit!"}, function(err, data, response){
@Bulletninja
Bulletninja / install_psql_php.sh
Last active Oct 29, 2015 — forked from giorgiofellipe/install_psql_php.sh
Install PHP PGSQL extensions on Mac OS X Yosemite (change PHP_VER with your PHP version)
View install_psql_php.sh
PHP_VER="5.5.29"
# Check if extension exists first
php -m | grep pgsql
# Update brew and install requirements
brew update
brew install autoconf
# Download PHP source and extract