To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.
- Homebrew
- Mountain Lion -> High Sierra
export default function createCrudHooks({ | |
baseKey, | |
indexFn, | |
singleFn, | |
createFn, | |
updateFn, | |
deleteFn, | |
}) { | |
const useIndex = (config) => useQuery([baseKey], indexFn, config) | |
const useSingle = (id, config) => |
import React, { useReducer, useState, useEffect } from 'react' | |
import PropTypes from 'prop-types' | |
/** */ | |
export const articleReducer = (state, action) => { | |
switch(action.type) { | |
case 'SET_CURRENT_ARTICLE': | |
return { | |
...state, | |
currentArticleId: action.payload.articleId |
import React, { useReducer, useContext, createContext } from 'react' | |
import PropTypes from 'prop-types' | |
const SomethingUsefulContext = createContext() | |
export const reducer = ( state, action ) => { | |
switch(action.type) { | |
default: | |
throw new Error(`Unrecognised action type: ${action.type} `) | |
} |
import React, { createContext, useReducer, useContext } from 'react' | |
import PropTypes from 'prop-types' | |
const ServiceRequestContext = createContext() | |
export const initialState = { | |
serviceRequests: new Map(), | |
selectedTicketId: null, | |
pendingRequest: null | |
} |
function useSelectors(reducer, mapStateToSelectors) { | |
const [state] = reducer; | |
const selectors = useMemo(() => mapStateToSelectors(state), [state]); | |
return selectors; | |
} | |
function useActions(reducer, mapDispatchToActions) { | |
const [, dispatch] = reducer; | |
const actions = useMemo(() => mapDispatchToActions(dispatch), [dispatch]); | |
return actions; |
function getFruit() { | |
try { | |
// Axios will trip on all HTTP error codes, pushing you into the catch. | |
const res = await axios.get('http://www.example.fake/fruit'); | |
} catch (err) { | |
// Examine error for http status code. | |
if (err.status) { | |
// Give more explanation if the API provides it. | |
throw new Error(`Call failed because: $err.status`); | |
} |
To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.
db.request_log__v2_0.aggregate([{ | |
"$redact": { | |
"$cond": [{ | |
"$and": [{ | |
"$eq": [{ | |
"$year": "$created_at" | |
}, 2018] | |
}, { | |
"$eq": [{ | |
"$month": "$created_at" |
const passport = require('passport-strategy'); | |
const url = require('url'); | |
const querystring = require('querystring'); | |
const util = require('util'); | |
const axios = require('axios'); | |
/**/ | |
function TenantStrategy(options, verify) { | |
this.name = 'tenant'; |