Skip to content

Instantly share code, notes, and snippets.

@Component({/* ... */})
export class MyComponent {
constructor() {
afterRender(() => {
// Run after *each* render
}, {phase: AfterRenderPhase.Write});
afterNextRender(() => {
// Run after the *next* render
}, {phase: AfterRenderPhase.Write});

Replacing Twitter: the distributed public forum

Fundamentally, freedom of speech is the idea that the government should not be able to prohibit, censor, or otherwise regulate what you can say.

There is a separate but related idea of a right to privacy: the idea that nobody but you and the intended recipient of a message should be able to read it. Perhaps the best known way to guarantee this with digital communications is to use end-to-end encryption, where only the sender and recipient have the keys to reveal the message.

With most centralized services like Twitter (run by private corporations), the right to privacy is not strongly guaranteed. Companies like Twitter can be (and have been) compelled by the government to provide access to this private content in response to subpoenas.

Similarly, private companies like Twitter can be (and have been) compelled by other forces (e.g. public opinion, advertisers) to regulate speech. This is because private corporations, unlike the government, have no obligatio

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:

'}} />
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 June 13, 2022 00:07
Basic GraphQL example using the GitHub API
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();
class Flix extends Component {
constructor(props) {
super(props);
this.state = {
person: People[0],
};
}
_goToNextPerson() {
@devknoll
devknoll / Bounce.js
Last active September 22, 2016 17:59
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);
}
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;
}
}
@devknoll
devknoll / resources.md
Last active August 29, 2015 14:21
Relay / GraphQL Resources
## 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