Skip to content

Instantly share code, notes, and snippets.

View ok2ju's full-sized avatar
😈
devdevdev^

Alexey V. ok2ju

😈
devdevdev^
View GitHub Profile

auth0-react static getAccessToken method

There are many use cases to use getAccessTokenSilently outside of a component (for example, in an Axios Interceptor or an Apollo Client).

It's tempting to ask for the option to pass an Auth0Client instance into the Auth0Provider so that its getTokenSilently method can used outside of the context of a component, eg.

const client = new Auth0Client();
export const getAccessToken = () => client.getTokenSilently();
import { useCalendar } from '@h6s/calendar';
import { useMachine } from '@xstate/react';
import { Button as AriaButton } from 'ariakit/button';
import clsx from 'clsx';
import { isSunday, isSameDay, addMonths, isFuture, isPast, setDate } from 'date-fns';
import format from 'date-fns/format';
import isWithinInterval from 'date-fns/isWithinInterval';
import { FC, useCallback, useMemo } from 'react';
import Select from '@components/forms/components/Select';
export const bindSelectors = (slicer, selectors) => (
Object.keys(selectors).reduce((boundMethods, methodName) => ({
...boundMethods,
[methodName]: (state, ...args) => selectors[methodName](slicer(state), ...args),
}), {})
);
const result = useSelector(selectors.getTheseObjects(ownProps.params.someId));
const path = require('path')
module.exports = {
pageExtensions: [
'js', 'md', 'mdx'
],
webpack: (config, { defaultLoaders }) => {
config.module.rules.push({
test: /\.js$/,
exclude: /node_modules/,
@ok2ju
ok2ju / es6-compose.md
Created March 5, 2019 11:11 — forked from JamieMason/es6-compose.md
ES6 JavaScript compose function

ES6 JavaScript Compose Function

Definition

const compose = (...fns) =>
  fns.reduceRight((prevFn, nextFn) =>
    (...args) => nextFn(prevFn(...args)),
    value => value
 );
@ok2ju
ok2ju / prosody-setup.lua
Created February 24, 2019 12:11 — forked from legastero/prosody-setup.lua
Set up a Prosody server to work with stanza.io/otalk (with websockets, mam, etc)
-- 1. apt-get install prosody-trunk
-- 2. Checkout prosody-modules on Google Code
-- 3. Move all modules to /usr/lib/prosody/modules
-- 4. Move the mod_smacks module to mod_smacks2 and copy it to mod_smacks3
-- 5. Move the files in mod_smacks* to match the new names
-- 6. In mod_smacks3/mod_smacks3.lua s/urn:xmpp:sm:2/urn:xmpp:sm:3/g
-- 7. Set the Prosody configuration to:
admins = { "ADMIN@HOST" }
daemonize = true
@ok2ju
ok2ju / multiFilter.js
Created February 8, 2019 08:50 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple criteria.
/**
* Filters an array of objects with multiple criteria.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria as the property names
* @return {Array}
*/
function multiFilter(array, filters) {
const filterKeys = Object.keys(filters);
// filters all elements passing the criteria
@ok2ju
ok2ju / connect.js
Created April 23, 2017 14:06 — forked from gaearon/connect.js
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@ok2ju
ok2ju / snippets.js
Created February 16, 2017 12:29 — forked from jakub-g/snippets.js
robust cd, execSync wrappers for nodejs 0.12+ and shelljs
var path = require('path');
var clc = require('cli-color');
var shelljs = require('shelljs');
function cd(dir) {
dir = path.resolve(dir)
shelljs.cd(dir);
var cwd = path.resolve(process.cwd());
@ok2ju
ok2ju / nativeJavaScript.js
Created October 29, 2016 07:26 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests