Skip to content

Instantly share code, notes, and snippets.

🏳️‍🌈
Just gayin' up the place the best I can

Michelle Tilley BinaryMuse

🏳️‍🌈
Just gayin' up the place the best I can
Block or report user

Report or block BinaryMuse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@smashwilson
smashwilson / init.js
Last active Aug 6, 2019
Init script blurb to fold mocha, jasmine, or minitest tests down to the "it" blocks
View init.js
atom.commands.add('atom-text-editor', 'me:fold-to-it', event => {
const editor = event.target.closest('atom-text-editor').getModel()
const languageMode = editor.getBuffer().getLanguageMode()
if (!languageMode.tree) return
editor.unfoldAll()
const startsWith = (node, text) => {
const startPosition = new Point(node.startPosition.row, node.startPosition.column)
const endPosition = startPosition.traverse([0, text.length])
@BinaryMuse
BinaryMuse / index.html
Last active Oct 10, 2015
JSBin Template
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.rawgit.com/lodash/lodash/3.0.1/lodash.min.js"></script>
<script src="//fb.me/react-0.14.0-rc1.js"></script>
<script src="//fb.me/react-dom-0.14.0-rc1.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">-->
<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">-->
<meta charset="utf-8">
@jsdf
jsdf / immutableJSFormatter.js
Last active Aug 18, 2016
Chrome devtools formatter for Immutable-js
View immutableJSFormatter.js
const immutableJSFormatter = {
header(x) {
if (x && x.toJS) return ['span', {}, x.toString()];
return null;
},
hasBody(x) {
return x && x.toJS;
},
body(x) {
return ['span', {}, JSON.stringify(x.toJS(), null, 2)];
@BinaryMuse
BinaryMuse / webpack.config.js
Last active Aug 29, 2019
webpack less -> css with source maps via extracttextplugin
View webpack.config.js
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var lessLoader = ExtractTextPlugin.extract(
"css?sourceMap!less?sourceMap"
);
module.exports = {
cache: true,
entry: { bundle: "./master/client/index.jsx" },
@aaronjensen
aaronjensen / connect.jsx
Last active Jul 28, 2017
Redux shim for converting from Fluxxor
View connect.jsx
const React = require('react');
const mapValues = require('lodash/object/mapValues');
const createGetState = require('app/redux_shims/create_get_state');
const Fluxxor = require('fluxxor');
const FluxMixin = Fluxxor.FluxMixin(React);
const StoreWatchMixin = Fluxxor.StoreWatchMixin;
const createDispatcher = require('app/redux_shims/create_dispatcher');
const Router = require('react-router');
function bindActionCreator(flux, router, action) {
@jondlm
jondlm / README.md
Last active Jan 3, 2018
React shallow render lifecycle breakdown
View README.md

React introduced shallow rendering in 0.13. This is an excellent feature that I wish was included earlier in React. It aims to solve the problem of unit testing components without going through a real, or jsdom mocked, DOM. I couldn't find any info online about what lifecycle events it actually fires. So I did some testing of my own. To reproduce, put component.js and test.js into a folder and run node test.js.

TLDR; shallow rendering only invokes the following lifecycle hooks (in order):

  1. getDefaultProps
  2. getInitialState
  3. componentWillMount stops here until re-render
  4. componentWillReceiveProps
  5. shouldComponentUpdate
  6. componentWillUpdate
@julianocomg
julianocomg / AffixWrapper.jsx
Last active Oct 9, 2019
A simple affix React component.
View AffixWrapper.jsx
/**
* @author Juliano Castilho <julianocomg@gmail.com>
*/
var React = require('react');
var AffixWrapper = React.createClass({
/**
* @type {Object}
*/
propTypes: {
@phated
phated / 1.good.js
Last active Aug 29, 2015
Idiomatic React - Rule #1: Don't generate children; Always forward them.
View 1.good.js
/*
List is an abstract React component for building lists.
Think of it like a wrapper around <ul> or <ol>
*/
var List = require('custom-components/list');
/*
ListItem is an abstract React component for adding items to the List component.
Think of this like a <li> that might have styling, classes, etc to work nicer in the List.
*/
var ListItem = require('custom-components/list-item');
View gist:1dd3dfb8e754080dad6c
import React from 'react';
import shallowEqual from 'react/lib/shallowEqual';
class PureRenderComponent extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
}
}
@benjamingr
benjamingr / gist:0237932cee84712951a2
Last active Apr 16, 2018
Promise unhandled rejection tracking global handler hook
View gist:0237932cee84712951a2

Possibly Unhandled Rejection NodeJS Promise Hook

###Unhandled Rejection Tracking

Several promise libraries such as bluebird and when as well as some native promise implementations offer potentially unhandled rejection tracking. This means that the following:

Promise.reject(new Error("err")); // never attach a `catch`
You can’t perform that action at this time.