Skip to content

Instantly share code, notes, and snippets.

View dpoindexter's full-sized avatar

Daniel Poindexter dpoindexter

  • Indeed
  • Austin, TX
View GitHub Profile
@dpoindexter
dpoindexter / cursor-definitions.d.ts
Created September 1, 2017 16:42
Cursor definitions
declare module 'immutable-cursor' {
import { Collection, Record } from 'immutable';
type Key = string | number | symbol;
type KeyPath = Array<string | number | symbol>;
type Primitive = string | number | boolean | symbol | undefined | null;
type ImmutableCollection =
@dpoindexter
dpoindexter / sideEffectsMixin.js
Created December 28, 2015 17:44
React component mixin for declarative side effects
class Update {
constructor (state) {
this.newState = state;
this.effects = [];
}
state (update) {
this.newState = { ...this.newState, update };
}
@dpoindexter
dpoindexter / draft.md
Created October 6, 2015 15:43
Building React apps with Omniscient

Building React apps with Omniscient Patterns and practices

First, if you haven't read these article, please do so.

  1. Thinking in React (https://facebook.github.io/react/docs/thinking-in-react.html) The main takeaway here is how to structure your app as a tree of components. Once you're used to breaking down a feature into sub-components, the rest of this starts to make a whole lot more sense.

  2. Simpler UI Reasoning with Unidirectional Data Flow (http://omniscientjs.github.io/guides/01-simpler-ui-reasoning-with-unidirectional/) This is a conceptual overview of how Omniscient helps us manage state and complexity when building React apps. Because there are a lot of new concepts here, it's really important to understand the "why" behind our approach.

@dpoindexter
dpoindexter / a-limit-react-work.md
Last active April 20, 2017 12:12
React Foundation Grid

"Push work down the tree"

One disadvantage of the top-down rendering approach we use is that the closer to the root of the application a component lives, the more it will be rerendered. The root component will be rerendered every time any data changes.

This is probably not a big deal for applications without much dynamic state, but let's say you have a input box at the bottom of a large tree of components (which will happen on pretty much any page containing a form). The user types, and every keystroke causes the entire app to rerender!

Well, this might be a big deal, or it might not be, depending on how you design your components. Some general guidelines will help us architect React apps that are fast by default, and don't need a whole lot of manual optimization.

HTML is work, components are placeholders

@dpoindexter
dpoindexter / context-v1.js
Last active August 29, 2015 14:23
React validation concept
- Use ComponentDidMount and context to attach to container
- On every render, all attached components evaluate their own validation state, and call setState on the corresponding Form property
<Form>
<ArbitraryComponent/>
<Input>
</Form>
Const ArbitraryComponent = component(() => <div><Input /></div>);
This file has been truncated, but you can view the full file.
10005 silly gentlyRm C:\inetpub\wwwroot\Trunk5\uShip.Static\node_modules\gulp-sass\node_modules\node-sass\node_modules\glob\node_modules\inflight\node_modules\wrappy is being purged
10006 verbose gentlyRm don't care about contents; nuking C:\inetpub\wwwroot\Trunk5\uShip.Static\node_modules\gulp-sass\node_modules\node-sass\node_modules\glob\node_modules\inflight\node_modules\wrappy
10007 verbose afterAdd C:\Users\dpoindexter\AppData\Roaming\npm-cache\hawk\2.3.1\package\package.json written
10008 silly install resolved [ { name: 'json-stringify-safe',
10008 silly install resolved version: '5.0.1',
10008 silly install resolved description: 'Like JSON.stringify, but doesn\'t blow up on circular refs.',
10008 silly install resolved keywords: [ 'json', 'stringify', 'circular', 'safe' ],
10008 silly install resolved homepage: 'https://github.com/isaacs/json-stringify-safe',
10008 silly install resolved bugs: { url: 'https://github.com/isaacs/json-stringify-safe/issues' },
10008 silly install reso
@dpoindexter
dpoindexter / Formatter.cs
Created January 30, 2015 23:47
Strategy to select a string formatter for a generic object
using System;
using System.Collections.Generic;
using System.Linq;
using FubuCore;
using uShip.Api.Common.Dto.Location;
namespace uShip.Web.Mvc.Builders
{
public class ObjectFormatter<TFormattable>
{
@dpoindexter
dpoindexter / gist:de3ebb7aa5d2269250e8
Created January 22, 2015 03:35
p4merge gitconfig section
[mergetool "p4merge"]
cmd = "p4merge.exe $BASE $LOCAL $REMOTE $MERGED"
path = c:/Program Files/Perforce/p4merge.exe
[merge]
tool = p4merge
@dpoindexter
dpoindexter / ControlExtensions.cs
Created December 27, 2012 16:46
Extension to get the AjaxPro path of the current ASP.Net WebForms control
using System;
using System.Linq;
using System.Web.UI;
namespace MyProject.Extensions
{
public static class ControlExtensions
{
public static string GetAjaxProPath(this Control control)
{
@dpoindexter
dpoindexter / jquery-ajaxpro-configuration.js
Created December 27, 2012 16:39
jQuery configuration to simplify use of AjaxPro with $.ajax API. Some of the weirdness of AjaxPro responses may have been fixed in the most recent version.
; (function($) {
/* For AJAX calls, defines a custom type "ajaxproresult" and how to convert from text type to
ajaxproresult. This allows us to convert both AjaxPro success (valid JSON) and exception
(invalid JSON, some kind of script result) to JSON */
$.ajaxSetup({
converters: {
//Converts AjaxPro responses to JSON, and handles the weird non-JSON string that AjaxPro returns on exception