Skip to content

Instantly share code, notes, and snippets.

View mturley's full-sized avatar

Mike Turley mturley

View GitHub Profile
@mturley
mturley / log-excerpt.txt
Created April 17, 2014 03:09
Exception in Enjin Minecraft Plugin
[03:05:51 WARN]: Exception in thread "pool-3-thread-2964"
[03:05:51 WARN]: org.apache.commons.lang.UnhandledException: Plugin EnjinMinecraftPlugin v2.5.6 generated an exception while executing task 9
at org.bukkit.craftbukkit.v1_7_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
@mturley
mturley / app.js
Created July 15, 2012 23:24
My quick and dirty DOM insertion animation attempt in Meteor
if (Meteor.is_client) {
// ...
var collections = {
Comments : new Meteor.Collection('comments'),
Likes : new Meteor.Collection('likes')
};
// ...
@mturley
mturley / MyComponent.js
Last active January 9, 2018 17:17
A Higher-Order React Component for Controlled State
import React from 'react';
import PropTypes from 'prop-types';
class MyComponent extends React.Component {
someMethod() {
const { setControlledState } = this.props;
setControlledState({ value: 'New Value' });
}
render() {
const { value } = this.props;
@mturley
mturley / Wizard.test.js
Created March 25, 2018 21:00
Merge conflicts in Wizard.test.js
import React from 'react';
import { mount } from 'enzyme';
<<<<<<< modal-wizard
import { Button, Row, Col, Wizard } from '../../index';
=======
import { Row, Col } from 'react-bootstrap';
import { Button } from '../Button';
import { Wizard } from './index';
import {
@mturley
mturley / reducer.js
Last active June 21, 2018 23:12
example of reducer handlers in an object
import {
BLUEPRINTS_FILTER_UPDATE_VALUES,
COMPONENTS_FILTER_UPDATE_VALUES, COMPONENTS_FILTER_ADD_VALUE
} from '../actions/filter';
// const filter = (state = [], action) => {
// switch (action.type) {
// case COMPONENTS_FILTER_ADD_VALUE:
// // ...
// return Object.assign({}, state,
@mturley
mturley / reducer2.js
Last active June 21, 2018 23:13
Another example of reducer handler functions, arrow function shorthand for immediate return, and helper functions
import {
BLUEPRINTS_FILTER_UPDATE_VALUES,
COMPONENTS_FILTER_UPDATE_VALUES, COMPONENTS_FILTER_ADD_VALUE
} from '../actions/filter';
// const filter = (state = [], action) => {
// switch (action.type) {
// case COMPONENTS_FILTER_ADD_VALUE:
// // ...
// return Object.assign({}, state,
@mturley
mturley / nfo-and-nab-example.txt
Created June 27, 2018 22:05
n, i, nfo, nit, np, nip and nab. Fish shell aliases and functions for using npm and grabbing package names super quickly.
~/git > nfo ngnx-local Wed Jun 27 18:01:36 2018
npm ERR! code E404
npm ERR! 404 Not found : ngnx-local
npm ERR! 404
npm ERR! 404 'ngnx-local' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
const getActivePlaybook = task => {
if (!task || !task.options || !task.options.playbooks) return {};
const { options: { playbooks } } = task;
if (playbooks.pre.status === 'Active') return playbooks.pre;
if (playbooks.post.status === 'Active') return playbooks.post;
return {};
};
const playbooksByTaskId = mostRecentTasks.reduce(
(map, task) => ({
@mturley
mturley / gist:c7348e5d31e63d7360b2f2ee493c5928
Created July 22, 2018 23:37
Errors running webpack-dev-server
ERROR in /Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/~/graphql-language-service-utils/dist/validateWithCustomRules.js
Module not found: Error: Can't resolve 'graphql/validation/rules/ExecutableDefinitions' in '/Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/node_modules/graphql-language-service-utils/dist'
@ /Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/~/graphql-language-service-utils/dist/validateWithCustomRules.js 20:18-75
@ /Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/~/graphql-language-service-utils/dist/index.js
@ /Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/~/graphql-language-service-interface/dist/getDefinition.js
@ /Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/~/graphql-language-service-interface/dist/index.js
@ /Users/mturley/.rvm/gems/ruby-2.4.2/bundler/gems/manageiq-graphql-5f68621f2791/~/codemir
@mturley
mturley / imperative-vs-declarative.md
Last active June 25, 2019 21:08
Imperative vs. Declarative Programming: The Value of React for Developers

Imperative vs Declarative Programming

The Value of React for Developers

Writing code for what we want the page to do, not how we want the browser to do it.

Basic concepts

I've been working on how to try and explain the fundamental difference between the following two concepts of how programming the interactions on a web page can be done. It's important to grasp both in order to understand the main benefit of React from a developer's perspective. There are also design benefits of React such as the ability to reuse and compose isolated components, but that is beyond the scope of this document.