Skip to content

Instantly share code, notes, and snippets.


Collin Donahue-Oponski colllin

View GitHub Profile
colllin / gist:12d77e03b6b6f717d5d1fe15b75bf2d4
Created Aug 3, 2016
Auth0 `Get User` database action script NO-OP
View gist:12d77e03b6b6f717d5d1fe15b75bf2d4
function getByEmail (email, callback) {
// This script should retrieve a user profile from your existing database,
// without authenticating the user.
// It is used to check if a user exists before executing flows that do not
// require authentication (signup and password reset).
// There are three ways this script can finish:
// 1. A user was successfully found. The profile should be in the following
// format:
// callback(null, profile);
colllin /
Last active Feb 9, 2021
FaunaDB Clear all GraphQL metadata

From Leo via slack on Jan 3rd, 2020 in #graphql channel:

This is the script you should run in order to delete all of the GraphQL metadata for the current DB (it won't delete any actual data):

// Remove GraphQL metadata from Collections, Functions, and Indexes
Foreach(Paginate(Collections(), {size:10000}), Lambda('ref', Update(Var('ref'), {data: {gql: null}})))
Foreach(Paginate(Functions(), {size:10000}), Lambda('ref', Update(Var('ref'), {data: {gql: null}})))
Foreach(Paginate(Indexes(), {size:10000}), Lambda('ref', Update(Var('ref'), {data: {gql: null}})))
colllin /
Last active Feb 8, 2021
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 /
Last active Dec 7, 2020
How to use UrlSpoiler to preview Gists
colllin /
Last active Nov 29, 2020
ion-list sticky headers

What this does:

Within an <ion-scroll>, this directive creates sticky item headers that get bumped out of the way by the next item.



  • Needs UnderscoreJS for its _.throttle utility.
  • Must be used within an <ion-scroll> or <ion-content>
colllin /
Created Aug 19, 2020
OpenAI Gym FlattenAction wrapper
import gym
class FlattenAction(gym.ActionWrapper):
"""Action wrapper that flattens the action."""
def __init__(self, env):
super(FlattenAction, self).__init__(env)
self.action_space = gym.spaces.utils.flatten_space(self.env.action_space)
def action(self, action):
return gym.spaces.utils.unflatten(self.env.action_space, action)
colllin /
Last active Aug 11, 2020
Auth0 + FaunaDB integration strategy



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.
> CreateIndex({
    name: 'users_by_messageSentAt_desc',
    source: Collection('messages'),
    values: [
        {field: ['data','sentAt'], reverse: true},
        {field: ['data','fromUser']}
colllin / Find Learning Rate.ipynb
Last active Mar 2, 2020
Learning Rate Finder in PyTorch
View Find Learning Rate.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
colllin / query-mailgun-emails-by-custom-vars.js
Created Jan 3, 2020
Query Mailgun emails by custom variables / custom data
View query-mailgun-emails-by-custom-vars.js
const util = require('util');
const _ = require('lodash');
const mailgun = require("mailgun-js");
async function queryByCustomData(data) {
let mg = mailgun({apiKey: process.env.MAILGUN_API_KEY});
let asyncGet = util.promisify(_.bind(mg.get, mg));
let response = await asyncGet(`/YOUR_MAIL_DOMAIN/events`, {
"user-variables": JSON.stringify(data),