Skip to content

Instantly share code, notes, and snippets.

View anthonybrown's full-sized avatar
🎯
Focusing

Tony Brown anthonybrown

🎯
Focusing
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
/////////////////////////////////////////////////////////
@anthonybrown
anthonybrown / style.css
Last active May 26, 2018 11:50
my vscode setup for OceanicNext
/* Ligatures */
.mtk16,
.mtk26,
.mtk36,
.mtk39 {
font-family: "Fira Code";
font-weight: 900;
}
/* Keywords, decorators, comments */
// Flexible Compound Components with context
import React from 'react'
import {Switch} from '../switch'
// Right now our component can only clone and pass props to immediate children.
// So we need some way for our compound components to implicitly accept the on
// state and toggle method regardless of where they're rendered within the
// Toggle component's "posterity" :)
//

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {
@anthonybrown
anthonybrown / bookmarklet
Created March 28, 2018 05:20 — forked from kentcdodds/bookmarklet
activeElement logger bookmarklet
javascript:(function(){if(window._activeElInterval){clearInterval(window._activeElInterval);delete window._activeElInterval;}else{var activeEl;window._activeElInterval=setInterval(function(){var currentActiveEl=document.activeElement;if(currentActiveEl!==activeEl){activeEl=currentActiveEl;console.log(activeEl);}},200);}})();
<form>
<div>
<label for="text">Text Input</label>
<input type="text" id="text" required>
</div>
<div>
<label for="minmaxlength">Text with Min and Max Length</label>
<input type="text" id="minmaxlength" minlength="3" maxlength="12">
</div>
@anthonybrown
anthonybrown / DebouncedProp.jsx
Created March 22, 2018 02:46 — forked from sastraxi/DebouncedProp.jsx
Store quickly-changing state directly in Redux (e.g. the value of a textarea) without a bajillion actions being dispatched
import React from 'react';
import _ from 'lodash';
/**
* Protect a heavyweight setter by caching values locally.
* Allows functional controlled components with e.g. a redux backing store,
* without dispatching actions on every keypress.
*
* @param {*} valueProp the value to cache (e.g. a key from mapStateToProps)
* @param {*} setterProp the heavyweight setter to protect (e.g. a key from mapDispatchToProps)
@anthonybrown
anthonybrown / .eslintrc
Last active March 14, 2018 20:31
Another eslintrc file I use
{
"extends": "airbnb",
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": [
"react",
"jsx-a11y",
import React, { Component } from "react";
import AppBar from "material-ui/AppBar";
import { Link } from "react-router-dom";
import FlatButton from "material-ui/FlatButton";
import UserStore from "../../stores/user_store";
import { Toolbar, ToolbarGroup } from "material-ui/Toolbar";
import history from "../../history";
import UserActions from "../../actions/user_actions";
import {
Logo,
@anthonybrown
anthonybrown / yarn-error-log
Created March 10, 2018 16:03
An error while running yarn build
Arguments:
/usr/local/Cellar/node/9.7.1/bin/node /usr/local/Cellar/yarn/1.5.1/libexec/bin/yarn.js run build
PATH:
/Users/tony/.rvm/gems/ruby-2.3.3/bin:/Users/tony/.rvm/gems/ruby-2.3.3@global/bin:/Users/tony/.rvm/rubies/ruby-2.3.3/bin:/usr/local/mysql/bin:/usr/local/opt/openssl/bin:/usr/local/opt/curl/bin:/usr/local/opt/python@2/libexec/bin:/usr/local/opt/php71/bin:/Users/tony/.composer/vendor/bin:/usr/local/opt/curl/bin:/Users/tony/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:./node_modules/.bin:/usr/local/bin:/usr/local/opt/go/libexec/bin/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/X11/bin:/Users/tony/.rvm/bin
Yarn version:
1.5.1
Node version: