Skip to content

Instantly share code, notes, and snippets.

View rclayton-the-terrible's full-sized avatar

Richard Clayton rclayton-the-terrible

View GitHub Profile
@andywer
andywer / _readme.md
Last active March 7, 2024 05:52
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

Hi, looks like this code fragment from your blog at: https://rclayton.silvrback.com/custom-errors-in-node-js

// I do something like this to wrap errors from other frameworks.
class InternalError extends DomainError {
  super(error.message);
  this.data = { error };
}

should be modified to have a constructor that takes that error from other frameworks like this?

@rbramley
rbramley / CloudEvents-0.1.avsc
Created April 6, 2018 17:07
CloudEvents 0.1 Avro schema (draft)
{
"namespace": "CloudEvents",
"type": "record",
"name": "Event",
"fields": [
{"name": "cloudEventsVersion", "type": "string", "doc": "The version of the CloudEvents specification which the event uses. This enables the interpretation of the context."},
{"name": "eventType", "type": "string", "doc": "Type of the event data. Producers can specify the format of this, depending on their service. This enables the interpretation of data, and can be used for routing, policy and more."},
{"name": "eventTypeVersion", "type": ["null", "string"], "doc": "The version of the event-type. This enables the interpretation of data by eventual consumers, requires the consumer to be knowledgeable about the producer."},
{"name": "source", "type": "string", "doc": "This describes the event producer. Often this will include information such as the type of the event source, the organization publishing the event, and some unique idenfitiers. The exact syntax and semantics behind the data encoded in the URI is e
@lfalke
lfalke / StripeCardsSection.js
Last active August 8, 2023 05:10
Usage of react-stripe-elements with Material UI (v1.0) styling
import React, { PureComponent } from 'react'
import Grid from 'material-ui/Grid'
import { CardNumberElement, CardExpiryElement, CardCVCElement } from 'react-stripe-elements'
import StripeElementWrapper from './StripeElementWrapper'
export default class extends PureComponent {
static displayName = 'StripeCardsSection'
const express = require('express');
const asyncRouter = require('../lib/async_router');
var router = asyncRouter(express.Router());
router.get('/', async (req, res, next) => {
// mkaing async errors
});
@ralayo-ut
ralayo-ut / README.md
Last active June 26, 2017 16:25 — forked from brandt/README.md
Creates a loopback alias with IP 10.200.10.1 at startup on Mac OS X

Loopback Alias

Creates an alias on the loopback interface (lo0) with the IP 10.200.10.1 on Mac OS X.

Installation

  1. Install the plist to: /Library/LaunchDaemons/com.runlevel1.lo0.alias.plist
  2. Set mode: chmod 0644 /Library/LaunchDaemons/com.runlevel1.lo0.alias.plist
  3. Set owner: sudo chown root:wheel /Library/LaunchDaemons/com.runlevel1.lo0.alias.plist
  4. Load: sudo launchctl load /Library/LaunchDaemons/com.runlevel1.lo0.alias.plist
admin:
port: 9990
ip: 0.0.0.0
routers:
# http 1.1: service -> [linkerd] -> linkerd -> service
# should lookup consul service then rewrite outgoing port to linkerd
- label: http1-out
protocol: http
servers:
@jonathansick
jonathansick / query.graphql
Last active January 20, 2024 07:58
GitHub GraphQL repo commit history query
{
repository(name: "sickvim", owner: "jonathansick") {
ref(qualifiedName: "master") {
target {
... on Commit {
id
history(first: 5) {
pageInfo {
hasNextPage
}
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@harto
harto / before.js
Created April 20, 2016 17:33
Mocha before() & beforeEach() execution order with nested describe()
'use strict';
describe('mocha before hooks', function () {
before(() => console.log('*** top-level before()'));
beforeEach(() => console.log('*** top-level beforeEach()'));
describe('nesting', function () {
before(() => console.log('*** nested before()'));
beforeEach(() => console.log('*** nested beforeEach()'));
it('is a nested spec', () => true);
});