Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Seldon arcseldon

View GitHub Profile
@arcseldon
arcseldon / free-er.js
Created Feb 28, 2016 — forked from DrBoolean/free-er.js
Free(er) monads in JS (pt 1)
View free-er.js
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
const kleisli_comp = (f, g) => x => f(x).chain(g)
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@arcseldon
arcseldon / free-er2.js
Created Feb 28, 2016 — forked from DrBoolean/free-er2.js
Free(er) Monads Pt2
View free-er2.js
const daggy = require('daggy')
const Task = require('data.task')
const _ = require('lodash')
const kleisli_comp = (f, g) => x => f(x).chain(g)
const compose = (f, g) => x => f(g(x))
const id = x => x
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@arcseldon
arcseldon / coyo_uses.js
Created Feb 28, 2016 — forked from DrBoolean/coyo_uses.js
Coyoneda Uses in JS
View coyo_uses.js
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
//===============Define Coyoneda=========
const Coyoneda = daggy.tagged('x', 'f')
Coyoneda.prototype.map = function(f) {
return Coyoneda(this.x, compose(f, this.f))
}
@arcseldon
arcseldon / Auth0JWTSigner.scala
Created Mar 5, 2016
Provides a blueprint for how to create an Auth0 JSON Web Token (JWT)
View Auth0JWTSigner.scala
// richard.seldon@auth0.com
// commons-codec-1.10.jar
// java-jwt-2.1.0.jar
// see docs here: https://auth0.com/docs/jwt
import java.security.SignatureException
import java.text.SimpleDateFormat
@arcseldon
arcseldon / noLoginForConnectionType.js
Created Mar 15, 2016
Auth0 Rule sample - checking for connection type and login count.
View noLoginForConnectionType.js
function noLoginForConnectionType(user, context, callback) {
user.app_metadata = user.app_metadata || {};
console.log('connection: ' + context.connection);
if (context.connection === 'google-oauth2'){
var cnt = context.stats.loginsCount;
console.log('user login count: ' + cnt);
if (cnt <= 1) {
console.log('Setting loginDisabled');
user.app_metadata.loginDisabled = true;
auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
@arcseldon
arcseldon / .eslintrc
Created Apr 29, 2016 — forked from hendrikswan/.eslintrc
Packages and build config for Build Cross Platform React Native Apps with Exponent and Redux
View .eslintrc
{
"extends": "airbnb/base",
"plugins": [
"react"
],
"env": {
"node": true,
"jasmine": true,
},
"rules": {
View customAuth0UserSerialization.md

Own version of com.auth0.SessionUtils with the following two methods overridden in custom impl.

     import org.springframework.beans.BeanUtils;
     ...
     
     
     public static Auth0User getAuth0User(final HttpServletRequest req) {
        System.out.println("GET AUTH0 USER");
 final MyAuth0User myAuth0User = (MyAuth0User) getSession(req).getAttribute(AUTH0_USER);
@arcseldon
arcseldon / Option1.js
Created Nov 8, 2016 — forked from pushpabrol/Option1.js
How to use ldapjs within a custom database connection in Auth0
View Option1.js
function login(email, password, callback) {
var ldap = require('ldapjs');
if (!global.ldapClient) {
// console.log('Global Client not found');
var client = ldap.createClient({
url: 'ldap://server:389',
idleTimeout: 30000
});
client.bind('uid=admin,ou=system', 'secret', function(err) {
View pinger-async-await.js
import _ from 'lodash';
import fetch from 'node-fetch';
import delay from 'delay';
export async function pingServers(servers) {
let failedServers = {};
for (const url of servers) {
let failures = 0;
for (const i of _.range(3)) {
const response = await fetch(url);
@arcseldon
arcseldon / contest-webtask.js
Created Nov 20, 2016 — forked from woloski/contest-webtask.js
Contest Signup Webtask
View contest-webtask.js
'use latest';
import express from 'express';
import { fromExpress } from 'webtask-tools';
import bodyParser from 'body-parser';
const app = express();
var jwt = require('express-jwt');
var jwtCheck = jwt({