Skip to content

Instantly share code, notes, and snippets.

Gerald Monaco devknoll

Block or report user

Report or block devknoll

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
View React.Freezer.md

Idea: React.Freezer

React.Freezer takes a frozen prop, that, when true:

  • Prevents React from making any mutations to the tree rooted at children
  • Logically unmounts any children and event handlers, as if children was set to null

Could form the basis for React escape hatches in general. E.g. dangerouslySetInnerHTML on every HTML Host element could be deprecated and instead be replaced with:

<React.Freezer children={{dangerousRawHTML: '<!-- foo -->'}} />
View stateless.js
import React, { PropTypes } from 'react';
export default Counter = ({ counter = 0 }) => (
<div clicked={{ counter: counter + 1 }}>{counter}</div>
);
Counter.propTypes = {
counter: PropTypes.number
};
@devknoll
devknoll / gist:8b274f1c5d05230bfade
Last active Feb 19, 2019
Basic GraphQL example using the GitHub API
View gist:8b274f1c5d05230bfade
import { graphql, GraphQLString, GraphQLInt } from 'graphql';
import { objectType, enumType, schemaFrom, listOf } from 'graphql-schema';
import request from 'promisingagent';
const repositorySortEnum = enumType('RepositorySort')
.value('CREATED', 'created')
.value('UPDATED', 'updated')
.value('PUSHED', 'pushed')
.value('FULL_NAME', 'full_name')
.end();
View Flix.js
class Flix extends Component {
constructor(props) {
super(props);
this.state = {
person: People[0],
};
}
_goToNextPerson() {
View Bounce.js
class BounceOnMount extends React.Component {
constructor(props: any) {
super(props);
this.state = {
bounceValue: new Animated.Value(props.start),
};
}
render(): ReactElement {
return this.props.children(this.state.bounceValue);
}
View gist:bd80f1f55f645140ad34
export default function CounterStore(state = initialState, action) {
switch (action.type) {
case INCREMENT_COUNTER:
return incremenent(state, action);
case DECREMENT_COUNTER:
return decremenent(state, action);
default:
return state;
}
}
View preseed.cfg
## Options to set on the command line
d-i debian-installer/locale string en_US.utf8
d-i console-setup/ask_detect boolean false
d-i console-setup/layout string USA
#d-i netcfg/get_hostname string dummy
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
# Continue without a default route
View gist:6832292
## Options to set on the command line
d-i debian-installer/locale string en_US.utf8
d-i console-setup/ask_detect boolean false
d-i console-setup/layout string USA
#d-i netcfg/get_hostname string dummy
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
# Continue without a default route
View gist:4530731
var type = Class.New(new[] { typeof(ReactiveScreen), typeof(IHasState) }, cls => // Inherit from ReactiveScreen and implement IHasState.
{
var state = cls.Field<IObservable<string>>(); // Default to null.
cls.Property<IObservable<string>>(Modifier.Public, "State")
.Get(Modifier.Public, () => state.Get())
.Set(Modifier.Private, (value) => state.Set(value)); // TODO: INotifyPropertyChanged support...
cls.Function(Modifier.Public, "GetRandomNumber", () => 4); // Chosen by a fair dice roll. Guaranteed to be random.
});
You can’t perform that action at this time.