Skip to content

Instantly share code, notes, and snippets.

View Sparragus's full-sized avatar
🛠️
Follow me on twitter: https://twitter.com/sparragus

Richard B. Kaufman-López Sparragus

🛠️
Follow me on twitter: https://twitter.com/sparragus
View GitHub Profile
@Sparragus
Sparragus / machine.js
Last active October 29, 2020 17:10
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions

Keybase proof

I hereby claim:

  • I am sparragus on github.
  • I am sparragus (https://keybase.io/sparragus) on keybase.
  • I have a public key ASDsUBYFM9SpfxO-VHvZS506acdWkyN1lpzyu-eUVQN3dAo

To claim this, I am signing this object:

@Sparragus
Sparragus / cloudSettings
Created February 11, 2020 14:33
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-11T14:33:38.015Z","extensionVersion":"v3.4.3"}
@Sparragus
Sparragus / cloudSettings
Last active February 11, 2020 14:32
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-11T14:32:55.527Z","extensionVersion":"v3.4.3"}
@Sparragus
Sparragus / PostsPage.js
Last active October 29, 2019 17:33
Recipe for handling requests in a React App
import React from 'react';
import useQuery from './useQuery.js';
import * as api from './api.js';
function LoadingPage () {
return <div>Loading...</div>
}
function ErrorPage ({ error }) {
return <div>Error: {error.message}</div>
@Sparragus
Sparragus / api.js
Created May 24, 2019 14:21
An example of how I build my own API library for each project
import { readAuthCookie } from '../helpers/cookie';
import * as errorTracker from '../helpers/errorTracker';
/*
Helpers
*/
const BASE_PATH = '/api/v1';
class APIError extends Error {
constructor(res, data) {
@Sparragus
Sparragus / readme.md
Created April 18, 2019 16:49 — forked from FrikkieSnyman/readme.md
GrapesJS - attributes, classes, and scripts

GrapesJS - attributes, classes, and scripts

Attributes

In order to add custom attributes to an HTML element that is generated by GrapesJS, one can simply make use of traits. For example, if you wish to produce an HTML element which contains the tag data-noout, a trait with the name data-noout can be added to a custom component.

    var domComps = editor.DomComponents;
    var dType = domComps.getType('default');
 var dModel = dType.model;
// Icon.js
import React from 'react'
export default function Icon ({ name }) {
const className = `icon-${name}`
return (
<i className={className} />
)
}
// Icon.test.js
import React from 'react'
import { shallow } from 'enzyme'
import Icon from './Icon'
describe('Icon', () => {
let tree, props
const buildTree = (newProps = {}) => {
@Sparragus
Sparragus / eslint-plugin.js
Created October 28, 2017 06:37
Eslint plugin with a rule that enforces blank lines between sibling JSX elements
const JSXELEMENT_CHILDREN = [
'JSXText',
'JSXExpressionContainer',
'JSXSpreadChild',
'JSXElement',
'JSXFragment'
]
const isJSXElementChildrenType = x => x && JSXELEMENT_CHILDREN.includes(x.type)
module.exports = {