Skip to content

Instantly share code, notes, and snippets.

@Bulletninja
Bulletninja / install_psql_php.sh
Last active October 29, 2015 21:47 — forked from giorgiofellipe/install_psql_php.sh
Install PHP PGSQL extensions on Mac OS X Yosemite (change PHP_VER with your PHP version)
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
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){
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:
@Bulletninja
Bulletninja / js_programming_patterns.js
Created November 6, 2019 06:18
Slick patterns to use in 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);
@Bulletninja
Bulletninja / useFieldArray.js
Created May 17, 2020 17:45 — forked from joshsalverda/useFieldArray.js
Custom useFieldArray hook for formik using immutability-helper
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(() => {
@Bulletninja
Bulletninja / Readme.md
Created May 26, 2020 21:45 — forked from colllin/Readme.md
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.
@Bulletninja
Bulletninja / Readme.md
Created May 26, 2020 22:26 — forked from colllin/Readme.md
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.