Skip to content

Instantly share code, notes, and snippets.

View BinaryMuse's full-sized avatar
🏳️‍🌈
Just gayin' up the place the best I can

Michelle Tilley BinaryMuse

🏳️‍🌈
Just gayin' up the place the best I can
View GitHub Profile
@smashwilson
smashwilson / init.js
Last active April 29, 2020 17:45
Init script blurb to fold mocha, jasmine, or minitest tests down to the "it" blocks
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 October 10, 2015 13:47
JSBin Template
<!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 May 19, 2022 10:51
Chrome devtools formatter for Immutable-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 August 29, 2019 13:44
webpack less -> css with source maps via extracttextplugin
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 July 28, 2017 18:43
Redux shim for converting from Fluxxor
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 January 3, 2018 05:59
React shallow render lifecycle breakdown

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 November 28, 2022 14:59
A simple affix React component.
/**
* @author Juliano Castilho <julianocomg@gmail.com>
*/
var React = require('react');
var AffixWrapper = React.createClass({
/**
* @type {Object}
*/
propTypes: {
@phated
phated / 1.good.js
Last active August 29, 2015 14:16
Idiomatic React - Rule #1: Don't generate children; Always forward them.
/*
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');
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 October 6, 2023 08:31
Promise unhandled rejection tracking global handler hook

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`